Skip to content

Commit aab4e01

Browse files
committed
Add dash count to lobby and overworld journals, if Dash Count Mod is enabled
1 parent df4423f commit aab4e01

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Runtime.CompilerServices;
2+
3+
namespace Celeste.Mod.CollabUtils2.UI {
4+
/// <summary>
5+
/// If Dash Count Mod is installed and enabled, it will simply mod IsDashCountEnabled() to return true instead of false,
6+
/// in order to enable dash count in the Collab Utils' journals.
7+
/// (It is simpler to implement them in Collab Utils directly, rather than hooking both journals with IL hooks.)
8+
/// </summary>
9+
static class OuiJournalCollabProgressDashCountMod {
10+
[MethodImpl(MethodImplOptions.NoInlining)]
11+
internal static bool IsDashCountEnabled() {
12+
return false;
13+
}
14+
}
15+
}

UI/OuiJournalCollabProgressInLobby.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static List<OuiJournalCollabProgressInLobby> GeneratePages(OuiJournal jou
5959
int totalStrawberries = 0;
6060
int totalDeaths = 0;
6161
int sumOfBestDeaths = 0;
62+
int sumOfBestDashes = 0;
6263
long totalTime = 0;
6364
long sumOfBestTimes = 0;
6465

@@ -183,6 +184,15 @@ public static List<OuiJournalCollabProgressInLobby> GeneratePages(OuiJournal jou
183184
allLevelsDone = false;
184185
}
185186

187+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
188+
if (item.Modes[0].SingleRunCompleted) {
189+
row.Add(new TextCell(Dialog.Deaths(item.Modes[0].BestDashes), currentPage.TextJustify, 0.5f, currentPage.TextColor));
190+
sumOfBestDashes += item.Modes[0].BestDashes;
191+
} else {
192+
row.Add(new IconCell("dot"));
193+
}
194+
}
195+
186196
if (item.TotalTimePlayed > 0) {
187197
row.Add(new TextCell(Dialog.Time(item.TotalTimePlayed), currentPage.TextJustify, 0.5f, currentPage.TextColor));
188198
} else {
@@ -239,7 +249,13 @@ public static List<OuiJournalCollabProgressInLobby> GeneratePages(OuiJournal jou
239249
totalsRow.Add(null)
240250
.Add(new TextCell(totalStrawberries.ToString(), currentPage.TextJustify, 0.6f, currentPage.TextColor))
241251
.Add(new TextCell(Dialog.Deaths(totalDeaths), currentPage.TextJustify, 0.6f, currentPage.TextColor))
242-
.Add(new TextCell(allLevelsDone ? Dialog.Deaths(sumOfBestDeaths) : "-", currentPage.TextJustify, 0.6f, currentPage.TextColor))
252+
.Add(new TextCell(allLevelsDone ? Dialog.Deaths(sumOfBestDeaths) : "-", currentPage.TextJustify, 0.6f, currentPage.TextColor));
253+
254+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
255+
totalsRow.Add(new TextCell(allLevelsDone ? Dialog.Deaths(sumOfBestDashes) : "-", currentPage.TextJustify, 0.6f, currentPage.TextColor));
256+
}
257+
258+
totalsRow
243259
.Add(new TextCell(Dialog.Time(totalTime), currentPage.TextJustify, 0.6f, currentPage.TextColor))
244260
.Add(new TextCell(allSpeedBerriesDone ? Dialog.Time(sumOfBestTimes) : "-", currentPage.TextJustify, 0.6f, currentPage.TextColor)).Add(null);
245261

@@ -273,7 +289,13 @@ public OuiJournalCollabProgressInLobby(OuiJournal journal, string levelSet, bool
273289
.AddColumn(new EmptyCell(64f))
274290
.AddColumn(new IconCell("strawberry", 150f))
275291
.AddColumn(new IconCell(skullTexture, 100f))
276-
.AddColumn(new IconCell(minDeathsTexture, 100f))
292+
.AddColumn(new IconCell(minDeathsTexture, 100f));
293+
294+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
295+
table.AddColumn(new IconCell("max480/DashCountMod/dashes", 80f));
296+
}
297+
298+
table
277299
.AddColumn(new IconCell("time", 220f))
278300
.AddColumn(new IconCell("CollabUtils2/speed_berry_pbs_heading", 220f))
279301
.AddColumn(new EmptyCell(30f));

UI/OuiJournalCollabProgressInOverworld.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,21 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
4747
.AddColumn(new EmptyCell(64f))
4848
.AddColumn(new IconCell("strawberry", 150f))
4949
.AddColumn(new IconCell("skullblue", 100f))
50-
.AddColumn(new IconCell("CollabUtils2MinDeaths/SpringCollab2020/1-Beginner", 100f))
50+
.AddColumn(new IconCell("CollabUtils2MinDeaths/SpringCollab2020/1-Beginner", 100f));
51+
52+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
53+
table.AddColumn(new IconCell("max480/DashCountMod/dashes", 80f));
54+
}
55+
56+
table
5157
.AddColumn(new IconCell("time", 220f))
5258
.AddColumn(new IconCell("CollabUtils2/speed_berry_pbs_heading", 220f))
5359
.AddColumn(new EmptyCell(30f));
5460

