Preset Manager (#5459)

* Add presets sidebar, proof of concept row-based listing.

* Complete and unify section check/x drawing.

* Add error state to InputString, and corresponding members and builders to InputOptions.
Implement saving and loading of preset files.

* Implement `Config::SetBlock()`.
Implement Apply.
Implement Delete.
Some json structure changes.

* Apply `CVarClear()` calls in CVar-prefixed widget functions.

* Comment out satellite preset pickers for now.

* clang

* Fix ButtonOptions initializer list.

* I hate clang...

* Loop new preset checkbox creation.
Restore auto-resizing to new preset popup.
Remove errant BeginDisabled in randomizer (merge artifact?).

* Add BlockInfo struct to make array with all info for each block.
Setup loops for all other same-ish situations (applying presets, setting up columns, etc) based on blockInfo.

* Save tracker windows info for later restoration.
Lay the groundwork for said restoration.

* Complete tracker window restoration on preset application.

* Fix RadioButtonsOptions builder parameter type.
Add race lockout to new and apply buttons.

* Revert application of CVarClear on UIWidgets widgets (need to preserve manually-set default states).

* Remove enhancements satellite picker.
Swap randomizer satellite picker to use the manager presets, only displays presets with randomizer section included.
Move built-in presets to the asset archive, and remove delete button on them.
Remove PresetEntries.cpp.

* Fix locations and tricks tabs not updating live when applying preset with new system.

* Apply RandoGenerating lockout to rando preset Apply button.

* Fix new presets not being properly filtered in satellite selectors.

* Fix currently selected presets getting deleted still being selected in satellite selectors.

* Change BigPoeTargetCount in preset files to 1.
This commit is contained in:
Malkierian
2025-05-23 14:57:49 -07:00
committed by GitHub
parent 3a069e621e
commit 99c3fa6006
27 changed files with 1114 additions and 889 deletions

View File

@@ -375,6 +375,10 @@ uint32_t notesIdleFrames = 0;
bool notesNeedSave = false;
const uint32_t notesMaxIdleFrames = 40; // two seconds of game time, since OnGameFrameUpdate is used to tick
static bool presetLoaded = false;
static std::unordered_map<std::string, ImVec2> presetPos;
static std::unordered_map<std::string, ImVec2> presetSize;
void ItemTrackerOnFrame() {
if (notesNeedSave && notesIdleFrames <= notesMaxIdleFrames) {
notesIdleFrames++;
@@ -398,6 +402,16 @@ bool HasEquipment(ItemTrackerItem item) {
return GameInteractor::IsSaveLoaded() ? (item.data & gSaveContext.inventory.equipment) : false;
}
void ItemTracker_LoadFromPreset(nlohmann::json trackerInfo) {
presetLoaded = true;
for (auto window : itemTrackerWindowIDs) {
if (trackerInfo.contains(window)) {
presetPos[window] = { trackerInfo[window]["pos"]["x"], trackerInfo[window]["pos"]["y"] };
presetSize[window] = { trackerInfo[window]["size"]["width"], trackerInfo[window]["size"]["height"] };
}
}
}
ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) {
ItemTrackerNumbers result;
result.currentCapacity = 0;
@@ -1171,6 +1185,12 @@ void BeginFloatingWindows(std::string UniqueName, ImGuiWindowFlags flags = 0) {
ImGui::PushStyleColor(ImGuiCol_WindowBg, color);
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 4.0f);
if (presetLoaded && presetPos.contains(UniqueName)) {
ImGui::SetNextWindowSize(presetSize[UniqueName]);
ImGui::SetNextWindowPos(presetPos[UniqueName]);
presetSize.erase(UniqueName);
presetPos.erase(UniqueName);
}
ImGui::Begin(UniqueName.c_str(), nullptr, windowFlags);
}
void EndFloatingWindows() {
@@ -1525,7 +1545,7 @@ void ItemTrackerWindow::DrawElement() {
SECTION_DISPLAY_EXTENDED_MAIN_WINDOW) ||
(CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Notes"), SECTION_DISPLAY_HIDDEN) ==
SECTION_DISPLAY_MAIN_WINDOW)) {
BeginFloatingWindows("Item Tracker##main window");
BeginFloatingWindows("Item Tracker");
DrawItemsInRows(mainWindowItems, 6);
if (CVarGetInteger(CVAR_TRACKER_ITEM("DisplayType.Notes"), SECTION_DISPLAY_HIDDEN) ==
@@ -1659,6 +1679,10 @@ void ItemTrackerWindow::DrawElement() {
EndFloatingWindows();
}
}
if (presetLoaded) {
shouldUpdateVectors = true;
presetLoaded = false;
}
}
static std::unordered_map<int32_t, const char*> itemTrackerCapacityTrackOptions = {