diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e5dec4..37cebf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,15 @@ set(LUNARIUM_SRC "src/core/types.cpp" "src/core/core_console.cpp" "src/core/run_mode.cpp" +"src/utils/stb/stb_image_write.cpp" +"src/utils/stb/stb_image.cpp" +"src/utils/args.cpp" +"src/utils/binaryFileBuffer.cpp" +"src/utils/frameCounter.cpp" +"src/utils/helpers.cpp" +"src/utils/highResTimer.cpp" +"src/utils/logger.cpp" +"src/utils/opRes.cpp" "src/window/window.cpp" "src/graphics/opengl/glGraphics.cpp" "src/graphics/opengl/glText.cpp" @@ -101,9 +110,6 @@ add_subdirectory(src/internal_libs/gui/dearimgui) # add gui add_subdirectory(src/internal_libs/gui) -# add utils -add_subdirectory(src/internal_libs/utils) - # add assets add_subdirectory(src/internal_libs/assets) @@ -147,7 +153,6 @@ target_link_directories(${PROJECT_NAME} PRIVATE external/glfw/src PRIVATE external/glm PRIVATE src/internal_libs/gui/dearimgui - PRIVATE src/internal_libs/utils PRIVATE src/internal_libs/assets PRIVATE src/run_modes/tester PRIVATE external/glad/src @@ -155,7 +160,7 @@ target_link_directories(${PROJECT_NAME} PRIVATE external/box2d/bin ) -target_link_libraries(${PROJECT_NAME} box2d glfw glad glm gui dearimgui utils assets lua_static pugixml freetype testbed game) +target_link_libraries(${PROJECT_NAME} box2d glfw glad glm gui dearimgui assets lua_static pugixml freetype testbed game) if (NOT NO_EDITOR) target_link_libraries(${PROJECT_NAME} editor) diff --git a/scripts/cmconfig.bat b/scripts/config.bat similarity index 100% rename from scripts/cmconfig.bat rename to scripts/config.bat diff --git a/scripts/cmconfig.sh b/scripts/config.sh old mode 100755 new mode 100644 similarity index 100% rename from scripts/cmconfig.sh rename to scripts/config.sh diff --git a/src/internal_libs/utils/CMakeLists.txt b/src/internal_libs/utils/CMakeLists.txt deleted file mode 100644 index 07459bb..0000000 --- a/src/internal_libs/utils/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_library(utils stb/stb_image_write.cpp stb/stb_image.cpp args.cpp binaryFileBuffer.cpp frameCounter.cpp - helpers.cpp highResTimer.cpp logger.cpp opRes.cpp) - -target_include_directories(utils - PUBLIC "${PROJECT_BINARY_DIR}" - PUBLIC ../../ - PUBLIC ../../../external/glm - PUBLIC ../../../external/box2d/include -) diff --git a/src/internal_libs/utils/grid.h b/src/internal_libs/utils/grid.h deleted file mode 100644 index c3ae810..0000000 --- a/src/internal_libs/utils/grid.h +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** -* File - grid.h -* Author - Joey Pollack -* Date - 2022/01/25 (y/m/d) -* Mod Date - 2022/01/25 (y/m/d) -* Description - A 2D fixed-size array of data. Size must be set when -* this container is created and can not be changed later. -* The 0, 0 position is the center of the grid (so the indices -* of a 10x10 grid go from 4, 4 to -4, -4). -******************************************************************************/ - -#ifndef GRID_H_ -#define GRID_H_ - -#include - -namespace lunarium -{ - template - class Grid - { - public: - Grid(Sizei size); - - T* operator[](Vec2i at); - T GetAt(Vec2i at); - void SetAt(Vec2i at, T value); - - void SetAll(T value); - - private: - - struct Node - { - T Data; - }; - - Sizei mHalfSize; - Sizei mSize; - Node** mGrid; - }; - - -//////////////////////////////////////////////////////////// -// IMPLEMENTATION -//////////////////////////////////////////////////////////// - - template - Grid::Grid(Sizei size) - : mSize(size) - { - mHalfSize.Width = size.Width / 2; - mHalfSize.Height = size.Height / 2; - - mGrid = new Node*[size.Width]; - for (int i = 0; i < size.Width; i++) - { - mGrid[i] = new Node[size.Height]; - } - } - - template - T* Grid::operator[](Vec2i at) - { - return &mGrid[at.X + mHalfSize.Width][at.Y + mHalfSize.Height].Data; - } - - template - T Grid::GetAt(Vec2i at) - { - return mGrid[at.X + mHalfSize.Width][at.Y + mHalfSize.Height].Data; - } - - template - void Grid::SetAt(Vec2i at, T value) - { - mGrid[at.X + mHalfSize.Width][at.Y + mHalfSize.Height].Data = value; - } - - template - void Grid::SetAll(T value) - { - for (int i = 0; i < mSize.Width; i++) - { - for (int j = 0; j < mSize.Height; j++) - { - mGrid[i][j].Data = value; - } - } - } -} -#endif // GRID_H_ \ No newline at end of file diff --git a/src/run_modes/game/world/world.cpp b/src/run_modes/game/world/world.cpp index ccf3902..dc2e947 100644 --- a/src/run_modes/game/world/world.cpp +++ b/src/run_modes/game/world/world.cpp @@ -19,10 +19,9 @@ namespace lunarium { namespace game { World::World(Camera* pCam, Sizei region_size, Sizei world_size) - : mpCamera(pCam), mRegionSize(region_size), mpWorldScript(nullptr), mRegions(region_size), mWorldSize(world_size) + : mpCamera(pCam), mRegionSize(region_size), mpWorldScript(nullptr), mWorldSize(world_size) { mActiveRegion = { 0, 0 }; - mRegions.SetAll(nullptr); } void World::OnLoad() @@ -61,43 +60,6 @@ namespace lunarium { namespace game // } - OpRes World::SetRegion(Region* region, Vec2i at) - { - if (*mRegions[at] != nullptr) - { - return OpRes::Fail("World::SetRegion failed because a region already exists at (%n, %n)", at.X, at.Y); - } - - // Validate the layers - each image needs to match the region size - for (int i = 0; i < region->mLayers.size(); i++) - { - if (region->mLayers[i]->GetWidth() != mRegionSize.Width - || region->mLayers[i]->GetHeight() != mRegionSize.Height) - { - return OpRes::Fail("World::SetRegion failed because the region contains layers that do not match the region size"); - } - } - - *mRegions[at] = region; - return OpRes::OK(); - } - - World::Region* World::GetRegion(Vec2i at) - { - return *mRegions[at]; - } - - bool World::RemoveRegion(Vec2i at) - { - if (*mRegions[at] == nullptr) - { - return false; - } - - *mRegions[at] = nullptr; - return true; - } - void World::SetWorldScript(Script* pScript) { mpWorldScript = pScript; diff --git a/src/run_modes/game/world/world.h b/src/run_modes/game/world/world.h index cb58d88..8307ee5 100644 --- a/src/run_modes/game/world/world.h +++ b/src/run_modes/game/world/world.h @@ -16,7 +16,6 @@ #include #include #include -#include namespace lunarium { @@ -72,7 +71,6 @@ namespace lunarium { namespace game lunarium::Script* mpWorldScript; Sizei mRegionSize; // in pixels Sizei mWorldSize; // num regions ex. 10x10 - Grid mRegions; Vec2i mActiveRegion; diff --git a/src/run_modes/testbed/scenes/simpleRenderScene.cpp b/src/run_modes/testbed/scenes/simpleRenderScene.cpp index b9c155c..b40887a 100644 --- a/src/run_modes/testbed/scenes/simpleRenderScene.cpp +++ b/src/run_modes/testbed/scenes/simpleRenderScene.cpp @@ -19,14 +19,13 @@ namespace lunarium { SimpleRenderScene::SimpleRenderScene(uint32_t logCat) - : BaseScene(logCat), mGrid({10, 10}) + : BaseScene(logCat) { } SimpleRenderScene::~SimpleRenderScene() { - delete *mGrid[{5, 5}]; delete mpTestImageLoad; } @@ -68,9 +67,6 @@ namespace lunarium angle = 0.0f; box_angle = 0.0f; - - // Setup the grid container - *mGrid[{-2, 0}] = new GridTestObj {5, "This is grid space -2, 0"}; } void SimpleRenderScene::OnTick(double delta) @@ -186,8 +182,6 @@ namespace lunarium g->DrawBox(Rectangle(400, 400, 128.0f, 128.0f), Color(0.0f, 1.0f, 0.0f, 1.0f), 2.0f, box_angle); - g->DrawString((*mGrid[{-2, 0,}])->msg.c_str(), Rectangle::MakeFromTopLeft(200.0f, 500.0f, 500.0f, 200.0f), Color(0.5f, 0.0f, 0.75f, 1.0f)); - //g->DrawImage(*mpTestImageLoad, glm::vec2(0.0f, 0.0f), Color::White()); //Rectangle src = Rectangle::MakeFromTopLeft(0.0f, 0.0f, (float)mpTestImageLoad->GetWidth(), (float)mpTestImageLoad->GetHeight()); //Rectangle src = Rectangle::MakeFromTopLeft(0.0f, 0.0f, mSrcWidth, mSrcHeight); diff --git a/src/run_modes/testbed/scenes/simpleRenderScene.h b/src/run_modes/testbed/scenes/simpleRenderScene.h index 3724424..0626845 100644 --- a/src/run_modes/testbed/scenes/simpleRenderScene.h +++ b/src/run_modes/testbed/scenes/simpleRenderScene.h @@ -11,7 +11,6 @@ #include "baseScene.h" #include -#include #include namespace lunarium @@ -45,8 +44,6 @@ namespace lunarium int X; std::string msg; }; - - Grid mGrid; }; } diff --git a/src/internal_libs/utils/args.cpp b/src/utils/args.cpp similarity index 100% rename from src/internal_libs/utils/args.cpp rename to src/utils/args.cpp diff --git a/src/internal_libs/utils/args.h b/src/utils/args.h similarity index 100% rename from src/internal_libs/utils/args.h rename to src/utils/args.h diff --git a/src/internal_libs/utils/binaryFileBuffer.cpp b/src/utils/binaryFileBuffer.cpp similarity index 100% rename from src/internal_libs/utils/binaryFileBuffer.cpp rename to src/utils/binaryFileBuffer.cpp diff --git a/src/internal_libs/utils/binaryFileBuffer.h b/src/utils/binaryFileBuffer.h similarity index 100% rename from src/internal_libs/utils/binaryFileBuffer.h rename to src/utils/binaryFileBuffer.h diff --git a/src/internal_libs/utils/frameCounter.cpp b/src/utils/frameCounter.cpp similarity index 100% rename from src/internal_libs/utils/frameCounter.cpp rename to src/utils/frameCounter.cpp diff --git a/src/internal_libs/utils/frameCounter.h b/src/utils/frameCounter.h similarity index 100% rename from src/internal_libs/utils/frameCounter.h rename to src/utils/frameCounter.h diff --git a/src/internal_libs/utils/helpers.cpp b/src/utils/helpers.cpp similarity index 100% rename from src/internal_libs/utils/helpers.cpp rename to src/utils/helpers.cpp diff --git a/src/internal_libs/utils/helpers.h b/src/utils/helpers.h similarity index 100% rename from src/internal_libs/utils/helpers.h rename to src/utils/helpers.h diff --git a/src/internal_libs/utils/highResTimer.cpp b/src/utils/highResTimer.cpp similarity index 100% rename from src/internal_libs/utils/highResTimer.cpp rename to src/utils/highResTimer.cpp diff --git a/src/internal_libs/utils/highResTimer.h b/src/utils/highResTimer.h similarity index 100% rename from src/internal_libs/utils/highResTimer.h rename to src/utils/highResTimer.h diff --git a/src/internal_libs/utils/logger.cpp b/src/utils/logger.cpp similarity index 100% rename from src/internal_libs/utils/logger.cpp rename to src/utils/logger.cpp diff --git a/src/internal_libs/utils/logger.h b/src/utils/logger.h similarity index 100% rename from src/internal_libs/utils/logger.h rename to src/utils/logger.h diff --git a/src/internal_libs/utils/opRes.cpp b/src/utils/opRes.cpp similarity index 100% rename from src/internal_libs/utils/opRes.cpp rename to src/utils/opRes.cpp diff --git a/src/internal_libs/utils/opRes.h b/src/utils/opRes.h similarity index 100% rename from src/internal_libs/utils/opRes.h rename to src/utils/opRes.h diff --git a/src/internal_libs/utils/stb/stb_image.cpp b/src/utils/stb/stb_image.cpp similarity index 100% rename from src/internal_libs/utils/stb/stb_image.cpp rename to src/utils/stb/stb_image.cpp diff --git a/src/internal_libs/utils/stb/stb_image.h b/src/utils/stb/stb_image.h similarity index 100% rename from src/internal_libs/utils/stb/stb_image.h rename to src/utils/stb/stb_image.h diff --git a/src/internal_libs/utils/stb/stb_image_write.cpp b/src/utils/stb/stb_image_write.cpp similarity index 100% rename from src/internal_libs/utils/stb/stb_image_write.cpp rename to src/utils/stb/stb_image_write.cpp diff --git a/src/internal_libs/utils/stb/std_image_write.h b/src/utils/stb/std_image_write.h similarity index 100% rename from src/internal_libs/utils/stb/std_image_write.h rename to src/utils/stb/std_image_write.h