Skip to content

Commit

Permalink
add funraising flags, sort rupee flags into their own menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheenoh committed Sep 2, 2024
1 parent b788995 commit 084b1a9
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 53 deletions.
1 change: 1 addition & 0 deletions modules/boot/include/menus/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum MenuIndex {
MN_GENERAL_FLAGS_INDEX,
MN_DUNGEON_FLAGS_INDEX,
MN_PORTAL_FLAGS_INDEX,
MN_RUPEE_FLAGS_INDEX,
MN_FLAG_RECORDS_INDEX,
MN_FLAG_LOG_INDEX,
// Inventory menu's sub menus
Expand Down
5 changes: 3 additions & 2 deletions modules/boot/src/menus/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const char* g_menuPaths[MN_COUNT] = {
"inventory", "memory", "practice",
"scene", "settings", "tools",
"warp", "general_flags", "dungeon_flags",
"portal_flags", "flag_records", "flag_log",
"item_wheel", "pause", "amounts",
"portal_flags", "rupee_flags", "flag_records",
"flag_log", "item_wheel", "pause",
"amounts",
"watches", "memory_editor", "memfiles",
"any_saves", "any_bite_saves", "hundo_saves",
"ad_saves", "nosq_saves", "glitchless_saves",
Expand Down
7 changes: 5 additions & 2 deletions modules/menus/menu_flags/include/flags_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ enum FlagsIndex {
GENERAL_FLAGS_INDEX,
DUNGEON_FLAGS_INDEX,
PORTAL_FLAGS_INDEX,
RUPEE_FLAGS_INDEX,
FLAG_RECORDS_INDEX,
FLAG_LOG_INDEX
FLAG_LOG_INDEX,

FLAGS_COUNT
};

class FlagsMenu : public Menu {
Expand All @@ -16,5 +19,5 @@ class FlagsMenu : public Menu {
virtual void draw();

private:
Line lines[5];
Line lines[FLAGS_COUNT];
};
4 changes: 4 additions & 0 deletions modules/menus/menu_flags/src/flags_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ KEEP_FUNC FlagsMenu::FlagsMenu(Cursor& cursor)
{"general flags", GENERAL_FLAGS_INDEX, "General flags", false},
{"dungeon flags", DUNGEON_FLAGS_INDEX, "Dungeon flags", false},
{"portal flags", PORTAL_FLAGS_INDEX, "Warp portal flags", false},
{"rupee flags", RUPEE_FLAGS_INDEX, "Rupee related flags", false},
{"flag records", FLAG_RECORDS_INDEX, "Edit flag records", false},
{"flag log", FLAG_LOG_INDEX, "Toggle the flag log", false},
} {}
Expand All @@ -31,6 +32,9 @@ void FlagsMenu::draw() {
case PORTAL_FLAGS_INDEX:
g_menuMgr->push(MN_PORTAL_FLAGS_INDEX);
return;
case RUPEE_FLAGS_INDEX:
g_menuMgr->push(MN_RUPEE_FLAGS_INDEX);
return;
case FLAG_RECORDS_INDEX:
g_menuMgr->push(MN_FLAG_RECORDS_INDEX);
return;
Expand Down
6 changes: 2 additions & 4 deletions modules/menus/menu_general_flags/include/general_flags_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

struct GeneralFlagsData {
bool l_bossFlag;
u16 l_donationAmount;
bool l_rupeeFlag;
bool l_midnaCharge;
bool l_transformWarp;
bool l_midnaZ;
bool l_eponaStolen;
bool l_eponaTamed;
bool l_maloMartCT;
bool l_mapWarping;
bool l_midnaHealed;
bool l_midnaRide;
Expand All @@ -18,10 +17,9 @@ struct GeneralFlagsData {

enum GeneralFlagsIndex {
BOSS_FLAG_INDEX,
DONATION_AMT_INDEX,
RUPEE_CS_FLAG_INDEX,
EPONA_STOLEN_INDEX,
EPONA_TAMED_INDEX,
MALO_MART_CT_INDEX,
MAP_WARPING_INDEX,
MIDNA_CHARGE_INDEX,
MIDNA_HEALTHY,
Expand Down
51 changes: 6 additions & 45 deletions modules/menus/menu_general_flags/src/general_flags_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ KEEP_FUNC GeneralFlagsMenu::GeneralFlagsMenu(Cursor& cursor)
: Menu(cursor),
lines{
{"boss flag", BOSS_FLAG_INDEX, "Sets the boss flag value", true, [](){return generalFlagsData->l_bossFlag;}},
{"donation amount:", DONATION_AMT_INDEX, "Sets the donation amount"},
{"rupee cutscenes", RUPEE_CS_FLAG_INDEX, "Toggle rupee cutscenes being enabled", true,
[](){return generalFlagsData->l_rupeeFlag;}},
{"epona stolen", EPONA_STOLEN_INDEX, "Toggle flag for Epona being stolen", true,
[](){return generalFlagsData->l_eponaStolen;}},
{"epona tamed", EPONA_TAMED_INDEX, "Toggle flag for Epona being tamed", true,
[](){return generalFlagsData->l_eponaTamed;}},
{"malo mart in castle town", MALO_MART_CT_INDEX, "Toggle flag for Malo Mart being open in Castle Town", true,
[](){return generalFlagsData->l_maloMartCT;}},
{"map warping", MAP_WARPING_INDEX, "Toggle flag for map warping", true, [](){return generalFlagsData->l_mapWarping;}},
{"midna charge", MIDNA_CHARGE_INDEX, "Toggle flag for Midna charge", true,
[](){return generalFlagsData->l_midnaCharge;}},
Expand All @@ -35,8 +34,6 @@ KEEP_FUNC GeneralFlagsMenu::GeneralFlagsMenu(Cursor& cursor)
GeneralFlagsMenu::~GeneralFlagsMenu() {}

void GeneralFlagsMenu::draw() {
cursor.setMode(Cursor::MODE_LIST);

if (!generalFlagsData) {
return;
}
Expand All @@ -48,41 +45,17 @@ void GeneralFlagsMenu::draw() {
generalFlagsData->l_midnaZ = dComIfGs_isEventBit(0x0C10);
generalFlagsData->l_eponaStolen = dComIfGs_isEventBit(0x0580);
generalFlagsData->l_eponaTamed = dComIfGs_isEventBit(0x0601);
generalFlagsData->l_maloMartCT = dComIfGs_isEventBit(0x2210);
generalFlagsData->l_mapWarping = dComIfGs_isEventBit(0x0604);
generalFlagsData->l_midnaHealed = dComIfGs_isEventBit(0x1E08);
generalFlagsData->l_midnaRide = dComIfGs_isTransformLV(3);
generalFlagsData->l_wolfSense = dComIfGs_isEventBit(0x4308);

// update donation amount
u8 high_bits = dComIfGs_getEventReg(0xf7ff);
u8 low_bits = dComIfGs_getEventReg(0xf8ff);

generalFlagsData->l_donationAmount = high_bits << 8 | low_bits;

for (int i = BLUE_RUPEE; i <= SILVER_RUPEE; i++) {
if (dComIfGs_isItemFirstBit(i)) {
generalFlagsData->l_rupeeFlag = true;
break;
}
}

if (GZ_getButtonTrig(BACK_BUTTON)) {
g_menuMgr->pop();
return;
}

switch (cursor.y) {
case DONATION_AMT_INDEX:
Cursor::moveList(generalFlagsData->l_donationAmount);

u8 high_bits = (generalFlagsData->l_donationAmount >> 8) & 0xFF;
u8 low_bits = generalFlagsData->l_donationAmount & 0xFF;

dComIfGs_setEventReg(0xf7ff, high_bits);
dComIfGs_setEventReg(0xf8ff, low_bits);
break;
}

if (GZ_getButtonTrig(SELECTION_BUTTON)) {
switch (cursor.y) {
case BOSS_FLAG_INDEX:
Expand All @@ -92,25 +65,15 @@ void GeneralFlagsMenu::draw() {
bossFlags = 255;
}
break;

case RUPEE_CS_FLAG_INDEX:
if (generalFlagsData->l_rupeeFlag) {
for (int i = BLUE_RUPEE; i <= SILVER_RUPEE; i++) {
dComIfGs_offItemFirstBit(i);
}
generalFlagsData->l_rupeeFlag = false;
} else {
for (int i = BLUE_RUPEE; i <= SILVER_RUPEE; i++) {
dComIfGs_onItemFirstBit(i);
}
}
break;
case EPONA_STOLEN_INDEX:
setEventFlag(0x0580);
break;
case EPONA_TAMED_INDEX:
setEventFlag(0x0601);
break;
case MALO_MART_CT_INDEX:
setEventFlag(0x2210);
break;
case MAP_WARPING_INDEX:
setEventFlag(0x0604);
break;
Expand Down Expand Up @@ -139,8 +102,6 @@ void GeneralFlagsMenu::draw() {
}
}

lines[DONATION_AMT_INDEX].printf(" <%d>", generalFlagsData->l_donationAmount);

cursor.move(0, MENU_LINE_NUM);
GZ_drawMenuLines(lines, cursor.y, MENU_LINE_NUM);
}
5 changes: 5 additions & 0 deletions modules/menus/menu_rupee_flags/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file(GLOB_RECURSE srcs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE asms CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.s")
list(APPEND srcs ${asms})
get_filename_component(rel_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
tpgz_add_module(${rel_name} "${srcs}" "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 changes: 6 additions & 0 deletions modules/menus/menu_rupee_flags/include/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace tpgz::modules {
void main();
void exit();
} // namespace tpgz::modules
32 changes: 32 additions & 0 deletions modules/menus/menu_rupee_flags/include/rupee_flags_menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once
#include "menus/menu.h"

struct RupeeFlagsData {
u16 l_donationAmount;
u16 l_fundraisingAmount;
bool l_fundraising1;
bool l_fundraising2;
bool l_rupeeFlag;
};

enum GeneralFlagsIndex {
DONATION_AMT_INDEX,
FUNDRAISING_AMT_INDEX,
FUNDRAISING_1_INDEX,
FUNDRAISING_2_INDEX,
RUPEE_CS_FLAG_INDEX,

RUPEE_FLAGS_COUNT
};

extern RupeeFlagsData* rupeeFlagsData;

class RupeeFlagsMenu : public Menu {
public:
RupeeFlagsMenu(Cursor&);
virtual ~RupeeFlagsMenu();
virtual void draw();

private:
Line lines[RUPEE_FLAGS_COUNT];
};
56 changes: 56 additions & 0 deletions modules/menus/menu_rupee_flags/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <main.h>
#include "menus/menu_rupee_flags/include/rupee_flags_menu.h"
#include "events/draw_listener.h"
#include "menus/utils/menu_mgr.h"
#include "utils/draw.h"

void onCreate();
void onLoad();
void onDraw();
void onUnload();
void onDelete();

RupeeFlagsMenu* l_menu;

namespace tpgz::modules {
void main() {
g_menuMgr->setCreateHook(onCreate);
g_menuMgr->setLoadHook(onLoad);
g_menuMgr->setUnloadHook(onUnload);
g_menuMgr->setDeleteHook(onDelete);
}
void exit() {
g_menuMgr->setCreateHook(nullptr);
g_menuMgr->setLoadHook(nullptr);
g_menuMgr->setUnloadHook(nullptr);
g_menuMgr->setDeleteHook(nullptr);
}
} // namespace tpgz::modules

void onCreate() {
g_menuMgr->setPersistentData(new RupeeFlagsData);
if (!g_menuMgr->getPermanentData<Cursor>()) {
g_menuMgr->setPermanentData(new Cursor);
}
}

void onLoad() {
rupeeFlagsData = g_menuMgr->getPersistentData<RupeeFlagsData>();
l_menu = new RupeeFlagsMenu(*g_menuMgr->getPermanentData<Cursor>());
g_drawListener->addListener(onDraw);
}

void onDraw() {
l_menu->draw();
}

void onUnload() {
g_drawListener->removeListener(onDraw);
delete l_menu;
}

void onDelete() {
auto data = g_menuMgr->getPersistentData<RupeeFlagsData>();
delete data;
g_menuMgr->setPersistentData<RupeeFlagsData>(nullptr);
}
Loading

0 comments on commit 084b1a9

Please sign in to comment.