Skip to content

Commit

Permalink
艦娘一覧ウインドウにcondition値によるフィルタリングを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
twinkfrag committed Feb 19, 2016
1 parent a899855 commit 3f45ed4
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,82 @@ public override bool Predicate(Ship ship)
return false;
}
}

public class ShipConditionFilter : ShipCatalogFilter
{
#region Both 変更通知プロパティ

private bool _Both;

public bool Both
{
get { return this._Both; }
set
{
if (this._Both != value)
{
this._Both = value;
this.RaisePropertyChanged();
this.Update();
}
}
}

#endregion

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

private bool _Brilliant;

public bool Brilliant
{
get { return this._Brilliant; }
set
{
if (this._Brilliant != value)
{
this._Brilliant = value;
this.RaisePropertyChanged();
this.Update();
}
}
}

#endregion

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

private bool _Unbrilliant;

public bool Unbrilliant
{
get { return this._Unbrilliant; }
set
{
if (this._Unbrilliant != value)
{
this._Unbrilliant = value;
this.RaisePropertyChanged();
this.Update();
}
}
}

#endregion

public ShipConditionFilter(Action updateAction)
: base(updateAction)
{
this._Both = true;
}

public override bool Predicate(Ship ship)
{
if (this.Both) return true;
if (this.Brilliant && ship.ConditionType == ConditionType.Brilliant) return true;
if (this.Unbrilliant && ship.ConditionType >= ConditionType.Normal) return true;

return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ShipCatalogWindowViewModel : WindowViewModel
public ShipExpeditionFilter ShipExpeditionFilter { get; }
public ShipSallyAreaFilter ShipSallyAreaFilter { get; }
public ShipDamagedFilter ShipDamagedFilter { get; }
public ShipConditionFilter ShipConditionFilter { get; }

public bool CheckAllShipTypes
{
Expand Down Expand Up @@ -143,6 +144,7 @@ public ShipCatalogWindowViewModel()
this.ShipExpeditionFilter = new ShipExpeditionFilter(this.Update);
this.ShipSallyAreaFilter = new ShipSallyAreaFilter(this.Update);
this.ShipDamagedFilter = new ShipDamagedFilter(this.Update);
this.ShipConditionFilter = new ShipConditionFilter(this.Update);

this.updateSource
.Do(_ => this.IsReloading = true)
Expand Down Expand Up @@ -179,7 +181,8 @@ private IObservable<Unit> UpdateAsync(SallyArea[] areas)
.Where(this.ShipRemodelingFilter.Predicate)
.Where(this.ShipExpeditionFilter.Predicate)
.Where(this.ShipSallyAreaFilter.Predicate)
.Where(this.ShipDamagedFilter.Predicate);
.Where(this.ShipDamagedFilter.Predicate)
.Where(this.ShipConditionFilter.Predicate);

this.Ships = this.SortWorker.Sort(list)
.Select((x, i) => new ShipViewModel(i + 1, x, areas.FirstOrDefault(y => y.Area == x.SallyArea)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</Style>
<Style TargetType="{x:Type StackPanel}">
<Setter Property="Margin"
Value="0,0,40,0" />
Value="0,0,25,0" />
<Setter Property="Grid.IsSharedSizeScope"
Value="True" />
</Style>
Expand Down Expand Up @@ -407,6 +407,28 @@
IsChecked="{Binding Undamaged, Mode=TwoWay}" />
</WrapPanel>
</Grid>

<Grid DataContext="{Binding ShipConditionFilter}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
SharedSizeGroup="FilterName" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Margin="0,2"
HorizontalAlignment="Right">
<Run Text="condition値" />
<Run Text=":" />
</TextBlock>
<WrapPanel Grid.Column="2">
<RadioButton Content="すべて"
IsChecked="{Binding Both, Mode=TwoWay}" />
<RadioButton Content="50以上"
IsChecked="{Binding Brilliant, Mode=TwoWay}" />
<RadioButton Content="49以下"
IsChecked="{Binding Unbrilliant, Mode=TwoWay}" />
</WrapPanel>
</Grid>
</StackPanel>
</WrapPanel>
</Border>
Expand Down

0 comments on commit 3f45ed4

Please sign in to comment.