From b845376e270c060730d4f8b9b0946a63908871da Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 9 Dec 2024 11:22:35 +0100 Subject: feature_config --- src/crepe/api/Config.h | 50 +++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'src/crepe/api') diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index a9745c3..e762d89 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -3,34 +3,21 @@ #include #include "../util/Log.h" - -#include "types.h" +#include "../types.h" namespace crepe { /** * \brief Global configuration interface * - * This class stores engine default settings. Properties on this class are only supposed to be - * modified *before* execution is handed over from the game programmer to the engine (i.e. the - * main loop is started). + * This struct stores both engine default settings and global configuration parameters. */ -class Config final { -public: +struct Config { //! Retrieve handle to global Config instance static Config & get_instance(); -private: - Config() = default; - ~Config() = default; - Config(const Config &) = default; - Config(Config &&) = default; - Config & operator=(const Config &) = default; - Config & operator=(Config &&) = default; - -public: //! Logging-related settings - struct { + struct log { // NOLINT /** * \brief Log level * @@ -38,7 +25,7 @@ public: */ Log::Level level = Log::Level::INFO; /** - * \brief Colored log output + * \brief Enable colored log output * * Enables log coloring using ANSI escape codes. */ @@ -46,7 +33,7 @@ public: } log; //! Save manager - struct { + struct savemgr { // NOLINT /** * \brief Save file location * @@ -56,25 +43,22 @@ public: std::string location = "save.crepe.db"; } savemgr; - //! physics-related settings - struct { - /** - * \brief gravity value of physics system - * - * Gravity value of game. - */ + //! Physics-related settings + struct physics { // NOLINT + //! Gravity value of physics system double gravity = 1; } physics; - //! default window settings - struct { - //! default screen size in pixels - ivec2 default_size = {1280, 720}; - std::string window_title = "Jetpack joyride clone"; - } window_settings; + //! Default window settings + struct window { // NOLINT + //! Default window size (in pixels) + ivec2 size = {1280, 720}; + //! Default window title + std::string title = "Jetpack joyride clone"; + } window; //! Asset loading options - struct { + struct asset { // NOLINT /** * \brief Pattern to match for Asset base directory * -- cgit v1.2.3 From f3a30b93aa76f546144c744a08a4ed04bef95192 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 9 Dec 2024 15:46:30 +0100 Subject: more WIP doxygen --- src/crepe/api/Asset.h | 4 ++-- src/doc/feature/bgm.dox | 22 ++++++++++++++++++++++ src/doc/feature/gameobject.dox | 4 ++-- src/doc/feature/proxy.dox | 7 ++++++- src/doc/feature/sfx.dox | 24 ++++++++++++++++++++++++ src/doc/features.dox | 5 ++--- 6 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 src/doc/feature/bgm.dox create mode 100644 src/doc/feature/sfx.dox (limited to 'src/crepe/api') diff --git a/src/crepe/api/Asset.h b/src/crepe/api/Asset.h index bfd0ac7..d802e83 100644 --- a/src/crepe/api/Asset.h +++ b/src/crepe/api/Asset.h @@ -43,13 +43,13 @@ private: /** * \brief Locate asset path, or throw exception if it cannot be found * - * This function resolves asset locations relative to crepe::Config::root_pattern if it is + * This function resolves asset locations relative to Config::asset::root_pattern if it is * set and \p src is a relative path. If \p src is an absolute path, it is canonicalized. * This function only returns if the file can be found. * * \param src Arbitrary path to resource file * - * \returns \p src if crepe::Config::root_pattern is empty + * \returns \p src if Config::asset::root_pattern is empty * \returns Canonical path to \p src * * \throws std::runtime_error if root_pattern cannot be found diff --git a/src/doc/feature/bgm.dox b/src/doc/feature/bgm.dox new file mode 100644 index 0000000..968abb8 --- /dev/null +++ b/src/doc/feature/bgm.dox @@ -0,0 +1,22 @@ +// vim:ft=doxygen +namespace crepe { +/** + +\defgroup feature_bgm Playing background music +\ingroup feature +\brief Add background music to a scene using the AudioSource component + +This page shows how to implement background music using the AudioSource +effects. + +\see AudioSource + +\par Example + +\note This example assumes you already have a GameObject. If not, read +\"\ref feature_gameobject\" first. + +\todo Merge #60 + +*/ +} diff --git a/src/doc/feature/gameobject.dox b/src/doc/feature/gameobject.dox index c561874..ac3927c 100644 --- a/src/doc/feature/gameobject.dox +++ b/src/doc/feature/gameobject.dox @@ -2,9 +2,9 @@ namespace crepe { /** -\defgroup feature_gameobject GameObjects +\defgroup feature_gameobject Entity basics \ingroup feature -\brief GameObject to create a Scene +\brief Building game entities using a GameObject GameObjects are the fundamental building blocks of a Scene. They represent entities in the game world and can have various components attached to them to define their diff --git a/src/doc/feature/proxy.dox b/src/doc/feature/proxy.dox index 02ed4a5..66bbd2f 100644 --- a/src/doc/feature/proxy.dox +++ b/src/doc/feature/proxy.dox @@ -6,7 +6,9 @@ namespace crepe { \ingroup feature \brief Use ValueBroker as if it were a regular variable -\todo Long description +Proxy provides operators that allow you to use a ValueBroker instance as if it +were a regular variable. Proxy implements a constructor that allows it to be +used as a substitute return type for any function that returns ValueBroker. \see ValueBroker \see Proxy @@ -30,6 +32,9 @@ void anywhere() { // implicitly calls .get() int out = calculation(foo); + + // explicitly cast (also calls .get()) + int casted = int(foo); } ``` diff --git a/src/doc/feature/sfx.dox b/src/doc/feature/sfx.dox new file mode 100644 index 0000000..2a5c9cc --- /dev/null +++ b/src/doc/feature/sfx.dox @@ -0,0 +1,24 @@ +// vim:ft=doxygen +namespace crepe { +/** + +\defgroup feature_sfx Playing sound effects +\ingroup feature +\brief Fire a sound effect using the AudioSource component + +This page shows how to implement one-shot sound effects using the AudioSource +component's 'fire and forget'-style API. + +\see AudioSource + +\par Example + +\note This example assumes you already have a GameObject to attach the +AudioSource component to, and uses a Script to control the AudioSource instance. +Separate pages describing these features in more detail can be found at \"\ref +feature_gameobject\" and \"\ref feature_script\" respectively. + +\todo Merge #60 + +*/ +} diff --git a/src/doc/features.dox b/src/doc/features.dox index 6734137..56d17c7 100644 --- a/src/doc/features.dox +++ b/src/doc/features.dox @@ -44,9 +44,8 @@ feature. - \ref feature_savemgr \n\copybrief feature_savemgr - Audio - - \todo Playing sound effects - - - \todo Adding background music to a scene + - \ref feature_sfx \n\copybrief feature_sfx + - \ref feature_bgm \n\copybrief feature_bgm - \todo AI -- cgit v1.2.3