54
CMakePresets.json
Normal file
54
CMakePresets.json
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -17,8 +17,8 @@ namespace game
|
|||||||
public:
|
public:
|
||||||
SDL_Window* window{};
|
SDL_Window* window{};
|
||||||
SDL_GLContext context{};
|
SDL_GLContext context{};
|
||||||
long previousUpdate{};
|
Uint64 previousUpdate{};
|
||||||
long previousTick{};
|
Uint64 previousTick{};
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ namespace game::state
|
|||||||
: World::CENTER;
|
: 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& saveData = data.save;
|
||||||
auto& itemSchema = data.itemSchema;
|
auto& itemSchema = data.itemSchema;
|
||||||
auto& dialogue = data.dialogue;
|
auto& dialogue = data.dialogue;
|
||||||
auto& menuSchema = data.menuSchema;
|
auto& menuSchema = data.menuSchema;
|
||||||
this->characterIndex = characterIndex;
|
this->characterIndex = selectedCharacterIndex;
|
||||||
|
|
||||||
character =
|
character =
|
||||||
entity::Character(data, vec2(World::BOUNDS.x + World::BOUNDS.z * 0.5f, World::BOUNDS.w - World::BOUNDS.y));
|
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);
|
save(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::tick(Resources& resources)
|
void Main::tick(Resources&)
|
||||||
{
|
{
|
||||||
character.tick();
|
character.tick();
|
||||||
cursor.tick();
|
cursor.tick();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using namespace game::util::imgui;
|
|||||||
|
|
||||||
namespace game::state::main
|
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& dialogue = character.data.dialogue;
|
||||||
auto size = ImGui::GetContentRegionAvail();
|
auto size = ImGui::GetContentRegionAvail();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using namespace game::util;
|
|||||||
|
|
||||||
namespace game::state::main
|
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;
|
static constexpr auto FEED_INCREMENT = 100.0f;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace game::state::main
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto stage = character.stage + 1;
|
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.stage = glm::clamp(0, stage - 1, (int)character.data.stages.size());
|
||||||
character.weight =
|
character.weight =
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace game::state::main
|
|||||||
{
|
{
|
||||||
if (grade.isFailure) continue;
|
if (grade.isFailure) continue;
|
||||||
|
|
||||||
auto scale = powf(0.5f, rangeCount);
|
auto scale = powf(0.5f, (float)rangeCount);
|
||||||
auto halfHeight = baseHeight * scale * 0.5f;
|
auto halfHeight = baseHeight * scale * 0.5f;
|
||||||
|
|
||||||
rangeCount++;
|
rangeCount++;
|
||||||
@@ -165,19 +165,19 @@ namespace game::state::main
|
|||||||
|
|
||||||
auto lineMin = ImVec2(barMin.x - LINE_WIDTH_BONUS, barMin.y + (barHeight * tryValue));
|
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 lineMax = ImVec2(barMin.x + barWidth + LINE_WIDTH_BONUS, lineMin.y + LINE_HEIGHT);
|
||||||
auto color = LINE_COLOR;
|
auto lineColor = LINE_COLOR;
|
||||||
color.w = isActive ? 1.0f : endTimerProgress;
|
lineColor.w = isActive ? 1.0f : endTimerProgress;
|
||||||
drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(color));
|
drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(lineColor));
|
||||||
|
|
||||||
if (!isActive && !isGameOver)
|
if (!isActive && !isGameOver)
|
||||||
{
|
{
|
||||||
range_draw(queuedChallenge.range, 1.0f - endTimerProgress);
|
range_draw(queuedChallenge.range, 1.0f - endTimerProgress);
|
||||||
|
|
||||||
auto lineMin = ImVec2(barMin.x - LINE_WIDTH_BONUS, barMin.y + (barHeight * queuedChallenge.tryValue));
|
auto queuedLineMin = 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 queuedLineMax = ImVec2(barMin.x + barWidth + LINE_WIDTH_BONUS, queuedLineMin.y + LINE_HEIGHT);
|
||||||
auto color = LINE_COLOR;
|
auto queuedLineColor = LINE_COLOR;
|
||||||
color.w = 1.0f - endTimerProgress;
|
queuedLineColor.w = 1.0f - endTimerProgress;
|
||||||
drawList->AddRectFilled(lineMin, lineMax, ImGui::GetColorU32(color));
|
drawList->AddRectFilled(queuedLineMin, queuedLineMax, ImGui::GetColorU32(queuedLineColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isActive)
|
if (isActive)
|
||||||
@@ -375,10 +375,10 @@ namespace game::state::main
|
|||||||
|
|
||||||
toastMessage.position.y -= TOAST_MESSAGE_SPEED;
|
toastMessage.position.y -= TOAST_MESSAGE_SPEED;
|
||||||
|
|
||||||
auto color = ImGui::GetStyleColorVec4(ImGuiCol_Text);
|
auto textColor = ImGui::GetStyleColorVec4(ImGuiCol_Text);
|
||||||
color.w = ((float)toastMessage.time / toastMessage.timeMax);
|
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--;
|
toastMessage.time--;
|
||||||
|
|
||||||
|
|||||||
@@ -28,18 +28,18 @@ namespace game::state::main
|
|||||||
return it;
|
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;
|
if (!dialogueEntry) return;
|
||||||
this->entry = entry;
|
this->entry = dialogueEntry;
|
||||||
|
|
||||||
isFinished = false;
|
isFinished = false;
|
||||||
index = 0;
|
index = 0;
|
||||||
time = 0.0f;
|
time = 0.0f;
|
||||||
isEnabled = true;
|
isEnabled = true;
|
||||||
character.isTalking = true;
|
character.isTalking = true;
|
||||||
if (!entry->animation.empty()) character.play_convert(entry->animation);
|
if (!dialogueEntry->animation.empty()) character.play_convert(dialogueEntry->animation);
|
||||||
if (entry->text.empty()) isEnabled = false;
|
if (dialogueEntry->text.empty()) isEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::tick(entity::Character& character)
|
void Text::tick(entity::Character& character)
|
||||||
@@ -98,7 +98,7 @@ namespace game::state::main
|
|||||||
auto font = ImGui::GetFont();
|
auto font = ImGui::GetFont();
|
||||||
auto fontSize = resource::Font::NORMAL;
|
auto fontSize = resource::Font::NORMAL;
|
||||||
|
|
||||||
ImGui::PushFont(font, fontSize);
|
ImGui::PushFont(font, (float)fontSize);
|
||||||
|
|
||||||
auto text = [&]()
|
auto text = [&]()
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ namespace game::state::main
|
|||||||
if (!entry->choices.empty())
|
if (!entry->choices.empty())
|
||||||
{
|
{
|
||||||
ImGui::SetCursorPos(ImVec2(ImGui::GetStyle().WindowPadding.x, available.y));
|
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)
|
for (auto& branch : entry->choices)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace game::state
|
|||||||
characters.update(resources, characterIndex);
|
characters.update(resources, characterIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Select::render(Resources& resources, Canvas& canvas)
|
void Select::render(Resources&, Canvas& canvas)
|
||||||
{
|
{
|
||||||
canvas.bind();
|
canvas.bind();
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ namespace game::state::select
|
|||||||
if (ImGui::BeginPopupModal("New Game Warning", &isNewGameWarning,
|
if (ImGui::BeginPopupModal("New Game Warning", &isNewGameWarning,
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize))
|
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?");
|
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();
|
ImGui::SameLine();
|
||||||
if (WIDGET_FX(ImGui::Button("No", widgetSize))) isNewGameWarning = false;
|
if (WIDGET_FX(ImGui::Button("No", popupWidgetSize))) isNewGameWarning = false;
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ namespace game::state::select
|
|||||||
? 0.0f
|
? 0.0f
|
||||||
: std::min(availableSize.x / textureSize.x, availableSize.y / textureSize.y);
|
: 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::SetCursorPos(ImVec2(ImGui::GetCursorPosX() + (availableSize.x * 0.5f) - (renderSize.y * 0.5f),
|
||||||
ImGui::GetCursorPosY() + (availableSize.y * 0.5f) - (size.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();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace game::util::imgui::widget
|
|||||||
auto min = ImGui::GetItemRectMin();
|
auto min = ImGui::GetItemRectMin();
|
||||||
auto max = ImGui::GetItemRectMax();
|
auto max = ImGui::GetItemRectMax();
|
||||||
auto time = ImGui::GetTime();
|
auto time = ImGui::GetTime();
|
||||||
auto period = sinf(time * FREQUENCY);
|
auto period = sinf((float)(time * FREQUENCY));
|
||||||
auto thickness = THICKNESS_MIN + (THICKNESS_MAX * period);
|
auto thickness = THICKNESS_MIN + (THICKNESS_MAX * period);
|
||||||
auto colorBorder = ImGui::GetStyleColorVec4(ImGuiCol_CheckMark);
|
auto colorBorder = ImGui::GetStyleColorVec4(ImGuiCol_CheckMark);
|
||||||
colorBorder.w = ALPHA_MIN + (ALPHA_MAX * period);
|
colorBorder.w = ALPHA_MIN + (ALPHA_MAX * period);
|
||||||
|
|||||||
@@ -47,5 +47,5 @@ namespace game::util::math
|
|||||||
float random_max(float max) { return random_in_range(0, max); }
|
float random_max(float max) { return random_in_range(0, max); }
|
||||||
float random_roll(float value) { return random() * value; }
|
float random_roll(float value) { return random() * value; }
|
||||||
bool random_bool() { return random() < 0.5f; };
|
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)); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,9 +67,10 @@ namespace game::util::physfs
|
|||||||
|
|
||||||
Archive::Archive(const std::filesystem::path& path, const std::string& mount)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ namespace game::util::time
|
|||||||
std::string get(const char* format)
|
std::string get(const char* format)
|
||||||
{
|
{
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto time = std::chrono::system_clock::to_time_t(now);
|
auto nowTime = std::chrono::system_clock::to_time_t(now);
|
||||||
auto localTime = *std::localtime(&time);
|
std::tm localTime{};
|
||||||
|
#ifdef _WIN32
|
||||||
|
localtime_s(&localTime, &nowTime);
|
||||||
|
#else
|
||||||
|
localtime_r(&nowTime, &localTime);
|
||||||
|
#endif
|
||||||
std::ostringstream timeString;
|
std::ostringstream timeString;
|
||||||
timeString << std::put_time(&localTime, format);
|
timeString << std::put_time(&localTime, format);
|
||||||
return timeString.str();
|
return timeString.str();
|
||||||
|
|||||||
Reference in New Issue
Block a user