diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..052e003 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,54 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 27, + "patch": 0 + }, + "configurePresets": [ + { + "name": "x64-Debug", + "displayName": "x64 Debug", + "description": "Visual Studio 2022 x64 Debug", + "generator": "Visual Studio 17 2022", + "architecture": "x64", + "binaryDir": "${sourceDir}/out/build/x64-Debug", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Debug" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "x64-Release", + "displayName": "x64 Release", + "description": "Visual Studio 2022 x64 Release", + "generator": "Visual Studio 17 2022", + "architecture": "x64", + "binaryDir": "${sourceDir}/out/build/x64-Release", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Release" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + } + ], + "buildPresets": [ + { + "name": "x64-Debug", + "configurePreset": "x64-Debug", + "configuration": "Debug" + }, + { + "name": "x64-Release", + "configurePreset": "x64-Release", + "configuration": "Release" + } + ] +} diff --git a/src/state.hpp b/src/state.hpp index 9e0175e..5d3be0c 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -17,8 +17,8 @@ namespace game public: SDL_Window* window{}; SDL_GLContext context{}; - long previousUpdate{}; - long previousTick{}; + Uint64 previousUpdate{}; + Uint64 previousTick{}; enum Type { diff --git a/src/state/main.cpp b/src/state/main.cpp index 123f33d..7740a37 100644 --- a/src/state/main.cpp +++ b/src/state/main.cpp @@ -24,14 +24,14 @@ namespace game::state : World::CENTER; } - void Main::set(Resources& resources, int characterIndex, enum Game game) + void Main::set(Resources& resources, int selectedCharacterIndex, enum Game game) { - auto& data = resources.character_get(characterIndex); + auto& data = resources.character_get(selectedCharacterIndex); auto& saveData = data.save; auto& itemSchema = data.itemSchema; auto& dialogue = data.dialogue; auto& menuSchema = data.menuSchema; - this->characterIndex = characterIndex; + this->characterIndex = selectedCharacterIndex; character = entity::Character(data, vec2(World::BOUNDS.x + World::BOUNDS.z * 0.5f, World::BOUNDS.w - World::BOUNDS.y)); @@ -114,7 +114,7 @@ namespace game::state save(resources); } - void Main::tick(Resources& resources) + void Main::tick(Resources&) { character.tick(); cursor.tick(); diff --git a/src/state/main/chat.cpp b/src/state/main/chat.cpp index c51c55a..f5064a1 100644 --- a/src/state/main/chat.cpp +++ b/src/state/main/chat.cpp @@ -7,7 +7,7 @@ using namespace game::util::imgui; namespace game::state::main { - void Chat::update(Resources& resources, Text& text, entity::Character& character) + void Chat::update(Resources&, Text& text, entity::Character& character) { auto& dialogue = character.data.dialogue; auto size = ImGui::GetContentRegionAvail(); diff --git a/src/state/main/cheats.cpp b/src/state/main/cheats.cpp index 9b982d7..0b02372 100644 --- a/src/state/main/cheats.cpp +++ b/src/state/main/cheats.cpp @@ -11,7 +11,7 @@ using namespace game::util; namespace game::state::main { - void Cheats::update(Resources& resources, entity::Character& character, Inventory& inventory, Text& text) + void Cheats::update(Resources&, entity::Character& character, Inventory& inventory, Text& text) { static constexpr auto FEED_INCREMENT = 100.0f; @@ -40,7 +40,7 @@ namespace game::state::main } auto stage = character.stage + 1; - if (WIDGET_FX(ImGui::SliderInt("Stage", &stage, 1, character.data.stages.size() + 1))) + if (WIDGET_FX(ImGui::SliderInt("Stage", &stage, 1, (int)character.data.stages.size() + 1))) { character.stage = glm::clamp(0, stage - 1, (int)character.data.stages.size()); character.weight = diff --git a/src/state/main/play.cpp b/src/state/main/play.cpp index ce093cf..0d01895 100644 --- a/src/state/main/play.cpp +++ b/src/state/main/play.cpp @@ -129,7 +129,7 @@ namespace game::state::main { if (grade.isFailure) continue; - auto scale = powf(0.5f, rangeCount); + auto scale = powf(0.5f, (float)rangeCount); auto halfHeight = baseHeight * scale * 0.5f; rangeCount++; @@ -165,19 +165,19 @@ namespace game::state::main auto lineMin = ImVec2(barMin.x - LINE_WIDTH_BONUS, barMin.y + (barHeight * tryValue)); auto lineMax = ImVec2(barMin.x + barWidth + LINE_WIDTH_BONUS, lineMin.y + LINE_HEIGHT); - auto color = LINE_COLOR; - color.w = isActive ? 1.0f : endTimerProgress; - drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(color)); + auto lineColor = LINE_COLOR; + lineColor.w = isActive ? 1.0f : endTimerProgress; + drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(lineColor)); if (!isActive && !isGameOver) { range_draw(queuedChallenge.range, 1.0f - endTimerProgress); - auto lineMin = ImVec2(barMin.x - LINE_WIDTH_BONUS, barMin.y + (barHeight * queuedChallenge.tryValue)); - auto lineMax = ImVec2(barMin.x + barWidth + LINE_WIDTH_BONUS, lineMin.y + LINE_HEIGHT); - auto color = LINE_COLOR; - color.w = 1.0f - endTimerProgress; - drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(color)); + auto queuedLineMin = ImVec2(barMin.x - LINE_WIDTH_BONUS, barMin.y + (barHeight * queuedChallenge.tryValue)); + auto queuedLineMax = ImVec2(barMin.x + barWidth + LINE_WIDTH_BONUS, queuedLineMin.y + LINE_HEIGHT); + auto queuedLineColor = LINE_COLOR; + queuedLineColor.w = 1.0f - endTimerProgress; + drawList->AddRectFilled(queuedLineMin, queuedLineMax, ImGui::GetColorU32(queuedLineColor)); } if (isActive) @@ -375,10 +375,10 @@ namespace game::state::main toastMessage.position.y -= TOAST_MESSAGE_SPEED; - auto color = ImGui::GetStyleColorVec4(ImGuiCol_Text); - color.w = ((float)toastMessage.time / toastMessage.timeMax); + auto textColor = ImGui::GetStyleColorVec4(ImGuiCol_Text); + textColor.w = ((float)toastMessage.time / toastMessage.timeMax); - drawList->AddText(toastMessage.position, ImGui::GetColorU32(color), toastMessage.message.c_str()); + drawList->AddText(toastMessage.position, ImGui::GetColorU32(textColor), toastMessage.message.c_str()); toastMessage.time--; diff --git a/src/state/main/text.cpp b/src/state/main/text.cpp index 8c97355..f1040ea 100644 --- a/src/state/main/text.cpp +++ b/src/state/main/text.cpp @@ -28,18 +28,18 @@ namespace game::state::main return it; } - void Text::set(resource::xml::Dialogue::Entry* entry, entity::Character& character) + void Text::set(resource::xml::Dialogue::Entry* dialogueEntry, entity::Character& character) { - if (!entry) return; - this->entry = entry; + if (!dialogueEntry) return; + this->entry = dialogueEntry; isFinished = false; index = 0; time = 0.0f; isEnabled = true; character.isTalking = true; - if (!entry->animation.empty()) character.play_convert(entry->animation); - if (entry->text.empty()) isEnabled = false; + if (!dialogueEntry->animation.empty()) character.play_convert(dialogueEntry->animation); + if (dialogueEntry->text.empty()) isEnabled = false; } void Text::tick(entity::Character& character) @@ -98,7 +98,7 @@ namespace game::state::main auto font = ImGui::GetFont(); auto fontSize = resource::Font::NORMAL; - ImGui::PushFont(font, fontSize); + ImGui::PushFont(font, (float)fontSize); auto text = [&]() { @@ -129,7 +129,7 @@ namespace game::state::main if (!entry->choices.empty()) { ImGui::SetCursorPos(ImVec2(ImGui::GetStyle().WindowPadding.x, available.y)); - auto buttonSize = imgui::row_widget_size_get(entry->choices.size()); + auto buttonSize = imgui::row_widget_size_get((int)entry->choices.size()); for (auto& branch : entry->choices) { diff --git a/src/state/select.cpp b/src/state/select.cpp index 55c38c3..07ee8b1 100644 --- a/src/state/select.cpp +++ b/src/state/select.cpp @@ -15,7 +15,7 @@ namespace game::state characters.update(resources, characterIndex); } - void Select::render(Resources& resources, Canvas& canvas) + void Select::render(Resources&, Canvas& canvas) { canvas.bind(); ImGui::Render(); diff --git a/src/state/select/info.cpp b/src/state/select/info.cpp index 5ee8136..5dd1dc4 100644 --- a/src/state/select/info.cpp +++ b/src/state/select/info.cpp @@ -114,11 +114,11 @@ namespace game::state::select if (ImGui::BeginPopupModal("New Game Warning", &isNewGameWarning, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize)) { - auto widgetSize = row_widget_size_get(save.is_valid() ? 2 : 1); + auto popupWidgetSize = row_widget_size_get(save.is_valid() ? 2 : 1); ImGui::TextWrapped("This will delete saved progress! Are you sure?"); - if (WIDGET_FX(ImGui::Button("Yes", widgetSize))) isNewGame = true; + if (WIDGET_FX(ImGui::Button("Yes", popupWidgetSize))) isNewGame = true; ImGui::SameLine(); - if (WIDGET_FX(ImGui::Button("No", widgetSize))) isNewGameWarning = false; + if (WIDGET_FX(ImGui::Button("No", popupWidgetSize))) isNewGameWarning = false; ImGui::EndPopup(); } } diff --git a/src/state/select/preview.cpp b/src/state/select/preview.cpp index d251182..c2c65b5 100644 --- a/src/state/select/preview.cpp +++ b/src/state/select/preview.cpp @@ -52,12 +52,12 @@ namespace game::state::select ? 0.0f : std::min(availableSize.x / textureSize.x, availableSize.y / textureSize.y); - auto size = ImVec2(textureSize.x * scale, textureSize.y * scale); + auto renderSize = ImVec2(textureSize.x * scale, textureSize.y * scale); - ImGui::SetCursorPos(ImVec2(ImGui::GetCursorPosX() + (availableSize.x * 0.5f) - (size.y * 0.5f), - ImGui::GetCursorPosY() + (availableSize.y * 0.5f) - (size.y * 0.5f))); + ImGui::SetCursorPos(ImVec2(ImGui::GetCursorPosX() + (availableSize.x * 0.5f) - (renderSize.y * 0.5f), + ImGui::GetCursorPosY() + (availableSize.y * 0.5f) - (renderSize.y * 0.5f))); - ImGui::Image(character.render.id, size); + ImGui::Image(character.render.id, renderSize); ImGui::EndTabItem(); } diff --git a/src/util/imgui/widget.cpp b/src/util/imgui/widget.cpp index 172fadd..a276d64 100644 --- a/src/util/imgui/widget.cpp +++ b/src/util/imgui/widget.cpp @@ -43,7 +43,7 @@ namespace game::util::imgui::widget auto min = ImGui::GetItemRectMin(); auto max = ImGui::GetItemRectMax(); auto time = ImGui::GetTime(); - auto period = sinf(time * FREQUENCY); + auto period = sinf((float)(time * FREQUENCY)); auto thickness = THICKNESS_MIN + (THICKNESS_MAX * period); auto colorBorder = ImGui::GetStyleColorVec4(ImGuiCol_CheckMark); colorBorder.w = ALPHA_MIN + (ALPHA_MAX * period); diff --git a/src/util/math.cpp b/src/util/math.cpp index 21db904..2c466d7 100644 --- a/src/util/math.cpp +++ b/src/util/math.cpp @@ -47,5 +47,5 @@ namespace game::util::math float random_max(float max) { return random_in_range(0, max); } float random_roll(float value) { return random() * value; } bool random_bool() { return random() < 0.5f; }; - void random_seed_set() { srand(std::time(nullptr)); } + void random_seed_set() { srand((unsigned int)std::time(nullptr)); } } diff --git a/src/util/physfs.cpp b/src/util/physfs.cpp index acde594..116ee00 100644 --- a/src/util/physfs.cpp +++ b/src/util/physfs.cpp @@ -67,9 +67,10 @@ namespace game::util::physfs Archive::Archive(const std::filesystem::path& path, const std::string& mount) { - if (!PHYSFS_mount(path.c_str(), mount.c_str(), 0)) + auto pathString = path.string(); + if (!PHYSFS_mount(pathString.c_str(), mount.c_str(), 0)) { - logger.error(std::format("Failed to mount archive: {} ({})", path.c_str(), error_get())); + logger.error(std::format("Failed to mount archive: {} ({})", pathString, error_get())); return; } diff --git a/src/util/time.cpp b/src/util/time.cpp index 465be36..baa646e 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -8,8 +8,13 @@ namespace game::util::time std::string get(const char* format) { auto now = std::chrono::system_clock::now(); - auto time = std::chrono::system_clock::to_time_t(now); - auto localTime = *std::localtime(&time); + auto nowTime = std::chrono::system_clock::to_time_t(now); + std::tm localTime{}; +#ifdef _WIN32 + localtime_s(&localTime, &nowTime); +#else + localtime_r(&nowTime, &localTime); +#endif std::ostringstream timeString; timeString << std::put_time(&localTime, format); return timeString.str();