Skip to content

Commit

Permalink
Model SallyArea
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyuvn committed May 16, 2015
1 parent 4870eee commit 79a12cd
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 131 deletions.
31 changes: 2 additions & 29 deletions Grabacr07.KanColleViewer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions Grabacr07.KanColleViewer/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -839,19 +839,13 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="ShipCatalog_SortieWaters" xml:space="preserve">
<value>Operation</value>
</data>
<data name="ShipCatalog_SortieWaters_1" xml:space="preserve">
<value>E3</value>
</data>
<data name="ShipCatalog_SortieWaters_2" xml:space="preserve">
<value>E4</value>
</data>
<data name="ShipCatalog_Operation_AL" xml:space="preserve">
<value>Participated in AL</value>
</data>
<data name="ShipCatalog_Operation_MI" xml:space="preserve">
<value>Participated in MI</value>
</data>
<data name="ShipCatalog_Operation_NeitherALnorMI" xml:space="preserve">
<data name="ShipCatalog_Operation_NotLocked" xml:space="preserve">
<value>Did not participate</value>
</data>
<data name="Settings_Operation_LoSCalculation" xml:space="preserve">
Expand Down Expand Up @@ -1298,9 +1292,6 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="ShipCatalog_CustomSort" xml:space="preserve">
<value>Game's sort</value>
</data>
<data name="ShipCatalog_SortieWaters_3" xml:space="preserve">
<value>E5</value>
</data>
<data name="Settings_Updates_CheckUpdatesBtn_ToolTip" xml:space="preserve">
<value>Check lastest translations version</value>
</data>
Expand Down
11 changes: 1 addition & 10 deletions Grabacr07.KanColleViewer/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -783,19 +783,13 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="ShipCatalog_SortieWaters" xml:space="preserve">
<value>出撃海域</value>
</data>
<data name="ShipCatalog_SortieWaters_1" xml:space="preserve">
<value>通商破壊</value>
</data>
<data name="ShipCatalog_SortieWaters_2" xml:space="preserve">
<value>攻略作戦</value>
</data>
<data name="ShipCatalog_Operation_AL" xml:space="preserve">
<value>AL 作戦参加済み</value>
</data>
<data name="ShipCatalog_Operation_MI" xml:space="preserve">
<value>MI 作戦参加済み</value>
</data>
<data name="ShipCatalog_Operation_NeitherALnorMI" xml:space="preserve">
<data name="ShipCatalog_Operation_NotLocked" xml:space="preserve">
<value>作戦出撃なし</value>
</data>
<data name="Settings_Operation_LoSCalculation" xml:space="preserve">
Expand Down Expand Up @@ -1230,9 +1224,6 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="ShipCatalog_CustomSort" xml:space="preserve">
<value>ゲーム内</value>
</data>
<data name="ShipCatalog_SortieWaters_3" xml:space="preserve">
<value>泊地攻撃</value>
</data>
<data name="ExitDialogConfirm" xml:space="preserve">
<value>「提督業も忙しい!」 を終了します。 よろしいですか?</value>
</data>
Expand Down
85 changes: 35 additions & 50 deletions Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipCatalogFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Grabacr07.KanColleWrapper.Models;
using Livet;
using Settings = Grabacr07.KanColleViewer.Models.Settings;
using Livet.EventListeners;

