feature(BuildCalc) Adding WIP wait button, and better styling
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
min="@Min"
|
||||
max="@Max"
|
||||
value="@Value"
|
||||
@onchange="OnChange"/>
|
||||
@onchange="OnInputChanged"/>
|
||||
</div>
|
||||
@if (FormInfoComponent != null)
|
||||
{
|
||||
@@ -46,16 +46,39 @@
|
||||
[Parameter]
|
||||
public EventCallback<ChangeEventArgs> OnChange { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool? ReadOnly { get; set; }
|
||||
void OnInputChanged(ChangeEventArgs changeEventArgs)
|
||||
{
|
||||
int valueWas = Value;
|
||||
int newValue = int.Parse(changeEventArgs.Value!.ToString()!);
|
||||
|
||||
if (newValue > Max)
|
||||
{
|
||||
newValue = Max;
|
||||
}
|
||||
|
||||
if (newValue < Min)
|
||||
{
|
||||
newValue = Min;
|
||||
}
|
||||
|
||||
if (valueWas != newValue)
|
||||
{
|
||||
Value = newValue;
|
||||
changeEventArgs.Value = newValue;
|
||||
OnChange.InvokeAsync(changeEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public int? Value { get; set; }
|
||||
public bool ReadOnly { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public int? Min { get; set; }
|
||||
public int Value { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public int? Max { get; set; }
|
||||
public int Min { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public int Max { get; set; } = 2048;
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -53,12 +53,7 @@ Affects entities you can build.</value>
|
||||
<value>Some raw JSON data to represent your build order.</value>
|
||||
</data>
|
||||
<data name="Tooltip Timing Info" xml:space="preserve">
|
||||
<value>Enter build details.
|
||||
|
||||
<b>Timing Interval:</b> set the max interval length for the build. <i>Ex. 240 (seconds) is 4 minutes, a possible timing for Thrum build order.</i>
|
||||
<b>Name:</b> the name of the build for saving purposes. <i>Ex. 'Safe Thrum Opener'</i>
|
||||
<b>Notes:</b> additional notes of the build for saving purposes. <i>Ex. 'Thrums are for harassing and defending against a ground Q'Rath army.'</i>
|
||||
<b>Color:</b> value to color charts when comparing builds. Not currently implemented.</value>
|
||||
<value>Enter build details.</value>
|
||||
</data>
|
||||
<data name="Tooltip Hotkey Info" xml:space="preserve">
|
||||
<value>Click on the desired entity to build it. <i>You cannot build entities you cannot afford, construct an ether extractor before spending ether.</i>
|
||||
|
||||
@@ -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>  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>  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)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -155,8 +155,10 @@ public interface IBuildComparisonService
|
||||
|
||||
public interface ITimingService
|
||||
{
|
||||
public int GetTiming();
|
||||
public void SetTiming(int timing);
|
||||
public int GetAttackTime();
|
||||
public void SetAttackTime(int timing);
|
||||
public int GetTravelTime();
|
||||
public void SetTravelTime(int timing);
|
||||
public void Subscribe(Action? action);
|
||||
public void Unsubscribe(Action? action);
|
||||
}
|
||||
|
||||
@@ -326,8 +326,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
atInterval = interval;
|
||||
|
||||
if (entity.EntityType != EntityType.Army) atInterval += BuildingInputDelay;
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace Services.Immortal;
|
||||
|
||||
public class EconomyService : IEconomyService
|
||||
{
|
||||
private List<EconomyModel> _economyOverTime = null!;
|
||||
private List<EconomyModel> economyOverTime = null!;
|
||||
|
||||
|
||||
public List<EconomyModel> GetOverTime()
|
||||
{
|
||||
return _economyOverTime;
|
||||
return economyOverTime;
|
||||
}
|
||||
|
||||
public void Subscribe(Action action)
|
||||
@@ -29,33 +29,33 @@ public class EconomyService : IEconomyService
|
||||
public void Calculate(IBuildOrderService buildOrder, ITimingService timing, int fromInterval)
|
||||
{
|
||||
//TODO Break all this up
|
||||
if (_economyOverTime == null)
|
||||
if (economyOverTime == null)
|
||||
{
|
||||
_economyOverTime = new List<EconomyModel>();
|
||||
for (var interval = 0; interval < timing.GetTiming(); interval++)
|
||||
_economyOverTime.Add(new EconomyModel { Interval = interval });
|
||||
economyOverTime = new List<EconomyModel>();
|
||||
for (var interval = 0; interval < timing.GetAttackTime(); interval++)
|
||||
economyOverTime.Add(new EconomyModel { Interval = interval });
|
||||
}
|
||||
|
||||
|
||||
if (_economyOverTime.Count > timing.GetTiming())
|
||||
_economyOverTime.RemoveRange(timing.GetTiming(), _economyOverTime.Count - timing.GetTiming());
|
||||
if (economyOverTime.Count > timing.GetAttackTime())
|
||||
economyOverTime.RemoveRange(timing.GetAttackTime(), economyOverTime.Count - timing.GetAttackTime());
|
||||
|
||||
while (_economyOverTime.Count < timing.GetTiming())
|
||||
_economyOverTime.Add(new EconomyModel { Interval = _economyOverTime.Count - 1 });
|
||||
while (economyOverTime.Count < timing.GetAttackTime())
|
||||
economyOverTime.Add(new EconomyModel { Interval = economyOverTime.Count - 1 });
|
||||
|
||||
for (var interval = fromInterval; interval < timing.GetTiming(); interval++)
|
||||
for (var interval = fromInterval; interval < timing.GetAttackTime(); interval++)
|
||||
{
|
||||
var economyAtSecond = _economyOverTime[interval];
|
||||
var economyAtSecond = economyOverTime[interval];
|
||||
if (interval > 0)
|
||||
{
|
||||
economyAtSecond.Alloy = _economyOverTime[interval - 1].Alloy;
|
||||
economyAtSecond.Ether = _economyOverTime[interval - 1].Ether;
|
||||
economyAtSecond.Pyre = _economyOverTime[interval - 1].Pyre;
|
||||
economyAtSecond.WorkerCount = _economyOverTime[interval - 1].WorkerCount;
|
||||
economyAtSecond.BusyWorkerCount = _economyOverTime[interval - 1].BusyWorkerCount;
|
||||
economyAtSecond.CreatingWorkerCount = _economyOverTime[interval - 1].CreatingWorkerCount;
|
||||
economyAtSecond.Harvesters = _economyOverTime[interval - 1].Harvesters.ToList();
|
||||
economyAtSecond.CreatingWorkerDelays = _economyOverTime[interval - 1].CreatingWorkerDelays.ToList();
|
||||
economyAtSecond.Alloy = economyOverTime[interval - 1].Alloy;
|
||||
economyAtSecond.Ether = economyOverTime[interval - 1].Ether;
|
||||
economyAtSecond.Pyre = economyOverTime[interval - 1].Pyre;
|
||||
economyAtSecond.WorkerCount = economyOverTime[interval - 1].WorkerCount;
|
||||
economyAtSecond.BusyWorkerCount = economyOverTime[interval - 1].BusyWorkerCount;
|
||||
economyAtSecond.CreatingWorkerCount = economyOverTime[interval - 1].CreatingWorkerCount;
|
||||
economyAtSecond.Harvesters = economyOverTime[interval - 1].Harvesters.ToList();
|
||||
economyAtSecond.CreatingWorkerDelays = economyOverTime[interval - 1].CreatingWorkerDelays.ToList();
|
||||
}
|
||||
|
||||
economyAtSecond.Interval = interval;
|
||||
@@ -159,12 +159,12 @@ public class EconomyService : IEconomyService
|
||||
|
||||
public EconomyModel GetEconomy(int atInterval)
|
||||
{
|
||||
if (atInterval >= _economyOverTime.Count)
|
||||
if (atInterval >= economyOverTime.Count)
|
||||
{
|
||||
return _economyOverTime.Last();
|
||||
return economyOverTime.Last();
|
||||
}
|
||||
|
||||
return _economyOverTime[atInterval];
|
||||
return economyOverTime[atInterval];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
public class TimingService : ITimingService
|
||||
{
|
||||
private int _timing = 1500;
|
||||
private int attackTime = 1500;
|
||||
private int travelTime = 30;
|
||||
|
||||
public void Subscribe(Action? action)
|
||||
{
|
||||
@@ -14,16 +15,30 @@ public class TimingService : ITimingService
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public int GetTiming()
|
||||
public int GetAttackTime()
|
||||
{
|
||||
return _timing;
|
||||
return attackTime;
|
||||
}
|
||||
|
||||
public void SetTiming(int timing)
|
||||
public void SetAttackTime(int timing)
|
||||
{
|
||||
if (_timing != timing)
|
||||
if (attackTime != timing)
|
||||
{
|
||||
_timing = timing;
|
||||
attackTime = timing;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int GetTravelTime()
|
||||
{
|
||||
return travelTime;
|
||||
}
|
||||
|
||||
public void SetTravelTime(int timing)
|
||||
{
|
||||
if (travelTime != timing)
|
||||
{
|
||||
travelTime = timing;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user