Skip to content

Commit f7b5d64

Browse files
committed
fen modal
1 parent 2e27cd0 commit f7b5d64

File tree

4 files changed

+128
-38
lines changed

4 files changed

+128
-38
lines changed

src/dsstats.razorlib/Modals/BuildModal.razor

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,63 @@
99

1010
<div class="modal" id="buildmodal" tabindex="-1" aria-labelledby="buildmodalLabel" aria-hidden="true">
1111
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
12-
<div class="modal-content">
13-
<div class="modal-header">
14-
<h5 class="modal-title" id="buildmodalLabel">Prepare to Start Build</h5>
15-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
16-
</div>
17-
<div class="modal-body">
18-
<h6>⚠️ Please follow these steps before continuing:</h6>
19-
<ol>
20-
<li><strong>Close all other applications.</strong></li>
21-
<li>Launch the <strong>Direct Strike Tutorial</strong> map in StarCraft II.</li>
22-
<li>
23-
Assign hotkeys:
24-
<ul>
25-
<li>Set Team 1's worker (top player) to hotkey <strong>1</strong></li>
26-
<li>Set Team 2's worker (bottom player) to hotkey <strong>2</strong></li>
27-
</ul>
28-
</li>
29-
<li><strong>Do not move the workers!</strong> They must stay centered for accurate unit placement.</li>
30-
<li>In <strong>dsstats</strong>, load the replay and select the desired build.</li>
31-
<li>Click the <strong>Build</strong> button (below) and <strong>switch back to StarCraft II immediately</strong>.</li>
32-
<li><strong>Don't touch your mouse or keyboard</strong> until the build is done.</li>
33-
<li>Ensure no other application is in focus during the build process.</li>
34-
</ol>
35-
<hr />
36-
<div>
37-
<label for="fenInput" class="form-label"><strong>Modify FEN (optional):</strong></label>
38-
<textarea id="fenInput" class="form-control" rows="4" @bind="fen"></textarea>
39-
<button class="btn btn-outline-primary mt-2" @onclick="ApplyFen">Apply FEN</button>
12+
@if (RemoteToggleService.IsMaui)
13+
{
14+
<div class="modal-content">
15+
<div class="modal-header">
16+
<h5 class="modal-title" id="buildmodalLabel">Prepare to Start Build <b>EXPERIMENTAL</b></h5>
17+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
18+
</div>
19+
<div class="modal-body">
20+
<h6>⚠️ Please follow these steps before continuing:</h6>
21+
<ol>
22+
<li><strong>Close all other applications.</strong></li>
23+
<li>Launch the <strong>Direct Strike Tutorial</strong> map in StarCraft II.</li>
24+
<li>
25+
Assign hotkeys:
26+
<ul>
27+
<li>Set Team 1's worker (top player) to hotkey <strong>1</strong></li>
28+
<li>Set Team 2's worker (bottom player) to hotkey <strong>2</strong></li>
29+
</ul>
30+
</li>
31+
<li><strong>Do not move the workers!</strong> They must stay centered for accurate unit placement.</li>
32+
<li>In <strong>dsstats</strong>, load the replay and select the desired build.</li>
33+
<li>Click the <strong>Build</strong> button (below) and <strong>switch back to StarCraft II immediately</strong>.</li>
34+
<li><strong>Don't touch your mouse or keyboard</strong> until the build is done.</li>
35+
<li>Ensure no other application is in focus during the build process.</li>
36+
</ol>
37+
<hr />
38+
<div>
39+
<label for="fenInput" class="form-label"><strong>Modify FEN (optional):</strong></label>
40+
<textarea id="fenInput" class="form-control" rows="4" @bind="fen"></textarea>
41+
<button class="btn btn-outline-primary mt-2" @onclick="ApplyFen">Apply FEN</button>
42+
</div>
43+
</div>
44+
<div class="modal-footer">
45+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
46+
<button type="button" class="btn btn-primary" @onclick="StartBuild">Start Build</button>
4047
</div>
4148
</div>
42-
<div class="modal-footer">
43-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
44-
<button type="button" class="btn btn-primary" @onclick="StartBuild">Start Build</button>
49+
}
50+
else
51+
{
52+
<div class="modal-content">
53+
<div class="modal-header">
54+
<h5 class="modal-title" id="buildmodalLabel">DS FEN String</h5>
55+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
56+
</div>
57+
<div class="modal-body">
58+
You can use this string to build the units in the Direct Strike Tutorial Map using the sc2dsstats app.
59+
<div>
60+
<label for="fenInput" class="form-label"><strong>FEN:</strong></label>
61+
<textarea id="fenInput" disabled class="form-control" rows="4" @bind="fen"></textarea>
62+
</div>
63+
</div>
64+
<div class="modal-footer">
65+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
66+
</div>
4567
</div>
46-
</div>
68+
}
4769
</div>
4870
</div>
4971

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@using Blazored.Toast.Services
2+
@using Microsoft.JSInterop
3+
@using dsstats.shared
4+
@using dsstats.shared.DsFen
5+
@using dsstats.shared.Interfaces
6+
@inject IJSRuntime JSRuntime
7+
8+
<div class="modal" id="fenmodal" tabindex="-1" aria-labelledby="fenmodalLabel" aria-hidden="true">
9+
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
10+
<div class="modal-content">
11+
<div class="modal-header">
12+
<h5 class="modal-title" id="fenmodalLabel">DS FEN String</h5>
13+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
14+
</div>
15+
<div class="modal-body">
16+
You can use this string to build the units in the Direct Strike Tutorial Map using the sc2dsstats app.
17+
<div>
18+
<label for="fenInput" class="form-label"><strong>FEN:</strong></label>
19+
<textarea id="fenInput" disabled class="form-control" rows="4" @bind="fen"></textarea>
20+
</div>
21+
</div>
22+
<div class="modal-footer">
23+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+
29+
@code {
30+
SpawnDto spawn = new();
31+
Commander commander = Commander.None;
32+
int team = 0;
33+
string fen = string.Empty;
34+
35+
public void Show(SpawnDto spawn, Commander commander, int team)
36+
{
37+
this.spawn = spawn;
38+
this.commander = commander;
39+
this.team = team;
40+
fen = DsFen.GetFen(spawn, commander, team);
41+
JSRuntime.InvokeVoidAsync("openModalById", "fenmodal");
42+
}
43+
44+
public void Hide()
45+
{
46+
JSRuntime.InvokeVoidAsync("closeModalById", "fenmodal");
47+
}
48+
}