namespace Grabacr07.KanColleViewer.ViewModels.Catalogs
{
Expand Down Expand Up @@ -430,7 +431,7 @@ public class ShipSallyAreaFilter : ShipCatalogFilter
{
#region None 変更通知プロパティ

private bool _None = true;
private bool _None;

public bool None
{
Expand All @@ -448,79 +449,63 @@ public bool None

#endregion

#region Area1 変更通知プロパティ
public IReadOnlyCollection<SallyAreaViewModel> Areas { get; private set; }

private bool _Area1 = true;

public bool Area1
public ShipSallyAreaFilter(Action updateAction) : base(updateAction)
{
get { return this._Area1; }
set
{
if (this._Area1 != value)
{
this._Area1 = value;
this.RaisePropertyChanged();
this.Update();
}
}
this.None = true;
this.Areas = SallyArea.Areas.Select(x => new SallyAreaViewModel(x, updateAction)).ToList();
}

#endregion

#region Area2 変更通知プロパティ

private bool _Area2 = true;

public bool Area2
public override bool Predicate(Ship ship)
{
get { return this._Area2; }
set
{
if (this._Area2 != value)
{
this._Area2 = value;
this.RaisePropertyChanged();
this.Update();
}
}
if (this.None && ship.SallyArea == 0) return true;
if (this.Areas.Any(x => x.IsSelected && x.Area.Id == ship.SallyArea)) return true;

return false;
}
}

#endregion
public class SallyAreaViewModel : ViewModel
{
public ISallyArea Area { get; set; }

#region Area3 変更通知プロパティ
private Action action;

private bool _Area3 = true;
#region Selected 変更通知プロパティ

public bool Area3
private bool _IsSelected;

public bool IsSelected
{
get { return this._Area3; }
get { return this._IsSelected; }
set
{
if (this._Area3 != value)
if (this._IsSelected != value)
{
this._Area3 = value;
this._IsSelected = value;
if (this.action != null) this.action();
this.RaisePropertyChanged();
this.Update();
}
}
}

#endregion


public ShipSallyAreaFilter(Action updateAction) : base(updateAction) { }

public override bool Predicate(Ship ship)
public SallyAreaViewModel(ISallyArea area, Action updateAction)
{
if (this.None && ship.SallyArea == 0) return true;
if (this.Area1 && ship.SallyArea == 1) return true;
if (this.Area2 && ship.SallyArea == 2) return true;
if (this.Area3 && ship.SallyArea == 3) return true;

return false;
this.Area = area;
this.IsSelected = true;
this.action = updateAction;

//return true;
this.CompositeDisposable.Add(new PropertyChangedEventListener(ResourceServiceWrapper.Current)
{
(sender, args) =>
{
this.RaisePropertyChanged("Area");
},
});
}
}
}
35 changes: 35 additions & 0 deletions Grabacr07.KanColleViewer/ViewModels/Catalogs/ShipViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Grabacr07.KanColleWrapper.Models;
using Livet;
using Livet.EventListeners;

namespace Grabacr07.KanColleViewer.ViewModels.Catalogs
{
Expand All @@ -14,11 +15,45 @@ public class ShipViewModel : ViewModel
public Ship Ship { get; private set; }
public List<SlotItemViewModel> SlotItems { get; private set; }

#region Area 変更通知プロパティ

private ISallyArea _Area;
public ISallyArea Area
{
get { return this._Area; }
set
{
if (this._Area != value)
{
this._Area = value;
this.RaisePropertyChanged();
}
}
}

#endregion


public ShipViewModel(int index, Ship ship)
{
this.Index = index;
this.Ship = ship;
this.SlotItems = ship.EquippedSlots.Select(i => new SlotItemViewModel(i)).ToList();

this.Update(ship);
this.CompositeDisposable.Add(new PropertyChangedEventListener(ship)
{
"SallyArea", (sender, args) => this.Update(ship),
});
this.CompositeDisposable.Add(new PropertyChangedEventListener(ResourceServiceWrapper.Current)
{
(sender, args) => this.RaisePropertyChanged("Area"),
});
}

private void Update(Ship ship)
{
this.Area = SallyArea.Get(ship);
}
}
}
53 changes: 21 additions & 32 deletions Grabacr07.KanColleViewer/Views/Catalogs/ShipCatalogWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,24 @@
<Run Text=":" />
</TextBlock>

<CheckBox Content="{Binding Resources.ShipCatalog_Operation_NeitherALnorMI, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
<CheckBox Content="{Binding Resources.ShipCatalog_Operation_NotLocked, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding None}"
Margin="10,0" />
<CheckBox Content="{Binding Resources.ShipCatalog_SortieWaters_1, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Area1}"
Margin="10,0" />
<CheckBox Content="{Binding Resources.ShipCatalog_SortieWaters_2, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Area2}"
Margin="10,0" />
<CheckBox Content="{Binding Resources.ShipCatalog_SortieWaters_3, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Area3}"
Margin="10,0" />

<ItemsControl ItemsSource="{Binding Areas}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Area.Name, Mode=OneWay}"
IsChecked="{Binding IsSelected}"
Margin="10,0" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
</Border>
</StackPanel>
Expand Down Expand Up @@ -900,39 +906,22 @@
<GridViewColumn.CellTemplate>
<DataTemplate>
<Border x:Name="Border"
Background="{Binding Area.Color, Mode=OneWay}"
Margin="-2,0">
<TextBlock x:Name="Text"
Text=""
Text="{Binding Area.Name, Mode=OneWay}"
Foreground="{DynamicResource ActiveForegroundBrushKey}"
Margin="5,3" />
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Ship.SallyArea}"
Value="1">
<Setter TargetName="Text"
Property="Text"
Value="{Binding Resources.ShipCatalog_SortieWaters_1, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
<Setter TargetName="Border"
Property="Background"
Value="#FF204080" />
</DataTrigger>
<DataTrigger Binding="{Binding Ship.SallyArea}"
Value="2">
<Setter TargetName="Text"
Property="Text"
Value="{Binding Resources.ShipCatalog_SortieWaters_2, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
<Setter TargetName="Border"
Property="Background"
Value="#FF1A811A" />
</DataTrigger>
<DataTrigger Binding="{Binding Ship.SallyArea}"
Value="3">
Value="0">
<Setter TargetName="Text"
Property="Text"
Value="{Binding Resources.ShipCatalog_SortieWaters_3, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" />
Value="" />
<Setter TargetName="Border"
Property="Background"
Value="#FFDE8607" />
Value="#00000000" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
Expand Down
1 change: 1 addition & 0 deletions Grabacr07.KanColleWrapper/KanColleWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<Compile Include="Models\Raw\kcsapi_powerup.cs" />
<Compile Include="Models\Raw\kcsapi_remodel_slotlist.cs" />
<Compile Include="Models\Raw\kcsapi_remodel_slotlist_detail.cs" />
<Compile Include="Models\SallyArea.cs" />
<Compile Include="Models\ShipSituation.cs" />
<Compile Include="Models\ShipSlot.cs" />
<Compile Include="Models\SlotItemType.cs" />
Expand Down
Loading

0 comments on commit 79a12cd

Please sign in to comment.