Stack Size Grid

- added good, warning and bad icons to the stack size grid.
This commit is contained in:
Brett Hewitson 2022-06-15 23:33:49 +10:00
parent ca9c053f08
commit b24904d13c
5 changed files with 63 additions and 6 deletions

View file

@ -27,6 +27,8 @@ namespace ServerManagerTool.Lib
}
}
Update();
return errors;
}
@ -45,6 +47,14 @@ namespace ServerManagerTool.Lib
public void UpdateForLocalization()
{
}
public void Update()
{
IsEnabled = this.Count > 0;
foreach (var stackSize in this)
stackSize.Update();
}
}
[DataContract]
@ -99,7 +109,10 @@ namespace ServerManagerTool.Lib
public override void InitializeFromINIValue(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
Update();
return;
}
var kvPair = value.Split(new[] { '=' }, 2);
var kvValue = kvPair[1].Trim(' ');
@ -136,6 +149,19 @@ namespace ServerManagerTool.Lib
{
return IsValid;
}
public static readonly DependencyProperty ValidStatusProperty = DependencyProperty.Register(nameof(ValidStatus), typeof(string), typeof(StackSizeOverride), new PropertyMetadata("N"));
public string ValidStatus
{
get { return (string)GetValue(ValidStatusProperty); }
set { SetValue(ValidStatusProperty, value); }
}
public void Update()
{
ValidStatus = IsValid ? (GameData.HasItemForClass(ItemClassString) ? "Y" : "W") : "N";
}
}
[DataContract]

View file

@ -5074,7 +5074,7 @@
</StackPanel>
</GroupBox.Header>
<DataGrid Name="StackSizeOverrideGrid" ItemsSource="{Binding ConfigOverrideItemMaxQuantity}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="true" SelectionMode="Single" CanUserResizeRows="False" RowHeaderWidth="25">
<DataGrid Name="StackSizeOverrideGrid" ItemsSource="{Binding ConfigOverrideItemMaxQuantity}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="true" SelectionMode="Single" CanUserResizeRows="False" RowHeaderWidth="25" SourceUpdated="StackSizeOverrideGrids_SourceUpdated">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridRow}">
<Style.Resources>
@ -5091,6 +5091,28 @@
<SolidColorBrush Color="#FFB4B4B4"/>
</DataGrid.VerticalGridLinesBrush>
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<Image HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.ValidStatus, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="Y">
<Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/StatusGood.ico,Size=32}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=DataContext.ValidStatus, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="N">
<Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/StatusBad.ico,Size=32}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=DataContext.ValidStatus, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="W">
<Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/StatusWarning.ico,Size=32}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
<DataGrid.Columns>
<DataGridTemplateColumn Width="2*" CanUserSort="True" SortMemberPath="DisplayName">
<DataGridTemplateColumn.Header>
@ -5098,7 +5120,7 @@
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox IsEditable="True" ItemsSource="{Binding BasePrimalItemList, ElementName=SettingsControl}" SelectedValue="{Binding ItemClassString, Mode=TwoWay, UpdateSourceTrigger=Explicit}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" LostFocus="ComboBoxItemList_LostFocus" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<ComboBox IsEditable="True" ItemsSource="{Binding BasePrimalItemList, ElementName=SettingsControl}" SelectedValue="{Binding ItemClassString, Mode=TwoWay, UpdateSourceTrigger=Explicit, NotifyOnSourceUpdated=True}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" LostFocus="ComboBoxItemList_LostFocus" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

View file

@ -1329,6 +1329,11 @@ namespace ServerManagerTool
Settings.NPCSpawnSettings.Update();
}
private void StackSizeOverrideGrids_SourceUpdated(object sender, DataTransferEventArgs e)
{
Settings.ConfigOverrideItemMaxQuantity.Update();
}
#region Dinos
private void DinoCustomization_Reset(object sender, RoutedEventArgs e)
{
@ -3277,7 +3282,7 @@ namespace ServerManagerTool
private void AddStackSizeOverride_Click(object sender, RoutedEventArgs e)
{
Settings.ConfigOverrideItemMaxQuantity.Add(new StackSizeOverride());
Settings.ConfigOverrideItemMaxQuantity.IsEnabled = true;
Settings.ConfigOverrideItemMaxQuantity.Update();
}
private void ClearStackSizeOverrides_Click(object sender, RoutedEventArgs e)
@ -3286,7 +3291,7 @@ namespace ServerManagerTool
return;
Settings.ConfigOverrideItemMaxQuantity.Clear();
Settings.ConfigOverrideItemMaxQuantity.IsEnabled = false;
Settings.ConfigOverrideItemMaxQuantity.Update();
}
private void PasteStackSizeOverride_Click(object sender, RoutedEventArgs e)
@ -3337,7 +3342,7 @@ namespace ServerManagerTool
var item = ((StackSizeOverride)((Button)e.Source).DataContext);
Settings.ConfigOverrideItemMaxQuantity.Remove(item);
Settings.ConfigOverrideItemMaxQuantity.IsEnabled = Settings.ConfigOverrideItemMaxQuantity.Count > 0;
Settings.ConfigOverrideItemMaxQuantity.Update();
}
private void SaveStackSizeOverride_Click(object sender, RoutedEventArgs e)
@ -3362,6 +3367,8 @@ namespace ServerManagerTool
if (item == null)
return;
Settings.ConfigOverrideItemMaxQuantity.RenderToModel();
var iniName = Settings.ConfigOverrideItemMaxQuantity.IniCollectionKey;
var iniValue = $"{iniName}={item.ToINIValue()}";

View file

@ -28,6 +28,7 @@
<li>Crafting Override Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for resources not familiar with (raw class names, not loaded via gamedata files), Errors will show for empty resources.</li>
<li>Prevent Transfer Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing creatures.</li>
<li>Map Spawner Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for spawners/creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing spawners/creatures.</li>
<li>Stack Size Grid - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for items not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing items.</li>
</ul>
</p>
</div>

View file

@ -19,9 +19,10 @@
<u style="font-size: .9em;">CHANGE</u>
<br/>
<ul>
<li>Crafting Override Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for resources not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing resources.</li>
<li>Crafting Override Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for items not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing items.</li>
<li>Prevent Transfer Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing creatures.</li>
<li>Map Spawner Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for spawners/creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing spawners/creatures.</li>
<li>Stack Size Grid - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for items not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing items.</li>
</ul>
</p>
</div>