UPGRADE! + cheats
Some checks failed
Build / Build Game (push) Has been cancelled

This commit is contained in:
2026-03-02 14:02:14 -05:00
parent 475fb5a847
commit 2a58c3b24b
10 changed files with 141 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
#include "main.hpp"
#include <array>
#include <glm/glm.hpp>
#include <imgui.h>
#include <imgui_impl_opengl3.h>
@@ -34,6 +35,8 @@ namespace game::state
auto& dialogue = data.dialogue;
auto& menuSchema = data.menuSchema;
this->characterIndex = selectedCharacterIndex;
konamiCodeIndex = 0;
konamiCodeStartTime = 0.0;
character =
entity::Character(data, vec2(World::BOUNDS.x + World::BOUNDS.z * 0.5f, World::BOUNDS.w - World::BOUNDS.y));
@@ -132,9 +135,55 @@ namespace game::state
void Main::update(Resources& resources)
{
static constexpr std::array<ImGuiKey, 10> KONAMI_CODE = {
ImGuiKey_UpArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow, ImGuiKey_DownArrow, ImGuiKey_LeftArrow,
ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_B, ImGuiKey_A};
static constexpr std::array<ImGuiKey, 6> KONAMI_INPUT_KEYS = {
ImGuiKey_UpArrow, ImGuiKey_DownArrow, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_B, ImGuiKey_A};
static constexpr auto KONAMI_CODE_INPUT_TIME_SECONDS = 5.0;
auto focus = focus_get();
auto& dialogue = character.data.dialogue;
if (!menu.isCheats)
{
for (auto key : KONAMI_INPUT_KEYS)
{
if (!ImGui::IsKeyPressed(key, false)) continue;
if (key == KONAMI_CODE[konamiCodeIndex])
{
konamiCodeIndex++;
konamiCodeStartTime = ImGui::GetTime();
}
else if (key == KONAMI_CODE[0])
{
konamiCodeIndex = 1;
konamiCodeStartTime = ImGui::GetTime();
}
else
{
konamiCodeIndex = 0;
konamiCodeStartTime = 0.0;
}
if (konamiCodeIndex >= (int)KONAMI_CODE.size())
{
menu.isCheats = true;
konamiCodeIndex = 0;
konamiCodeStartTime = 0.0;
toasts.push("Cheats unlocked!");
character.data.menuSchema.sounds.cheatsActivated.play();
}
}
if (konamiCodeIndex > 0 && (ImGui::GetTime() - konamiCodeStartTime > KONAMI_CODE_INPUT_TIME_SECONDS))
{
konamiCodeIndex = 0;
konamiCodeStartTime = 0.0;
}
}
if (isWindows)
{
menu.update(resources, itemManager, character, cursor, text, worldCanvas);

View File

@@ -42,6 +42,8 @@ namespace game::state
int areaIndex{};
float autosaveTime{};
int konamiCodeIndex{};
double konamiCodeStartTime{};
bool isWindows{true};

View File

@@ -76,6 +76,9 @@ namespace game::state::main
auto canvasSize = ivec2(std::max(1.0f, previewSize.x), std::max(1.0f, previewSize.y));
if (!canvases.contains(i)) canvases.emplace((int)i, Canvas(canvasSize, Canvas::FLIP));
auto& canvas = canvases[i];
bool isPossibleToUpgrade = item.upgradeID.has_value() && item.upgradeCount.has_value() &&
schema.idToStringMap.contains(*item.upgradeID);
bool isAbleToUpgrade = isPossibleToUpgrade && quantity >= *item.upgradeCount;
canvas.zoom = math::to_percent(previewScale);
canvas.pan = vec2(rect.x, rect.y);
canvas.bind();
@@ -90,7 +93,30 @@ namespace game::state::main
quantity <= 0 ? ImVec4(0, 0, 0, 1) : ImVec4(1, 1, 1, 1))) &&
quantity > 0)
{
if (category.isEdible)
if (ImGui::IsKeyDown(ImGuiMod_Shift))
{
if (isAbleToUpgrade)
{
if (ImGui::IsKeyDown(ImGuiMod_Ctrl))
{
while (quantity >= *item.upgradeCount)
{
values.at(*item.upgradeID)++;
quantity -= *item.upgradeCount;
}
}
else
{
values.at(*item.upgradeID)++;
quantity -= *item.upgradeCount;
}
schema.sounds.upgrade.play();
}
else
schema.sounds.upgradeFail.play();
}
else if (category.isEdible)
{
if (itemManager.items.size() + 1 >= ItemManager::LIMIT)
character.data.itemSchema.sounds.dispose.play();
@@ -143,6 +169,14 @@ namespace game::state::main
else if (eatSpeedBonus < 0)
ImGui::Text("Eat Speed Penalty: %0.2f%% / sec", *eatSpeedBonus);
}
if (isPossibleToUpgrade)
{
ImGui::Text("Upgrade: %ix -> %s", *item.upgradeCount, schema.idToStringMap.at(*item.upgradeID).c_str());
if (isAbleToUpgrade)
ImGui::TextUnformatted("(Shift + Click -> Upgrade)\n(Shift + Ctrl + Click -> Upgrade All)");
}
ImGui::PopStyleColor();
ImGui::Separator();

View File

@@ -28,13 +28,13 @@ namespace game::state::main
state::Configuration configuration;
#if DEBUG
bool isCheats{true};
bool isCheats{};
bool isDebug{true};
#else
bool isCheats{};
bool isDebug{};
#endif
bool isOpen{true};
bool isChat{true};
util::imgui::WindowSlide slide{};

View File

@@ -22,13 +22,14 @@ namespace game::state::main
auto& pan = canvas.pan;
auto& zoom = canvas.zoom;
auto& io = ImGui::GetIO();
bool isPan{true};
auto isMouseMiddleDown = ImGui::IsMouseDown(ImGuiMouseButton_Middle);
auto isMouseLeftDown = ImGui::IsMouseDown(ImGuiMouseButton_Left);
auto isCtrlDown = ImGui::IsKeyDown(ImGuiMod_Ctrl);
auto panMultiplier = ZOOM_BASE / zoom;
if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) && !ImGui::IsAnyItemActive())
{
if ((isMouseMiddleDown) && isPan)
if ((isMouseMiddleDown) || (isMouseLeftDown && isCtrlDown))
{
cursor.queue_play({cursorSchema.animations.pan.get()});
pan -= imgui::to_vec2(io.MouseDelta) * panMultiplier;