diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be6d15..29aedcb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,24 +32,6 @@ else() FetchContent_MakeAvailable(raylib) endif() -if (EXISTS ${IMGUI_DIR}) - set(imgui_SOURCE_DIR ${IMGUI_DIR}) -else() - message(STATUS "Downloading imgui library") - include(FetchContent) - FetchContent_Declare(imgui URL ${IMGUI_LINK}) - FetchContent_MakeAvailable(imgui) -endif() - -if (EXISTS ${RLIMGUI_DIR}) - set(rlimgui_SOURCE_DIR ${RLIMGUI_DIR}) -else() - message(STATUS "Downloading rlImGui library") - include(FetchContent) - FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK}) - FetchContent_MakeAvailable(rlimgui) -endif() - if (EXISTS ${INIFILE_DIR}) set(inifile-cpp_SOURCE_DIR ${INIFILE_DIR}) else() @@ -63,16 +45,8 @@ endif() # yes... im using glob... dont judge me.... file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "src/*.cpp") -file(GLOB VENDOR_SOURCES CONFIGURE_DEPENDS - "${imgui_SOURCE_DIR}/*.cpp" - "${imgui_SOURCE_DIR}/misc/cpp/*.cpp" - "${rlimgui_SOURCE_DIR}/*.cpp") - -set(PROJECT_INCLUDE +set(PROJECT_INCLUDE "src" - ${imgui_SOURCE_DIR} - ${imgui_SOURCE_DIR}/backends - ${rlimgui_SOURCE_DIR} ${inifile-cpp_SOURCE_DIR}/include) set(PROJECT_LIBRARY raylib) @@ -81,7 +55,50 @@ set(PROJECT_DEFINITION "_PANDA_CORE_") ############################################################## -add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES} ${VENDOR_SOURCES}) +if(NOT DEFINED PANDA_INCLUDE_IMGUI) + set(PANDA_INCLUDE_IMGUI "true") + message(STATUS "PANDA_INCLUDE_IMGUI not defined, default to true") +endif() + +if(DEFINED PANDA_INCLUDE_IMGUI AND PANDA_INCLUDE_IMGUI STREQUAL "true") + set(PROJECT_DEFINITION ${PROJECT_DEFINITION} PANDA_INCLUDE_IMGUI) + + if (EXISTS ${IMGUI_DIR}) + set(imgui_SOURCE_DIR ${IMGUI_DIR}) + else() + message(STATUS "Downloading imgui library") + include(FetchContent) + FetchContent_Declare(imgui URL ${IMGUI_LINK}) + FetchContent_MakeAvailable(imgui) + endif() + + if (EXISTS ${RLIMGUI_DIR}) + set(rlimgui_SOURCE_DIR ${RLIMGUI_DIR}) + else() + message(STATUS "Downloading rlImGui library") + include(FetchContent) + FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK}) + FetchContent_MakeAvailable(rlimgui) + endif() + + file(GLOB IMGUI_SOURCES CONFIGURE_DEPENDS + "${imgui_SOURCE_DIR}/*.cpp" + "${imgui_SOURCE_DIR}/misc/cpp/*.cpp" + "${rlimgui_SOURCE_DIR}/*.cpp") + + set (PROJECT_SOURCES ${PROJECT_SOURCES} ${IMGUI_SOURCES}) + + set(PROJECT_INCLUDE + ${PROJECT_INCLUDE} + ${imgui_SOURCE_DIR} + ${imgui_SOURCE_DIR}/backends + ${rlimgui_SOURCE_DIR}) +endif() + + +############################################################## + +add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_INCLUDE}) target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_LIBRARY}) target_compile_definitions(${PROJECT_NAME} PUBLIC ${PROJECT_DEFINITION}) diff --git a/src/Panda.hpp b/src/Panda.hpp index 0b3aa2f..55e14ea 100755 --- a/src/Panda.hpp +++ b/src/Panda.hpp @@ -146,15 +146,13 @@ namespace panda // ### GUI #ifdef PANDA_INCLUDE_IMGUI - void GuiInit(); void GuiDestroy(); void GuiBegin(); void GuiEnd(); void GuiThemeSetup(); - #endif - + // ### atlas bool LoadTextureAtlas(const char *image_path, const char *ini_path, std::string AtlasKey); bool UnloadTextureAtlas(std::string AtlasKey); diff --git a/src/utils/Distance.cpp b/src/utils/Distance.cpp index 02dd615..185ceba 100644 --- a/src/utils/Distance.cpp +++ b/src/utils/Distance.cpp @@ -1,7 +1,6 @@ -#include -#include - #include "Panda.hpp" +#include +#include double panda::distance(const Vector2 &p1, const Vector2 &p2) { diff --git a/src/utils/Easing.cpp b/src/utils/Easing.cpp index 2c18a9f..91e4f24 100755 --- a/src/utils/Easing.cpp +++ b/src/utils/Easing.cpp @@ -1,6 +1,5 @@ -#include - #include "utils/Easing.hpp" +#include namespace cur = easing; diff --git a/src/utils/GridMap.cpp b/src/utils/GridMap.cpp index 912baed..38c2490 100644 --- a/src/utils/GridMap.cpp +++ b/src/utils/GridMap.cpp @@ -1,4 +1,5 @@ -#include "GridMap.hpp" +#include "Panda.hpp" +#include void panda::DrawGridMap(Texture texture, Camera2D cam) { diff --git a/src/utils/GridMap.hpp b/src/utils/GridMap.hpp deleted file mode 100755 index febf153..0000000 --- a/src/utils/GridMap.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "utils/RaylibDeprecated.hpp" -#include - -/** - * Draw GridMap using cam, use this inside BeginMode2D - * @param {Texture} texture : - * @param {Camera2D} cam : - */ -void DrawGridMap(Texture texture, Camera2D cam); - -/** - * This is quick version without cam, does not support zoom - * @param {Texture} texture : - * @param {Camera2D} cam : - */ -void DrawGridMapQuick(Texture texture, Vector2 offset); - -Texture LoadDefaultGridMap(); diff --git a/src/utils/Matrix.cpp b/src/utils/Matrix.cpp index e71f277..ad4ef97 100644 --- a/src/utils/Matrix.cpp +++ b/src/utils/Matrix.cpp @@ -1,6 +1,5 @@ -#include - #include "Panda.hpp" +#include namespace panda { void Matrix::identity() diff --git a/src/utils/Pool.hpp b/src/utils/Pool.hpp index 63fe7b5..e2c00f7 100755 --- a/src/utils/Pool.hpp +++ b/src/utils/Pool.hpp @@ -1,54 +1,9 @@ #pragma once - #include #include -#include -#include - -#include "utils/Random.hpp" namespace panda { - - // template - // class Pool - // { - // public: - // Pool(int size) : container(size) { } - - // T &get() - // { - // if (activeIndex != container.size()) - // { - // activeIndex++; - // return container[activeIndex-1]; - // } - // else - // { - // if (custom) - // { - // return container[custom()]; - // } - // else - // { - // int r = Random::getInstance().UNI() * (container.size()-1); - // return container[r]; - // } - // } - // } - - // void put(int index) - // { - // activeIndex--; - // std::swap(container[activeIndex], container[index]); - // } - - // // int countActive() { return activeIndex; } - // int activeIndex; - // std::vector container; - // std::function custom; - // }; - template class PoolPointer { private: diff --git a/src/utils/Random.cpp b/src/utils/Random.cpp index 652d649..ca0d09a 100755 --- a/src/utils/Random.cpp +++ b/src/utils/Random.cpp @@ -1,4 +1,4 @@ -#include "utils/Random.hpp" +#include "Panda.hpp" static inline uint64_t splitmix64(uint64_t &x) { uint64_t z = (x += 0x9e3779b97f4a7c15); diff --git a/src/utils/Random.hpp b/src/utils/Random.hpp deleted file mode 100755 index f01df0f..0000000 --- a/src/utils/Random.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include - -namespace panda -{ - class Random { - public: - Random(uint64_t seed = 521288629); - void SetSeed(uint64_t seed); - - uint64_t Next(); - double Next_UNI(); - double Range(double min, double max); - - private: - uint64_t s[4]; - }; -} \ No newline at end of file diff --git a/src/utils/TextureAtlas.cpp b/src/utils/TextureAtlas.cpp index d37ef1a..22c2c91 100755 --- a/src/utils/TextureAtlas.cpp +++ b/src/utils/TextureAtlas.cpp @@ -1,8 +1,8 @@ +#include "Panda.hpp" +#include #include #include -#include - -#include "Panda.hpp" +#include namespace {