Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ptsd #47

Merged
merged 21 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ if (MSVC)
set(TARGET_COMPILE_OPTIONS
/W4
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/build)
else ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/build)
else()
set(TARGET_COMPILE_OPTIONS
-Wall -Wextra -pedantic
)
Expand Down Expand Up @@ -44,7 +45,7 @@ endif ()

include(cmake/Dependencies.cmake)

set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SRC_FILES
${SRC_DIR}/Core/Context.cpp
${SRC_DIR}/Core/DebugMessageCallback.cpp
Expand Down Expand Up @@ -116,7 +117,7 @@ set(SRC_FILES
${SRC_DIR}/Map/Map.cpp

)
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(INCLUDE_FILES
${INCLUDE_DIR}/Map/Map.hpp
${INCLUDE_DIR}/Map/MapUtility.hpp
Expand Down Expand Up @@ -226,7 +227,9 @@ set(INCLUDE_FILES

)

set(TEST_DIR ${CMAKE_SOURCE_DIR}/test)
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)


set(TEST_FILES
${TEST_DIR}/SimpleTest.cpp
${TEST_DIR}/NotSimpleTest.cpp
Expand Down
64 changes: 51 additions & 13 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,70 @@ FetchContent_Declare(

URL https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.zip
URL_HASH MD5=970535b75b1b69ebd018a0fa05af63d1
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/glew
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/glew
)

FetchContent_Declare(
sdl2

URL https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-2.26.5.zip
URL_HASH MD5=0664f3980570c4641128866e6c9f2e29
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/sdl2
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2
)

FetchContent_Declare(
sdl2_image

URL https://github.com/libsdl-org/SDL_image/releases/download/release-2.6.3/SDL2_image-2.6.3.zip
URL_HASH MD5=ecedb5078bbd31e7d1552e2b1443d2f6
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/sdl2_image
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_image
)

FetchContent_Declare(
sdl2_ttf

URL https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.2/SDL2_ttf-2.20.2.zip
URL_HASH MD5=7258258fdb2a4adb0072d337f94305f9
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/sdl2_ttf
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_ttf
)
FetchContent_Declare(
sdl2_mixer

URL https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.3/SDL2_mixer-2.6.3.zip
URL_HASH MD5=fb3e71ef072ff8dd793cec3ed384f9a0
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/sdl2_mixer
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2_mixer
)

FetchContent_Declare( # At this time 1.11.0 has some issues formatting `const unsigned char *`
spdlog

URL https://github.com/gabime/spdlog/archive/refs/tags/v1.10.0.zip
URL_HASH MD5=031565384b28f29e44c6e7fb247ad48a
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/spdlog
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/spdlog
)

FetchContent_Declare(
glm

URL https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip
URL_HASH MD5=69895110052f0d711c9c54fbf385f6f5
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/glm
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/glm
)

FetchContent_Declare(
googletest

URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip
URL_HASH MD5=a1279c6fb5bf7d4a5e0d0b2a4adb39ac
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/googletest
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/googletest
)

FetchContent_Declare(
imgui

URL https://github.com/ocornut/imgui/archive/refs/tags/v1.90.4-docking.zip
URL_HASH MD5=384084df566474aec3729df4ea30b937
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui
)

set(BUILD_SHARED_LIBS FALSE)
Expand Down Expand Up @@ -96,7 +104,34 @@ add_compile_definitions(GLEW_NO_GLU)
FetchContent_GetProperties(glew)
if (NOT ${glew_POPULATED})
FetchContent_Populate(glew)
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glew/build/cmake)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/build/cmake)
endif()

FetchContent_GetProperties(imgui)
if (NOT ${imgui_POPULATED})
FetchContent_Populate(imgui)
set(IMGUI_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/backends/imgui_impl_sdl2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/backends/imgui_impl_opengl3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/imgui_tables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/imgui_widgets.cpp
)

set(IMGUI_INCLUDE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/
${CMAKE_CURRENT_SOURCE_DIR}/lib/imgui/backends/
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/include/
)

add_library(ImGui STATIC
${IMGUI_SOURCE}
)
target_include_directories(ImGui PUBLIC
${IMGUI_INCLUDE_DIR}
)
endif()

