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/MenuTypes.h"
|
||||||
#include "soh/SohGui/SohMenu.h"
|
#include "soh/SohGui/SohMenu.h"
|
||||||
#include "soh/SohGui/SohGui.hpp"
|
#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;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
@ -116,8 +119,7 @@ enum PresetSection {
|
||||||
struct PresetInfo {
|
struct PresetInfo {
|
||||||
nlohmann::json presetValues;
|
nlohmann::json presetValues;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
bool applySettings = true, applyEnhancements = true, applyAudio = true, applyCosmetics = true, applyRando = true,
|
bool apply[PRESET_SECTION_MAX];
|
||||||
applyTrackers = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlockInfo {
|
struct BlockInfo {
|
||||||
|
@ -180,6 +182,7 @@ void LoadPresets() {
|
||||||
}
|
}
|
||||||
presets[json["presetName"]].presetValues = json;
|
presets[json["presetName"]].presetValues = json;
|
||||||
presets[json["presetName"]].fileName = preset.path().filename().stem().string();
|
presets[json["presetName"]].fileName = preset.path().filename().stem().string();
|
||||||
|
std::fill_n(presets[json["presetName"]].apply, PRESET_SECTION_MAX, true);
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
ifs.close();
|
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;
|
presets[newPresetName].fileName = newPresetName;
|
||||||
|
std::fill_n(presets[newPresetName].apply, PRESET_SECTION_MAX, true);
|
||||||
SavePreset(newPresetName);
|
SavePreset(newPresetName);
|
||||||
newPresetName = "";
|
newPresetName = "";
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
@ -298,23 +347,37 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
ImGui::Text(name.c_str());
|
ImGui::Text(name.c_str());
|
||||||
for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) {
|
for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains(blockInfo[i].names[1]),
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains(blockInfo[i].names[1]), &info.apply[i],
|
||||||
&info.applySettings, blockInfo[i].names[1]);
|
blockInfo[i].names[1]);
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
UIWidgets::PushStyleButton(THEME_COLOR);
|
UIWidgets::PushStyleButton(THEME_COLOR);
|
||||||
if (UIWidgets::Button(("Apply##" + name).c_str(), UIWidgets::ButtonOptions().Padding({ 6.0f, 6.0f }))) {
|
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++) {
|
||||||
for (auto& item : section.items()) {
|
if (info.apply[i]) {
|
||||||
if (section[item.key()].is_null()) {
|
if (info.presetValues["blocks"].contains(blockInfo[i].names[1])) {
|
||||||
CVarClearBlock(item.key().c_str());
|
if (i == PRESET_SECTION_TRACKERS) {
|
||||||
} else {
|
ItemTracker_LoadFromPreset(
|
||||||
Ship::Context::GetInstance()->GetConfig()->SetBlock(
|
info.presetValues["blocks"][blockInfo[i].names[1]]["windows"]);
|
||||||
fmt::format("{}.{}", "CVars", item.key()), item.value());
|
CheckTracker::CheckTracker_LoadFromPreset(
|
||||||
Ship::Context::GetInstance()->GetConsoleVariables()->Load();
|
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());
|
||||||
|
} else {
|
||||||
|
Ship::Context::GetInstance()->GetConfig()->SetBlock(
|
||||||
|
fmt::format("{}.{}", "CVars", item.key()), item.value());
|
||||||
|
Ship::Context::GetInstance()->GetConsoleVariables()->Load();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto& section : info.presetValues["blocks"]) {}
|
||||||
}
|
}
|
||||||
UIWidgets::PopStyleButton();
|
UIWidgets::PopStyleButton();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
|
@ -91,6 +91,10 @@ bool previousShowHidden = false;
|
||||||
bool hideShopUnshuffledChecks = false;
|
bool hideShopUnshuffledChecks = false;
|
||||||
bool alwaysShowGS = false;
|
bool alwaysShowGS = false;
|
||||||
|
|
||||||
|
static bool presetLoaded = false;
|
||||||
|
static ImVec2 presetPos;
|
||||||
|
static ImVec2 presetSize;
|
||||||
|
|
||||||
std::map<uint32_t, RandomizerCheck> startingShopItem = {
|
std::map<uint32_t, RandomizerCheck> startingShopItem = {
|
||||||
{ SCENE_KOKIRI_SHOP, RC_KF_SHOP_ITEM_1 },
|
{ SCENE_KOKIRI_SHOP, RC_KF_SHOP_ITEM_1 },
|
||||||
{ SCENE_BAZAAR, RC_MARKET_BAZAAR_ITEM_1 },
|
{ SCENE_BAZAAR, RC_MARKET_BAZAAR_ITEM_1 },
|
||||||
|
@ -979,7 +983,13 @@ void CheckTrackerWindow::DrawElement() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);
|
if (presetLoaded) {
|
||||||
|
ImGui::SetNextWindowSize(presetSize);
|
||||||
|
ImGui::SetNextWindowPos(presetPos);
|
||||||
|
presetLoaded = false;
|
||||||
|
} else {
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(400, 540), ImGuiCond_FirstUseEver);
|
||||||
|
}
|
||||||
BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar);
|
BeginFloatWindows("Check Tracker", mIsVisible, ImGuiWindowFlags_NoScrollbar);
|
||||||
|
|
||||||
if (!GameInteractor::IsSaveLoaded() || !initialized) {
|
if (!GameInteractor::IsSaveLoaded() || !initialized) {
|
||||||
|
@ -2007,6 +2017,12 @@ void RecalculateAvailableChecks() {
|
||||||
GetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS).count());
|
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() {
|
void CheckTrackerWindow::Draw() {
|
||||||
if (!IsVisible()) {
|
if (!IsVisible()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -62,4 +62,5 @@ void UpdateAllAreas();
|
||||||
void RecalculateAllAreaTotals();
|
void RecalculateAllAreaTotals();
|
||||||
void SpoilAreaFromCheck(RandomizerCheck rc);
|
void SpoilAreaFromCheck(RandomizerCheck rc);
|
||||||
void RecalculateAvailableChecks();
|
void RecalculateAvailableChecks();
|
||||||
|
void CheckTracker_LoadFromPreset(nlohmann::json info);
|
||||||
} // namespace CheckTracker
|
} // namespace CheckTracker
|
||||||
|
|
|
@ -445,6 +445,9 @@ const EntranceData* GetEntranceData(s16 index) {
|
||||||
return nullptr;
|
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
|
// Used for verifying the names on both sides of entrance pairs match. Keeping for ease of use for further name changes
|
||||||
// later
|
// later
|
||||||
// TODO: Figure out how to remove the need for duplicate entrance names so this is no longer necessary
|
// 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 GetLastEntranceOverride();
|
||||||
s16 GetCurrentGrottoId();
|
s16 GetCurrentGrottoId();
|
||||||
const EntranceData* GetEntranceData(s16);
|
const EntranceData* GetEntranceData(s16);
|
||||||
|
void EntranceTracker_LoadFromPreset(nlohmann::json info);
|
||||||
|
|
||||||
class EntranceTrackerSettingsWindow : public Ship::GuiWindow {
|
class EntranceTrackerSettingsWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -398,6 +398,9 @@ bool HasEquipment(ItemTrackerItem item) {
|
||||||
return GameInteractor::IsSaveLoaded() ? (item.data & gSaveContext.inventory.equipment) : false;
|
return GameInteractor::IsSaveLoaded() ? (item.data & gSaveContext.inventory.equipment) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemTracker_LoadFromPreset(nlohmann::json trackerInfo) {
|
||||||
|
}
|
||||||
|
|
||||||
ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) {
|
ItemTrackerNumbers GetItemCurrentAndMax(ItemTrackerItem item) {
|
||||||
ItemTrackerNumbers result;
|
ItemTrackerNumbers result;
|
||||||
result.currentCapacity = 0;
|
result.currentCapacity = 0;
|
||||||
|
|
|
@ -25,6 +25,23 @@ bool HasEquipment(ItemTrackerItem);
|
||||||
#define ITEM_TRACKER_ITEM_CUSTOM(id, name, nameFaded, data, drawFunc) \
|
#define ITEM_TRACKER_ITEM_CUSTOM(id, name, nameFaded, data, drawFunc) \
|
||||||
{ id, #name, #nameFaded "_Faded", 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 {
|
typedef struct ItemTrackerDungeon {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
std::vector<uint32_t> items;
|
std::vector<uint32_t> items;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue