mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-25 17:48:50 -05:00
Only update vectors when options change
This commit is contained in:
parent
267c27036c
commit
b0cdfc1be1
@ -30,6 +30,10 @@ void DrawSong(ItemTrackerItem item);
|
|||||||
|
|
||||||
OSContPad* buttonsPressed;
|
OSContPad* buttonsPressed;
|
||||||
|
|
||||||
|
bool shouldUpdateVectors = true;
|
||||||
|
|
||||||
|
std::vector<ItemTrackerItem> mainWindowItems = {};
|
||||||
|
|
||||||
std::vector<ItemTrackerItem> inventoryItems = {
|
std::vector<ItemTrackerItem> inventoryItems = {
|
||||||
ITEM_TRACKER_ITEM(ITEM_STICK, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_NUT, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_BOMB, 0, DrawItem),
|
ITEM_TRACKER_ITEM(ITEM_STICK, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_NUT, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_BOMB, 0, DrawItem),
|
||||||
ITEM_TRACKER_ITEM(ITEM_BOW, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_ARROW_FIRE, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_DINS_FIRE, 0, DrawItem),
|
ITEM_TRACKER_ITEM(ITEM_BOW, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_ARROW_FIRE, 0, DrawItem), ITEM_TRACKER_ITEM(ITEM_DINS_FIRE, 0, DrawItem),
|
||||||
@ -63,6 +67,8 @@ std::vector<ItemTrackerItem> dungeonRewardMedallions = {
|
|||||||
ITEM_TRACKER_ITEM(QUEST_MEDALLION_SPIRIT, 1 << 3, DrawQuest), ITEM_TRACKER_ITEM(QUEST_MEDALLION_SHADOW, 1 << 4, DrawQuest), ITEM_TRACKER_ITEM(QUEST_MEDALLION_LIGHT, 1 << 5, DrawQuest),
|
ITEM_TRACKER_ITEM(QUEST_MEDALLION_SPIRIT, 1 << 3, DrawQuest), ITEM_TRACKER_ITEM(QUEST_MEDALLION_SHADOW, 1 << 4, DrawQuest), ITEM_TRACKER_ITEM(QUEST_MEDALLION_LIGHT, 1 << 5, DrawQuest),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<ItemTrackerItem> dungeonRewards = {};
|
||||||
|
|
||||||
std::vector<ItemTrackerItem> songItems = {
|
std::vector<ItemTrackerItem> songItems = {
|
||||||
ITEM_TRACKER_ITEM(QUEST_SONG_LULLABY, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_EPONA, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_SARIA, 0, DrawSong),
|
ITEM_TRACKER_ITEM(QUEST_SONG_LULLABY, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_EPONA, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_SARIA, 0, DrawSong),
|
||||||
ITEM_TRACKER_ITEM(QUEST_SONG_SUN, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_TIME, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_STORMS, 0, DrawSong),
|
ITEM_TRACKER_ITEM(QUEST_SONG_SUN, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_TIME, 0, DrawSong), ITEM_TRACKER_ITEM(QUEST_SONG_STORMS, 0, DrawSong),
|
||||||
@ -102,6 +108,8 @@ std::map<uint16_t, std::string> itemTrackerDungeonShortNames = {
|
|||||||
{ SCENE_GERUDOWAY, "HIDE" },
|
{ SCENE_GERUDOWAY, "HIDE" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::vector<ItemTrackerItem> dungeonItems = {};
|
||||||
|
|
||||||
std::unordered_map<uint32_t, ItemTrackerItem> actualItemTrackerItemMap = {
|
std::unordered_map<uint32_t, ItemTrackerItem> actualItemTrackerItemMap = {
|
||||||
{ ITEM_BOTTLE, ITEM_TRACKER_ITEM(ITEM_BOTTLE, 0, DrawItem) },
|
{ ITEM_BOTTLE, ITEM_TRACKER_ITEM(ITEM_BOTTLE, 0, DrawItem) },
|
||||||
{ ITEM_BIG_POE, ITEM_TRACKER_ITEM(ITEM_BIG_POE, 0, DrawItem) },
|
{ ITEM_BIG_POE, ITEM_TRACKER_ITEM(ITEM_BIG_POE, 0, DrawItem) },
|
||||||
@ -592,6 +600,7 @@ void LabeledComboBoxRightAligned(const char* label, const char* cvar, std::vecto
|
|||||||
if (ImGui::Selectable(options[i].c_str())) {
|
if (ImGui::Selectable(options[i].c_str())) {
|
||||||
CVar_SetS32(cvar, i);
|
CVar_SetS32(cvar, i);
|
||||||
SohImGui::needs_save = true;
|
SohImGui::needs_save = true;
|
||||||
|
shouldUpdateVectors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,6 +617,7 @@ void PaddedEnhancementCheckbox(const char* text, const char* cvarName, s32 defau
|
|||||||
if (ImGui::Checkbox(text, &val)) {
|
if (ImGui::Checkbox(text, &val)) {
|
||||||
CVar_SetS32(cvarName, val);
|
CVar_SetS32(cvarName, val);
|
||||||
SohImGui::needs_save = true;
|
SohImGui::needs_save = true;
|
||||||
|
shouldUpdateVectors = true;
|
||||||
}
|
}
|
||||||
if (padBottom) {
|
if (padBottom) {
|
||||||
ImGui::Dummy(ImVec2(0.0f, 0.0f));
|
ImGui::Dummy(ImVec2(0.0f, 0.0f));
|
||||||
@ -615,28 +625,27 @@ void PaddedEnhancementCheckbox(const char* text, const char* cvarName, s32 defau
|
|||||||
}
|
}
|
||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
|
|
||||||
void DrawItemTracker(bool& open) {
|
void UpdateVectors() {
|
||||||
if (!open) {
|
if (!shouldUpdateVectors) {
|
||||||
CVar_SetS32("gItemTrackerEnabled", 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int iconSize = CVar_GetS32("gItemTrackerIconSize", 36);
|
|
||||||
int iconSpacing = CVar_GetS32("gItemTrackerIconSpacing", 12);
|
|
||||||
int comboButton1Mask = buttonMap[CVar_GetS32("gItemTrackerComboButton1", 6)];
|
|
||||||
int comboButton2Mask = buttonMap[CVar_GetS32("gItemTrackerComboButton2", 8)];
|
|
||||||
bool comboButtonsHeld = buttonsPressed != nullptr && buttonsPressed[0].button & comboButton1Mask && buttonsPressed[0].button & comboButton2Mask;
|
|
||||||
bool isPaused = CVar_GetS32("gItemTrackerShowOnlyPaused", 0) == 0 || gGlobalCtx != nullptr && gGlobalCtx->pauseCtx.state > 0;
|
|
||||||
|
|
||||||
if (isPaused && (CVar_GetS32("gItemTrackerDisplayType", 0) == 0 ? CVar_GetS32("gItemTrackerEnabled", 0) : comboButtonsHeld)) {
|
SohImGui::console->SendInfoMessage("updateVectors");
|
||||||
if (
|
|
||||||
(CVar_GetS32("gItemTrackerInventoryItemsDisplayType", 1) == 1) ||
|
dungeonRewards.clear();
|
||||||
(CVar_GetS32("gItemTrackerEquipmentItemsDisplayType", 1) == 1) ||
|
dungeonRewards.insert(dungeonRewards.end(), dungeonRewardStones.begin(), dungeonRewardStones.end());
|
||||||
(CVar_GetS32("gItemTrackerMiscItemsDisplayType", 1) == 1) ||
|
dungeonRewards.insert(dungeonRewards.end(), dungeonRewardMedallions.begin(), dungeonRewardMedallions.end());
|
||||||
(CVar_GetS32("gItemTrackerDungeonRewardsDisplayType", 1) == 1) ||
|
|
||||||
(CVar_GetS32("gItemTrackerSongsDisplayType", 1) == 1) ||
|
dungeonItems.clear();
|
||||||
(CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 1) == 1)
|
if (CVar_GetS32("gItemTrackerDisplayDungeonItemsHorizontal", 1) && CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 2) == 2) {
|
||||||
) {
|
dungeonItems = GetDungeonItemsVector(itemTrackerDungeons, 12);
|
||||||
std::vector<ItemTrackerItem> mainWindowItems = {};
|
dungeonItems[23] = ITEM_TRACKER_ITEM(ITEM_KEY_SMALL, SCENE_GERUDOWAY, DrawDungeonItem);
|
||||||
|
} else {
|
||||||
|
dungeonItems = GetDungeonItemsVector(itemTrackerDungeons);
|
||||||
|
dungeonItems[35] = ITEM_TRACKER_ITEM(ITEM_KEY_SMALL, SCENE_GERUDOWAY, DrawDungeonItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindowItems.clear();
|
||||||
if (CVar_GetS32("gItemTrackerInventoryItemsDisplayType", 1) == 1) {
|
if (CVar_GetS32("gItemTrackerInventoryItemsDisplayType", 1) == 1) {
|
||||||
mainWindowItems.insert(mainWindowItems.end(), inventoryItems.begin(), inventoryItems.end());
|
mainWindowItems.insert(mainWindowItems.end(), inventoryItems.begin(), inventoryItems.end());
|
||||||
}
|
}
|
||||||
@ -663,11 +672,35 @@ void DrawItemTracker(bool& open) {
|
|||||||
mainWindowItems.insert(mainWindowItems.end(), songItems.begin(), songItems.end());
|
mainWindowItems.insert(mainWindowItems.end(), songItems.begin(), songItems.end());
|
||||||
}
|
}
|
||||||
if (CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 2) == 1) {
|
if (CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 2) == 1) {
|
||||||
std::vector<ItemTrackerItem> dungeonItemsTemp = GetDungeonItemsVector(itemTrackerDungeons);
|
mainWindowItems.insert(mainWindowItems.end(), dungeonItems.begin(), dungeonItems.end());
|
||||||
dungeonItemsTemp[35] = ITEM_TRACKER_ITEM(ITEM_KEY_SMALL, SCENE_GERUDOWAY, DrawDungeonItem);
|
|
||||||
mainWindowItems.insert(mainWindowItems.end(), dungeonItemsTemp.begin(), dungeonItemsTemp.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldUpdateVectors = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawItemTracker(bool& open) {
|
||||||
|
UpdateVectors();
|
||||||
|
if (!open) {
|
||||||
|
CVar_SetS32("gItemTrackerEnabled", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int iconSize = CVar_GetS32("gItemTrackerIconSize", 36);
|
||||||
|
int iconSpacing = CVar_GetS32("gItemTrackerIconSpacing", 12);
|
||||||
|
int comboButton1Mask = buttonMap[CVar_GetS32("gItemTrackerComboButton1", 6)];
|
||||||
|
int comboButton2Mask = buttonMap[CVar_GetS32("gItemTrackerComboButton2", 8)];
|
||||||
|
bool comboButtonsHeld = buttonsPressed != nullptr && buttonsPressed[0].button & comboButton1Mask && buttonsPressed[0].button & comboButton2Mask;
|
||||||
|
bool isPaused = CVar_GetS32("gItemTrackerShowOnlyPaused", 0) == 0 || gGlobalCtx != nullptr && gGlobalCtx->pauseCtx.state > 0;
|
||||||
|
|
||||||
|
if (isPaused && (CVar_GetS32("gItemTrackerDisplayType", 0) == 0 ? CVar_GetS32("gItemTrackerEnabled", 0) : comboButtonsHeld)) {
|
||||||
|
if (
|
||||||
|
(CVar_GetS32("gItemTrackerInventoryItemsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerEquipmentItemsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerMiscItemsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerDungeonRewardsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerSongsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 1) == 1) ||
|
||||||
|
(CVar_GetS32("gItemTrackerNotesDisplayType", 2) == 1)
|
||||||
|
) {
|
||||||
BeginFloatingWindows("Item Tracker##main window");
|
BeginFloatingWindows("Item Tracker##main window");
|
||||||
DrawItemsInRows(mainWindowItems, 6);
|
DrawItemsInRows(mainWindowItems, 6);
|
||||||
|
|
||||||
@ -705,10 +738,7 @@ void DrawItemTracker(bool& open) {
|
|||||||
DrawItemsInRows(dungeonRewardStones);
|
DrawItemsInRows(dungeonRewardStones);
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
} else {
|
} else {
|
||||||
std::vector<ItemTrackerItem> dungeonRewardItems = {};
|
DrawItemsInRows(dungeonRewards, 3);
|
||||||
dungeonRewardItems.insert(dungeonRewardItems.end(), dungeonRewardMedallions.begin(), dungeonRewardMedallions.end());
|
|
||||||
dungeonRewardItems.insert(dungeonRewardItems.end(), dungeonRewardStones.begin(), dungeonRewardStones.end());
|
|
||||||
DrawItemsInRows(dungeonRewardItems, 3);
|
|
||||||
}
|
}
|
||||||
EndFloatingWindows();
|
EndFloatingWindows();
|
||||||
}
|
}
|
||||||
@ -722,13 +752,9 @@ void DrawItemTracker(bool& open) {
|
|||||||
if (CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 2) == 2) {
|
if (CVar_GetS32("gItemTrackerDungeonItemsDisplayType", 2) == 2) {
|
||||||
BeginFloatingWindows("Dungeon Items Tracker");
|
BeginFloatingWindows("Dungeon Items Tracker");
|
||||||
if (CVar_GetS32("gItemTrackerDisplayDungeonItemsHorizontal", 1)) {
|
if (CVar_GetS32("gItemTrackerDisplayDungeonItemsHorizontal", 1)) {
|
||||||
std::vector<ItemTrackerItem> dungeonItemsTemp = GetDungeonItemsVector(itemTrackerDungeons, 12);
|
DrawItemsInRows(dungeonItems, 12);
|
||||||
dungeonItemsTemp[23] = ITEM_TRACKER_ITEM(ITEM_KEY_SMALL, SCENE_GERUDOWAY, DrawDungeonItem);
|
|
||||||
DrawItemsInRows(dungeonItemsTemp, 12);
|
|
||||||
} else {
|
} else {
|
||||||
std::vector<ItemTrackerItem> dungeonItemsTemp = GetDungeonItemsVector(itemTrackerDungeons);
|
DrawItemsInRows(dungeonItems);
|
||||||
dungeonItemsTemp[35] = ITEM_TRACKER_ITEM(ITEM_KEY_SMALL, SCENE_GERUDOWAY, DrawDungeonItem);
|
|
||||||
DrawItemsInRows(dungeonItemsTemp);
|
|
||||||
}
|
}
|
||||||
EndFloatingWindows();
|
EndFloatingWindows();
|
||||||
}
|
}
|
||||||
@ -748,7 +774,7 @@ void DrawItemTrackerOptions(bool& open) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(600,360), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(600,375), ImGuiCond_FirstUseEver);
|
||||||
|
|
||||||
if (!ImGui::Begin("Item Tracker Settings", &open, ImGuiWindowFlags_NoFocusOnAppearing)) {
|
if (!ImGui::Begin("Item Tracker Settings", &open, ImGuiWindowFlags_NoFocusOnAppearing)) {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -825,7 +851,7 @@ void DrawItemTrackerOptions(bool& open) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitItemTracker() {
|
void InitItemTracker() {
|
||||||
// TODO: We want to persist this open, but currently I'm not sure of a way to dependably wait till the textures are loaded before we draw the tracker
|
// TODO: We want to persist this open, but currently the tracker is crashing if it's opened to quickly on launch
|
||||||
SohImGui::AddWindow("Randomizer", "Item Tracker", DrawItemTracker);
|
SohImGui::AddWindow("Randomizer", "Item Tracker", DrawItemTracker);
|
||||||
SohImGui::AddWindow("Randomizer", "Item Tracker Settings", DrawItemTrackerOptions);
|
SohImGui::AddWindow("Randomizer", "Item Tracker Settings", DrawItemTrackerOptions);
|
||||||
float trackerBgR = CVar_GetFloat("gItemTrackerBgColorR", 0);
|
float trackerBgR = CVar_GetFloat("gItemTrackerBgColorR", 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user