set(DEPENDENCY_LINK_LIBRARIES
Expand All @@ -109,11 +144,14 @@ set(DEPENDENCY_LINK_LIBRARIES
SDL2_mixer::SDL2_mixer-static

spdlog::spdlog

ImGui
)

set(DEPENDENCY_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/lib/sdl2/include/
${CMAKE_SOURCE_DIR}/lib/glew/include/
${CMAKE_SOURCE_DIR}/lib/spdlog/include/
${CMAKE_SOURCE_DIR}/lib/glm/
${CMAKE_CURRENT_SOURCE_DIR}/lib/sdl2/include/
${CMAKE_CURRENT_SOURCE_DIR}/lib/glew/include/
${CMAKE_CURRENT_SOURCE_DIR}/lib/spdlog/include/
${CMAKE_CURRENT_SOURCE_DIR}/lib/glm/
${IMGUI_INCLUDE_DIR}
)
2 changes: 2 additions & 0 deletions include/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class App {

private:
State m_CurrentState = State::START;
bool showDemoWindow = true;

MenuScene mapScene;

};

#endif
16 changes: 0 additions & 16 deletions include/Component/Component.hpp

This file was deleted.

47 changes: 0 additions & 47 deletions include/Component/Object.hpp

This file was deleted.

2 changes: 2 additions & 0 deletions include/Core/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Context {
void SetWindowWidth(unsigned int width) { m_WindowWidth = width; }
void SetWindowHeight(unsigned int height) { m_WindowHeight = height; }

void Setup();

static int IsCurosrAtBoarder() {
/*
* will check if the cursor at the window boarder
Expand Down
5 changes: 0 additions & 5 deletions include/Util/Animation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ class Animation : public Core::Drawable {
*/
void Draw(const Util::Transform &transform, const float zIndex) override;

/**
* @brief Reset the animation to its initial frame.
*/
void Reset() { SetCurrentFrame(0); }

/**
* @brief Start playing the animation.
* If the animation is already playing, this method won't do anything.
Expand Down
7 changes: 5 additions & 2 deletions include/Util/AssetStore.inl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ void AssetStore<T>::Load(const std::string &filepath) {

template <typename T>
T AssetStore<T>::Get(const std::string &filepath) {
if (m_Map.find(filepath) != m_Map.end()) {
return m_Map[filepath];

auto result = m_Map.find(filepath);
if (result != m_Map.end()) {
return result->second;

}

Load(filepath);
Expand Down
6 changes: 5 additions & 1 deletion include/Util/BGM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include "Util/AssetStore.hpp"
#include "pch.hpp" // IWYU pragma: export


#include "Util/AssetStore.hpp"


namespace Util {
/**
* @class BGM
Expand Down Expand Up @@ -108,7 +113,6 @@ class BGM {
private:
static Util::AssetStore<std::shared_ptr<Mix_Music>> s_Store;

std::shared_ptr<Mix_Music> m_BGM;
};

} // namespace Util
Expand Down
5 changes: 4 additions & 1 deletion include/Util/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

#include "pch.hpp" // IWYU pragma: export

#include <functional>
#include <glm/fwd.hpp>

#include "Core/Drawable.hpp"
#include "Core/Texture.hpp"


#include "Camera.hpp"

#include "Util/AssetStore.hpp"
#include "Util/Transform.hpp"

Expand Down Expand Up @@ -78,6 +79,8 @@ class Image : public Core::Drawable {

static Util::AssetStore<std::shared_ptr<SDL_Surface>> s_Store;

static Util::AssetStore<std::shared_ptr<SDL_Surface>> s_Store;

private:
std::unique_ptr<Core::Texture> m_Texture = nullptr;

Expand Down
11 changes: 6 additions & 5 deletions include/Util/Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,22 @@ class Input {
static void Update();

private:
static SDL_Event s_Event;
static void UpdateKeyState(const SDL_Event *event);

static const Uint8 *s_CurrentKeyState;
static std::unordered_map<int, bool> s_LastKeyState;
static SDL_Event s_Event;

static glm::vec2 s_CursorPosition;
static glm::vec2 s_ScrollDistance;

static std::unordered_map<Keycode, std::pair<bool, bool>> s_MouseState;
static std::unordered_map<Keycode, std::pair<bool, bool>> s_KeyState;

static bool s_Scroll;
static bool s_MouseMoving;
static bool s_Exit;

static bool s_LBUp;

static ImGuiIO s_Io;

};

} // namespace Util
Expand Down
4 changes: 2 additions & 2 deletions include/Util/Keycode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ enum class Keycode {
// Below are the keycodes handling mouse buttons.

MOUSE_LB = 513,
MOUSE_RB = 514,
MOUSE_MB = 515,
MOUSE_MB = 514,
MOUSE_RB = 515,
};
// clang-format on
} // namespace Util
Expand Down
6 changes: 5 additions & 1 deletion include/Util/SFX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "Util/AssetStore.hpp"
#include "pch.hpp" // IWYU pragma: export

#include "Util/AssetStore.hpp"


namespace Util {

/**
Expand Down Expand Up @@ -91,8 +95,8 @@ class SFX {

private:
static Util::AssetStore<std::shared_ptr<Mix_Chunk>> s_Store;
std::shared_ptr<Mix_Chunk> m_Chunk;

std::unique_ptr<Mix_Chunk> m_Chunk;
};

} // namespace Util
Expand Down
Loading
Loading