Skip to content

Commit 842f50f

Browse files
committed
add build modal
1 parent 45234ce commit 842f50f

File tree

7 files changed

+110
-15
lines changed

7 files changed

+110
-15
lines changed

src/dsstats.db8services/RemoteToggleService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using dsstats.shared.Interfaces;
1+
using dsstats.shared;
2+
using dsstats.shared.Interfaces;
23

34
namespace dsstats.db8services;
45

@@ -15,6 +16,11 @@ public class RemoteToggleService : IRemoteToggleService
1516
public event EventHandler? FromServerChanged = null;
1617
public event EventHandler? CultureChanged = null;
1718

19+
public void Build(SpawnDto spawn, Commander commander, int team)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
1824
public void SetCulture(string culture)
1925
{
2026
_culture = culture;

src/dsstats.maui/dsstats.builder/dsstats.builder/Builds/ZergBuild.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public ZergBuild()
1616
{ "Mutalisk", new('s') },
1717
{ "Corruptor", new('d') },
1818
{ "Infestor", new('f') },
19-
{ "Swarmhost", new('g') },
19+
{ "Swarm Host", new('g') },
2020
{ "Viper", new('z') },
2121
{ "Ultralisk", new('x') },
22-
{ "Broodloard", new('c') },
22+
{ "Brood Lord", new('c') },
2323
};
2424

2525
AbilityMap = new Dictionary<string, BuildOption>

src/dsstats.maui/dsstats.builder/dsstats.builder/DsBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static List<InputEvent> BuildArmy(Commander commander, int screenWidth, i
2525

2626
// setup
2727
events.AddRange(EnterString("Infinite"));
28+
events.AddRange(EnterString($"Tier"));
2829
events.AddRange(EnterString("Clear"));
2930
events.AddRange(EnterString($"Enemy {commander}"));
3031

src/dsstats.maui/dsstats.maui8/Services/RemoteToggleService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
using dsstats.builder;
3+
using dsstats.shared;
24
using dsstats.shared.Interfaces;
35

46
namespace dsstats.maui8.Services;
@@ -36,4 +38,9 @@ public void SetCulture(string culture)
3638
_culture = culture;
3739
OnCultureChanged(new());
3840
}
41+
42+
public void Build(SpawnDto spawn, Commander commander, int team)
43+
{
44+
DsBuilder.Build(spawn, commander, team);
45+
}
3946
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
@using Microsoft.JSInterop
2+
@using dsstats.shared
3+
@using dsstats.shared.Interfaces
4+
@inject IJSRuntime JSRuntime
5+
@inject IRemoteToggleService RemoteToggleService
6+
7+
<div class="modal" id="buildmodal" tabindex="-1" aria-labelledby="buildmodalLabel" aria-hidden="true">
8+
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
9+
<div class="modal-content">
10+
<div class="modal-header">
11+
<h5 class="modal-title" id="buildmodalLabel">Prepare to Start Build</h5>
12+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
13+
</div>
14+
<div class="modal-body">
15+
<h6>⚠️ Please follow these steps before continuing:</h6>
16+
<ol>
17+
<li><strong>Close all other applications.</strong></li>
18+
<li>Launch the <strong>Direct Strike Tutorial</strong> map in StarCraft II.</li>
19+
<li>
20+
Assign hotkeys:
21+
<ul>
22+
<li>Set Team 1's worker (top player) to hotkey <strong>1</strong></li>
23+
<li>Set Team 2's worker (bottom player) to hotkey <strong>2</strong></li>
24+
</ul>
25+
</li>
26+
<li><strong>Do not move the workers!</strong> They must stay centered for accurate unit placement.</li>
27+
<li>In <strong>dsstats</strong>, load the replay and select the desired build.</li>
28+
<li>Click the <strong>Build</strong> button (below) and <strong>switch back to StarCraft II immediately</strong>.</li>
29+
<li><strong>Don't touch your mouse or keyboard</strong> until the build is done.</li>
30+
<li>Ensure no other application is in focus during the build process.</li>
31+
</ol>
32+
<hr />
33+
<p><strong>How It Works:</strong> The builder reads your replay, calculates unit placements, and simulates input to recreate the build exactly.</p>
34+
</div>
35+
<div class="modal-footer">
36+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
37+
<button type="button" class="btn btn-primary" @onclick="StartBuild">Start Build</button>
38+
</div>
39+
</div>
40+
</div>
41+
</div>
42+
43+
@code {
44+
SpawnDto spawn = new();
45+
Commander commander = Commander.None;
46+
int team = 0;
47+
48+
private void StartBuild()
49+
{
50+
RemoteToggleService.Build(spawn, commander, team);
51+
}
52+
53+
54+
public void Show(SpawnDto spawn, Commander commander, int team)
55+
{
56+
this.spawn = spawn;
57+
this.commander = commander;
58+
this.team = team;
59+
JSRuntime.InvokeVoidAsync("openModalById", "buildmodal");
60+
}
61+
62+
public void Hide()
63+
{
64+
JSRuntime.InvokeVoidAsync("closeModalById", "buildmodal");
65+
}
66+
}

