Skip to content

Commit

Permalink
add option to export locked ships only
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze committed Oct 8, 2023
1 parent 689f488 commit 5b98476
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ private async Task UpdateFleet()
}

[RelayCommand]
private async Task UpdateShips()
private async Task UpdateShips(bool? allShips)
{
string data = await BrowserHost.GetShipData();
if (allShips is not bool all) return;

string data = await BrowserHost.GetShipData(all);

ExecuteScriptAsync?.Invoke($"loadShipData('{data}')");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@

<Button Command="{Binding UpdateFleetCommand}" Content="{Binding AirControlSimulator.Fleet}" />

<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.Ships}" />
<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.LockedShips}">
<Button.CommandParameter>
<system:Boolean>False</system:Boolean>
</Button.CommandParameter>
</Button>

<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.AllShips}">
<Button.CommandParameter>
<system:Boolean>True</system:Boolean>
</Button.CommandParameter>
</Button>

<Button Command="{Binding UpdateEquipmentCommand}" Content="{Binding AirControlSimulator.LockedEquipment}">
<Button.CommandParameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
<data name="Fleet" xml:space="preserve">
<value>Fleet</value>
</data>
<data name="Ships" xml:space="preserve">
<value>Ships</value>
<data name="LockedShips" xml:space="preserve">
<value>Locked ships</value>
</data>
<data name="Title" xml:space="preserve">
<value>Air control simulator</value>
Expand All @@ -138,4 +138,7 @@
<data name="AllEquipment" xml:space="preserve">
<value>All equipment</value>
</data>
<data name="AllShips" xml:space="preserve">
<value>All ships</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
<data name="Fleet" xml:space="preserve">
<value>艦隊</value>
</data>
<data name="Ships" xml:space="preserve">
<value>艦娘</value>
<data name="LockedShips" xml:space="preserve">
<value>ロック済みのみ艦娘</value>
</data>
<data name="Title" xml:space="preserve">
<value>制空権シミュレータ</value>
Expand All @@ -138,4 +138,7 @@
<data name="AllEquipment" xml:space="preserve">
<value>未ロックも含める装備</value>
</data>
<data name="AllShips" xml:space="preserve">
<value>未ロックも含める艦娘</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class AirControlSimulatorTranslationViewModel
public string Title => AirControlSimulatorResources.Title;

public string Fleet => AirControlSimulatorResources.Fleet;
public string Ships => AirControlSimulatorResources.Ships;
public string Equipment => AirControlSimulatorResources.Equipment;
public string LockedShips => AirControlSimulatorResources.LockedShips;
public string AllShips => AirControlSimulatorResources.AllShips;
public string LockedEquipment => AirControlSimulatorResources.LockedEquipment;
public string AllEquipment => AirControlSimulatorResources.AllEquipment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ private async Task UpdateFleet()
}

[RelayCommand]
private async Task UpdateShips()
private async Task UpdateShips(bool? allShips)
{
string data = await BrowserHost.GetShipData();
if (allShips is not bool all) return;

string data = await BrowserHost.GetShipData(all);

ExecuteScriptAsync?.Invoke($"loadShipData('{data}')");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@

<Button Command="{Binding UpdateFleetCommand}" Content="{Binding AirControlSimulator.Fleet}" />

<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.Ships}" />
<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.LockedShips}">
<Button.CommandParameter>
<system:Boolean>False</system:Boolean>
</Button.CommandParameter>
</Button>

<Button Command="{Binding UpdateShipsCommand}" Content="{Binding AirControlSimulator.AllShips}">
<Button.CommandParameter>
<system:Boolean>True</system:Boolean>
</Button.CommandParameter>
</Button>

<Button Command="{Binding UpdateEquipmentCommand}" Content="{Binding AirControlSimulator.LockedEquipment}">
<Button.CommandParameter>
Expand Down
2 changes: 1 addition & 1 deletion BrowserLibCore/IBrowserHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface IBrowserHost : IStreamingHub<IBrowserHost, IBrowser>
Task<bool> IsServerAlive();
Task<int> GetTheme();
Task<string?> GetFleetData();
Task<string> GetShipData();
Task<string> GetShipData(bool allShips);
Task<string> GetEquipmentData(bool allEquipment);
}
10 changes: 6 additions & 4 deletions ElectronicObserver/Services/DataSerializationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ private string DeckBuilderFleet4()
);
}

public string FleetAnalysisShips()
public string FleetAnalysisShips(bool allShips)
{
return FleetAnalysisShips(KCDatabase.Instance.Ships.Values);
return FleetAnalysisShips(KCDatabase.Instance.Ships.Values
.Where(s => allShips || s.IsLocked));
}