5561
int totalStrawberries = 0;
5662
int totalDeaths = 0;
5763
int sumOfBestDeaths = 0;
64+
int sumOfBestDashes = 0;
5865
long totalTime = 0;
5966
long sumOfBestTimes = 0;
6067

@@ -75,6 +82,7 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
7582
int lobbyTotalStrawberries = areaData.Mode[0].TotalStrawberries;
7683
int lobbyDeaths = item.Modes[0].Deaths;
7784
int lobbySumOfBestDeaths = 0;
85+
int lobbySumOfBestDashes = 0;
7886
long lobbyTotalTime = item.TotalTimePlayed;
7987
long lobbySumOfBestTimes = 0;
8088
bool lobbyLevelsDone = true;
@@ -117,6 +125,8 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
117125
lobbySumOfBestDeaths += lobbyMap.Modes[0].BestDeaths;
118126
}
119127

128+
lobbySumOfBestDashes += lobbyMap.Modes[0].BestDashes;
129+
120130
if (!lobbyMap.Modes[0].HeartGem) {
121131
lobbyLevelsDone = false;
122132
}
@@ -164,9 +174,24 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
164174
} else {
165175
row.Add(new IconCell("dot"));
166176
}
177+
178+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
179+
if (lobbyMapLevelSet == null) {
180+
row.Add(new TextCell(Dialog.Deaths(item.Modes[0].BestDashes), TextJustify, 0.5f, TextColor));
181+
sumOfBestDashes += item.Modes[0].BestDashes;
182+
} else if (lobbyAllMapsCompletedInSingleRun) {
183+
row.Add(new TextCell(Dialog.Deaths(lobbySumOfBestDashes), TextJustify, 0.5f, TextColor));
184+
} else {
185+
row.Add(new IconCell("dot"));
186+
}
187+
}
167188
} else {
168189
row.Add(new IconCell("dot"));
169190
allLevelsDone = false;
191+
192+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
193+
row.Add(new IconCell("dot"));
194+
}
170195
}
171196

172197
if (lobbyTotalTime > 0) {
@@ -194,6 +219,7 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
194219
totalStrawberries += lobbyStrawberries;
195220
totalDeaths += lobbyDeaths;
196221
sumOfBestDeaths += lobbySumOfBestDeaths;
222+
sumOfBestDashes += lobbySumOfBestDashes;
197223
totalTime += lobbyTotalTime;
198224
allMapsCompletedInSingleRun &= lobbyAllMapsCompletedInSingleRun;
199225

@@ -209,7 +235,13 @@ public OuiJournalCollabProgressInOverworld(OuiJournal journal)
209235
.Add(null)
210236
.Add(new TextCell(totalStrawberries.ToString(), TextJustify, 0.6f, TextColor))
211237
.Add(new TextCell(Dialog.Deaths(totalDeaths), TextJustify, 0.6f, TextColor))
212-
.Add(new TextCell(allLevelsDone && allMapsCompletedInSingleRun ? Dialog.Deaths(sumOfBestDeaths) : "-", TextJustify, 0.6f, TextColor))
238+
.Add(new TextCell(allLevelsDone && allMapsCompletedInSingleRun ? Dialog.Deaths(sumOfBestDeaths) : "-", TextJustify, 0.6f, TextColor));
239+
240+
if (OuiJournalCollabProgressDashCountMod.IsDashCountEnabled()) {
241+
totalsRow.Add(new TextCell(allLevelsDone && allMapsCompletedInSingleRun ? Dialog.Deaths(sumOfBestDashes) : "-", TextJustify, 0.6f, TextColor));
242+
}
243+
244+
totalsRow
213245
.Add(new TextCell(Dialog.Time(totalTime), TextJustify, 0.6f, TextColor))
214246
.Add(new TextCell(allSpeedBerriesDone ? Dialog.Time(sumOfBestTimes) : "-", TextJustify, 0.6f, TextColor)).Add(null);
215247

everest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Name: CollabUtils2
2-
Version: 1.6.7
2+
Version: 1.6.8
33
DLL: bin/Debug/net452/CollabUtils2.dll
44
Dependencies:
55
- Name: Everest

0 commit comments

Comments
 (0)