Trade cleanup (#4971)

* Move adult trade to flags

* Move child trade to flags

* Fix vanilla

* Address review

* Rename `trade_shuffle` to `ShuffleTradeItems`

* Fix mac build

* Update GIVanillaBehavior.h

* Update z_kankyo.c

* Update z_en_heishi2.c
This commit is contained in:
Pepe20129
2025-02-25 12:09:01 +01:00
committed by GitHub
parent db41c6513b
commit 06387060d6
32 changed files with 246 additions and 165 deletions

View File

@@ -19,7 +19,6 @@ extern "C" {
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
extern PlayState* gPlayState;
#include "textures/icon_item_static/icon_item_static.h"
@@ -414,22 +413,6 @@ void DrawInfoTab() {
void DrawBGSItemFlag(uint8_t itemID) {
const ItemMapEntry& slotEntry = itemMapping[itemID];
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1));
ImGui::SameLine();
int tradeIndex = itemID - ITEM_POCKET_EGG;
bool hasItem = (gSaveContext.ship.quest.data.randomizer.adultTradeItems & (1 << tradeIndex)) != 0;
bool shouldHaveItem = hasItem;
ImGui::Checkbox(("##adultTradeFlag" + std::to_string(itemID)).c_str(), &shouldHaveItem);
if (hasItem != shouldHaveItem) {
if (shouldHaveItem) {
gSaveContext.ship.quest.data.randomizer.adultTradeItems |= (1 << tradeIndex);
if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_NONE) {
INV_CONTENT(ITEM_TRADE_ADULT) = ITEM_POCKET_EGG + tradeIndex;
}
} else {
gSaveContext.ship.quest.data.randomizer.adultTradeItems &= ~(1 << tradeIndex);
Inventory_ReplaceItem(gPlayState, itemID, Randomizer_GetNextAdultTradeItem());
}
}
}
void DrawInventoryTab() {
@@ -476,9 +459,6 @@ void DrawInventoryTab() {
if (ImGui::BeginPopup(itemPopupPicker)) {
if (ImGui::Button("##itemNonePicker", ImVec2(32.0f, 32.0f))) {
gSaveContext.inventory.items[selectedIndex] = ITEM_NONE;
if (selectedIndex == SLOT_TRADE_ADULT) {
gSaveContext.ship.quest.data.randomizer.adultTradeItems = 0;
}
ImGui::CloseCurrentPopup();
}
UIWidgets::SetLastItemHoverText("None");
@@ -512,13 +492,6 @@ void DrawInventoryTab() {
ImGui::PopStyleVar();
if (ret) {
gSaveContext.inventory.items[selectedIndex] = slotEntry.id;
// Set adult trade item flag if you're playing adult trade shuffle in rando
if (IS_RANDO &&
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHUFFLE_ADULT_TRADE) &&
selectedIndex == SLOT_TRADE_ADULT &&
slotEntry.id >= ITEM_POCKET_EGG && slotEntry.id <= ITEM_CLAIM_CHECK) {
gSaveContext.ship.quest.data.randomizer.adultTradeItems |= ADULT_TRADE_FLAG(slotEntry.id);
}
ImGui::CloseCurrentPopup();
}
UIWidgets::SetLastItemHoverText(SohUtils::GetItemName(slotEntry.id));