src/dsstats.razorlib/Replays/ReplayPlayerDetails.razor

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@using Microsoft.JSInterop
2+
@using dsstats.razorlib.Modals
23
@using dsstats.shared
34
@using dsstats.razorlib.Services
45
@using dsstats.shared.Interfaces
56
@inject IDsDataService dsDataService
7+
@inject IRemoteToggleService remoteToggleService
68

79
<div class="card w-auto">
810
<div class="card-header bgchart">
@@ -74,7 +76,7 @@
7476
<div class="col-auto">
7577
<h5>
7678
<span class="badge border border-info">
77-
ArmyValue <span class="text-warning">@HelperService.GetBigNumberString(armyValue)</span>
79+
Value <span class="text-warning">@HelperService.GetBigNumberString(armyValue)</span>
7880
</span>
7981
</h5>
8082
</div>
@@ -84,11 +86,20 @@
8486
<div class="col-auto">
8587
<h5>
8688
<span class="badge border border-info">
87-
ArmyLife <span class="text-warning">@HelperService.GetBigNumberString(armyLife)</span>
89+
Life <span class="text-warning">@HelperService.GetBigNumberString(armyLife)</span>
8890
</span>
8991
</h5>
9092
</div>
9193
}
94+
@if (remoteToggleService.IsMaui && Spawn != null)
95+
{
96+
<div class="col-auto">
97+
<button type="button" class="btn btn-sm btn-outline-light"
98+
@onclick="e => buildModal?.Show(Spawn, Player.Race, Player.Team)">
99+
Build
100+
</button>
101+
</div>
102+
}
92103
</div>
93104
<div class="table-responsive w-auto">
94105
<table class="tptable table table-sm">
@@ -116,6 +127,8 @@
116127
</div>
117128
</div>
118129

130+
<BuildModal @ref="buildModal" />
131+
119132
@code {
120133
[Parameter, EditorRequired]
121134
public Breakpoint Breakpoint { get; set; }
@@ -135,6 +148,7 @@
135148
SpawnDto? Spawn = null;
136149
SpawnInfo spawnInfo = new();
137150
ListBuildUnit? highlightUnit = null;
151+
BuildModal? buildModal;
138152

139153
bool showMap = false;
140154
bool showUpgrades = false;
@@ -168,10 +182,10 @@
168182
if (Spawn is not null)
169183
{
170184
spawnInfo = await dsDataService.GetSpawnInfo(new SpawnRequest()
171-
{
172-
Units = Spawn.Units.Select(s => s.Unit).ToList(),
173-
Commander = Player.Race
174-
});
185+
{
186+
Units = Spawn.Units.Select(s => s.Unit).ToList(),
187+
Commander = Player.Race
188+
});
175189
SetInfos(Spawn, spawnInfo);
176190
}
177191
replayPlayerChartMap?.Update(Spawn, spawnInfo, Player.Team);
@@ -199,12 +213,12 @@
199213
spawnArmyValue += buildUnit.Cost * spawnUnit.Count;
200214
spawnArmyLife += (buildUnit.Life + buildUnit.Shields) * spawnUnit.Count;
201215
spawnUnits.Add(new()
202-
{
203-
Name = buildUnit.Name,
204-
ChartName = spawnUnit.Unit.Name,
205-
Count = spawnUnit.Count,
206-
Color = HelperService.GetUnitColor(buildUnit.Color)
207-
});
216+
{
217+
Name = buildUnit.Name,
218+
ChartName = spawnUnit.Unit.Name,
219+
Count = spawnUnit.Count,
220+
Color = HelperService.GetUnitColor(buildUnit.Color)
221+
});
208222
}
209223
else
210224
{

src/dsstats.shared/Interfaces/IRemoteToggleService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public interface IRemoteToggleService
99
bool FromServer { get; }
1010
bool IsMaui { get; }
1111
string Culture { get; }
12+
void Build(SpawnDto spawn, Commander commander, int team);
1213
}

0 commit comments

Comments
 (0)