Skip to content

Commit

Permalink
Use WarriorMedals color export
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanawy committed Sep 28, 2024
1 parent f1b3e0f commit afbfce5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/history_table.as
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HistoryTable
string formattedTime = "";
string icon = "";
if (@target != null && target.time > 0) {
icon = target.icon;
icon = target.coloredIcon();
formattedTime = "\\$fff" + Time::Format(target.time);
} else {
icon = Icons::Spinner;
Expand Down Expand Up @@ -132,7 +132,7 @@ class HistoryTable
}
if (settingColumnShowMedal) {
UI::TableNextColumn();
UI::Text(run.beaten.icon);
UI::Text(run.beaten.coloredIcon());
}
if (settingColumnShowTime) {
UI::TableNextColumn();
Expand Down
19 changes: 9 additions & 10 deletions src/main.as
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void Main()
#if DEPENDENCY_WARRIORMEDALS
print("WarriorMedals detected");
targets.InsertAt(1, warrior);
warrior.color = WarriorMedals::GetColorStr();
#else
warn("WarriorMedals not installed");
#endif
Expand Down Expand Up @@ -144,7 +145,7 @@ void RenderChangeTargetPopup()
if (UI::BeginPopup(POPUP_CHANGE_TARGET)) {
string text = TEXT_DEFAULT_TARGET;
if (!autoChangeTarget && @currentTarget != null) {
text = currentTarget.icon + "\\$fff" + Time::Format(currentTarget.time);
text = currentTarget.coloredIcon() + "\\$fff" + Time::Format(currentTarget.time);
}
if (UI::BeginCombo(Icons::ClockO, text)) {
if (UI::Selectable(TEXT_DEFAULT_TARGET, autoChangeTarget)) {
Expand All @@ -158,10 +159,10 @@ void RenderChangeTargetPopup()
continue;
}
if (UI::Selectable(
target.icon + "\\$fff" + Time::Format(target.time),
target.coloredIcon() + "\\$fff" + Time::Format(target.time),
@target == @currentTarget && !autoChangeTarget
)) {
print("Target change " + target.icon);
print("Target change " + target.coloredIcon());
autoChangeTarget = false;
SetTarget(target);
UI::CloseCurrentPopup();
Expand Down Expand Up @@ -228,11 +229,11 @@ void RenderMenu() {
continue;
}
if (UI::MenuItem(
target.icon + " \\$fff" + Time::Format(target.time),
target.coloredIcon() + " \\$fff" + Time::Format(target.time),
"",
@target == @currentTarget && !autoChangeTarget
)) {
print("Target change " + target.icon);
print("Target change " + target.coloredIcon());
autoChangeTarget = false;
SetTarget(target);
}
Expand Down Expand Up @@ -297,7 +298,7 @@ void SetTarget(Target @target)
return;
}
@currentTarget = target;
print("New target: " + target.icon);
print("New target: " + target.coloredIcon());
runs.UpdateDeltaTimes(currentTarget, thresholdsTable);
}

Expand Down Expand Up @@ -469,17 +470,15 @@ void OnMapChange(CGameCtnChallenge@ map)
uint newPbTime = scoreMgr.Map_GetRecord_v2(userId, map.MapInfo.MapUid, "PersonalBest", "", "TimeAttack", "");
if (newPbTime != 0) {
pb.time = newPbTime;
print(pb.icon + Time::Format(pb.time));
print(pb.coloredIcon() + Time::Format(pb.time));
}
}
UpdateCurrentTarget();

#if DEPENDENCY_CHAMPIONMEDALS
// UpdateChampionTime();
UpdateCustomMedalTime(champion, function() { return ChampionMedals::GetCMTime(); });
#endif
#if DEPENDENCY_WARRIORMEDALS
// UpdateWarriorTime();
UpdateCustomMedalTime(warrior, function() { return WarriorMedals::GetWMTimeAsync(); });
#endif
}
Expand All @@ -496,7 +495,7 @@ void UpdateCustomMedalTime(Target @medal, MedalTimeCB @GetTime) {
int newTime = GetTime();
if (medal.time != int(newTime)) {
medal.time = newTime;
print(medal.icon + Time::Format(medal.time) + " attempt#" + attempts);
print(medal.coloredIcon() + Time::Format(medal.time) + " attempt#" + attempts);
UpdateCurrentTarget();
}
sleep(1000 * attempts);
Expand Down
2 changes: 1 addition & 1 deletion src/run.as
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Run
string ToString()
{
return
"Run #" + id + " " + Time::Format(time) + beaten.icon + " \\$fff "
"Run #" + id + " " + Time::Format(time) + beaten.coloredIcon() + " \\$fff "
+ ICON_PB + ICON_DELTA + ": " + pbDelta + " isPB: "
+ (isPB ? Icons::Check : Icons::Times)
+ " No respawn time: " + Time::Format(noRespawnTime)
Expand Down
7 changes: 6 additions & 1 deletion src/target.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ class Target {

Target(string &in color, string &in icon, int time = 0) {
this.color = color;
this.icon = color + icon;
this.icon = icon;
this.time = time;
}

string coloredIcon()
{
return color + icon;
}

bool hasTime()
{
return time > 0;
Expand Down

0 comments on commit afbfce5

Please sign in to comment.