fix: don't show duplicate gregs on item tracker (#2498)

Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
briaguya 2023-02-17 11:05:15 -05:00 committed by GitHub
parent 494bdcdb25
commit 9325e6d0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include <Hooks.h> #include <Hooks.h>
#include <algorithm>
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
@ -855,14 +856,14 @@ void UpdateVectors() {
if (CVarGetInteger("gItemTrackerDungeonItemsDisplayType", 0) == 1) { if (CVarGetInteger("gItemTrackerDungeonItemsDisplayType", 0) == 1) {
mainWindowItems.insert(mainWindowItems.end(), dungeonItems.begin(), dungeonItems.end()); mainWindowItems.insert(mainWindowItems.end(), dungeonItems.begin(), dungeonItems.end());
} }
if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 1) {
// insert empty items until we're on a new row for greg // if we're adding greg to the misc window,
while (mainWindowItems.size() % 6) { // and misc isn't on the main window,
mainWindowItems.push_back(ITEM_TRACKER_ITEM(ITEM_NONE, 0, DrawItem)); // and it doesn't already have greg, add him
} if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 2 &&
mainWindowItems.insert(mainWindowItems.end(), gregItems.begin(), gregItems.end()); CVarGetInteger("gItemTrackerMiscItemsDisplayType", 1) != 1 &&
} std::none_of(miscItems.begin(), miscItems.end(), [](ItemTrackerItem item){return item.id == ITEM_RUPEE_GREEN;})) {
if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 2) {
miscItems.insert(miscItems.end(), gregItems.begin(), gregItems.end()); miscItems.insert(miscItems.end(), gregItems.begin(), gregItems.end());
} else { } else {
for (auto it = miscItems.begin(); it != miscItems.end();) { for (auto it = miscItems.begin(); it != miscItems.end();) {
@ -874,6 +875,17 @@ void UpdateVectors() {
} }
} }
// if we're adding greg to the main window
if (CVarGetInteger("gItemTrackerGregDisplayType", 0) == 1) {
// insert empty items until we're on a new row for greg
while (mainWindowItems.size() % 6) {
mainWindowItems.push_back(ITEM_TRACKER_ITEM(ITEM_NONE, 0, DrawItem));
}
// add greg
mainWindowItems.insert(mainWindowItems.end(), gregItems.begin(), gregItems.end());
}
shouldUpdateVectors = false; shouldUpdateVectors = false;
} }