Skip to content

Commit c72cf19

Browse files
committed
fix progress bar not being reset after exiting practice mode
Fixes #33
1 parent 0335408 commit c72cf19

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

run-info/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.1.1
2+
- Fix progress bar not resetting when exiting practice mode
3+
14
## 2.1.0
25
- Add option for specific amount of decimal places
36
- Add option to show run in progress bar percentage

run-info/main.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class $modify(PlayLayer) {
162162
float m_initial_percent = 0;
163163
bool m_show_in_percentage = false;
164164
bool m_show_in_progress_bar = false;
165+
bool m_has_edited_progress_sprite = false;
165166
};
166167

167168
bool init(GJGameLevel* level, bool unk1, bool unk2) {
@@ -257,9 +258,18 @@ class $modify(PlayLayer) {
257258
void updateProgressbar() {
258259
PlayLayer::updateProgressbar();
259260

260-
if (m_isPlatformer) return;
261-
if (!(m_isPracticeMode || m_isTestMode)) return;
262-
if (!Mod::get()->getSettingValue<bool>("enabled")) return;
261+
bool exit = m_isPlatformer;
262+
exit = exit || !(m_isPracticeMode || m_isTestMode);
263+
exit = exit || !Mod::get()->getSettingValue<bool>("enabled");
264+
if (exit) {
265+
if (m_fields->m_has_edited_progress_sprite) {
266+
if (m_progressFill) {
267+
m_progressFill->setPositionX(2.f);
268+
}
269+
m_fields->m_has_edited_progress_sprite = false;
270+
}
271+
return;
272+
}
263273

264274
auto from = m_fields->m_initial_percent;
265275
auto to = this->getCurrentPercent();
@@ -271,11 +281,17 @@ class $modify(PlayLayer) {
271281
m_percentageLabel->setString(fmt::format("{1:.{0}f}-{2:.{0}f}%", decimal, from_trunc, to_trunc).c_str());
272282
}
273283

274-
if (m_progressFill && m_fields->m_show_in_progress_bar) {
275-
float x = from / 100.0f * m_progressWidth;
276-
float width = (to - from) / 100.0f * m_progressWidth;
277-
m_progressFill->setTextureRect({ x, 0.0f, width, m_progressHeight });
278-
m_progressFill->setPositionX(2.0f + x);
284+
if (m_progressFill) {
285+
if (m_fields->m_show_in_progress_bar) {
286+
float x = from / 100.0f * m_progressWidth;
287+
float width = (to - from) / 100.0f * m_progressWidth;
288+
m_progressFill->setTextureRect({ x, 0.0f, width, m_progressHeight });
289+
m_progressFill->setPositionX(2.0f + x);
290+
m_fields->m_has_edited_progress_sprite = true;
291+
} else if (m_fields->m_has_edited_progress_sprite) {
292+
m_progressFill->setPositionX(2.f);
293+
m_fields->m_has_edited_progress_sprite = false;
294+
}
279295
}
280296
}
281297
};

run-info/mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"mac": "2.2074",
77
"ios": "2.2074"
88
},
9-
"version": "2.1.0",
9+
"version": "2.1.1",
1010
"id": "mat.run-info",
1111
"name": "Run Info",
1212
"developer": "mat",

0 commit comments

Comments
 (0)