Skip to content

Commit

Permalink
Merge branch 'new_item_menu' into mod-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Dec 28, 2023
2 parents 21a1573 + d03471d commit 7591cdc
Show file tree
Hide file tree
Showing 23 changed files with 863 additions and 654 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[0x83];
extern u8 gItemAgeReqs[];
extern u8 gSlotAgeReqs[];
extern u8 gItemSlots[71];
extern u8 gItemSlots[56];
extern void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*);
extern s16 gLinkObjectIds[2];
extern u32 gObjectTableSize;
Expand Down
2 changes: 0 additions & 2 deletions soh/include/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,6 @@ 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: 29 additions & 31 deletions soh/include/z64item.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,38 +116,36 @@ typedef enum {
} DungeonItem;

typedef enum {
/* 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,
/* 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,
/* 0x0F */ SLOT_HAMMER,
/* 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,
/* 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,
/* 0xFF */ SLOT_NONE = 0xFF
} InventorySlot;

Expand Down
4 changes: 2 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[28];
/* 0x00 */ u8 items[24];
/* 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,7 @@ typedef enum {

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


Expand Down
39 changes: 17 additions & 22 deletions soh/soh/Enhancements/boss-rush/BossRush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct BossRushSetting {
std::vector<std::array<std::string, LANGUAGE_MAX>> choices;
} BossRushSetting;

BossRushSetting BossRushOptions[BOSSRUSH_OPTIONS_AMOUNT] = {
BossRushSetting BossRushOptions[BOSSRUSH_OPTIONS_AMOUNT] = {
{
{ "BOSSES:", "BOSSE:", "BOSS:" },
{
Expand Down Expand Up @@ -309,7 +309,7 @@ void BossRush_InitSave() {

// Set health
uint16_t health = 16;
switch (gSaveContext.bossRushOptions[BR_OPTIONS_HEARTS]) {
switch (gSaveContext.bossRushOptions[BR_OPTIONS_HEARTS]) {
case BR_CHOICE_HEARTS_7:
health *= 7;
break;
Expand Down Expand Up @@ -351,57 +351,52 @@ void BossRush_InitSave() {
}

// Set items
std::array<u8, 28> brItems = {
ITEM_NONE, ITEM_BOMB, ITEM_NONE, ITEM_NUT, ITEM_LENS, ITEM_NONE,
ITEM_NONE, ITEM_SLINGSHOT, ITEM_BOOMERANG, ITEM_STICK, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_BOW, ITEM_HOOKSHOT, ITEM_HAMMER, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_ARROW_LIGHT,
std::array<u8, 24> brItems = {
ITEM_STICK, ITEM_NUT, ITEM_BOMB, ITEM_BOW, ITEM_NONE, ITEM_NONE,
ITEM_SLINGSHOT, ITEM_NONE, ITEM_NONE, ITEM_HOOKSHOT, ITEM_NONE, ITEM_NONE,
ITEM_BOOMERANG, ITEM_LENS, ITEM_NONE, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NONE,
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE,
};

if (gSaveContext.bossRushOptions[BR_OPTIONS_LONGSHOT] == BR_CHOICE_LONGSHOT_YES) {
brItems[SLOT_HOOKSHOT] = ITEM_LONGSHOT;
brItems[9] = ITEM_LONGSHOT;
}

switch (gSaveContext.bossRushOptions[BR_OPTIONS_BOTTLE]) {
case BR_CHOICE_BOTTLE_EMPTY:
brItems[SLOT_BOTTLE_1] = ITEM_BOTTLE;
brItems[18] = ITEM_BOTTLE;
break;
case BR_CHOICE_BOTTLE_FAIRY:
brItems[SLOT_BOTTLE_1] = ITEM_FAIRY;
brItems[18] = ITEM_FAIRY;
break;
case BR_CHOICE_BOTTLE_REDPOTION:
brItems[SLOT_BOTTLE_1] = ITEM_POTION_RED;
brItems[18] = ITEM_POTION_RED;
break;
case BR_CHOICE_BOTTLE_GREENPOTION:
brItems[SLOT_BOTTLE_1] = ITEM_POTION_GREEN;
brItems[18] = ITEM_POTION_GREEN;
break;
case BR_CHOICE_BOTTLE_BLUEPOTION:
brItems[SLOT_BOTTLE_1] = ITEM_POTION_BLUE;
brItems[18] = ITEM_POTION_BLUE;
break;
default:
break;
}

if (gSaveContext.bossRushOptions[BR_OPTIONS_BUNNYHOOD] == BR_CHOICE_BUNNYHOOD_YES) {
brItems[SLOT_TRADE_CHILD] = ITEM_MASK_BUNNY;
}

if (gSaveContext.bossRushOptions[BR_OPTIONS_HOVERBOOTS] == BR_CHOICE_HOVERBOOTS_YES) {
brItems[SLOT_BOOTS_HOVER] = ITEM_BOOTS_HOVER;
brItems[23] = ITEM_MASK_BUNNY;
}

for (int item = 0; item < ARRAY_COUNT(gSaveContext.inventory.items); item++) {
gSaveContext.inventory.items[item] = brItems[item];
}

// Set consumable counts
std::array<s8, 16> brAmmo = { 0, 10, 0, 5, 0, 0, 0, 10, 0, 5, 0, 0, 0, 10, 0, 0 };
std::array<s8, 16> brAmmo = { 5, 5, 10, 10, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

if (gSaveContext.bossRushOptions[BR_OPTIONS_AMMO] == BR_CHOICE_AMMO_FULL) {
brAmmo = { 0, 20, 0, 20, 0, 0, 0, 30, 0, 10, 0, 0, 0, 30, 0, 0 };
brAmmo = { 10, 20, 20, 30, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
} else if (gSaveContext.bossRushOptions[BR_OPTIONS_AMMO] == BR_CHOICE_AMMO_MAXED) {
brAmmo = { 0, 40, 0, 40, 0, 0, 0, 50, 0, 30, 0, 0, 0, 50, 0, 0 };
brAmmo = { 30, 40, 40, 50, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
}

for (int ammo = 0; ammo < ARRAY_COUNT(gSaveContext.inventory.ammo); ammo++) {
Expand Down
3 changes: 2 additions & 1 deletion soh/soh/Enhancements/controls/GameControlEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ namespace GameControlEditor {
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");
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, but you can clear the item on D-pad down by re-equipping it over itself.");
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 (ImGui::CollapsingHeader("DPad items position")) {
if ((CVarGetInteger("gDpadEquips",0) || CVarGetInteger("gAltItemMenu", 0)) && ImGui::CollapsingHeader("DPad items position")) {
if (ImGui::BeginTable("tabledpaditems", 1, FlagsTable)) {
ImGui::TableSetupColumn("DPad items settings", FlagsCell, TablesCellsWidth);
Table_InitHeader(false);
Expand Down
14 changes: 6 additions & 8 deletions soh/soh/Enhancements/debugger/debugSaveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,16 +639,12 @@ 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 < 5; y++) {
for (int32_t y = 0; y < 4; 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 @@ -1709,9 +1705,11 @@ 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) || CVarGetInteger("gAltItemMenu", 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
}
if (CVarGetInteger("gDpadEquips", 0)) {
ImGui::SameLine();
ImGui::InputScalar("D-pad Down", ImGuiDataType_U8, &gSaveContext.equips.buttonItems[5], &one, NULL);
Expand Down
66 changes: 66 additions & 0 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,71 @@ void RegisterRandomizedEnemySizes() {
});
}

void AltItemMenu_Update() {
if (CVarGetInteger("gAltItemMenu", 0)) { // Enabled: force equip ocarina on D-up and match equipped bow, if any
uint16_t targetCBtn = 3;
uint16_t targetButtonIndex = targetCBtn + 1;
for (uint16_t otherSlotIndex = 0; otherSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); otherSlotIndex++) {
uint16_t otherButtonIndex = otherSlotIndex + 1;
if (otherSlotIndex == targetCBtn) {
continue;
}

if (gSaveContext.equips.cButtonSlots[otherSlotIndex] == SLOT_OCARINA) {
// Assign the other button to the target's current item
if (gSaveContext.equips.buttonItems[targetButtonIndex] != ITEM_NONE) {
gSaveContext.equips.buttonItems[otherButtonIndex] =
gSaveContext.equips.buttonItems[targetButtonIndex];
gSaveContext.equips.cButtonSlots[otherSlotIndex] =
gSaveContext.equips.cButtonSlots[targetCBtn];
Interface_LoadItemIcon2(gPlayState, otherButtonIndex);
} else {
gSaveContext.equips.buttonItems[otherButtonIndex] = ITEM_NONE;
gSaveContext.equips.cButtonSlots[otherSlotIndex] = SLOT_NONE;
}
//break; // 'Assume there is only one possible pre-existing equip'
}

if (gSaveContext.equips.cButtonSlots[otherSlotIndex] == SLOT_BOW) {
switch (gSaveContext.equips.buttonItems[otherButtonIndex]) {
case ITEM_BOW_ARROW_FIRE:
case ITEM_BOW_ARROW_ICE:
case ITEM_BOW_ARROW_LIGHT:
INV_CONTENT(ITEM_BOW) = gSaveContext.equips.buttonItems[otherButtonIndex];
break;
}
}
}

gSaveContext.equips.buttonItems[targetButtonIndex] = INV_CONTENT(ITEM_OCARINA_FAIRY);
gSaveContext.equips.cButtonSlots[targetCBtn] = SLOT_OCARINA;
Interface_LoadItemIcon1(gPlayState, targetButtonIndex);
} else { // Disabled: reset bow item to Fairy Bow if some magic arrow is equipped
switch (INV_CONTENT(ITEM_BOW)) {
case ITEM_BOW_ARROW_FIRE:
case ITEM_BOW_ARROW_ICE:
case ITEM_BOW_ARROW_LIGHT:
INV_CONTENT(ITEM_BOW) = ITEM_BOW;
break;
}
}
}

void AltItemMenu_Register() {
static int altItemMenuOld = -1;
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnInterfaceUpdate>([]() {
int altItemMenu = CVarGetInteger("gAltItemMenu", 0);
if (altItemMenu != altItemMenuOld) {
AltItemMenu_Update();
}
altItemMenuOld = altItemMenu;
});

GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int16_t _) {
AltItemMenu_Update();
});
}

void InitMods() {
RegisterTTS();
RegisterInfiniteMoney();
Expand Down Expand Up @@ -1096,4 +1161,5 @@ void InitMods() {
RegisterRandomizerSheikSpawn();
RegisterRandomizedEnemySizes();
NameTag_RegisterHooks();
AltItemMenu_Register();
}
8 changes: 8 additions & 0 deletions soh/soh/Enhancements/presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const std::vector<const char*> enhancementsCvars = {
"gDisableCritWiggle",
"gChestSizeDependsStoneOfAgony",
"gSkipArrowAnimation",
"gSeparateArrows",
"gCustomizeShootingGallery",
"gInstantShootingGalleryWin",
"gConstantAdultGallery",
Expand Down Expand Up @@ -247,6 +248,7 @@ const std::vector<const char*> enhancementsCvars = {
"gAddTraps.Speed",
"gAddTraps.Tele",
"gAddTraps.Void",
"gAltItemMenu",
"gBombArrows",
};

Expand Down Expand Up @@ -632,6 +634,9 @@ 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 @@ -753,6 +758,9 @@ 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
Loading

0 comments on commit 7591cdc

Please sign in to comment.