src/dsstats.razorlib/Replays/ReplayPlayerDetails.razor

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@using dsstats.shared
44
@using dsstats.razorlib.Services
55
@using dsstats.shared.Interfaces
6+
@using static dsstats.razorlib.Replays.ReplayPlayersDetailContainer
67
@inject IDsDataService dsDataService
78
@inject IRemoteToggleService remoteToggleService
89

@@ -91,11 +92,11 @@
9192
</h5>
9293
</div>
9394
}
94-
@if (remoteToggleService.IsMaui && Spawn != null)
95+
@if (Spawn != null)
9596
{
9697
<div class="col-auto">
9798
<button type="button" class="btn btn-sm btn-outline-light"
98-
@onclick="e => buildModal?.Show(Spawn, Player.Race, Player.Team)">
99+
@onclick="e => OnBuildRequest.InvokeAsync(new DsBuildInfo() { Spawn = Spawn, Commander = Player.Race, Team = Player.Team })">
99100
Build
100101
</button>
101102
</div>
@@ -127,8 +128,6 @@
127128
</div>
128129
</div>
129130

130-
<BuildModal @ref="buildModal" />
131-
132131
@code {
133132
[Parameter, EditorRequired]
134133
public Breakpoint Breakpoint { get; set; }
@@ -142,13 +141,15 @@
142141
[Parameter, EditorRequired]
143142
public Lazy<Task<IJSObjectReference>> moduleTask { get; set; } = default!;
144143

144+
[Parameter]
145+
public EventCallback<DsBuildInfo> OnBuildRequest { get; set; }
146+
145147
bool IsWinner;
146148
bool isLoading;
147149

148150
SpawnDto? Spawn = null;
149151
SpawnInfo spawnInfo = new();
150152
ListBuildUnit? highlightUnit = null;
151-
BuildModal? buildModal;
152153

153154
bool showMap = false;
154155
bool showUpgrades = false;

src/dsstats.razorlib/Replays/ReplayPlayersDetailContainer.razor

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using Microsoft.JSInterop
2+
@using dsstats.razorlib.Modals
23
@using dsstats.shared
34
@inject IJSRuntime JSRuntime
45
@implements IDisposable
@@ -11,17 +12,23 @@
1112
@ref="@detail.ReplayPlayerDetails"
1213
Breakpoint="breakpoint"
1314
Player="detail.ReplayPlayer" MiddleInfo="MiddleInfo"
14-
moduleTask="moduleTask" />
15+
moduleTask="moduleTask"
16+
OnBuildRequest="RequestBuild" />
1517
</div>
1618
}
1719
</div>
1820

21+
22+
<BuildModal @ref="buildModal" />
23+
24+
1925
@code {
2026
[Parameter, EditorRequired]
2127
public MiddleInfo MiddleInfo { get; set; } = default!;
2228

2329
private List<ReplayPlayerDetailListItem> replayPlayerDetails = new();
2430
private Breakpoint breakpoint = Breakpoint.All;
31+
BuildModal? buildModal;
2532

2633
private Lazy<Task<IJSObjectReference>> moduleTask = null!;
2734

@@ -82,6 +89,11 @@
8289
InvokeAsync(() => StateHasChanged());
8390
}
8491

92+
public void RequestBuild(DsBuildInfo dsBuildInfo)
93+
{
94+
buildModal?.Show(dsBuildInfo.Spawn, dsBuildInfo.Commander, dsBuildInfo.Team);
95+
}
96+
8597
public void Dispose()
8698
{
8799
if (moduleTask.IsValueCreated)
@@ -95,4 +107,11 @@
95107
public ReplayPlayerDto ReplayPlayer { get; set; } = null!;
96108
public ReplayPlayerDetails? ReplayPlayerDetails { get; set; }
97109
}
110+
111+
public record DsBuildInfo
112+
{
113+
public SpawnDto Spawn { get; set; } = new();
114+
public Commander Commander { get; set; } = Commander.None;
115+
public int Team { get; set; } = 0;
116+
}
98117
}

0 commit comments

Comments
 (0)