Skip to content

Commit f3d7ea3

Browse files
Reordered save entries; save editor now defaults to valid-only editing, with toggle for everything; add cannon checkbox for WMOTR (whoops)
1 parent 1818498 commit f3d7ea3

2 files changed

Lines changed: 46 additions & 4 deletions

File tree

src/port/data/SaveConversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ using json = nlohmann::json;
1414
#define SAVE_FILE_VERSION 1
1515

1616
static std::string entries[] = {
17-
"CG", "BOB", "WF", "JRB", "CCM", "BBH", "HMC", "LLL", "SSL", "DDD", "SL",
17+
"BOB", "WF", "JRB", "CCM", "BBH", "HMC", "LLL", "SSL", "DDD", "SL",
1818
"WDW", "TTM", "THI", "TTC", "RR", "BITDW", "BITFS", "BITS", "PSS", "COTMC",
19-
"TOTWC", "VCUTM", "WMOTR", "SA", "CAKE_END"
19+
"TOTWC", "VCUTM", "WMOTR", "SA", "CG", "CAKE_END"
2020
};
2121

2222
template<typename T>

src/port/ui/SaveEditor.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,37 @@ static char courseNames[][31] = {
3232
#undef DEFINE_COURSES_END
3333
#undef DEFINE_BONUS_COURSE
3434

35+
std::unordered_map<int16_t, std::pair<u8, bool>> allowedStarFlags = {
36+
{ COURSE_BOB, {0x7F, true } },
37+
{ COURSE_WF, {0x7F, true } },
38+
{ COURSE_JRB, {0x7F, true } },
39+
{ COURSE_CCM, {0x7F, true } },
40+
{ COURSE_BBH, {0x7F, false} },
41+
{ COURSE_HMC, {0x7F, false} },
42+
{ COURSE_LLL, {0x7F, false} },
43+
{ COURSE_SSL, {0x7F, true} },
44+
{ COURSE_DDD, {0xFF, false} },
45+
{ COURSE_SL, {0x7F, true } },
46+
{ COURSE_WDW, {0x7F, true } },
47+
{ COURSE_TTM, {0x7F, true } },
48+
{ COURSE_THI, {0x7F, true } },
49+
{ COURSE_TTC, {0x7F, false} },
50+
{ COURSE_RR, {0x7F, true } },
51+
{ COURSE_BITDW, {0x01, false} },
52+
{ COURSE_BITFS, {0x01, false} },
53+
{ COURSE_BITS, {0x01, false} },
54+
{ COURSE_PSS, {0x03, false} },
55+
{ COURSE_COTMC, {0x01, false} },
56+
{ COURSE_TOTWC, {0x01, false} },
57+
{ COURSE_VCUTM, {0x01, false} },
58+
{ COURSE_WMOTR, {0x01, true } },
59+
{ COURSE_SA, {0x01, false} },
60+
{ COURSE_NONE, {0x1F, false} }
61+
};
62+
3563
bool shouldPopUpOpen = false;
64+
bool shouldAllowAllStars = false;
65+
bool shouldAllowEdit = false;
3666
RandoCheckId popUpId = RC_UNKNOWN;
3767
std::map<RandoItemId, const char*> objectMap = {
3868
{ RI_COIN_BLUE, "Blue Coin Icon" },
@@ -171,6 +201,7 @@ void SaveEditorWindow::DrawElement() {
171201
ImGui::SeparatorText("Rando Save Loaded, use the Rando Tab to make changes");
172202
}
173203
ImGui::BeginDisabled(IS_RANDO(gCurrSaveFileNum - 1));
204+
if (ImGui::Checkbox("Allow all stars", &shouldAllowAllStars)) {}
174205
for (int i = 1; i < COURSE_COUNT; i++) {
175206
ImGui::PushID(i - 1);
176207
u8 courseStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, i - 1);
@@ -182,17 +213,23 @@ void SaveEditorWindow::DrawElement() {
182213
std::string labelStr = "##courseStars" + std::to_string(s);
183214
const char* label = labelStr.c_str();
184215
bool isChecked = courseStarFlags & (1 << s);
185-
216+
shouldAllowEdit = (allowedStarFlags.contains(i) && (allowedStarFlags[i].first & (1 << s))) ||
217+
(shouldAllowAllStars);
218+
ImGui::BeginDisabled(!shouldAllowEdit);
186219
UIWidgets::PushStyleCheckbox(WIDGET_COLOR);
187220
if (UIWidgets::Checkbox(label, &isChecked)) {
188221
ModifyStarFlags(isChecked, i, s, gCurrSaveFileNum - 1);
189222
}
190223
UIWidgets::PopStyleCheckbox();
191-
} else if (s == 7 && i < COURSE_BONUS_STAGES) {
224+
ImGui::EndDisabled();
225+
} else if (s == 7 && (i < COURSE_BONUS_STAGES || i == COURSE_WMOTR)) {
192226
std::string labelStr = "##courseCannon" + std::to_string(s);
193227
const char* label = labelStr.c_str();
194228
bool isChecked = gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[i] & (1 << 7);
229+
shouldAllowEdit = (allowedStarFlags.contains(i) && (allowedStarFlags[i].second)) ||
230+
(shouldAllowAllStars);
195231

232+
ImGui::BeginDisabled(!shouldAllowEdit);
196233
UIWidgets::PushStyleCheckbox(WIDGET_COLOR);
197234
if (UIWidgets::Checkbox(label, &isChecked,
198235
UIWidgets::CheckboxOptions{}.Tooltip("Course Cannon"))) {
@@ -203,6 +240,7 @@ void SaveEditorWindow::DrawElement() {
203240
}
204241
}
205242
UIWidgets::PopStyleCheckbox();
243+
ImGui::EndDisabled();
206244

207245
} else {
208246
if (i < COURSE_BONUS_STAGES) {
@@ -236,11 +274,15 @@ void SaveEditorWindow::DrawElement() {
236274
std::string labelStr = "##castleStars" + std::to_string(s);
237275
const char* label = labelStr.c_str();
238276
bool isChecked = gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags & (1 << (24 + s));
277+
shouldAllowEdit = (allowedStarFlags.contains(COURSE_NONE) && (allowedStarFlags[COURSE_NONE].first & (1 << s))) ||
278+
(shouldAllowAllStars);
279+
ImGui::BeginDisabled(!shouldAllowEdit);
239280
UIWidgets::PushStyleCheckbox(WIDGET_COLOR);
240281
if (UIWidgets::Checkbox(label, &isChecked)) {
241282
ModifyStarFlags(isChecked, COURSE_NONE, s, gCurrSaveFileNum - 1);
242283
}
243284
UIWidgets::PopStyleCheckbox();
285+
ImGui::EndDisabled();
244286

245287
ImGui::TableNextColumn();
246288
}

0 commit comments

Comments
 (0)