You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.5 KiB
124 lines
3.5 KiB
@inject IJSRuntime JsRuntime; |
|
|
|
@inject IBuildOrderService BuildOrderService |
|
@inject IEconomyService EconomyService |
|
@inject IToastService ToastService |
|
@inject ITimingService TimingService |
|
|
|
@using System.Data |
|
@implements IDisposable |
|
|
|
<FormLayoutComponent> |
|
<FormNumberComponent Max="600" |
|
Min="0" |
|
Value="BuildDelay" |
|
OnChange="@OnBuildingInputDelayChanged"> |
|
<FormLabelComponent>Building Input Delay</FormLabelComponent> |
|
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent> |
|
</FormNumberComponent> |
|
<div class="optionRow"> |
|
<FormLayoutComponent> |
|
<FormNumberComponent Max="600" |
|
Min="1" |
|
Value="WaitTime" |
|
OnChange="@OnWaitTimeChanged"> |
|
<FormLabelComponent>Wait Time</FormLabelComponent> |
|
</FormNumberComponent> |
|
<ButtonComponent OnClick="OnWaitClicked">Add Wait</ButtonComponent> |
|
</FormLayoutComponent> |
|
<FormLayoutComponent> |
|
<FormNumberComponent Max="2048" |
|
Min="1" |
|
Value="WaitTo" |
|
OnChange="@OnWaitToChanged"> |
|
<FormLabelComponent>Wait To</FormLabelComponent> |
|
</FormNumberComponent> |
|
<ButtonComponent OnClick="OnWaitToClicked">Add Wait</ButtonComponent> |
|
</FormLayoutComponent> |
|
</div> |
|
</FormLayoutComponent> |
|
|
|
<style> |
|
.optionRow { |
|
display: flex; |
|
gap: 12px; |
|
} |
|
</style> |
|
|
|
@code { |
|
private int BuildDelay { get; set; } = 2; |
|
private int WaitTime { get; set; } = 30; |
|
private int WaitTo { get; set; } = 30; |
|
|
|
protected override void OnInitialized() |
|
{ |
|
TimingService.Subscribe(RefreshDefaults); |
|
|
|
RefreshDefaults(); |
|
} |
|
|
|
void IDisposable.Dispose() |
|
{ |
|
TimingService.Unsubscribe(RefreshDefaults); |
|
} |
|
|
|
void RefreshDefaults() |
|
{ |
|
BuildDelay = TimingService.BuildingInputDelay; |
|
WaitTime = TimingService.WaitTime; |
|
WaitTo = TimingService.WaitTo; |
|
|
|
StateHasChanged(); |
|
|
|
} |
|
|
|
void OnBuildingInputDelayChanged(ChangeEventArgs changeEventArgs) |
|
{ |
|
TimingService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!); |
|
} |
|
|
|
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs) |
|
{ |
|
TimingService.WaitTime = (int)changeEventArgs.Value!; |
|
WaitTime = (int)changeEventArgs.Value!; |
|
} |
|
|
|
void OnWaitToChanged(ChangeEventArgs changeEventArgs) |
|
{ |
|
TimingService.WaitTo = (int)changeEventArgs.Value!; |
|
WaitTo = (int)changeEventArgs.Value!; |
|
} |
|
|
|
private void OnWaitClicked() |
|
{ |
|
if (BuildOrderService.AddWait(WaitTime)) |
|
{ |
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval()); |
|
} |
|
} |
|
|
|
private void OnWaitToClicked() |
|
{ |
|
if (BuildOrderService.AddWaitTo(WaitTo)) |
|
{ |
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval()); |
|
} |
|
} |
|
|
|
protected override bool ShouldRender() |
|
{ |
|
#if DEBUG |
|
JsRuntime.InvokeVoidAsync("console.time", "TimingComponent"); |
|
#endif |
|
|
|
return true; |
|
} |
|
|
|
protected override void OnAfterRender(bool firstRender) |
|
{ |
|
#if DEBUG |
|
JsRuntime.InvokeVoidAsync("console.timeEnd", "TimingComponent"); |
|
#endif |
|
} |
|
|
|
} |