Skip to content

Commit

Permalink
random ui things
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Aug 14, 2024
1 parent 532d4d3 commit 0b7052d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
8 changes: 8 additions & 0 deletions max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void HookUpdateState(void *a, void *b, void *c, void *d) {
Max::get().inputs.pop_front();
}
g_update_state_trampoline(a, b, c, d);
if (Max::get().use_igt)
*(Max::get().timer() + 1) = *Max::get().timer();
}

using Void = void();
Expand Down Expand Up @@ -903,3 +905,9 @@ void Max::draw_text_small(int x, int y, const wchar_t *text, uint32_t color,
std::array<uv_data, 1024> *Max::tile_uvs() {
return (std::array<uv_data, 1024> *)((size_t)get_asset(254)->data + 0xc);
}

uint16_t Max::get_room_tile_flags(int x, int y, uint16_t mask) {
using GetFunc = uint16_t(int x, int y, uint16_t mask);
static GetFunc *get = (GetFunc *)get_address("room_tile_flags");
return get(x, y, mask);
}
3 changes: 3 additions & 0 deletions max.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ struct Max {
void draw_text_small(int x, int y, const wchar_t *text,
uint32_t color = 0xffffffff, uint32_t shader = 0x29);

uint16_t get_room_tile_flags(int x, int y, uint16_t mask);

bool skip{false};
std::optional<bool> paused{std::nullopt};
std::optional<bool> set_pause{std::nullopt};
Expand All @@ -300,6 +302,7 @@ struct Max {
{GAME_INPUT::HUD, 'H'}, {GAME_INPUT::CRING, 'F'},
};

bool use_igt{false};
bool use_keymap{false};
bool atlas_loaded{false};
};
4 changes: 4 additions & 0 deletions search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
{
"skip_credits"sv, PatternCommandBuffer{}.from_exe_base(0x476d9), // TODO
},
{
"room_tile_flags"sv,
PatternCommandBuffer{}.from_exe_base(0x1A190), // TODO
},
/*{
"load_asset"sv, PatternCommandBuffer{}.from_exe_base(0x74450), // TODO
},
Expand Down
7 changes: 5 additions & 2 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void UI::DrawPlayer() {
Max::get().player_flute());
ImGui::InputScalar("Item##PlayerCurrentItem", ImGuiDataType_U8,
Max::get().item());
ImGui::InputScalar("Ingame time##StateIngameTime", ImGuiDataType_U32,
ImGui::InputScalar("In-game time##StateIngameTime", ImGuiDataType_U32,
Max::get().timer());
ImGui::InputScalar("Total time##StateTotalTime", ImGuiDataType_U32,
Max::get().timer() + 1);
Expand Down Expand Up @@ -538,6 +538,7 @@ void UI::UpdateOptions() {
Max::get().force_palette = std::nullopt;
}
Max::get().use_keymap = options["input_custom"].value;
Max::get().use_igt = options["cheat_igt"].value;
}

uint8_t AnyKey() {
Expand Down Expand Up @@ -1615,8 +1616,10 @@ void UI::HUD() {
3.f);
std::string coord =
fmt::format("Screen: {},{}\n Tile: {},{}", x, y, rx, ry);
coord += fmt::format("\n Flags: 0x{:X}",
Max::get().get_room_tile_flags(rx, ry, 0xffff));
if (fg && bg)
coord += fmt::format("\n ID: {},{}", fg->id, bg->id);
coord += fmt::format("\n ID: {},{}", fg->id, bg->id);
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
ImGui::SetTooltip(coord.c_str());
}
Expand Down
8 changes: 6 additions & 2 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class UI {
"Patches out the Groundhog Day checks,\nso you can always get up to 4 "
"extra hearts."}},
{"cheat_hud",
{false, "Hide ingame HUD",
{false, "Hide in-game HUD",
"Removes all HUD elements, including the menus.", "toggle_hud"}},
{"cheat_player",
{false, "Hide player character", "Doesn't render the player character.",
Expand All @@ -133,6 +133,10 @@ class UI {
"toggle_clouds"}},
{"cheat_credits",
{false, "Skip credits", "Skips credits and drops the key immediately."}},
{"cheat_igt",
{false, "Use in-game time",
"Replaces total game time with\nIGT that doesn't include paused "
"time."}},

{"input_block",
{true, "Block game input on UI input",
Expand Down Expand Up @@ -162,7 +166,7 @@ class UI {
"Shows what you haven't seen yet, but darker."}},
{"map_reveal",
{false, "Reveal unseen minimap tiles in game",
"Marks all tiles seen on the actual ingame map."}},
"Marks all tiles seen on the actual in-game map."}},
{"map_areas",
{false, "Show all map borders on minimap",
"Draws all special map borders instead of only selected layer."}},
Expand Down

0 comments on commit 0b7052d

Please sign in to comment.