public string FleetAnalysisEquipment(bool allEquipment)
Expand Down Expand Up @@ -103,13 +104,14 @@ public string AirControlSimulatorLink(AirControlSimulatorViewModel airControlSim
bases.Skip(2).FirstOrDefault(),
airControlSimulator.ShipData switch
{
true => KCDatabase.Instance.Ships.Values,
true => KCDatabase.Instance.Ships.Values
.Where(s => airControlSimulator.IncludeUnlockedShips || s.IsLocked),
_ => null,
},
airControlSimulator.EquipmentData switch
{
true => KCDatabase.Instance.Equipments.Values
.Where(e => airControlSimulator.AllEquipment || e!.IsLocked)
.Where(e => airControlSimulator.IncludeUnlockedEquipment || e!.IsLocked)
.Cast<EquipmentData>(),
_ => null,
},
Expand Down
4 changes: 2 additions & 2 deletions ElectronicObserver/Window/BrowserHostHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public Task<int> GetTheme()
return a;
}

public Task<string> GetShipData()
public Task<string> GetShipData(bool allShips)
{
DataSerializationService service = Ioc.Default.GetService<DataSerializationService>()!;

return Task.Run(() => service.FleetAnalysisShips());
return Task.Run(() => service.FleetAnalysisShips(allShips));
}

public Task<string> GetEquipmentData(bool allEquipment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,24 @@
Header="{Binding AirControlSimulator.Data}"
Visibility="{Binding DataSelectionVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
>
<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding AirControlSimulator.Ships}" IsChecked="{Binding ShipData}" />
<CheckBox Content="{Binding AirControlSimulator.Equipment}" IsChecked="{Binding EquipmentData}" />
<RadioButton
Content="{Binding AirControlSimulator.LockedEquipment}"
IsChecked="{Binding LockedEquipment}"
IsEnabled="{Binding EquipmentData}"
/>
<RadioButton
Content="{Binding AirControlSimulator.AllEquipment}"
IsChecked="{Binding AllEquipment}"
IsEnabled="{Binding EquipmentData}"
/>
<StackPanel>
<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding AirControlSimulator.Ships}" IsChecked="{Binding ShipData}" />
<CheckBox
Content="{Binding AirControlSimulator.IncludeUnlocked}"
IsChecked="{Binding IncludeUnlockedShips}"
IsEnabled="{Binding ShipData}"
/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding AirControlSimulator.Equipment}" IsChecked="{Binding EquipmentData}" />
<CheckBox
Content="{Binding AirControlSimulator.IncludeUnlocked}"
IsChecked="{Binding IncludeUnlockedEquipment}"
IsEnabled="{Binding EquipmentData}"
/>
</StackPanel>
</StackPanel>
</GroupBox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,8 @@
<data name="Equipment" xml:space="preserve">
<value>Equipment</value>
</data>
<data name="AllEquipment" xml:space="preserve">
<value>All equipment</value>
</data>
<data name="LockedEquipment" xml:space="preserve">
<value>Locked equipment</value>
<data name="IncludeUnlocked" xml:space="preserve">
<value>Include unlocked</value>
</data>
<data name="Ok" xml:space="preserve">
<value>OK</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@
<data name="Equipment" xml:space="preserve">
<value>装備</value>
</data>
<data name="LockedEquipment" xml:space="preserve">
<value>ロック済みのみ</value>
</data>
<data name="AllEquipment" xml:space="preserve">
<data name="IncludeUnlocked" xml:space="preserve">
<value>未ロックも含める</value>
</data>
<data name="Ok" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public class AirControlSimulatorTranslationViewModel : TranslationBaseViewModel

public string Ships => AirControlSimulatorResources.Ships;
public string Equipment => AirControlSimulatorResources.Equipment;
public string AllEquipment => AirControlSimulatorResources.AllEquipment;
public string LockedEquipment => AirControlSimulatorResources.LockedEquipment;
public string IncludeUnlocked => AirControlSimulatorResources.IncludeUnlocked;

public string CopyLink => SortieRecordViewerResources.CopyLink;
public string Ok => AirControlSimulatorResources.Ok;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public partial class AirControlSimulatorViewModel : WindowViewModelBase

public bool DataSelectionVisible { get; set; } = true;
public bool ShipData { get; set; } = true;
public bool IncludeUnlockedShips { get; set; } = true;
public bool EquipmentData { get; set; } = true;
public bool LockedEquipment { get; set; } = true;
public bool AllEquipment { get; set; }
public bool IncludeUnlockedEquipment { get; set; } = true;

public bool ElectronicObserverBrowser { get; set; } = true;
public bool SystemBrowser { get; set; }
Expand Down Expand Up @@ -61,7 +61,7 @@ public AirControlSimulatorViewModel(Func<AirControlSimulatorViewModel, string>?
foreach (MapAreaData map in maps)
{
int mapAreaID = map.MapAreaID;
string? name = map.NameEN;
string name = map.NameEN;

if (string.IsNullOrWhiteSpace(map.NameEN) || map.NameEN == "※")
{
Expand Down

0 comments on commit 5b98476

Please sign in to comment.