mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Save tracker windows info for later restoration.
Lay the groundwork for said restoration.
This commit is contained in:
parent
38cf4a571e
commit
8dba1bcdd9
7 changed files with 117 additions and 13 deletions
|
@ -9,6 +9,9 @@
|
|||
#include "soh/SohGui/MenuTypes.h"
|
||||
#include "soh/SohGui/SohMenu.h"
|
||||
#include "soh/SohGui/SohGui.hpp"
|
||||
#include "soh/Enhancements/randomizer/randomizer_check_tracker.h"
|
||||
#include "soh/Enhancements/randomizer/randomizer_entrance_tracker.h"
|
||||
#include "soh/Enhancements/randomizer/randomizer_item_tracker.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
@ -116,8 +119,7 @@ enum PresetSection {
|
|||
struct PresetInfo {
|
||||
nlohmann::json presetValues;
|
||||
std::string fileName;
|
||||
bool applySettings = true, applyEnhancements = true, applyAudio = true, applyCosmetics = true, applyRando = true,
|
||||
applyTrackers = true;
|
||||
bool apply[PRESET_SECTION_MAX];
|
||||
};
|
||||
|
||||
struct BlockInfo {
|
||||
|
@ -180,6 +182,7 @@ void LoadPresets() {
|
|||
}
|
||||
presets[json["presetName"]].presetValues = json;
|
||||
presets[json["presetName"]].fileName = preset.path().filename().stem().string();
|
||||
std::fill_n(presets[json["presetName"]].apply, PRESET_SECTION_MAX, true);
|
||||
} catch (...) {}
|
||||
ifs.close();
|
||||
}
|
||||
|
@ -251,7 +254,53 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (saveSection[PRESET_SECTION_TRACKERS]) {
|
||||
for (auto id : itemTrackerWindowIDs) {
|
||||
auto window = ImGui::FindWindowByName(id);
|
||||
if (window != nullptr) {
|
||||
auto size = window->Size;
|
||||
auto pos = window->Pos;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"][id]["size"]["width"] = size.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"][id]["size"]["height"] = size.y;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"][id]["pos"]["x"] = pos.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"][id]["pos"]["y"] = pos.y;
|
||||
}
|
||||
}
|
||||
|
||||
auto window = ImGui::FindWindowByName("Entrance Tracker");
|
||||
if (window != nullptr) {
|
||||
auto size = window->Size;
|
||||
auto pos = window->Pos;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Entrance Tracker"]["size"]["width"] = size.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Entrance Tracker"]["size"]["height"] = size.y;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Entrance Tracker"]["pos"]["x"] = pos.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Entrance Tracker"]["pos"]["y"] = pos.y;
|
||||
}
|
||||
|
||||
window = ImGui::FindWindowByName("Check Tracker");
|
||||
if (window != nullptr) {
|
||||
auto size = window->Size;
|
||||
auto pos = window->Pos;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Check Tracker"]["size"]["width"] = size.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Check Tracker"]["size"]["height"] = size.y;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Check Tracker"]["pos"]["x"] = pos.x;
|
||||
presets[newPresetName].presetValues["blocks"][blockInfo[PRESET_SECTION_TRACKERS].names[1]]
|
||||
["windows"]["Check Tracker"]["pos"]["y"] = pos.y;
|
||||
}
|
||||
}
|
||||
presets[newPresetName].fileName = newPresetName;
|
||||
std::fill_n(presets[newPresetName].apply, PRESET_SECTION_MAX, true);
|
||||
SavePreset(newPresetName);
|
||||
newPresetName = "";
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
@ -298,13 +347,24 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
|||
ImGui::Text(name.c_str());
|
||||
for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) {
|
||||
ImGui::TableNextColumn();
|
||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains(blockInfo[i].names[1]),
|
||||
&info.applySettings, blockInfo[i].names[1]);
|
||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains(blockInfo[i].names[1]), &info.apply[i],
|
||||
blockInfo[i].names[1]);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
UIWidgets::PushStyleButton(THEME_COLOR);
|
||||
if (UIWidgets::Button(("Apply##" + name).c_str(), UIWidgets::ButtonOptions().Padding({ 6.0f, 6.0f }))) {
|
||||
for (auto& section : info.presetValues["blocks"]) {
|
||||
for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) {
|
||||
if (info.apply[i]) {
|
||||
if (info.presetValues["blocks"].contains(blockInfo[i].names[1])) {
|
||||
if (i == PRESET_SECTION_TRACKERS) {
|
||||
ItemTracker_LoadFromPreset(
|
||||
info.presetValues["blocks"][blockInfo[i].names[1]]["windows"]);
|
||||
CheckTracker::CheckTracker_LoadFromPreset(
|
||||
info.presetValues["blocks"][blockInfo[i].names[1]]["windows"]["Entrance Tracker"]);
|
||||
EntranceTracker_LoadFromPreset(
|
||||
info.presetValues["blocks"][blockInfo[i].names[1]]["windows"]["Check Tracker"]);
|
||||
}
|
||||
auto section = info.presetValues["blocks"][blockInfo[i].names[1]];
|
||||
for (auto& item : section.items()) {
|
||||
if (section[item.key()].is_null()) {
|
||||
CVarClearBlock(item.key().c_str());
|
||||
|
@ -316,6 +376,9 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& section : info.presetValues["blocks"]) {}
|
||||
}
|
||||
UIWidgets::PopStyleButton();
|
||||
ImGui::TableNextColumn();
|
||||
UIWidgets::PushStyleButton(THEME_COLOR);
|
||||
|
|
|
@ -91,6 +91,10 @@ bool previousShowHidden = false;
|
|||
bool hideShopUnshuffledChecks = false;
|
||||
bool alwaysShowGS = false;
|
||||
|
||||
static bool presetLoaded = false;
|
||||
static ImVec2 presetPos;
|
||||
static ImVec2 presetSize;
|
||||
|
||||
std::map<uint32_t, RandomizerCheck> startingShopItem = {
|
||||
{ SCENE_KOKIRI_SHOP, RC_KF_SHOP_ITEM_1 },
|
||||
{ SCENE_BAZAAR, RC_MARKET_BAZAAR_ITEM_1 },
|
||||
|
@ -979,7 +983,13 @@ void CheckTrackerWindow::DrawElement() {
|
|||
}
|
||||
}
|
||||
|
||||
if (presetLoaded) {
|
||||
ImGui::SetNextWindowSize(presetSize);
|
||||
ImGui::SetNextWindowPos(presetPos);
|
||||
presetLoaded = false;
|
||||
} else {
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);
|
||||
}
|
||||
BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar);
|
||||
|
||||
if (!GameInteractor::IsSaveLoaded() || !initialized) {
|
||||
|
@ -2007,6 +2017,12 @@ void RecalculateAvailableChecks() {
|
|||
GetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS).count());
|
||||
}
|
||||
|
||||
void CheckTracker_LoadFromPreset(nlohmann::json info) {
|
||||
presetLoaded = true;
|
||||
presetPos = { info["pos"]["x"], info["pos"]["y"] };
|
||||
presetSize = { info["size"]["width"], info["size"]["height"] };
|
||||
}
|
||||
|
||||
void CheckTrackerWindow::Draw() {
|
||||
if (!IsVisible()) {
|
||||
return;
|
||||
|
|
|
@ -62,4 +62,5 @@ void UpdateAllAreas();
|
|||
void RecalculateAllAreaTotals();
|
||||
void SpoilAreaFromCheck(RandomizerCheck rc);
|
||||
void RecalculateAvailableChecks();
|
||||
void CheckTracker_LoadFromPreset(nlohmann::json info);
|
||||
} // namespace CheckTracker
|
||||
|
|
|
@ -445,6 +445,9 @@ const EntranceData* GetEntranceData(s16 index) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void EntranceTracker_LoadFromPreset(nlohmann::json info) {
|
||||
}
|
||||
|
||||
// Used for verifying the names on both sides of entrance pairs match. Keeping for ease of use for further name changes
|
||||
// later
|
||||
// TODO: Figure out how to remove the need for duplicate entrance names so this is no longer necessary
|
||||
|
|
|
@ -90,6 +90,7 @@ void InitEntranceTrackingData();
|
|||
s16 GetLastEntranceOverride();
|
||||
s16 GetCurrentGrottoId();
|
||||
const EntranceData* GetEntranceData(s16);
|
||||
void EntranceTracker_LoadFromPreset(nlohmann::json info);
|
||||
|
||||
class EntranceTrackerSettingsWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
|
|
|
@ -398,6 +398,9 @@ bool HasEquipment(ItemTrackerItem item) {
|
|||
return GameInteractor::IsSaveLoaded() ? (item.data & gSaveContext.inventory.equipment) : false;
|
||||
}
|
||||
|
||||
void ItemTracker_LoadFromPreset(nlohmann::json trackerInfo) {
|
||||
}
|
||||
|
||||
ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) {
|
||||
ItemTrackerNumbers result;
|
||||
result.currentCapacity = 0;
|
||||
|
|
|
@ -25,6 +25,23 @@ bool HasEquipment(ItemTrackerItem);
|
|||
#define ITEM_TRACKER_ITEM_CUSTOM(id, name, nameFaded, data, drawFunc) \
|
||||
{ id, #name, #nameFaded "_Faded", data, drawFunc }
|
||||
|
||||
static std::vector<const char*> itemTrackerWindowIDs = { "Item Tracker##main window",
|
||||
"Inventory Items Tracker",
|
||||
"Equipment Items Tracker",
|
||||
"Misc Items Tracker",
|
||||
"Dungeon Rewards Tracker",
|
||||
"Songs Tracker",
|
||||
"Dungeon Items Tracker",
|
||||
"Greg Tracker",
|
||||
"Triforce Piece Tracker",
|
||||
"Boss Soul Tracker",
|
||||
"Ocarina Button Tracker",
|
||||
"Overworld Key Tracker",
|
||||
"Fishing Pole Tracker",
|
||||
"Personal Notes",
|
||||
"Total Checks" };
|
||||
void ItemTracker_LoadFromPreset(nlohmann::json trackerInfo);
|
||||
|
||||
typedef struct ItemTrackerDungeon {
|
||||
uint32_t id;
|
||||
std::vector<uint32_t> items;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue