Skip to content

Commit

Permalink
Add some more savedata checkboxes to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Aug 17, 2024
1 parent a24a775 commit 8abf027
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
8 changes: 8 additions & 0 deletions max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ uint8_t *Max::options() {
return (uint8_t *)(*(size_t *)get_address("slots") + 0x400 + 0x75048);
}

uint64_t *Max::eggs() { return (uint64_t *)(slot() + 0x418 + 0x188); }

uint8_t *Max::flames() { return (uint8_t *)(slot() + 0x418 + 0x21e); }

uint64_t *Max::chests() { return (uint64_t *)(slot() + 0x418 + 0x120); }

uint16_t *Max::candles() { return (uint16_t *)(slot() + 0x418 + 0x1e0); }

Pause *Max::pause() {
return (Pause *)((*(size_t *)get_address("slots") + 0x93608));
};
Expand Down
4 changes: 4 additions & 0 deletions max.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ struct Max {
uint8_t *keys();
uint8_t *item();
uint8_t *options();
uint64_t *eggs();
uint8_t *flames();
uint64_t *chests();
uint16_t *candles();
Pause *pause();
uint32_t *timer();
void save_game();
Expand Down
106 changes: 105 additions & 1 deletion ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#pragma comment(lib, "version.lib")

const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127;
const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255;
const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255,
u8_five = 5;
const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768,
s16_max = 32767;
const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0,
Expand Down Expand Up @@ -94,6 +95,73 @@ std::array misc_names{
"Unknown",
};

std::array egg_names{
"Reference Egg",
"Brown Egg",
"Raw Egg",
"Pickled Egg",
"Big Egg",
"Swan Egg",
"Forbidden Egg",
"Shadow Egg",
"Vanity Egg",
"Egg As A Service",
"Depraved Egg",
"Chaos Egg",
"Upside Down Egg",
"Evil Egg",
"Sweet Egg",
"Chocolate Egg",
"Value Egg",
"Plant Egg",
"Red Egg",
"Orange Egg",
"Sour Egg",
"Post Modern Egg",
"Universal Basic Egg",
"Laissez-faire Egg",
"Zen Egg",
"Future Egg",
"Friendship Egg",
"Truth Egg",
"Transcendental Egg",
"Ancient Egg",
"Magic Egg",
"Mystic Egg",
"Holiday Egg",
"Rain Egg",
"Razzle Egg",
"Dazzle Egg",
"Virtual Egg",
"Normal Egg",
"Great Egg",
"Gorgeous Egg",
"Planet Egg",
"Moon Egg",
"Galaxy Egg",
"Sunset Egg",
"Goodnight Egg",
"Dream Egg",
"Travel Egg",
"Promise Egg",
"Ice Egg",
"Fire Egg",
"Bubble Egg",
"Desert Egg",
"Clover Egg",
"Brick Egg",
"Neon Egg",
"Iridescent Egg",
"Rust Egg",
"Scarlet Egg",
"Sapphire Egg",
"Ruby Egg",
"Jade Egg",
"Obsidian Egg",
"Crystal Egg",
"Golden Egg",
};

const std::map<std::string, PLAYER_INPUT> notes{
{"A4", (PLAYER_INPUT)(PLAYER_INPUT::RIGHT | PLAYER_INPUT::LB)},
{"A#4",
Expand Down Expand Up @@ -281,6 +349,19 @@ void Flags(const std::array<const char *, SIZE> names_array, T *flag_field,
}
}

template <typename T>
void UnnamedFlags(const char *name, T *flag_field, int num, int offset = 0) {
for (int idx{0}; idx < num; ++idx) {
T value = (T)std::pow(2, idx);
bool on = (*flag_field & value) == value;

if (ImGui::Checkbox(fmt::format("{} {}", name, idx + 1 + offset).c_str(),
&on)) {
*flag_field ^= value;
}
}
}

ImVec2 Normalize(ImVec2 pos) {
ImGuiIO &io = ImGui::GetIO();
ImVec2 res = io.DisplaySize;
Expand Down Expand Up @@ -312,6 +393,29 @@ void UI::DrawPlayer() {
Flags(item_names, Max::get().items(), false);
if (ImGui::CollapsingHeader("Miscellaneous##PlayerMisc"))
Flags(misc_names, Max::get().upgrades(), false);
if (ImGui::CollapsingHeader("Eggs##PlayerEggs"))
Flags(egg_names, Max::get().eggs(), false);
if (ImGui::CollapsingHeader("Candles##PlayerCandles")) {
UnnamedFlags("Candle", Max::get().candles(), 16);
}
if (ImGui::CollapsingHeader("Chests##PlayerChests")) {
UnnamedFlags("Chest", Max::get().chests(), 64);
UnnamedFlags("Chest", Max::get().chests() + 1, 64, 64);
}
if (ImGui::CollapsingHeader("Flames##PlayerFlames")) {
ImGui::SliderScalar("Blue Flame / Seahorse##BlueFlameSlider",
ImGuiDataType_U8, Max::get().flames(), &u8_zero,
&u8_five);
ImGui::SliderScalar("Purple Flame / Dog##PurpleFlameSlider",
ImGuiDataType_U8, Max::get().flames() + 1, &u8_zero,
&u8_five);
ImGui::SliderScalar("Violet Flame / Chameleon##VioletFlameSlider",
ImGuiDataType_U8, Max::get().flames() + 2, &u8_zero,
&u8_five);
ImGui::SliderScalar("Green Flame / Ostrich##GreenFlameSlider",
ImGuiDataType_U8, Max::get().flames() + 3, &u8_zero,
&u8_five);
}

if (ImGui::CollapsingHeader("Consumables##PlayerConsumables")) {
ImGui::DragScalar("Health##PlayerHealth", ImGuiDataType_S8,
Expand Down

0 comments on commit 8abf027

Please sign in to comment.