feat(Storage) Storage feature done
This commit is contained in:
@@ -84,7 +84,7 @@ else
|
|||||||
toastService.RemoveToast(Toast!);
|
toastService.RemoveToast(Toast!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
toastService.Unsubscribe(OnUpdate);
|
toastService.Unsubscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
entityDialogService.Subscribe(OnUpdate);
|
entityDialogService.Subscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
entityDialogService.Unsubscribe(OnUpdate);
|
entityDialogService.Unsubscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
searchService.Unsubscribe(OnSearchChanged);
|
searchService.Unsubscribe(OnSearchChanged);
|
||||||
timer.Elapsed -= FocusTimer;
|
timer.Elapsed -= FocusTimer;
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
@layout PageLayout
|
@layout PageLayout
|
||||||
|
|
||||||
<DevOnlyComponent>
|
<DevOnlyComponent>
|
||||||
<PermissionsPage/>
|
<StoragePage/>
|
||||||
</DevOnlyComponent>
|
</DevOnlyComponent>
|
||||||
|
|
||||||
<HomePage/>
|
<HomePage/>
|
||||||
@@ -257,8 +257,8 @@
|
|||||||
|
|
||||||
var hotkeyGroup = keyService.GetHotkeyGroup();
|
var hotkeyGroup = keyService.GetHotkeyGroup();
|
||||||
var isHoldSpace = keyService.IsHoldingSpace();
|
var isHoldSpace = keyService.IsHoldingSpace();
|
||||||
var faction = filterService.GetFactionType();
|
var faction = filterService.GetFaction();
|
||||||
var immortal = filterService.GetImmortalType();
|
var immortal = filterService.GetImmortal();
|
||||||
|
|
||||||
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@
|
|||||||
var hotkey = KeyService.GetHotkey();
|
var hotkey = KeyService.GetHotkey();
|
||||||
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
||||||
var isHoldSpace = KeyService.IsHoldingSpace();
|
var isHoldSpace = KeyService.IsHoldingSpace();
|
||||||
var faction = FilterService.GetFactionType();
|
var faction = FilterService.GetFaction();
|
||||||
var immortal = FilterService.GetImmortalType();
|
var immortal = FilterService.GetImmortal();
|
||||||
|
|
||||||
var foundEntity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
var foundEntity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,33 @@
|
|||||||
@inject IJSRuntime jsRuntime;
|
@inject IJSRuntime JsRuntime;
|
||||||
@inject IImmortalSelectionService filterService
|
@inject IImmortalSelectionService FilterService
|
||||||
|
|
||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormSelectComponent OnChange="@OnFactionChanged">
|
<FormSelectComponent OnChange="@OnFactionChanged">
|
||||||
<FormLabelComponent>Faction</FormLabelComponent>
|
<FormLabelComponent>Faction</FormLabelComponent>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<option value="@FactionType.Aru">Aru</option>
|
<option value="@DataType.FACTION_Aru"
|
||||||
<option value="@FactionType.QRath" selected>Q'Rath</option>
|
selected="@(FilterService.GetFaction().Equals(DataType.FACTION_Aru))">Aru</option>
|
||||||
|
<option value="@DataType.FACTION_QRath"
|
||||||
|
selected="@(FilterService.GetFaction().Equals(DataType.FACTION_QRath))">Q'Rath</option>
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
</FormSelectComponent>
|
</FormSelectComponent>
|
||||||
|
|
||||||
<FormSelectComponent OnChange="@OnImmortalChanged">
|
<FormSelectComponent OnChange="@OnImmortalChanged">
|
||||||
<FormLabelComponent>Immortal</FormLabelComponent>
|
<FormLabelComponent>Immortal</FormLabelComponent>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
@if (filterService.GetFactionType() == FactionType.QRath)
|
@if (FilterService.GetFaction() == DataType.FACTION_QRath)
|
||||||
{
|
{
|
||||||
<option value="@DataType.IMMORTAL_Orzum" selected>Orzum</option>
|
<option value="@DataType.IMMORTAL_Orzum"
|
||||||
<option value="@DataType.IMMORTAL_Ajari">Ajari</option>
|
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Orzum))">Orzum</option>
|
||||||
|
<option value="@DataType.IMMORTAL_Ajari"
|
||||||
|
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Ajari))">Ajari</option>
|
||||||
}
|
}
|
||||||
@if (filterService.GetFactionType() == FactionType.Aru)
|
@if (FilterService.GetFaction() == DataType.FACTION_Aru)
|
||||||
{
|
{
|
||||||
<option value="@DataType.IMMORTAL_Mala" selected>Mala</option>
|
<option value="@DataType.IMMORTAL_Mala"
|
||||||
<option value="@DataType.IMMORTAL_Xol">Xol</option>
|
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Mala))">Mala</option>
|
||||||
|
<option value="@DataType.IMMORTAL_Xol"
|
||||||
|
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Xol))">Xol</option>
|
||||||
}
|
}
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
</FormSelectComponent>
|
</FormSelectComponent>
|
||||||
@@ -31,18 +37,18 @@
|
|||||||
|
|
||||||
void OnFactionChanged(ChangeEventArgs e)
|
void OnFactionChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
filterService.SelectFactionType(e.Value!.ToString()!);
|
FilterService.SelectFaction(e.Value!.ToString()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnImmortalChanged(ChangeEventArgs e)
|
void OnImmortalChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
filterService.SelectImmortalType(e.Value!.ToString()!);
|
FilterService.SelectImmortal(e.Value!.ToString()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ShouldRender()
|
protected override bool ShouldRender()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
jsRuntime.InvokeVoidAsync("console.time", "FilterComponent");
|
JsRuntime.InvokeVoidAsync("console.time", "FilterComponent");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -51,7 +57,7 @@
|
|||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
jsRuntime.InvokeVoidAsync("console.timeEnd", "FilterComponent");
|
JsRuntime.InvokeVoidAsync("console.timeEnd", "FilterComponent");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
// Move to Filter Service
|
// Move to Filter Service
|
||||||
bool InvalidFaction(EntityModel entity)
|
bool InvalidFaction(EntityModel entity)
|
||||||
{
|
{
|
||||||
if (entity.Faction() != null && entity.Faction()?.Faction != filterService.GetFactionType() && filterService.GetFactionType() != FactionType.Any)
|
if (entity.Faction() != null && entity.Faction()?.Faction != filterService.GetFaction() && filterService.GetFaction() != DataType.Any)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -176,8 +176,8 @@
|
|||||||
bool InvalidVanguard(EntityModel entity)
|
bool InvalidVanguard(EntityModel entity)
|
||||||
{
|
{
|
||||||
if (entity.VanguardAdded() != null
|
if (entity.VanguardAdded() != null
|
||||||
&& entity.VanguardAdded()?.ImmortalId != filterService.GetImmortalType()
|
&& entity.VanguardAdded()?.ImmortalId != filterService.GetImmortal()
|
||||||
&& filterService.GetImmortalType() != ImmortalType.Any)
|
&& filterService.GetImmortal() != DataType.Any)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
{
|
{
|
||||||
foreach (var replaced in entity.Replaceds())
|
foreach (var replaced in entity.Replaceds())
|
||||||
{
|
{
|
||||||
if (filterService.GetImmortalType() == replaced.ImmortalId)
|
if (filterService.GetImmortal() == replaced.ImmortalId)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -319,8 +319,8 @@
|
|||||||
|
|
||||||
var hotkeyGroup = keyService.GetHotkeyGroup();
|
var hotkeyGroup = keyService.GetHotkeyGroup();
|
||||||
var isHoldSpace = keyService.IsHoldingSpace();
|
var isHoldSpace = keyService.IsHoldingSpace();
|
||||||
var faction = filterService.GetFactionType();
|
var faction = filterService.GetFaction();
|
||||||
var immortal = filterService.GetImmortalType();
|
var immortal = filterService.GetImmortal();
|
||||||
|
|
||||||
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
@inject IJSRuntime jsRuntime;
|
@inject IJSRuntime JsRuntime;
|
||||||
|
|
||||||
@inject IBuildOrderService buildOrderService
|
@inject IBuildOrderService BuildOrderService
|
||||||
@inject IEconomyService economyService
|
@inject IEconomyService EconomyService
|
||||||
@inject IToastService toastService
|
@inject IToastService ToastService
|
||||||
@inject ITimingService timingService
|
@inject ITimingService TimingService
|
||||||
|
|
||||||
|
@using System.Data
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormNumberComponent Max="600"
|
<FormNumberComponent Max="600"
|
||||||
Min="0"
|
Min="0"
|
||||||
Value="@buildOrderService.BuildingInputDelay"
|
Value="BuildDelay"
|
||||||
OnChange="@OnBuildingInputDelayChanged">
|
OnChange="@OnBuildingInputDelayChanged">
|
||||||
<FormLabelComponent>Building Input Delay</FormLabelComponent>
|
<FormLabelComponent>Building Input Delay</FormLabelComponent>
|
||||||
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent>
|
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent>
|
||||||
@@ -17,7 +20,7 @@
|
|||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormNumberComponent Max="600"
|
<FormNumberComponent Max="600"
|
||||||
Min="1"
|
Min="1"
|
||||||
Value="@WaitTime"
|
Value="WaitTime"
|
||||||
OnChange="@OnWaitTimeChanged">
|
OnChange="@OnWaitTimeChanged">
|
||||||
<FormLabelComponent>Wait Time</FormLabelComponent>
|
<FormLabelComponent>Wait Time</FormLabelComponent>
|
||||||
</FormNumberComponent>
|
</FormNumberComponent>
|
||||||
@@ -26,7 +29,7 @@
|
|||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormNumberComponent Max="2048"
|
<FormNumberComponent Max="2048"
|
||||||
Min="1"
|
Min="1"
|
||||||
Value="@WaitTo"
|
Value="WaitTo"
|
||||||
OnChange="@OnWaitToChanged">
|
OnChange="@OnWaitToChanged">
|
||||||
<FormLabelComponent>Wait To</FormLabelComponent>
|
<FormLabelComponent>Wait To</FormLabelComponent>
|
||||||
</FormNumberComponent>
|
</FormNumberComponent>
|
||||||
@@ -43,45 +46,69 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private int BuildDelay { get; set; } = 2;
|
||||||
private int WaitTime { get; set; } = 30;
|
private int WaitTime { get; set; } = 30;
|
||||||
private int WaitTo { 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)
|
void OnBuildingInputDelayChanged(ChangeEventArgs changeEventArgs)
|
||||||
{
|
{
|
||||||
buildOrderService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!);
|
TimingService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
|
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
|
||||||
{
|
{
|
||||||
|
TimingService.WaitTime = (int)changeEventArgs.Value!;
|
||||||
WaitTime = (int)changeEventArgs.Value!;
|
WaitTime = (int)changeEventArgs.Value!;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnWaitToChanged(ChangeEventArgs changeEventArgs)
|
void OnWaitToChanged(ChangeEventArgs changeEventArgs)
|
||||||
{
|
{
|
||||||
|
TimingService.WaitTo = (int)changeEventArgs.Value!;
|
||||||
WaitTo = (int)changeEventArgs.Value!;
|
WaitTo = (int)changeEventArgs.Value!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWaitClicked()
|
private void OnWaitClicked()
|
||||||
{
|
{
|
||||||
if (buildOrderService.AddWait(WaitTime))
|
if (BuildOrderService.AddWait(WaitTime))
|
||||||
{
|
{
|
||||||
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWaitToClicked()
|
private void OnWaitToClicked()
|
||||||
{
|
{
|
||||||
if (buildOrderService.AddWaitTo(WaitTo))
|
if (BuildOrderService.AddWaitTo(WaitTo))
|
||||||
{
|
{
|
||||||
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ShouldRender()
|
protected override bool ShouldRender()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
jsRuntime.InvokeVoidAsync("console.time", "TimingComponent");
|
JsRuntime.InvokeVoidAsync("console.time", "TimingComponent");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -90,9 +117,8 @@
|
|||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
jsRuntime.InvokeVoidAsync("console.timeEnd", "TimingComponent");
|
JsRuntime.InvokeVoidAsync("console.timeEnd", "TimingComponent");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
@inject IEconomyService economyService
|
@inject IEconomyService economyService
|
||||||
@inject IToastService toastService
|
@inject IToastService toastService
|
||||||
@inject ITimingService timingService
|
@inject ITimingService timingService
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
<FormLayoutComponent>
|
<FormLayoutComponent>
|
||||||
<FormNumberComponent Max="2048"
|
<FormNumberComponent Max="2048"
|
||||||
@@ -30,6 +31,16 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
timingService.Subscribe(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
|
{
|
||||||
|
timingService.Unsubscribe(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
void OnAttackTimeChanged(ChangeEventArgs changeEventArgs)
|
void OnAttackTimeChanged(ChangeEventArgs changeEventArgs)
|
||||||
{
|
{
|
||||||
timingService.SetAttackTime(int.Parse(changeEventArgs.Value!.ToString()!));
|
timingService.SetAttackTime(int.Parse(changeEventArgs.Value!.ToString()!));
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ grid-template-areas: 'loader sand compare compare' ;">
|
|||||||
var hotkey = KeyService.GetHotkey();
|
var hotkey = KeyService.GetHotkey();
|
||||||
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
||||||
var isHoldSpace = KeyService.IsHoldingSpace();
|
var isHoldSpace = KeyService.IsHoldingSpace();
|
||||||
var faction = FilterService.GetFactionType();
|
var faction = FilterService.GetFaction();
|
||||||
var immortal = FilterService.GetImmortalType();
|
var immortal = FilterService.GetImmortal();
|
||||||
|
|
||||||
if (hotkey == "`")
|
if (hotkey == "`")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,8 +127,8 @@
|
|||||||
List<EntityModel> searches = default!;
|
List<EntityModel> searches = default!;
|
||||||
|
|
||||||
|
|
||||||
string selectedFactionType = FactionType.Any;
|
string selectedFactionType = DataType.Any;
|
||||||
string selectedImmortalType = ImmortalType.Any;
|
string selectedImmortalType = DataType.Any;
|
||||||
string selectedEntityType = EntityType.Army;
|
string selectedEntityType = EntityType.Army;
|
||||||
string searchText = "";
|
string searchText = "";
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
{
|
{
|
||||||
selectedFactionType = EntityFilterService.GetFactionType();
|
selectedFactionType = EntityFilterService.GetFactionType();
|
||||||
|
|
||||||
if (selectedFactionType == FactionType.Any)
|
if (selectedFactionType == DataType.Any)
|
||||||
{
|
{
|
||||||
factions = defaults.ToList();
|
factions = defaults.ToList();
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
{
|
{
|
||||||
selectedImmortalType = EntityFilterService.GetImmortalType();
|
selectedImmortalType = EntityFilterService.GetImmortalType();
|
||||||
|
|
||||||
if (selectedImmortalType == ImmortalType.Any)
|
if (selectedImmortalType == DataType.Any)
|
||||||
{
|
{
|
||||||
immortals = factions.ToList();
|
immortals = factions.ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,16 +51,16 @@
|
|||||||
<FormSelectComponent OnChange="@OnFactionChanged">
|
<FormSelectComponent OnChange="@OnFactionChanged">
|
||||||
<FormLabelComponent>Faction</FormLabelComponent>
|
<FormLabelComponent>Faction</FormLabelComponent>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<option value="@FactionType.Any" selected>Any</option>
|
<option value="@DataType.Any" selected>Any</option>
|
||||||
<option value="@FactionType.Aru">Aru</option>
|
<option value="@DataType.FACTION_Aru">Aru</option>
|
||||||
<option value="@FactionType.QRath">Q'Rath</option>
|
<option value="@DataType.FACTION_QRath">Q'Rath</option>
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
</FormSelectComponent>
|
</FormSelectComponent>
|
||||||
|
|
||||||
<FormSelectComponent OnChange="@OnImmortalChanged">
|
<FormSelectComponent OnChange="@OnImmortalChanged">
|
||||||
<FormLabelComponent>Immortal</FormLabelComponent>
|
<FormLabelComponent>Immortal</FormLabelComponent>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<option value="@ImmortalType.Any" selected>Any</option>
|
<option value="@DataType.Any" selected>Any</option>
|
||||||
<option value="@DataType.IMMORTAL_Mala">Mala</option>
|
<option value="@DataType.IMMORTAL_Mala">Mala</option>
|
||||||
<option value="@DataType.IMMORTAL_Xol">Xol</option>
|
<option value="@DataType.IMMORTAL_Xol">Xol</option>
|
||||||
<option value="@DataType.IMMORTAL_Orzum">Orzum</option>
|
<option value="@DataType.IMMORTAL_Orzum">Orzum</option>
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ else
|
|||||||
documentationService.Load();
|
documentationService.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
documentationService.Unsubscribe(StateHasChanged);
|
documentationService.Unsubscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ else
|
|||||||
documentationService.Load();
|
documentationService.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
documentationService.Unsubscribe(StateHasChanged);
|
documentationService.Unsubscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
noteService.Unsubscribe(StateHasChanged);
|
noteService.Unsubscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ else
|
|||||||
noteService.Load();
|
noteService.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
noteService.Unsubscribe(StateHasChanged);
|
noteService.Unsubscribe(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
PermissionService.Unsubscribe(Update);
|
PermissionService.Unsubscribe(Update);
|
||||||
}
|
}
|
||||||
|
|||||||
+151
-8
@@ -1,13 +1,11 @@
|
|||||||
@page "/storage"
|
@page "/storage"
|
||||||
|
|
||||||
@inject IStorageService StorageService
|
@inject IStorageService StorageService
|
||||||
|
|
||||||
@using Services.Website
|
@using Services.Website
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
@layout PageLayout
|
@layout PageLayout
|
||||||
|
|
||||||
<LayoutMediumContentComponent>
|
<LayoutMediumContentComponent>
|
||||||
|
|
||||||
@if (!_enabledPermissions)
|
@if (!_enabledPermissions)
|
||||||
{
|
{
|
||||||
<AlertComponent Type="@SeverityType.Error">
|
<AlertComponent Type="@SeverityType.Error">
|
||||||
@@ -25,6 +23,90 @@
|
|||||||
OnChange="EntityViewChanged"/>
|
OnChange="EntityViewChanged"/>
|
||||||
</FormLayoutComponent>
|
</FormLayoutComponent>
|
||||||
</PaperComponent>
|
</PaperComponent>
|
||||||
|
|
||||||
|
<PaperComponent>
|
||||||
|
<FormLayoutComponent>
|
||||||
|
<FormNumberComponent Max="2048"
|
||||||
|
Min="0"
|
||||||
|
Value="@(_attackTime == null ? 0 : (int)_attackTime)"
|
||||||
|
OnChange="AttackTimeChanged">
|
||||||
|
<FormLabelComponent>Attack Time</FormLabelComponent>
|
||||||
|
<FormInfoComponent>
|
||||||
|
@if (_attackTime != null)
|
||||||
|
{
|
||||||
|
<i>  T @Interval.ToTime((int)_attackTime)</i>
|
||||||
|
}
|
||||||
|
</FormInfoComponent>
|
||||||
|
</FormNumberComponent>
|
||||||
|
|
||||||
|
<FormNumberComponent Max="2048"
|
||||||
|
Min="0"
|
||||||
|
Value="@(_travelTime == null ? 0 : (int)_travelTime)"
|
||||||
|
OnChange="TravelTimeChanged">
|
||||||
|
<FormLabelComponent>Travel Time</FormLabelComponent>
|
||||||
|
<FormInfoComponent>
|
||||||
|
@if (_travelTime != null)
|
||||||
|
{
|
||||||
|
<i>  T @Interval.ToTime((int)_travelTime)</i>
|
||||||
|
}
|
||||||
|
</FormInfoComponent>
|
||||||
|
</FormNumberComponent>
|
||||||
|
|
||||||
|
<FormSelectComponent OnChange="@OnFactionChanged">
|
||||||
|
<FormLabelComponent>Faction</FormLabelComponent>
|
||||||
|
<ChildContent>
|
||||||
|
<option value="@DataType.FACTION_Aru"
|
||||||
|
selected="@(Faction.Equals(DataType.FACTION_Aru))">Aru</option>
|
||||||
|
<option value="@DataType.FACTION_QRath"
|
||||||
|
selected="@(Faction.Equals(DataType.FACTION_QRath))">Q'Rath</option>
|
||||||
|
</ChildContent>
|
||||||
|
</FormSelectComponent>
|
||||||
|
|
||||||
|
<FormSelectComponent OnChange="@OnImmortalChanged">
|
||||||
|
<FormLabelComponent>Immortal</FormLabelComponent>
|
||||||
|
<ChildContent>
|
||||||
|
@if (Faction == DataType.FACTION_QRath)
|
||||||
|
{
|
||||||
|
<option value="@DataType.IMMORTAL_Orzum"
|
||||||
|
selected="@(Immortal.Equals(DataType.IMMORTAL_Orzum))">Orzum</option>
|
||||||
|
<option value="@DataType.IMMORTAL_Ajari"
|
||||||
|
selected="@(Immortal.Equals(DataType.IMMORTAL_Ajari))">Ajari</option>
|
||||||
|
}
|
||||||
|
@if (Faction == DataType.FACTION_Aru)
|
||||||
|
{
|
||||||
|
<option value="@DataType.IMMORTAL_Mala"
|
||||||
|
selected="@(Immortal.Equals(DataType.IMMORTAL_Mala))">Mala</option>
|
||||||
|
<option value="@DataType.IMMORTAL_Xol"
|
||||||
|
selected="@(Immortal.Equals(DataType.IMMORTAL_Xol))">Xol</option>
|
||||||
|
}
|
||||||
|
</ChildContent>
|
||||||
|
</FormSelectComponent>
|
||||||
|
|
||||||
|
|
||||||
|
<FormNumberComponent Max="600"
|
||||||
|
Min="0"
|
||||||
|
Value="@(_buildingInputDelay == null ? 0 : (int)_buildingInputDelay)"
|
||||||
|
OnChange="OnBuildingInputDelayChanged">
|
||||||
|
<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="1"
|
||||||
|
Value="@(_waitTime == null ? 0 : (int)_waitTime)"
|
||||||
|
OnChange="@OnWaitTimeChanged">
|
||||||
|
<FormLabelComponent>Wait Time</FormLabelComponent>
|
||||||
|
</FormNumberComponent>
|
||||||
|
</FormLayoutComponent>
|
||||||
|
<FormLayoutComponent>
|
||||||
|
<FormNumberComponent Max="2048"
|
||||||
|
Min="1"
|
||||||
|
Value="@(_waitTo == null ? 0 : (int)_waitTo)"
|
||||||
|
OnChange="@OnWaitToChanged">
|
||||||
|
<FormLabelComponent>Wait To</FormLabelComponent>
|
||||||
|
</FormNumberComponent>
|
||||||
|
|
||||||
|
</FormLayoutComponent>
|
||||||
|
</PaperComponent>
|
||||||
}
|
}
|
||||||
|
|
||||||
<ContentDividerComponent/>
|
<ContentDividerComponent/>
|
||||||
@@ -41,20 +123,46 @@
|
|||||||
{
|
{
|
||||||
_enabledPermissions = StorageService.GetValue<bool>(StorageKeys.EnabledStorage);
|
_enabledPermissions = StorageService.GetValue<bool>(StorageKeys.EnabledStorage);
|
||||||
|
|
||||||
Update();
|
RefreshDefaults();
|
||||||
|
|
||||||
StorageService.Subscribe(Update);
|
StorageService.Subscribe(RefreshDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
public void Dispose()
|
|
||||||
{
|
{
|
||||||
StorageService.Unsubscribe(Update);
|
StorageService.Unsubscribe(RefreshDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
private int? _attackTime = null;
|
||||||
|
private int? _travelTime = null;
|
||||||
|
|
||||||
|
private string? _faction = null;
|
||||||
|
private string? _immortal = null;
|
||||||
|
|
||||||
|
private string? Faction => _faction == null ? DataType.FACTION_QRath : _faction;
|
||||||
|
private string? Immortal => _immortal == null ? DataType.IMMORTAL_Orzum : _immortal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int? _buildingInputDelay;
|
||||||
|
private int? _waitTime;
|
||||||
|
private int? _waitTo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void RefreshDefaults()
|
||||||
{
|
{
|
||||||
_isEntityPlainView = StorageService.GetValue<bool>(StorageKeys.IsPlainView);
|
_isEntityPlainView = StorageService.GetValue<bool>(StorageKeys.IsPlainView);
|
||||||
|
_attackTime = StorageService.GetValue<int?>(StorageKeys.AttackTime);
|
||||||
|
_travelTime = StorageService.GetValue<int?>(StorageKeys.TravelTime);
|
||||||
|
|
||||||
|
|
||||||
|
_faction = StorageService.GetValue<string?>(StorageKeys.SelectedFaction);
|
||||||
|
_immortal = StorageService.GetValue<string?>(StorageKeys.SelectedImmortal);
|
||||||
|
|
||||||
|
_buildingInputDelay = StorageService.GetValue<int?>(StorageKeys.BuildInputDelay);
|
||||||
|
_waitTime = StorageService.GetValue<int?>(StorageKeys.WaitTime);
|
||||||
|
_waitTo = StorageService.GetValue<int?>(StorageKeys.WaitTo);
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
@@ -65,4 +173,39 @@
|
|||||||
{
|
{
|
||||||
StorageService.SetValue(StorageKeys.IsPlainView, obj.Value);
|
StorageService.SetValue(StorageKeys.IsPlainView, obj.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AttackTimeChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.AttackTime, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TravelTimeChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.TravelTime, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFactionChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.SelectedFaction, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnImmortalChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.SelectedImmortal, obj.Value);
|
||||||
|
}
|
||||||
|
private void OnBuildingInputDelayChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.BuildInputDelay, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWaitTimeChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.WaitTime, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWaitToChanged(ChangeEventArgs obj)
|
||||||
|
{
|
||||||
|
StorageService.SetValue(StorageKeys.WaitTo, obj.Value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
entityDialogService.Subscribe(OnUpdate);
|
entityDialogService.Subscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
entityDialogService.Unsubscribe(OnUpdate);
|
entityDialogService.Unsubscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
searchService.Unsubscribe(OnUpdate);
|
searchService.Unsubscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
ageTimer.Enabled = true;
|
ageTimer.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
toastService.Unsubscribe(OnUpdate);
|
toastService.Unsubscribe(OnUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
+171
-171
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
public static class DataType
|
public static class DataType
|
||||||
{
|
{
|
||||||
|
public static string Any = "Any";
|
||||||
|
public static string None = "None";
|
||||||
|
|
||||||
public static string PYREEVENT_TowerKilled = "9a923928-b016-49f2-8c7d-950abf09e287";
|
public static string PYREEVENT_TowerKilled = "9a923928-b016-49f2-8c7d-950abf09e287";
|
||||||
public static string PYREEVENT_CampTaken = "cc27a9b2-69e2-4322-8102-7a9f8bea7871";
|
public static string PYREEVENT_CampTaken = "cc27a9b2-69e2-4322-8102-7a9f8bea7871";
|
||||||
public static string PYREEVENT_MinerTaken = "5b158cf2-2810-4a2a-8131-c4fe4b392ce9";
|
public static string PYREEVENT_MinerTaken = "5b158cf2-2810-4a2a-8131-c4fe4b392ce9";
|
||||||
@@ -14,6 +17,8 @@ public static class DataType
|
|||||||
public static string FAMILY_Rae = "ce8d60f3-b590-4619-ad90-27e65f77312b";
|
public static string FAMILY_Rae = "ce8d60f3-b590-4619-ad90-27e65f77312b";
|
||||||
public static string FAMILY_Demonic = "f61a3630-9474-4ec3-bc71-997cacc52bc1";
|
public static string FAMILY_Demonic = "f61a3630-9474-4ec3-bc71-997cacc52bc1";
|
||||||
public static string FAMILY_NazRa = "56cc934f-57a9-442c-909a-25690f836679";
|
public static string FAMILY_NazRa = "56cc934f-57a9-442c-909a-25690f836679";
|
||||||
|
|
||||||
|
public static string FACTION_Neutral = "95da29af-99da-45fe-80f6-4ae1cc0d0f47";
|
||||||
public static string FACTION_Aru = "fb103962-7518-48df-b7d9-83906a009db8";
|
public static string FACTION_Aru = "fb103962-7518-48df-b7d9-83906a009db8";
|
||||||
public static string FACTION_Iratek = "dbc12bda-b4f2-4fa0-8270-18dc1646d62d";
|
public static string FACTION_Iratek = "dbc12bda-b4f2-4fa0-8270-18dc1646d62d";
|
||||||
public static string FACTION_Yul = "9c0492af-1ef8-4113-9010-92178493f8b3";
|
public static string FACTION_Yul = "9c0492af-1ef8-4113-9010-92178493f8b3";
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using Model.Types;
|
using Model.Entity.Data;
|
||||||
|
using Model.Types;
|
||||||
|
|
||||||
namespace Model.Entity.Parts;
|
namespace Model.Entity.Parts;
|
||||||
|
|
||||||
public class EntityFactionModel : IEntityPartInterface
|
public class EntityFactionModel : IEntityPartInterface
|
||||||
{
|
{
|
||||||
public string Type { get; set; } = "EntityFactionModel";
|
public string Type { get; set; } = "EntityFactionModel";
|
||||||
public string Faction { get; set; } = FactionType.QRath;
|
public string Faction { get; set; } = DataType.FACTION_QRath;
|
||||||
}
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
namespace Model.Types;
|
|
||||||
|
|
||||||
public static class FactionType
|
|
||||||
{
|
|
||||||
public static string None = "None";
|
|
||||||
public static string Any = "Any";
|
|
||||||
public static string Neutral = "Neutral";
|
|
||||||
public static string QRath = "QRath";
|
|
||||||
public static string Aru = "Aru";
|
|
||||||
public static string Jora = "Jora";
|
|
||||||
public static string Talmetra = "Talmetra";
|
|
||||||
public static string Iratek = "Iratek";
|
|
||||||
public static string Herlesh = "Herlesh";
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace Model.Types;
|
|
||||||
|
|
||||||
public static class ImmortalType
|
|
||||||
{
|
|
||||||
public static string None = "None";
|
|
||||||
public static string Any = "Any";
|
|
||||||
}
|
|
||||||
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
|
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Components.ProtectedBrowserStorage;
|
using Model.BuildOrders;
|
||||||
using Model.BuildOrders;
|
|
||||||
using Model.Doc;
|
using Model.Doc;
|
||||||
using Model.Economy;
|
using Model.Economy;
|
||||||
using Model.Entity;
|
using Model.Entity;
|
||||||
@@ -11,7 +10,6 @@ using Model.Website;
|
|||||||
using Model.Website.Enums;
|
using Model.Website.Enums;
|
||||||
using Model.Work.Tasks;
|
using Model.Work.Tasks;
|
||||||
using Services.Immortal;
|
using Services.Immortal;
|
||||||
using Services.Website;
|
|
||||||
|
|
||||||
namespace Services;
|
namespace Services;
|
||||||
|
|
||||||
@@ -226,6 +224,9 @@ public interface IBuildComparisonService
|
|||||||
|
|
||||||
public interface ITimingService
|
public interface ITimingService
|
||||||
{
|
{
|
||||||
|
public int BuildingInputDelay { get; set; }
|
||||||
|
public int WaitTime { get; set; }
|
||||||
|
public int WaitTo { get; set; }
|
||||||
public int GetAttackTime();
|
public int GetAttackTime();
|
||||||
public void SetAttackTime(int timing);
|
public void SetAttackTime(int timing);
|
||||||
public int GetTravelTime();
|
public int GetTravelTime();
|
||||||
@@ -284,10 +285,10 @@ public interface IEntityDisplayService
|
|||||||
|
|
||||||
public interface IImmortalSelectionService
|
public interface IImmortalSelectionService
|
||||||
{
|
{
|
||||||
public string GetFactionType();
|
public string GetFaction();
|
||||||
public string GetImmortalType();
|
public string GetImmortal();
|
||||||
public bool SelectFactionType(string factionType);
|
public bool SelectFaction(string faction);
|
||||||
public bool SelectImmortalType(string immortalType);
|
public bool SelectImmortal(string immortal);
|
||||||
public void Subscribe(Action action);
|
public void Subscribe(Action action);
|
||||||
public void Unsubscribe(Action action);
|
public void Unsubscribe(Action action);
|
||||||
}
|
}
|
||||||
@@ -323,7 +324,6 @@ public interface IMemoryTesterService
|
|||||||
|
|
||||||
public interface IBuildOrderService
|
public interface IBuildOrderService
|
||||||
{
|
{
|
||||||
public int BuildingInputDelay { get; set; }
|
|
||||||
public Dictionary<int, List<EntityModel>> StartedOrders { get; }
|
public Dictionary<int, List<EntityModel>> StartedOrders { get; }
|
||||||
public Dictionary<int, List<EntityModel>> CompletedOrders { get; }
|
public Dictionary<int, List<EntityModel>> CompletedOrders { get; }
|
||||||
public Dictionary<string, int> UniqueCompletedTimes { get; }
|
public Dictionary<string, int> UniqueCompletedTimes { get; }
|
||||||
|
|||||||
@@ -14,18 +14,20 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
{
|
{
|
||||||
private readonly BuildOrderModel _buildOrder = new();
|
private readonly BuildOrderModel _buildOrder = new();
|
||||||
|
|
||||||
|
private readonly ITimingService _timingService;
|
||||||
|
|
||||||
private readonly IToastService _toastService;
|
private readonly IToastService _toastService;
|
||||||
|
|
||||||
private int _lastInterval;
|
private int _lastInterval;
|
||||||
|
|
||||||
public BuildOrderService(IToastService toastService)
|
public BuildOrderService(IToastService toastService, ITimingService timingService)
|
||||||
{
|
{
|
||||||
_toastService = toastService;
|
_toastService = toastService;
|
||||||
|
_timingService = timingService;
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int BuildingInputDelay { get; set; } = 2;
|
|
||||||
|
|
||||||
public Dictionary<int, List<EntityModel>> StartedOrders => _buildOrder.StartedOrders;
|
public Dictionary<int, List<EntityModel>> StartedOrders => _buildOrder.StartedOrders;
|
||||||
public Dictionary<int, List<EntityModel>> CompletedOrders => _buildOrder.CompletedOrders;
|
public Dictionary<int, List<EntityModel>> CompletedOrders => _buildOrder.CompletedOrders;
|
||||||
public Dictionary<string, int> UniqueCompletedTimes => _buildOrder.UniqueCompletedTimes;
|
public Dictionary<string, int> UniqueCompletedTimes => _buildOrder.UniqueCompletedTimes;
|
||||||
@@ -245,9 +247,7 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
&& entityRemoved.Production()!.ProducedBy != null
|
&& entityRemoved.Production()!.ProducedBy != null
|
||||||
&& entityRemoved.Supply() != null
|
&& entityRemoved.Supply() != null
|
||||||
&& entityRemoved.Supply()!.Takes > 0)
|
&& entityRemoved.Supply()!.Takes > 0)
|
||||||
{
|
|
||||||
_buildOrder.TrainingCapacityUsed.Remove(_buildOrder.TrainingCapacityUsed.Last());
|
_buildOrder.TrainingCapacityUsed.Remove(_buildOrder.TrainingCapacityUsed.Last());
|
||||||
}
|
|
||||||
|
|
||||||
if (entityRemoved.Info().Descriptive == DescriptiveType.Worker)
|
if (entityRemoved.Info().Descriptive == DescriptiveType.Worker)
|
||||||
{
|
{
|
||||||
@@ -358,11 +358,12 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
Console.WriteLine("Produced by Nothing");
|
Console.WriteLine("Produced by Nothing");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var uniqueCompleted = _buildOrder.UniqueCompleted[producedBy];
|
var uniqueCompleted = _buildOrder.UniqueCompleted[producedBy];
|
||||||
|
|
||||||
var shortestIncrement = int.MaxValue;
|
var shortestIncrement = int.MaxValue;
|
||||||
var trainingSlots = 0;
|
var trainingSlots = 0;
|
||||||
bool didDelay = false;
|
var didDelay = false;
|
||||||
|
|
||||||
foreach (var productionEntity in uniqueCompleted) trainingSlots += productionEntity.Supply()!.Grants;
|
foreach (var productionEntity in uniqueCompleted) trainingSlots += productionEntity.Supply()!.Grants;
|
||||||
|
|
||||||
@@ -377,28 +378,30 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
var duration = used.StopUsageTime - used.StartingUsageTime;
|
var duration = used.StopUsageTime - used.StartingUsageTime;
|
||||||
if (duration < shortestIncrement) shortestIncrement = duration;
|
if (duration < shortestIncrement) shortestIncrement = duration;
|
||||||
|
|
||||||
Console.WriteLine($"Used slots {used.UsedSlots} Duration {duration} Start {used.StartingUsageTime} Stop {used.StopUsageTime} ");
|
Console.WriteLine(
|
||||||
|
$"Used slots {used.UsedSlots} Duration {duration} Start {used.StartingUsageTime} Stop {used.StopUsageTime} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usedSlots + supply.Takes <= trainingSlots)
|
if (usedSlots + supply.Takes <= trainingSlots)
|
||||||
{
|
{
|
||||||
if (didDelay)
|
if (didDelay)
|
||||||
|
_toastService.AddToast(new ToastModel
|
||||||
{
|
{
|
||||||
_toastService.AddToast(new ToastModel{Title = "Waited", SeverityType = SeverityType.Information, Message = $"Had to wait {checkedInterval - _lastInterval}s for Training Queue."});
|
Title = "Waited", SeverityType = SeverityType.Information,
|
||||||
}
|
Message = $"Had to wait {checkedInterval - _lastInterval}s for Training Queue."
|
||||||
|
});
|
||||||
|
|
||||||
Console.WriteLine($"Time {checkedInterval} did Delay {didDelay}");
|
Console.WriteLine($"Time {checkedInterval} did Delay {didDelay}");
|
||||||
|
|
||||||
return checkedInterval;
|
return checkedInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkedInterval += shortestIncrement;
|
checkedInterval += shortestIncrement;
|
||||||
didDelay = true;
|
didDelay = true;
|
||||||
|
|
||||||
if (shortestIncrement == int.MaxValue)
|
if (shortestIncrement == int.MaxValue)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("MaxValue");
|
||||||
Console.WriteLine($"MaxValue");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,7 +424,7 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
{
|
{
|
||||||
atInterval = interval;
|
atInterval = interval;
|
||||||
|
|
||||||
if (entity.EntityType != EntityType.Army) atInterval += BuildingInputDelay;
|
if (entity.EntityType != EntityType.Army) atInterval += _timingService.BuildingInputDelay;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ public class EntityViewType
|
|||||||
{
|
{
|
||||||
public static string Detailed = "Detailed";
|
public static string Detailed = "Detailed";
|
||||||
public static string Plain = "Plain";
|
public static string Plain = "Plain";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EntityDisplayService : IEntityDisplayService
|
public class EntityDisplayService : IEntityDisplayService
|
||||||
{
|
{
|
||||||
private string _displayType;
|
private string _displayType;
|
||||||
@@ -15,11 +15,11 @@ public class EntityDisplayService : IEntityDisplayService
|
|||||||
public EntityDisplayService(IStorageService storageService)
|
public EntityDisplayService(IStorageService storageService)
|
||||||
{
|
{
|
||||||
_displayType = storageService.GetValue<bool>(StorageKeys.IsPlainView)
|
_displayType = storageService.GetValue<bool>(StorageKeys.IsPlainView)
|
||||||
? EntityViewType.Plain : EntityViewType.Detailed;
|
? EntityViewType.Plain
|
||||||
|
: EntityViewType.Detailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<string> DefaultChoices()
|
public List<string> DefaultChoices()
|
||||||
{
|
{
|
||||||
return new List<string> { EntityViewType.Detailed, EntityViewType.Plain };
|
return new List<string> { EntityViewType.Detailed, EntityViewType.Plain };
|
||||||
@@ -42,7 +42,7 @@ public class EntityDisplayService : IEntityDisplayService
|
|||||||
|
|
||||||
public void SetDisplayType(string displayType)
|
public void SetDisplayType(string displayType)
|
||||||
{
|
{
|
||||||
this._displayType = displayType;
|
_displayType = displayType;
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
{
|
{
|
||||||
private readonly List<string> _entityChoices = new();
|
private readonly List<string> _entityChoices = new();
|
||||||
|
|
||||||
private readonly List<string> _factionChoices = new() { FactionType.Any, FactionType.QRath, FactionType.Aru };
|
private readonly List<string> _factionChoices = new() { DataType.Any, DataType.FACTION_QRath, DataType.FACTION_Aru };
|
||||||
private readonly List<string> _immortalChoices = new();
|
private readonly List<string> _immortalChoices = new();
|
||||||
private string _entityType = EntityType.Army;
|
private string _entityType = EntityType.Army;
|
||||||
private string _searchText = "";
|
private string _searchText = "";
|
||||||
private string _selectedFaction = FactionType.Any;
|
private string _selectedFaction = DataType.Any;
|
||||||
private string _selectedImmortal = ImmortalType.Any;
|
private string _selectedImmortal = DataType.Any;
|
||||||
|
|
||||||
public EntityFilterService()
|
public EntityFilterService()
|
||||||
{
|
{
|
||||||
@@ -59,8 +59,8 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
{
|
{
|
||||||
if (_selectedFaction == factionType)
|
if (_selectedFaction == factionType)
|
||||||
{
|
{
|
||||||
_selectedFaction = FactionType.None;
|
_selectedFaction = DataType.None;
|
||||||
_selectedImmortal = ImmortalType.None;
|
_selectedImmortal = DataType.None;
|
||||||
|
|
||||||
RefreshImmortalChoices();
|
RefreshImmortalChoices();
|
||||||
RefreshEntityChoices();
|
RefreshEntityChoices();
|
||||||
@@ -71,7 +71,7 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
}
|
}
|
||||||
|
|
||||||
_selectedFaction = factionType;
|
_selectedFaction = factionType;
|
||||||
_selectedImmortal = ImmortalType.Any;
|
_selectedImmortal = DataType.Any;
|
||||||
|
|
||||||
RefreshImmortalChoices();
|
RefreshImmortalChoices();
|
||||||
RefreshEntityChoices();
|
RefreshEntityChoices();
|
||||||
@@ -84,7 +84,7 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
{
|
{
|
||||||
if (_selectedImmortal == immortalType)
|
if (_selectedImmortal == immortalType)
|
||||||
{
|
{
|
||||||
_selectedImmortal = ImmortalType.None;
|
_selectedImmortal = DataType.None;
|
||||||
NotifyDataChanged(EntityFilterEvent.OnRefreshImmortal);
|
NotifyDataChanged(EntityFilterEvent.OnRefreshImmortal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -148,13 +148,13 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
_immortalChoices.Add(ImmortalType.Xol);
|
_immortalChoices.Add(ImmortalType.Xol);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Any)
|
if (_selectedFaction == DataType.FACTION_QRath || _selectedFaction == DataType.Any)
|
||||||
{
|
{
|
||||||
_immortalChoices.Add(DataType.IMMORTAL_Orzum);
|
_immortalChoices.Add(DataType.IMMORTAL_Orzum);
|
||||||
_immortalChoices.Add(DataType.IMMORTAL_Ajari);
|
_immortalChoices.Add(DataType.IMMORTAL_Ajari);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.Aru || _selectedFaction == FactionType.Any)
|
if (_selectedFaction == DataType.FACTION_Aru || _selectedFaction == DataType.Any)
|
||||||
{
|
{
|
||||||
_immortalChoices.Add(DataType.IMMORTAL_Mala);
|
_immortalChoices.Add(DataType.IMMORTAL_Mala);
|
||||||
_immortalChoices.Add(DataType.IMMORTAL_Xol);
|
_immortalChoices.Add(DataType.IMMORTAL_Xol);
|
||||||
@@ -165,8 +165,8 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
{
|
{
|
||||||
_entityChoices.Clear();
|
_entityChoices.Clear();
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Aru ||
|
if (_selectedFaction == DataType.FACTION_QRath || _selectedFaction == DataType.FACTION_Aru ||
|
||||||
_selectedFaction == FactionType.Any)
|
_selectedFaction == DataType.Any)
|
||||||
{
|
{
|
||||||
_entityChoices.Add(EntityType.Army);
|
_entityChoices.Add(EntityType.Army);
|
||||||
_entityChoices.Add(EntityType.Immortal);
|
_entityChoices.Add(EntityType.Immortal);
|
||||||
@@ -178,7 +178,7 @@ public class EntityFilterService : IEntityFilterService
|
|||||||
_entityChoices.Add(EntityType.Worker);
|
_entityChoices.Add(EntityType.Worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.Any) _entityChoices.Add(EntityType.Any);
|
if (_selectedFaction == DataType.Any) _entityChoices.Add(EntityType.Any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,29 @@
|
|||||||
using Model.Entity.Data;
|
using Model.Entity.Data;
|
||||||
using Model.Types;
|
using Services.Website;
|
||||||
|
|
||||||
namespace Services.Immortal;
|
namespace Services.Immortal;
|
||||||
|
|
||||||
public class ImmortalSelectionService : IImmortalSelectionService
|
public class ImmortalSelectionService : IImmortalSelectionService, IDisposable
|
||||||
{
|
{
|
||||||
private string _selectedFaction = FactionType.QRath;
|
private string _selectedFaction = DataType.FACTION_QRath;
|
||||||
private string _selectedImmortal = DataType.IMMORTAL_Orzum;
|
private string _selectedImmortal = DataType.IMMORTAL_Orzum;
|
||||||
|
|
||||||
|
private readonly IStorageService _storageService;
|
||||||
|
|
||||||
|
public ImmortalSelectionService(IStorageService storageService)
|
||||||
|
{
|
||||||
|
_storageService = storageService;
|
||||||
|
|
||||||
|
_storageService.Subscribe(RefreshDefaults);
|
||||||
|
|
||||||
|
RefreshDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
|
{
|
||||||
|
_storageService.Unsubscribe(RefreshDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
public void Subscribe(Action action)
|
public void Subscribe(Action action)
|
||||||
{
|
{
|
||||||
OnChange += action;
|
OnChange += action;
|
||||||
@@ -18,37 +34,49 @@ public class ImmortalSelectionService : IImmortalSelectionService
|
|||||||
OnChange -= action;
|
OnChange -= action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFactionType()
|
public string GetFaction()
|
||||||
{
|
{
|
||||||
return _selectedFaction;
|
return _selectedFaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetImmortalType()
|
public string GetImmortal()
|
||||||
{
|
{
|
||||||
return _selectedImmortal;
|
return _selectedImmortal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SelectFactionType(string factionType)
|
public bool SelectFaction(string faction)
|
||||||
{
|
{
|
||||||
if (_selectedFaction == factionType) return false;
|
if (_selectedFaction == faction) return false;
|
||||||
_selectedFaction = factionType;
|
_selectedFaction = faction;
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.QRath) _selectedImmortal = DataType.IMMORTAL_Orzum;
|
if (_selectedFaction == DataType.FACTION_QRath) _selectedImmortal = DataType.IMMORTAL_Orzum;
|
||||||
|
|
||||||
if (_selectedFaction == FactionType.Aru) _selectedImmortal = DataType.IMMORTAL_Mala;
|
if (_selectedFaction == DataType.FACTION_Aru) _selectedImmortal = DataType.IMMORTAL_Mala;
|
||||||
|
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SelectImmortalType(string immortalType)
|
public bool SelectImmortal(string immortal)
|
||||||
{
|
{
|
||||||
if (_selectedImmortal == immortalType) return false;
|
if (_selectedImmortal == immortal) return false;
|
||||||
_selectedImmortal = immortalType;
|
_selectedImmortal = immortal;
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshDefaults()
|
||||||
|
{
|
||||||
|
var foundFaction = _storageService.GetValue<string?>(StorageKeys.SelectedFaction);
|
||||||
|
var foundImmortal = _storageService.GetValue<string?>(StorageKeys.SelectedImmortal);
|
||||||
|
|
||||||
|
if (foundFaction != null) _selectedFaction = foundFaction;
|
||||||
|
|
||||||
|
if (foundImmortal != null) _selectedImmortal = foundImmortal;
|
||||||
|
|
||||||
|
NotifyDataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private event Action OnChange = null!;
|
private event Action OnChange = null!;
|
||||||
|
|
||||||
private void NotifyDataChanged()
|
private void NotifyDataChanged()
|
||||||
|
|||||||
@@ -1,10 +1,27 @@
|
|||||||
namespace Services.Immortal;
|
using Services.Website;
|
||||||
|
|
||||||
public class TimingService : ITimingService
|
namespace Services.Immortal;
|
||||||
|
|
||||||
|
public class TimingService : ITimingService, IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly IStorageService _storageService;
|
||||||
private int attackTime = 1500;
|
private int attackTime = 1500;
|
||||||
private int travelTime = 30;
|
private int travelTime = 30;
|
||||||
|
|
||||||
|
public TimingService(IStorageService storageService)
|
||||||
|
{
|
||||||
|
_storageService = storageService;
|
||||||
|
|
||||||
|
_storageService.Subscribe(RefreshDefaults);
|
||||||
|
|
||||||
|
RefreshDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDisposable.Dispose()
|
||||||
|
{
|
||||||
|
_storageService.Unsubscribe(RefreshDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
public void Subscribe(Action? action)
|
public void Subscribe(Action? action)
|
||||||
{
|
{
|
||||||
OnChange += action;
|
OnChange += action;
|
||||||
@@ -15,6 +32,10 @@ public class TimingService : ITimingService
|
|||||||
OnChange -= action;
|
OnChange -= action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int BuildingInputDelay { get; set; } = 2;
|
||||||
|
public int WaitTime { get; set; } = 30;
|
||||||
|
public int WaitTo { get; set; } = 60;
|
||||||
|
|
||||||
public int GetAttackTime()
|
public int GetAttackTime()
|
||||||
{
|
{
|
||||||
return attackTime;
|
return attackTime;
|
||||||
@@ -43,6 +64,29 @@ public class TimingService : ITimingService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshDefaults()
|
||||||
|
{
|
||||||
|
//TODO Timing has changed in Storage
|
||||||
|
//TODO Timing has changed in itself
|
||||||
|
|
||||||
|
var foundAttackTime = _storageService.GetValue<int?>(StorageKeys.AttackTime);
|
||||||
|
var foundTravelTime = _storageService.GetValue<int?>(StorageKeys.TravelTime);
|
||||||
|
|
||||||
|
var foundBuildInputDefault = _storageService.GetValue<int?>(StorageKeys.BuildInputDelay);
|
||||||
|
|
||||||
|
var foundWaitTime = _storageService.GetValue<int?>(StorageKeys.WaitTime);
|
||||||
|
var foundWaitTo = _storageService.GetValue<int?>(StorageKeys.WaitTo);
|
||||||
|
|
||||||
|
if (foundAttackTime != null) attackTime = (int)foundAttackTime;
|
||||||
|
if (foundTravelTime != null) travelTime = (int)foundTravelTime;
|
||||||
|
|
||||||
|
if (foundBuildInputDefault != null) BuildingInputDelay = (int)foundBuildInputDefault;
|
||||||
|
if (foundWaitTime != null) WaitTime = (int)foundWaitTime;
|
||||||
|
if (foundWaitTo != null) WaitTo = (int)foundWaitTo;
|
||||||
|
|
||||||
|
NotifyDataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private event Action? OnChange;
|
private event Action? OnChange;
|
||||||
|
|
||||||
private void NotifyDataChanged()
|
private void NotifyDataChanged()
|
||||||
|
|||||||
@@ -15,14 +15,14 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0-preview.1" />
|
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0-preview.1"/>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.ProtectedBrowserStorage" Version="5.0.0-rc.1.20451.17" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.ProtectedBrowserStorage" Version="5.0.0-rc.1.20451.17"/>
|
||||||
<PackageReference Include="Microsoft.JSInterop" Version="7.0.0-preview.2.22153.2" />
|
<PackageReference Include="Microsoft.JSInterop" Version="7.0.0-preview.2.22153.2"/>
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Model\Model.csproj" />
|
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
using Blazored.LocalStorage;
|
using Microsoft.JSInterop;
|
||||||
using Microsoft.JSInterop;
|
|
||||||
|
|
||||||
namespace Services.Website;
|
namespace Services.Website;
|
||||||
|
|
||||||
public class PermissionService : IPermissionService
|
public class PermissionService : IPermissionService
|
||||||
{
|
{
|
||||||
private bool isLoaded;
|
|
||||||
|
|
||||||
|
|
||||||
private IJSRuntime _jsRuntime;
|
private IJSRuntime _jsRuntime;
|
||||||
private bool isStorageEnabled = false;
|
private readonly IStorageService _storageService;
|
||||||
private IToastService _toastService;
|
private IToastService _toastService;
|
||||||
private IStorageService _storageService;
|
private bool isLoaded;
|
||||||
|
private bool isStorageEnabled = false;
|
||||||
|
|
||||||
public PermissionService(IJSRuntime jsRuntime, IToastService toastService, IStorageService storageService)
|
public PermissionService(IJSRuntime jsRuntime, IToastService toastService, IStorageService storageService)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using Microsoft.JSInterop;
|
|
||||||
using Model.Feedback;
|
using Model.Feedback;
|
||||||
|
|
||||||
namespace Services.Website;
|
namespace Services.Website;
|
||||||
@@ -9,27 +8,30 @@ public class StorageKeys
|
|||||||
public static string EnabledStorage = "StorageEnabled";
|
public static string EnabledStorage = "StorageEnabled";
|
||||||
public static string EnabledDataCollection = "StorageDataCollection";
|
public static string EnabledDataCollection = "StorageDataCollection";
|
||||||
public static string IsPlainView { get; set; } = "IsPlainView";
|
public static string IsPlainView { get; set; } = "IsPlainView";
|
||||||
|
public static string AttackTime { get; set; } = "AttackTime";
|
||||||
|
public static string TravelTime { get; set; } = "TravelTime";
|
||||||
|
public static string SelectedFaction { get; set; } = "SelectedFaction";
|
||||||
|
public static string SelectedImmortal { get; set; } = "SelectedImmortal";
|
||||||
|
public static string BuildInputDelay { get; set; } = "BuildInputDelay";
|
||||||
|
public static string WaitTime { get; set; } = "WaitTime";
|
||||||
|
|
||||||
|
public static string WaitTo { get; set; } = "WaitTo";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StorageService : IStorageService
|
public class StorageService : IStorageService
|
||||||
{
|
{
|
||||||
private readonly ISyncLocalStorageService _localStorageService;
|
private readonly ISyncLocalStorageService _localStorageService;
|
||||||
private IJSRuntime _jsRuntime;
|
|
||||||
private readonly IToastService _toastService;
|
private readonly IToastService _toastService;
|
||||||
private bool isLoaded;
|
private bool isLoaded;
|
||||||
private bool isStorageEnabled;
|
|
||||||
|
|
||||||
|
|
||||||
public StorageService(IJSRuntime jsRuntime, IToastService toastService,
|
public StorageService(IToastService toastService,
|
||||||
ISyncLocalStorageService localStorageService)
|
ISyncLocalStorageService localStorageService)
|
||||||
{
|
{
|
||||||
_jsRuntime = jsRuntime;
|
|
||||||
_toastService = toastService;
|
_toastService = toastService;
|
||||||
_localStorageService = localStorageService;
|
_localStorageService = localStorageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string enabledKey => StorageKeys.EnabledStorage;
|
|
||||||
|
|
||||||
public void Subscribe(Action action)
|
public void Subscribe(Action action)
|
||||||
{
|
{
|
||||||
OnChange += action;
|
OnChange += action;
|
||||||
@@ -51,12 +53,28 @@ public class StorageService : IStorageService
|
|||||||
{
|
{
|
||||||
_localStorageService.SetItem(key, value);
|
_localStorageService.SetItem(key, value);
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
|
|
||||||
|
_toastService.AddToast(new ToastModel
|
||||||
|
{
|
||||||
|
Title = "Test 1",
|
||||||
|
SeverityType = SeverityType.Error,
|
||||||
|
Message = "Storage must be enabled before Storage can be used."
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.Equals(StorageKeys.EnabledStorage))
|
if (key.Equals(StorageKeys.EnabledStorage))
|
||||||
{
|
{
|
||||||
_localStorageService.Clear();
|
_localStorageService.Clear();
|
||||||
|
|
||||||
|
_toastService.AddToast(new ToastModel
|
||||||
|
{
|
||||||
|
Title = "Test 2",
|
||||||
|
SeverityType = SeverityType.Error,
|
||||||
|
Message = "Storage must be enabled before Storage can be used."
|
||||||
|
});
|
||||||
|
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,29 +96,20 @@ public class StorageService : IStorageService
|
|||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Load()
|
public Task Load()
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return Task.CompletedTask;
|
||||||
|
|
||||||
|
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
|
||||||
isStorageEnabled = GetValue<bool>(enabledKey);
|
|
||||||
|
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private event Action OnChange = null!;
|
private event Action OnChange = null!;
|
||||||
|
|
||||||
private void NotifyDataChanged()
|
private void NotifyDataChanged()
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
OnChange();
|
OnChange();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user