Skip to content
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

Support for Champion and Warrior medal #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion UltimateMedals.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ bool showHeader = true;
bool showPbest = true;

#if TMNEXT||MP4
[Setting category="Medals" name="Show Champion"]
bool showChampion = false;

[Setting category="Medals" name="Show Warrior"]
bool showWarrior = true;

[Setting category="Medals" name="Show Author"]
bool showAuthor = true;

Expand Down Expand Up @@ -85,6 +91,12 @@ int fontSize = 16;

/* Custom names */
#if TMNEXT||MP4
[Setting category="Display Text" name="Show Champion Text"]
string championText = "Champion";

[Setting category="Display Text" name="Warrior Text"]
string warriorText = "Warrior";

[Setting category="Display Text" name="Author Text"]
string authorText = "Author";

Expand Down Expand Up @@ -124,6 +136,8 @@ const array<string> medals = {
"\\$db4" + Icons::Circle, // gold medal
#if TMNEXT||MP4
"\\$071" + Icons::Circle, // author medal
"\\$16a" + Icons::Circle, // warrior medal
"\\$c13" + Icons::Circle // champion medal
#elif TURBO
"\\$0f1" + Icons::Circle, // trackmaster medal
"\\$964" + Icons::Circle, // super bronze medal
Expand Down Expand Up @@ -199,6 +213,8 @@ class Record {
}

#if TMNEXT||MP4
Record@ champion = Record(championText, 6, -7);
Record@ warrior = Record(warriorText, 5, -6);
Record@ author = Record(authorText, 4, -5);
#elif TURBO
Record@ stmaster = Record(stmasterText, 8, -9);
Expand All @@ -213,7 +229,7 @@ Record@ bronze = Record(bronzeText, 1, -2);
Record@ pbest = Record(pbestText, 0, -1, "\\$0ff");

#if TMNEXT||MP4
array<Record@> times = {author, gold, silver, bronze, pbest};
array<Record@> times = {champion, warrior, author, gold, silver, bronze, pbest};
#elif TURBO
array<Record@> times = {stmaster, sgold, ssilver, sbronze, tmaster, gold, silver, bronze, pbest};

Expand Down Expand Up @@ -463,6 +479,8 @@ void LoadFont() {

void UpdateHidden() {
#if TMNEXT||MP4
champion.hidden = !showChampion || champion.time == 0;
warrior.hidden = !showWarrior || warrior.time == 0;
author.hidden = !showAuthor;
#elif TURBO
// If no super times, never show them
Expand All @@ -480,6 +498,8 @@ void UpdateHidden() {

void UpdateText() {
#if TMNEXT||MP4
champion.name = championText;
warrior.name = warriorText;
author.name = authorText;
#elif TURBO
stmaster.name = stmasterText;
Expand Down Expand Up @@ -524,6 +544,24 @@ void Main() {
if(windowVisible && map !is null && map.MapInfo.MapUid != "" && app.Editor is null) {
if(currentMapUid != map.MapInfo.MapUid) {
#if TMNEXT||MP4

champion.time = 0;
warrior.time = 0;

#if DEPENDENCY_CHAMPIONMEDALS
sleep(1000);
uint cm_time = ChampionMedals::GetCMTime();
champion.time = cm_time;
#else
champion.hidden = true;
#endif

#if DEPENDENCY_WARRIORMEDALS
uint wm_time = WarriorMedals::GetWMTimeAsync();
warrior.time = wm_time;
#else
warrior.hidden = true;
#endif
author.time = map.TMObjective_AuthorTime;
#elif TURBO
int mapNumber = Text::ParseInt(map.MapName);
Expand Down Expand Up @@ -651,9 +689,20 @@ void Main() {
pbest.time = -1;
pbest.medal = 0;
}

#if TMNEXT
// Somehow the only way to show the right medal next to PB (Doesn't work in CalcMedal())
if (pbest.time <= champion.time && champion.time > 0) {
pbest.medal = 6;
} else if (pbest.time <= warrior.time && champion.time > 0) {
pbest.medal = 5;
}
#endif

} else if(map is null || map.MapInfo.MapUid == "") {
#if TMNEXT||MP4
champion.time = -7;
warrior.time = -6;
author.time = -5;
#elif TURBO
stmaster.time = -9;
Expand Down
3 changes: 3 additions & 0 deletions info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ category = "Race"

siteid = 118
version = "1.12.0"

[script]
optional_dependencies = [ "ChampionMedals", "WarriorMedals" ]