forked from HarbourMasters/Ghostship
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGhostshipMenuRando.cpp
More file actions
173 lines (155 loc) · 8.87 KB
/
Copy pathGhostshipMenuRando.cpp
File metadata and controls
173 lines (155 loc) · 8.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "port/ui/GhostshipMenu.h"
#include "port/Rando/CheckTracker/CheckTracker.h"
#include "port/Rando/Spoiler/Spoiler.h"
#include "port/ui/Notification.h"
#define WIDGET_COLOR UIWidgets::Colors(CVarGetInteger("gSettings.Menu.Theme", 5))
namespace GhostshipGui {
extern std::shared_ptr<GhostshipMenu> mGhostshipMenu;
extern std::shared_ptr<Rando::CheckTracker::CheckTrackerWindow> mRandoCheckTrackerWindow;
extern std::shared_ptr<Rando::CheckTracker::SettingsWindow> mRandoCheckTrackerSettingsWindow;
using namespace UIWidgets;
void GhostshipMenu::AddMenuRando() {
// Add Rando Menu
AddMenuEntry("Rando", CVAR_SETTING("Menu.RandoSidebarSection"));
WidgetPath path = { "Rando", "General", SECTION_COLUMN_1 };
AddSidebarEntry("Rando", path.sidebarName, 1);
path.column = SECTION_COLUMN_1;
AddWidget(path, "Randomizer Options", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Enable Rando", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("Enabled"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Enables the randomizer feature."));
AddWidget(path, "Logic Type", WIDGET_CVAR_COMBOBOX)
.CVar(Rando::StaticData::Options[RO_LOGIC].cvar)
.RaceDisable(false)
.Options(ComboboxOptions()
.Tooltip("Sets the Logic type for the seed.")
.ComboMap(Rando::StaticData::logicOptions)
.DefaultIndex(RO_LOGIC_GLITCHLESS)
.ComponentAlignment(ComponentAlignments::Right)
.LabelPosition(LabelPositions::Near));
AddWidget(path, "SeperatorBar", WIDGET_SEPARATOR);
AddWidget(path, "Generate Spoiler Log", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("GenerateLog"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Generates a Spoiler Log in the randomizer folder.").DefaultValue(true));
// TODO: populate combobox with existing spoiler logs
AddWidget(path, "Load Existing Spoiler Log", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("UseExistingLog"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Uses a Spoiler Log in the randomizer folder."))
.PreFunc([](WidgetInfo& info) {
info.options->Disabled(CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0));
});
AddWidget(path, "Available Spoiler Logs", WIDGET_CUSTOM).CustomFunction([](WidgetInfo& info) {
ImGui::BeginDisabled(!CVarGetInteger(CVAR_RANDOMIZER_SETTING("UseExistingLog"), 0));
if (UIWidgets::CVarCombobox("Seed", CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), Rando::Spoiler::spoilerLogs)) {
if (CVarGetInteger(CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), 0) == 0) {
CVarSetString(CVAR_RANDOMIZER_SETTING("SpoilerFile"), "");
} else {
CVarSetString(
"gRandoSettings.SpoilerFile",
Rando::Spoiler::spoilerLogs[CVarGetInteger(CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), 0)]
.c_str());
}
}
ImGui::EndDisabled();
});
AddWidget(path, "Manual Seed Entry", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Generates a seed using the provided input."));
AddWidget(path, "Seed", WIDGET_CUSTOM).CustomFunction([](WidgetInfo& info) {
ImGui::BeginDisabled(!CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0));
UIWidgets::PushStyleInput(WIDGET_COLOR);
ImGui::InputText("##ManualSeed", seedString, MAX_SEED_STRING_SIZE, ImGuiInputTextFlags_CallbackCharFilter,
UIWidgets::TextFilters::FilterAlphaNum);
UIWidgets::Tooltip("Characters from a-z, A-Z, and 0-9 are supported.\n"
"Character limit is 1023, after which the seed will be truncated.\n");
ImGui::SameLine();
if (UIWidgets::Button(ICON_FA_ERASER, UIWidgets::ButtonOptions()
.Size(UIWidgets::Sizes::Inline)
.Color(WIDGET_COLOR)
.Padding(ImVec2(10.f, 6.f)))) {
memset(seedString, 0, MAX_SEED_STRING_SIZE);
}
if (strnlen(seedString, MAX_SEED_STRING_SIZE) == 0) {
ImGui::SameLine(17.0f);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "Leave blank for random seed");
}
UIWidgets::PopStyleInput();
ImGui::EndDisabled();
});
AddWidget(path, "Create Spoiler Log", WIDGET_BUTTON)
.Callback([](WidgetInfo& info) {
nlohmann::json spoiler =
Rando::Spoiler::GenerateFromPoolGeneration(Rando::Logic::shuffledPool, Rando::Logic::shuffledEntrances);
std::string fileName = std::to_string(spoiler["finalSeed"].get<u32>()).c_str();
fileName += ".json";
Rando::Spoiler::SaveToFile(fileName, spoiler);
Notification::Emit({ .prefix = fileName + " ",
.message = "Spoiler Log created.",
.messageColor = ImVec4(0, 0.3f, 0.85f, 1) });
})
.Options(ButtonOptions().Tooltip("Creates a Spoiler Log from the current SaveFile."))
.PreFunc([](WidgetInfo& info) { info.options->Disabled(Rando::Logic::shuffledPool.empty()); });
AddWidget(path, "SeperatorBar", WIDGET_SEPARATOR);
path = { "Rando", "Enhancements", SECTION_COLUMN_1 };
AddSidebarEntry("Rando", path.sidebarName, 1);
path.column = SECTION_COLUMN_1;
AddWidget(path, "Skip Get Item Cutscene", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("SkipRandoGI"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Skips the cutscene when collecting a Star."));
path = { "Rando", "Shuffle Options", SECTION_COLUMN_1 };
AddSidebarEntry("Rando", path.sidebarName, 2);
path.column = SECTION_COLUMN_1;
AddWidget(path, "Item Options", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Shuffle Stars", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_STARS].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Stars into the Item Pool."));
AddWidget(path, "Shuffle Red Coin Stars", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_RED_COIN_STARS].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Stars spawned from collecting 8 Red Coins into the Item Pool."))
.PreFunc(
[](WidgetInfo& info) { info.options->Disabled(Rando::StaticData::Options[RO_SHUFFLE_STARS].cvar == 0); });
AddWidget(path, "Shuffle Red Coins", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_COINS_RED].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Red Coins into the Item Pool."));
AddWidget(path, "Shuffle Blue Coins", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_COINS_BLUE].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Blue Coins into the Item Pool."));
path.column = SECTION_COLUMN_2;
AddWidget(path, "Entrance Options", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Shuffle Bowser Levels", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_ENTRANCES_BOWSER].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Bowser in the Dark World and Fire Sea Entrances."));
AddWidget(path, "Shuffle Bowser in the Sky Level", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_ENTRANCES_BOWSER_FINAL].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Bowser in the Sky Entrance."));
AddWidget(path, "Shuffle Cap Unlock Levels", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_ENTRANCES_CAP].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Cap Unlock Entrances."));
AddWidget(path, "Shuffle Paintings", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_ENTRANCES_PAINTING].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Painting Entrances including Rainbow Ride."));
AddWidget(path, "Shuffle Secret Levels", WIDGET_CVAR_CHECKBOX)
.CVar(Rando::StaticData::Options[RO_SHUFFLE_ENTRANCES_SECRET].cvar)
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Shuffles Castle Secret Entrances."));
path = { "Rando", "Check Tracker", SECTION_COLUMN_1 };
AddSidebarEntry("Rando", path.sidebarName, 1);
path.column = SECTION_COLUMN_1;
AddWidget(path, "Popout Settings", WIDGET_WINDOW_BUTTON)
.CVar("gWindows.CheckTrackerSettings")
.WindowName("Check Tracker Settings");
}
} // namespace GhostshipGui