diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 16:12:47 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-05 16:12:47 +0100 |
commit | e36ea050972fcaaf3d85d672755bad4ebb2dcd80 (patch) | |
tree | 5145e0b66650eea1df301106b7d197a586be65f3 /src/crepe/api | |
parent | 333b07775be1ef20fdb5909672c1e4dcabec1b40 (diff) | |
parent | b770475741b7c33d57331f3139c55a3f237ad274 (diff) |
merge `master` into `loek/savemgr`
Diffstat (limited to 'src/crepe/api')
30 files changed, 58 insertions, 63 deletions
diff --git a/src/crepe/api/AssetManager.cpp b/src/crepe/api/AssetManager.cpp index 560df6c..b891760 100644 --- a/src/crepe/api/AssetManager.cpp +++ b/src/crepe/api/AssetManager.cpp @@ -2,7 +2,7 @@ #include "AssetManager.h" -using namespace crepe::api; +using namespace crepe; AssetManager & AssetManager::get_instance() { static AssetManager instance; diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/AssetManager.h index 3e72a49..fefbed9 100644 --- a/src/crepe/api/AssetManager.h +++ b/src/crepe/api/AssetManager.h @@ -5,7 +5,7 @@ #include <string> #include <unordered_map> -namespace crepe::api { +namespace crepe { class AssetManager { @@ -30,6 +30,6 @@ public: bool reload = false); }; -} // namespace crepe::api +} // namespace crepe #include "AssetManager.hpp" diff --git a/src/crepe/api/AssetManager.hpp b/src/crepe/api/AssetManager.hpp index 468724c..977b4e1 100644 --- a/src/crepe/api/AssetManager.hpp +++ b/src/crepe/api/AssetManager.hpp @@ -2,7 +2,7 @@ #include "AssetManager.h" -namespace crepe::api { +namespace crepe { template <typename asset> std::shared_ptr<asset> AssetManager::cache(const std::string & file_path, @@ -21,4 +21,4 @@ std::shared_ptr<asset> AssetManager::cache(const std::string & file_path, return new_asset; } -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp index 35b8d83..63fd0d7 100644 --- a/src/crepe/api/AudioSource.cpp +++ b/src/crepe/api/AudioSource.cpp @@ -1,10 +1,10 @@ #include <memory> -#include "../Sound.h" +#include "../facade/Sound.h" #include "AudioSource.h" -using namespace crepe::api; +using namespace crepe; AudioSource::AudioSource(std::unique_ptr<Asset> audio_clip) { this->sound = std::make_unique<crepe::Sound>(std::move(audio_clip)); diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h index 7980212..42add50 100644 --- a/src/crepe/api/AudioSource.h +++ b/src/crepe/api/AudioSource.h @@ -6,10 +6,8 @@ #include "../Component.h" namespace crepe { -class Sound; -} -namespace crepe::api { +class Sound; //! Audio source component class AudioSource : Component { @@ -35,7 +33,7 @@ public: float volume; private: - std::unique_ptr<crepe::Sound> sound; + std::unique_ptr<Sound> sound; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index 6133cc8..21638f4 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -9,7 +9,7 @@ class ScriptSystem; class ComponentManager; } // namespace crepe -namespace crepe::api { +namespace crepe { class Script; @@ -30,6 +30,6 @@ protected: std::unique_ptr<Script> script = nullptr; }; -} // namespace crepe::api +} // namespace crepe #include "BehaviorScript.hpp" diff --git a/src/crepe/api/BehaviorScript.hpp b/src/crepe/api/BehaviorScript.hpp index 2a3502f..4751607 100644 --- a/src/crepe/api/BehaviorScript.hpp +++ b/src/crepe/api/BehaviorScript.hpp @@ -7,7 +7,7 @@ #include "BehaviorScript.h" #include "Script.h" -namespace crepe::api { +namespace crepe { template <class T> BehaviorScript & BehaviorScript::set_script() { @@ -19,4 +19,4 @@ BehaviorScript & BehaviorScript::set_script() { return *this; } -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/CircleCollider.h b/src/crepe/api/CircleCollider.h index 762574b..931b012 100644 --- a/src/crepe/api/CircleCollider.h +++ b/src/crepe/api/CircleCollider.h @@ -1,7 +1,7 @@ #pragma once #include "../Collider.h" -namespace crepe::api { +namespace crepe { class CircleCollider : public Collider { public: @@ -10,4 +10,4 @@ public: int radius; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp index fb5bd1a..fc6313d 100644 --- a/src/crepe/api/Color.cpp +++ b/src/crepe/api/Color.cpp @@ -1,6 +1,6 @@ #include "Color.h" -using namespace crepe::api; +using namespace crepe; Color Color::white = Color(255, 255, 255, 0); Color Color::red = Color(255, 0, 0, 0); diff --git a/src/crepe/api/Color.h b/src/crepe/api/Color.h index e818de4..6b54888 100644 --- a/src/crepe/api/Color.h +++ b/src/crepe/api/Color.h @@ -1,6 +1,6 @@ #pragma once -namespace crepe::api { +namespace crepe { class Color { @@ -34,4 +34,4 @@ private: static Color black; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index aef4d54..4e6d1fa 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -2,7 +2,7 @@ #include "../util/log.h" -namespace crepe::api { +namespace crepe { class Config { private: @@ -27,7 +27,7 @@ public: * Only messages with equal or higher priority than this value will be * logged. */ - util::LogLevel level = util::LogLevel::INFO; + LogLevel level = LogLevel::INFO; /** * \brief Colored log output * @@ -42,4 +42,4 @@ public: } savemgr; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Force.cpp b/src/crepe/api/Force.cpp index e359adc..3c33ad3 100644 --- a/src/crepe/api/Force.cpp +++ b/src/crepe/api/Force.cpp @@ -2,7 +2,7 @@ #include "Force.h" -namespace crepe::api { +namespace crepe { Force::Force(uint32_t game_object_id, uint32_t magnitude, uint32_t direction) : Component(game_object_id) { @@ -18,4 +18,4 @@ Force::Force(uint32_t game_object_id, uint32_t magnitude, uint32_t direction) std::round(magnitude * std::sin(radian_direction))); } -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Force.h b/src/crepe/api/Force.h index 8da9a00..c08a8b9 100644 --- a/src/crepe/api/Force.h +++ b/src/crepe/api/Force.h @@ -4,7 +4,7 @@ #include "../Component.h" -namespace crepe::api { +namespace crepe { class Force : public Component { public: @@ -14,4 +14,4 @@ public: int32_t force_y; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/GameObject.cpp b/src/crepe/api/GameObject.cpp index b167187..445a60d 100644 --- a/src/crepe/api/GameObject.cpp +++ b/src/crepe/api/GameObject.cpp @@ -1,6 +1,6 @@ #include "GameObject.h" -using namespace crepe::api; +using namespace crepe; using namespace std; GameObject::GameObject(uint32_t id, string name, string tag, int layer) diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h index 57508c5..b5d6399 100644 --- a/src/crepe/api/GameObject.h +++ b/src/crepe/api/GameObject.h @@ -3,7 +3,7 @@ #include <cstdint> #include <string> -namespace crepe::api { +namespace crepe { class GameObject { public: @@ -19,6 +19,6 @@ public: int layer; }; -} // namespace crepe::api +} // namespace crepe #include "GameObject.hpp" diff --git a/src/crepe/api/GameObject.hpp b/src/crepe/api/GameObject.hpp index 3c7e867..77cf40e 100644 --- a/src/crepe/api/GameObject.hpp +++ b/src/crepe/api/GameObject.hpp @@ -4,7 +4,7 @@ #include "GameObject.h" -namespace crepe::api { +namespace crepe { template <typename T, typename... Args> T & GameObject::add_component(Args &&... args) { @@ -12,4 +12,4 @@ T & GameObject::add_component(Args &&... args) { return mgr.add_component<T>(this->id, std::forward<Args>(args)...); } -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Point.h b/src/crepe/api/Point.h index b47b7e6..575d624 100644 --- a/src/crepe/api/Point.h +++ b/src/crepe/api/Point.h @@ -1,6 +1,6 @@ #pragma once -namespace crepe::api { +namespace crepe { class Point { public: @@ -8,4 +8,4 @@ public: double y; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp index ebf9fb9..0a6262a 100644 --- a/src/crepe/api/Rigidbody.cpp +++ b/src/crepe/api/Rigidbody.cpp @@ -1,6 +1,6 @@ #include "Rigidbody.h" -using namespace crepe::api; +using namespace crepe; Rigidbody::Rigidbody(uint32_t game_object_id, int mass, int gravity_scale, BodyType bodyType) diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h index 6079a76..518ed94 100644 --- a/src/crepe/api/Rigidbody.h +++ b/src/crepe/api/Rigidbody.h @@ -4,7 +4,7 @@ #include "../Component.h" -namespace crepe::api { +namespace crepe { // FIXME: can't this enum be defined inside the class declaration of Rigidbody? enum class BodyType { @@ -27,4 +27,4 @@ public: BodyType body_type; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/SaveManager.cpp b/src/crepe/api/SaveManager.cpp index 87e634b..d35fc7b 100644 --- a/src/crepe/api/SaveManager.cpp +++ b/src/crepe/api/SaveManager.cpp @@ -1,4 +1,4 @@ -#include "../DB.h" +#include "../facade/DB.h" #include "../util/log.h" #include "Config.h" @@ -7,7 +7,6 @@ using namespace std; using namespace crepe; -using namespace crepe::api; template <> string SaveManager::serialize(const string & value) { diff --git a/src/crepe/api/SaveManager.h b/src/crepe/api/SaveManager.h index a1f239d..035e2b7 100644 --- a/src/crepe/api/SaveManager.h +++ b/src/crepe/api/SaveManager.h @@ -5,10 +5,8 @@ #include "../ValueBroker.h" namespace crepe { -class DB; -} -namespace crepe::api { +class DB; class SaveManager { public: diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp index 5016ed0..390cec7 100644 --- a/src/crepe/api/Script.cpp +++ b/src/crepe/api/Script.cpp @@ -1,3 +1,3 @@ #include "Script.h" -using namespace crepe::api; +using namespace crepe; diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 59e6ec0..49e625f 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -6,7 +6,7 @@ namespace crepe { class ScriptSystem; } -namespace crepe::api { +namespace crepe { class BehaviorScript; @@ -29,10 +29,10 @@ protected: std::vector<std::reference_wrapper<T>> get_components(); private: - friend class crepe::api::BehaviorScript; + friend class crepe::BehaviorScript; BehaviorScript * parent = nullptr; }; -} // namespace crepe::api +} // namespace crepe #include "Script.hpp" diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 8004fe3..d96c0e8 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -5,7 +5,7 @@ #include "BehaviorScript.h" #include "Script.h" -namespace crepe::api { +namespace crepe { template <typename T> T & Script::get_component() { @@ -22,4 +22,4 @@ std::vector<std::reference_wrapper<T>> Script::get_components() { return mgr.get_components_by_id<T>(this->parent->game_object_id); } -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 806f147..3dd44f2 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -1,15 +1,14 @@ #include <cstdint> #include <memory> -#include "api/Texture.h" -#include "util/log.h" +#include "../util/log.h" #include "Component.h" #include "Sprite.h" +#include "Texture.h" using namespace std; using namespace crepe; -using namespace crepe::api; Sprite::Sprite(uint32_t id, shared_ptr<Texture> image, const Color & color, const FlipSettings & flip) diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index b06125e..bdb4da9 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -9,7 +9,7 @@ #include "Component.h" -namespace crepe::api { +namespace crepe { struct FlipSettings { bool flip_x = 1; @@ -29,4 +29,4 @@ public: uint8_t order_in_layer; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index 481ef7c..8fc5c13 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -1,12 +1,12 @@ #include <SDL2/SDL_render.h> -#include "util/log.h" +#include "../facade/SDLContext.h" +#include "../util/log.h" #include "Asset.h" -#include "SDLContext.h" #include "Texture.h" -using namespace crepe::api; +using namespace crepe; using namespace std; Texture::Texture(unique_ptr<Asset> res) { diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index f8481e3..9a86f6f 100644 --- a/src/crepe/api/Texture.h +++ b/src/crepe/api/Texture.h @@ -12,7 +12,7 @@ namespace crepe { class SDLContext; } -namespace crepe::api { +namespace crepe { class Texture { @@ -30,4 +30,4 @@ private: friend class crepe::SDLContext; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/Transform.cpp b/src/crepe/api/Transform.cpp index 3b218bc..70b16bd 100644 --- a/src/crepe/api/Transform.cpp +++ b/src/crepe/api/Transform.cpp @@ -6,9 +6,10 @@ #include "Component.h" #include "Transform.h" -using namespace crepe::api; +using namespace crepe; -Transform::Transform(uint32_t game_id, const Point & point, double rot, double scale) +Transform::Transform(uint32_t game_id, const Point & point, double rot, + double scale) : Component(game_id), position(point), rotation(rot), scale(scale) { dbg_trace(); } diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h index c451c16..d416088 100644 --- a/src/crepe/api/Transform.h +++ b/src/crepe/api/Transform.h @@ -6,7 +6,7 @@ #include "Component.h" -namespace crepe::api { +namespace crepe { class Transform : public Component { // FIXME: What's the difference between the `Point` and `Position` @@ -24,4 +24,4 @@ public: double scale; }; -} // namespace crepe::api +} // namespace crepe |