-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for Champion and Warrior medals #50
base: main
Are you sure you want to change the base?
Changes from all commits
f4f1b7d
a3bb0dc
dd47e19
a1908ea
98f6496
ae8dd91
5f705c1
741cfa4
a8f7eb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
bool get_IsChampionMedalsActive() { | ||
#if DEPENDENCY_CHAMPIONMEDALS | ||
auto plugin = Meta::GetPluginFromID("ChampionMedals"); | ||
if (plugin !is null) { | ||
return plugin.Enabled; | ||
} | ||
return false; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
bool get_IsWarriorMedalsActive() { | ||
#if DEPENDENCY_WARRIORMEDALS | ||
auto plugin = Meta::GetPluginFromID("WarriorMedals"); | ||
if (plugin !is null) { | ||
return plugin.Enabled; | ||
} | ||
return false; | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
bool get_ShowChampionMedals() { | ||
return enableChampionMedals && IsChampionMedalsActive; | ||
} | ||
|
||
bool get_ShowWarriorMedals() { | ||
return enableWarriorMedals && IsWarriorMedalsActive; | ||
} | ||
|
||
[Setting category="Display Text" name="Champion Text" if="get_IsChampionMedalsActive"] | ||
string championText = "Champion"; | ||
|
||
[Setting category="Display Text" name="Warrior Text" if="get_IsWarriorMedalsActive"] | ||
string warriorText = "Warrior"; | ||
|
||
[Setting category="Additional Medals" name="Enable Champion Medals" if="get_IsChampionMedalsActive"] | ||
bool enableChampionMedals = true; | ||
|
||
[Setting category="Additional Medals" name="Enable Warrior Medals" if="get_IsWarriorMedalsActive"] | ||
bool enableWarriorMedals = true; | ||
|
||
int GetChampionMedalsTime() { | ||
#if DEPENDENCY_CHAMPIONMEDALS | ||
if (!IsChampionMedalsActive) { | ||
return -1; | ||
} | ||
return ChampionMedals::GetCMTime(); | ||
#else | ||
return -1; | ||
#endif | ||
} | ||
|
||
int GetWarriorMedalsTime() { | ||
#if DEPENDENCY_WARRIORMEDALS | ||
if (!IsWarriorMedalsActive) { | ||
return -1; | ||
} | ||
return WarriorMedals::GetWMTime(); | ||
#else | ||
return -1; | ||
#endif | ||
} | ||
|
||
uint additionalMedalCoroNonce = 0; | ||
|
||
void WaitForAdditionalMedalsTimes(const string &in mapUid) { | ||
#if TMNEXT | ||
// wait a few frames before checking for additional medals | ||
yield(5); | ||
auto myNonce = ++additionalMedalCoroNonce; | ||
while (myNonce == additionalMedalCoroNonce && mapUid == currentMapUid) { | ||
// set this to false if any time is < 0 | ||
bool haveAllTimes = true; | ||
|
||
if (champion.time < 0 && ShowChampionMedals) { | ||
champion.time = GetChampionMedalsTime(); | ||
haveAllTimes = haveAllTimes && champion.time >= 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You should add in this check for champion medals because they can also not exist at times like warrior medals.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this comes up a bit on my test version of this plugin+PR |
||
trace("Champion time: " + champion.time); | ||
} | ||
|
||
if (warrior.time < 0 && ShowWarriorMedals) { | ||
warrior.time = GetWarriorMedalsTime(); | ||
haveAllTimes = haveAllTimes && warrior.time >= 0; | ||
// warrior medal returns 0 if it does not exist | ||
if (warrior.time == 0) { | ||
warrior.hidden = true; | ||
} | ||
trace("Warrior time: " + warrior.time); | ||
} | ||
|
||
UpdatePBMedalLabel(); | ||
if (haveAllTimes) { | ||
break; | ||
} | ||
|
||
yield(5); | ||
} | ||
trace("Additional medals times loaded"); | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you be checking if you have all times? Or should you have separate checks for if you have the Champion time and the warrior time? It feels to have it be the same check when one could not be there.