Skip to content

Commit

Permalink
Overhaul item menu layout
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Nov 26, 2023
1 parent 0ddb071 commit 6b6805d
Show file tree
Hide file tree
Showing 24 changed files with 724 additions and 325 deletions.
2 changes: 1 addition & 1 deletion soh/include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extern "C"
extern void* gItemIcons[0x82];
extern u8 gItemAgeReqs[];
extern u8 gSlotAgeReqs[];
extern u8 gItemSlots[56];
extern u8 gItemSlots[71];
extern void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*);
extern s16 gLinkObjectIds[2];
extern u32 gObjectTableSize;
Expand Down
2 changes: 2 additions & 0 deletions soh/include/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ typedef struct {
/* 0x0266 */ u8 worldMapPoints[20]; // 0 = hidden; 1 = displayed; 2 = highlighted
/* 0x027A */ u8 tradeQuestLocation;
/* 0x027C */ SkelAnime playerSkelAnime;
Vtx* arrowSelectVtx;
s16 arrowMenuAnimPos;
} PauseContext; // size = 0x2C0

typedef enum {
Expand Down
60 changes: 31 additions & 29 deletions soh/include/z64item.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,36 +116,38 @@ typedef enum {
} DungeonItem;

typedef enum {
/* 0x00 */ SLOT_STICK,
/* 0x01 */ SLOT_NUT,
/* 0x02 */ SLOT_BOMB,
/* 0x03 */ SLOT_BOW,
/* 0x04 */ SLOT_ARROW_FIRE,
/* 0x05 */ SLOT_DINS_FIRE,
/* 0x06 */ SLOT_SLINGSHOT,
/* 0x07 */ SLOT_OCARINA,
/* 0x08 */ SLOT_BOMBCHU,
/* 0x09 */ SLOT_HOOKSHOT,
/* 0x0A */ SLOT_ARROW_ICE,
/* 0x0B */ SLOT_FARORES_WIND,
/* 0x0C */ SLOT_BOOMERANG,
/* 0x0D */ SLOT_LENS,
/* 0x0E */ SLOT_BEAN,
/* 0x00 */ SLOT_DINS_FIRE,
/* 0x01 */ SLOT_BOMB,
/* 0x02 */ SLOT_BOMBCHU,
/* 0x03 */ SLOT_NUT,
/* 0x04 */ SLOT_LENS,
/* 0x05 */ SLOT_BEAN,
/* 0x06 */ SLOT_FARORES_WIND,
/* 0x07 */ SLOT_SLINGSHOT,
/* 0x08 */ SLOT_BOOMERANG,
/* 0x09 */ SLOT_STICK,
/* 0x0A */ SLOT_BOOTS_HOVER,
/* 0x0B */ SLOT_TRADE_CHILD,
/* 0x0C */ SLOT_NAYRUS_LOVE,
/* 0x0D */ SLOT_BOW,
/* 0x0E */ SLOT_HOOKSHOT,
/* 0x0F */ SLOT_HAMMER,
/* 0x10 */ SLOT_ARROW_LIGHT,
/* 0x11 */ SLOT_NAYRUS_LOVE,
/* 0x12 */ SLOT_BOTTLE_1,
/* 0x13 */ SLOT_BOTTLE_2,
/* 0x14 */ SLOT_BOTTLE_3,
/* 0x15 */ SLOT_BOTTLE_4,
/* 0x16 */ SLOT_TRADE_ADULT,
/* 0x17 */ SLOT_TRADE_CHILD,
/* 0x18 */ SLOT_TUNIC_KOKIRI,
/* 0x19 */ SLOT_TUNIC_GORON,
/* 0x1A */ SLOT_TUNIC_ZORA,
/* 0x1B */ SLOT_BOOTS_KOKIRI,
/* 0x1C */ SLOT_BOOTS_IRON,
/* 0x1D */ SLOT_BOOTS_HOVER,
/* 0x10 */ SLOT_BOOTS_IRON,
/* 0x11 */ SLOT_TRADE_ADULT,
/* 0x12 */ SLOT_EMPTY_LEFT,
/* 0x13 */ SLOT_BOTTLE_1,
/* 0x14 */ SLOT_BOTTLE_2,
/* 0x15 */ SLOT_BOTTLE_3,
/* 0x16 */ SLOT_BOTTLE_4,
/* 0x17 */ SLOT_EMPTY_RIGHT,
/* 0x18 */ SLOT_OCARINA,
/* 0x19 */ SLOT_ARROW_FIRE,
/* 0x1A */ SLOT_ARROW_ICE,
/* 0x1B */ SLOT_ARROW_LIGHT,
/* 0x1C */ SLOT_TUNIC_KOKIRI,
/* 0x1D */ SLOT_TUNIC_GORON,
/* 0x1E */ SLOT_TUNIC_ZORA,
/* 0x1F */ SLOT_BOOTS_KOKIRI,
/* 0xFF */ SLOT_NONE = 0xFF
} InventorySlot;

Expand Down
5 changes: 3 additions & 2 deletions soh/include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct {
} ItemEquips; // size = 0x0A

typedef struct {
/* 0x00 */ u8 items[24];
/* 0x00 */ u8 items[28];
/* 0x18 */ s8 ammo[16];
/* 0x28 */ u16 equipment; // a mask where each nibble corresponds to a type of equipment `EquipmentType`, and each bit to an owned piece `EquipInv*`
/* 0x2C */ u32 upgrades;
Expand Down Expand Up @@ -389,7 +389,8 @@ typedef enum {

typedef enum {
/* 0 */ LINK_AGE_ADULT,
/* 1 */ LINK_AGE_CHILD
/* 1 */ LINK_AGE_CHILD,
/* 9 */ LINK_AGE_EITHER = 9
} LinkAge;


Expand Down
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/controls/GameControlEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ namespace GameControlEditor {
"To make the cursor only move a single space during name entry no matter how long a direction is held, manually set gDpadHoldChange to 0");
UIWidgets::PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips");
DrawHelpIcon("Equip items and equipment on the D-pad\nIf used with D-pad on Pause Screen, you must hold C-Up to equip instead of navigate");
UIWidgets::PaddedEnhancementCheckbox("Toggle minimap with D-pad down", "gMapOnDDown");
DrawHelpIcon("Toggle the minimap by pressing down on the D-pad\nIf \"D-pad as Equip Items\" is enabled, equipping an item on D-pad down will prevent you from toggling the map");
window->EndGroupPanelPublic(0);
}

Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ void Draw_Placements(){
ImGui::EndTable();
}
}
if (CVarGetInteger("gDpadEquips",0) && ImGui::CollapsingHeader("DPad items position")) {
if (ImGui::CollapsingHeader("DPad items position")) {
if (ImGui::BeginTable("tabledpaditems", 1, FlagsTable)) {
ImGui::TableSetupColumn("DPad items settings", FlagsCell, TablesCellsWidth);
Table_InitHeader(false);
Expand Down
3 changes: 3 additions & 0 deletions soh/soh/Enhancements/custom-message/CustomMessageTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ typedef enum {
TEXT_WARP_RANDOM_REPLACED_TEXT = 0x9200,
TEXT_LAKE_HYLIA_WATER_SWITCH_SIGN = 0x346, // 0x3yy for cuttable sign range
TEXT_LAKE_HYLIA_WATER_SWITCH_NAVI = 0x1B3, // 0x1yy for Navi msg range
TEXT_FIRE_ARROW = 0x0070,
TEXT_ICE_ARROW = 0x0071,
TEXT_LIGHT_ARROW = 0x0072,
} TextIDs;

#ifdef __cplusplus
Expand Down
12 changes: 8 additions & 4 deletions soh/soh/Enhancements/debugger/debugSaveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,16 @@ void DrawInventoryTab() {
ImGui::Checkbox("Restrict to valid items", &restrictToValid);
UIWidgets::InsertHelpHoverText("Restricts items and ammo to only what is possible to legally acquire in-game");

for (int32_t y = 0; y < 4; y++) {
for (int32_t y = 0; y < 5; y++) {
for (int32_t x = 0; x < 6; x++) {
int32_t index = x + y * 6;
static int32_t selectedIndex = -1;
static const char* itemPopupPicker = "itemPopupPicker";

if (index >= ARRAY_COUNT(gSaveContext.inventory.items)) {
break;
}

ImGui::PushID(index);

if (x != 0) {
Expand Down Expand Up @@ -1705,10 +1709,10 @@ void DrawPlayerTab() {
ImGui::SameLine();
ImGui::InputScalar("C Right", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[3], &one, NULL);

ImGui::NewLine();
ImGui::Text("Current D-pad Equips");
ImGui::InputScalar("D-pad Up ", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[4], &one, NULL); // Two spaces at the end for aligning, not elegant but it's working
if (CVarGetInteger("gDpadEquips", 0)) {
ImGui::NewLine();
ImGui::Text("Current D-pad Equips");
ImGui::InputScalar("D-pad Up ", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[4], &one, NULL); // Two spaces at the end for aligning, not elegant but it's working
ImGui::SameLine();
ImGui::InputScalar("D-pad Down", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[5], &one, NULL);
// Intentionnal to not put everything on the same line, else it's taking too much for lower resolution.
Expand Down
7 changes: 0 additions & 7 deletions soh/soh/Enhancements/presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ const std::vector<const char*> enhancementsCvars = {
"gDisableCritWiggle",
"gChestSizeDependsStoneOfAgony",
"gSkipArrowAnimation",
"gSeparateArrows",
"gCustomizeShootingGallery",
"gInstantShootingGalleryWin",
"gConstantAdultGallery",
Expand Down Expand Up @@ -576,9 +575,6 @@ const std::vector<PresetEntry> enhancedPresetEntries = {
// Skip Magic Arrow Equip Animation
PRESET_ENTRY_S32("gSkipArrowAnimation", 1),

// Equip arrows on multiple slots
PRESET_ENTRY_S32("gSeparateArrows", 1),

// Disable Navi Call Audio
PRESET_ENTRY_S32("gDisableNaviCallAudio", 1),

Expand Down Expand Up @@ -700,9 +696,6 @@ const std::vector<PresetEntry> randomizerPresetEntries = {
// Exit Market at Night
PRESET_ENTRY_S32("gMarketSneak", 1),

// Equip arrows on multiple slots
PRESET_ENTRY_S32("gSeparateArrows", 1),

// Disable Navi Call Audio
PRESET_ENTRY_S32("gDisableNaviCallAudio", 1),

Expand Down
29 changes: 16 additions & 13 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ const char* constCameraStrings[] = {
OTRGlobals::OTRGlobals() {
std::vector<std::string> OTRFiles;
std::string mqPath = LUS::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName);
if (std::filesystem::exists(mqPath)) {
if (std::filesystem::exists(mqPath)) {
OTRFiles.push_back(mqPath);
}
}
std::string ootPath = LUS::Context::LocateFileAcrossAppDirs("oot.otr", appShortName);
if (std::filesystem::exists(ootPath)) {
OTRFiles.push_back(ootPath);
Expand All @@ -262,7 +262,7 @@ OTRGlobals::OTRGlobals() {
}
}
}
std::unordered_set<uint32_t> ValidHashes = {
std::unordered_set<uint32_t> ValidHashes = {
OOT_PAL_MQ,
OOT_NTSC_JP_MQ,
OOT_NTSC_US_MQ,
Expand Down Expand Up @@ -849,7 +849,7 @@ void CheckSoHOTRVersion(std::string otrPath) {
}

// Checks the program version stored in the otr and compares the major value to soh
// For Windows/Mac/Linux if the version doesn't match, offer to
// For Windows/Mac/Linux if the version doesn't match, offer to
void DetectOTRVersion(std::string fileName, bool isMQ) {
bool isOtrOld = false;
std::string otrPath = LUS::Context::LocateFileAcrossAppDirs(fileName, appShortName);
Expand Down Expand Up @@ -1033,7 +1033,7 @@ extern "C" void InitOTR() {
SpeechSynthesizer::Instance = new SAPISpeechSynthesizer();
SpeechSynthesizer::Instance->Init();
#endif

clearMtx = (uintptr_t)&gMtxClear;
OTRMessage_Init();
OTRAudio_Init();
Expand Down Expand Up @@ -1063,7 +1063,7 @@ extern "C" void InitOTR() {
}
#endif

std::shared_ptr<LUS::Config> conf = OTRGlobals::Instance->context->GetConfig();
std::shared_ptr<LUS::Config> conf = OTRGlobals::Instance->context->GetConfig();
conf->RegisterConfigVersionUpdater(std::make_shared<LUS::ConfigVersion1Updater>());
conf->RegisterConfigVersionUpdater(std::make_shared<LUS::ConfigVersion2Updater>());
conf->RunVersionUpdates();
Expand Down Expand Up @@ -1458,11 +1458,11 @@ std::shared_ptr<LUS::IResource> GetResourceByNameHandlingMQ(const char* path) {

extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) {
auto res = GetResourceByNameHandlingMQ(path);

if (res == nullptr) {
return nullptr;
}

return (char*)res->GetRawPointer();
}

Expand Down Expand Up @@ -1544,7 +1544,7 @@ extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) {

if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
return (char*)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);

return nullptr;
}

Expand Down Expand Up @@ -2113,10 +2113,10 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {

extern "C" int Controller_ShouldRumble(size_t slot) {
auto controlDeck = LUS::Context::GetInstance()->GetControlDeck();

if (slot < controlDeck->GetNumConnectedPorts()) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);

if (physicalDevice->GetProfile(slot)->UseRumble && physicalDevice->CanRumble()) {
return 1;
}
Expand Down Expand Up @@ -2338,7 +2338,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) {
Player_GetMask(play) == PLAYER_MASK_TRUTH) ||
(Randomizer_GetSettingValue(RSK_GOSSIP_STONE_HINTS) == RO_GOSSIP_STONES_NEED_STONE && CHECK_QUEST_ITEM(QUEST_STONE_OF_AGONY)))) {

Actor* stone = GET_PLAYER(play)->targetActor;
Actor* stone = GET_PLAYER(play)->targetActor;
actorParams = stone->params;

// if we're in a generic grotto
Expand Down Expand Up @@ -2374,7 +2374,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) {
messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_GANONDORF);
}
} else if (textId == TEXT_SHEIK_NEED_HOOK || textId == TEXT_SHEIK_HAVE_HOOK) {
messageEntry = OTRGlobals::Instance->gRandomizer->GetSheikMessage(gPlayState->sceneNum, textId);
messageEntry = OTRGlobals::Instance->gRandomizer->GetSheikMessage(gPlayState->sceneNum, textId);
// textId: TEXT_SCRUB_RANDOM + (randomizerInf - RAND_INF_SCRUBS_PURCHASED_DODONGOS_CAVERN_DEKU_SCRUB_NEAR_BOMB_BAG_LEFT)
} else if (textId >= TEXT_SCRUB_RANDOM && textId <= TEXT_SCRUB_RANDOM + NUM_SCRUBS) {
RandomizerInf randoInf = (RandomizerInf)((textId - TEXT_SCRUB_RANDOM) + RAND_INF_SCRUBS_PURCHASED_DODONGOS_CAVERN_DEKU_SCRUB_NEAR_BOMB_BAG_LEFT);
Expand Down Expand Up @@ -2478,6 +2478,9 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) {
if (textId == TEXT_MARKET_GUARD_NIGHT && CVarGetInteger("gMarketSneak", 0) && play->sceneNum == SCENE_MARKET_ENTRANCE_NIGHT) {
messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, TEXT_MARKET_GUARD_NIGHT);
}
if (textId >= TEXT_FIRE_ARROW && textId <= TEXT_LIGHT_ARROW) {
messageEntry = CustomMessageManager::Instance->RetrieveMessage(customMessageTableID, textId);
}
font->charTexBuf[0] = (messageEntry.GetTextBoxType() << 4) | messageEntry.GetTextBoxPosition();
switch (gSaveContext.language) {
case LANGUAGE_FRA:
Expand Down
19 changes: 13 additions & 6 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,17 @@ void SaveManager::InitFileDebug() {
for (int button = 0; button < ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots); button++) {
gSaveContext.childEquips.cButtonSlots[button] = SLOT_NONE;
}
gSaveContext.childEquips.buttonItems[4] = ITEM_OCARINA_FAIRY;
gSaveContext.childEquips.cButtonSlots[3] = SLOT_OCARINA;
gSaveContext.childEquips.equipment = 0;
for (int button = 0; button < ARRAY_COUNT(gSaveContext.adultEquips.buttonItems); button++) {
gSaveContext.adultEquips.buttonItems[button] = ITEM_NONE;
}
for (int button = 0; button < ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots); button++) {
gSaveContext.adultEquips.cButtonSlots[button] = SLOT_NONE;
}
gSaveContext.adultEquips.buttonItems[4] = ITEM_OCARINA_FAIRY;
gSaveContext.adultEquips.cButtonSlots[3] = SLOT_OCARINA;
gSaveContext.adultEquips.equipment = 0;
gSaveContext.unk_54 = 0;
gSaveContext.savedSceneNum = 0x51;
Expand All @@ -682,19 +686,22 @@ void SaveManager::InitFileDebug() {
for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); button++) {
gSaveContext.equips.cButtonSlots[button] = sCButtonSlots[button];
}
gSaveContext.equips.buttonItems[4] = ITEM_OCARINA_FAIRY;
gSaveContext.equips.cButtonSlots[3] = SLOT_OCARINA;
gSaveContext.equips.equipment = 0x1122;

// Inventory
static std::array<u8, 24> sItems = {
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_ARROW_FIRE, ITEM_DINS_FIRE,
ITEM_SLINGSHOT, ITEM_OCARINA_FAIRY, ITEM_BOMBCHU, ITEM_HOOKSHOT, ITEM_ARROW_ICE, ITEM_FARORES_WIND,
ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE,
ITEM_BOTTLE, ITEM_POTION_RED, ITEM_POTION_GREEN, ITEM_POTION_BLUE, ITEM_POCKET_EGG, ITEM_WEIRD_EGG,
static std::array<u8, 28> sItems = {
ITEM_DINS_FIRE, ITEM_BOMB, ITEM_BOMBCHU, ITEM_NUT, ITEM_LENS, ITEM_BEAN,
ITEM_FARORES_WIND, ITEM_SLINGSHOT, ITEM_BOOMERANG, ITEM_STICK, ITEM_BOOTS_HOVER, ITEM_WEIRD_EGG,
ITEM_NAYRUS_LOVE, ITEM_BOW, ITEM_HOOKSHOT, ITEM_HAMMER, ITEM_BOOTS_IRON, ITEM_CLAIM_CHECK,
ITEM_NONE, ITEM_BOTTLE, ITEM_POTION_RED, ITEM_POTION_GREEN, ITEM_POTION_BLUE, ITEM_NONE,
ITEM_OCARINA_FAIRY, ITEM_ARROW_FIRE, ITEM_ARROW_ICE, ITEM_ARROW_LIGHT
};
for (int item = 0; item < ARRAY_COUNT(gSaveContext.inventory.items); item++) {
gSaveContext.inventory.items[item] = sItems[item];
}
static std::array<s8, 16> sAmmo = { 50, 50, 10, 30, 1, 1, 30, 1, 50, 1, 1, 1, 1, 1, 1, 1 };
static std::array<s8, 16> sAmmo = { 1, 20, 50, 20, 1, 10, 1, 30, 1, 10, 1, 1, 1, 30, 1, 1 };
for (int ammo = 0; ammo < ARRAY_COUNT(gSaveContext.inventory.ammo); ammo++) {
gSaveContext.inventory.ammo[ammo] = sAmmo[ammo];
}
Expand Down
2 changes: 0 additions & 2 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,6 @@ void DrawEnhancementsMenu() {
UIWidgets::Tooltip("After completing the mask trading sub-quest, press A and any direction on the mask slot to change masks");
UIWidgets::PaddedEnhancementCheckbox("Nuts explode bombs", "gNutsExplodeBombs", true, false);
UIWidgets::Tooltip("Makes nuts explode bombs, similar to how they interact with bombchus. This does not affect bombflowers.");
UIWidgets::PaddedEnhancementCheckbox("Equip Multiple Arrows at Once", "gSeparateArrows", true, false);
UIWidgets::Tooltip("Allow the bow and magic arrows to be equipped at the same time on different slots");
UIWidgets::PaddedEnhancementCheckbox("Bow as Child/Slingshot as Adult", "gBowSlingShotAmmoFix", true, false);
UIWidgets::Tooltip("Allows child to use bow with arrows.\nAllows adult to use slingshot with seeds.\n\nRequires glitches or 'Timeless Equipment' cheat to equip.");
UIWidgets::PaddedEnhancementCheckbox("Better Farore's Wind", "gBetterFW", true, false);
Expand Down
Loading

0 comments on commit 6b6805d

Please sign in to comment.