feature(BuildCalc) Adding WIP wait button, and better styling

This commit is contained in:
2022-04-15 04:04:58 -04:00
parent 04c1718259
commit a0cd7d9b45
13 changed files with 192 additions and 87 deletions
@@ -27,12 +27,23 @@
<div class="calculatorGrid">
<div class="gridItem" style="grid-area: timing;">
<ButtonComponent OnClick="OnResetClicked">Clear Build Order</ButtonComponent>
<ButtonComponent ButtonType="ButtonType.Secondary" OnClick="OnResetClicked">Clear Build Order</ButtonComponent>
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Timing Info"]">
<TimingComponent></TimingComponent>
</InfoTooltipComponent>
</PanelComponent>
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Filter Info"]">
<FilterComponent></FilterComponent>
</InfoTooltipComponent>
</PanelComponent>
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Options Info"]">
<OptionsComponent></OptionsComponent>
</InfoTooltipComponent>
</PanelComponent>
</div>
@@ -44,20 +55,6 @@
</PanelComponent>
</div>
<div class="gridItem" style="grid-area: filter;">
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Filter Info"]">
<FilterComponent></FilterComponent>
</InfoTooltipComponent>
</PanelComponent>
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Options Info"]">
<OptionsComponent></OptionsComponent>
</InfoTooltipComponent>
</PanelComponent>
</div>
<div class="gridItem" style="grid-area: view;">
<PanelComponent>
<InfoTooltipComponent InfoText="@locale["Tooltip Entity Info"]">
@@ -182,7 +179,7 @@
grid-template-rows: 600px 400px 450px;
grid-template-areas:
'timing view view view'
'filter bank army army'
'timing bank army army'
'keys keys highlights buildorder'
'chart chart chart chart';
}
@@ -202,7 +199,6 @@
grid-template-areas:
'timing'
'view'
'filter'
'keys'
'bank'
'army'
@@ -1,20 +1,28 @@
@inject IJSRuntime jsRuntime
@inject IBuildOrderService buildOrder
@inject ITimingService timingService
@implements IDisposable
<FormLayoutComponent>
<FormDisplayComponent Label="Army ready at">
<Display>@lastInterval | T @Interval.ToTime(lastInterval)</Display>
</FormDisplayComponent>
<div style="display: flex; gap: 24px;">
<FormDisplayComponent Label="Army Completed At">
<Display>@lastInterval | T @Interval.ToTime(lastInterval)</Display>
</FormDisplayComponent>
<FormDisplayComponent Label="Army Attacking At">
<Display>@(lastInterval + timingService.GetTravelTime()) | T @Interval.ToTime(lastInterval + timingService.GetTravelTime())</Display>
</FormDisplayComponent>
</div>
<FormDisplayComponent Label="Army units built">
<Display>
<div style="display: flex; width: 100%; gap: 12px; flex-wrap: wrap;">
<div class="armyCardsContainer">
@foreach (var unit in armyCount)
{
<div style="width:90px; height: 60px; border: 1px solid gray; padding: 8px;">
<div>@unit.Value.ToString()x</div>
<div class="armyCard">
<div class="armyCountPosition">
<div class="armyCount">@unit.Value.ToString()x</div>
</div>
<div>@unit.Key</div>
</div>
}
@@ -24,9 +32,33 @@
</FormLayoutComponent>
<style>
.armyCardsContainer {
display: flex;
width: 100%;
gap: 16px;
flex-wrap: wrap;
}
.armyCard {
width:100px;
height: 80px;
padding: 16px;
}
.armyCountPosition {
height: 0;
top: -20px;
left: -16px;
position: relative;
}
.armyCount {
font-weight: bolder;
}
</style>
@code {
private int lastInterval;
readonly Dictionary<string, int> armyCount = new();
@@ -36,11 +68,13 @@
protected override void OnInitialized()
{
buildOrder.Subscribe(OnBuildOrderChanged);
timingService.Subscribe(StateHasChanged);
}
void IDisposable.Dispose()
{
buildOrder.Unsubscribe(OnBuildOrderChanged);
timingService.Unsubscribe(StateHasChanged);
}
protected override bool ShouldRender()
@@ -1,5 +1,6 @@
@inject IEconomyService economyService
@inject IBuildOrderService buildOrderService
@inject ITimingService timingService
@inject IJSRuntime jsRuntime;
@implements IDisposable
@@ -81,8 +82,9 @@ else
protected override void OnInitialized()
{
buildOrderService.Subscribe(OnBuilderOrderChanged);
timingService.Subscribe(OnBuilderOrderChanged);
ageTimer = new Timer(3000);
ageTimer = new Timer(1000);
ageTimer.Elapsed += OnAge!;
ageTimer.Enabled = true;
@@ -114,6 +116,7 @@ else
void IDisposable.Dispose()
{
buildOrderService.Unsubscribe(OnBuilderOrderChanged);
timingService.Unsubscribe(OnBuilderOrderChanged);
}
@@ -13,6 +13,17 @@
<FormLabelComponent>Building Input Delay</FormLabelComponent>
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent>
</FormNumberComponent>
<FormNumberComponent Max="600"
Min="0"
Value="30"
OnChange="@OnWaitTimeChanged">
<FormLabelComponent>Wait Time</FormLabelComponent>
<FormInfoComponent>Not implemented</FormInfoComponent>
</FormNumberComponent>
<ButtonComponent OnClick="OnWaitClicked">Add Wait</ButtonComponent>
</FormLayoutComponent>
@@ -22,6 +33,16 @@
{
buildOrderService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!);
}
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
{
toastService.AddToast(new ToastModel(){Title = "Not Implemented", SeverityType = SeverityType.Warning, Message = "The ability to wait for X seconds in a build order hasn't been implemented yet."});
}
public void OnWaitClicked()
{
toastService.AddToast(new ToastModel(){Title = "Not Implemented", SeverityType = SeverityType.Warning, Message = "The ability to wait for X seconds in a build order hasn't been implemented yet."});
}
protected override bool ShouldRender()
{
@@ -8,33 +8,50 @@
<FormLayoutComponent>
<FormNumberComponent Max="2048"
Min="0"
Value="@timingService.GetTiming()"
OnChange="@OnTimingChanged">
<FormLabelComponent>Timing interval</FormLabelComponent>
<FormInfoComponent>Altering the time interval is currently disabled.</FormInfoComponent>
Value="@timingService.GetAttackTime()"
OnChange="@OnAttackTimeChanged">
<FormLabelComponent>Attack Time</FormLabelComponent>
<FormInfoComponent><i>&emsp; T @Interval.ToTime(timingService.GetAttackTime())</i></FormInfoComponent>
</FormNumberComponent>
<FormTextComponent Label="Name" Placeholder="Fast Thrones..." Value="@buildOrderService.GetName()" OnChange="OnNameChanged"/>
<FormNumberComponent Max="2048"
Min="0"
Value="@timingService.GetTravelTime()"
OnChange="@OnTravelTimeChanged">
<FormLabelComponent>Travel Time</FormLabelComponent>
<FormInfoComponent><i>&emsp; T @Interval.ToTime(timingService.GetTravelTime())</i></FormInfoComponent>
</FormNumberComponent>
<FormTextAreaComponent Label="Notes"
Value="@buildOrderService.GetNotes()"
OnChange="@OnNotesChanged">
</FormTextAreaComponent>
<FormTextComponent Label="Color" Placeholder="red..." Value="@buildOrderService.GetColor()" OnChange="OnColorChanged"/>
</FormLayoutComponent>
@code {
void OnTimingChanged(ChangeEventArgs changeEventArgs)
void OnAttackTimeChanged(ChangeEventArgs changeEventArgs)
{
timingService.SetTiming(int.Parse(changeEventArgs.Value!.ToString()!));
timingService.SetAttackTime(int.Parse(changeEventArgs.Value!.ToString()!));
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
toastService.AddToast(new ToastModel()
toastService.AddToast(new ToastModel
{
Title = "Timing Interval",
Message = "Timing interval has changed.",
Title = "Attack Time",
Message = "Attack Time has changed.",
SeverityType = SeverityType.Success
});
StateHasChanged();
}
void OnTravelTimeChanged(ChangeEventArgs changeEventArgs)
{
timingService.SetTravelTime(int.Parse(changeEventArgs.Value!.ToString()!));
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
toastService.AddToast(new ToastModel
{
Title = "Travel Time",
Message = "Travel Time has changed.",
SeverityType = SeverityType.Success
});
StateHasChanged();
}
void OnNameChanged(ChangeEventArgs changeEventArgs)