Skip to content

Commit

Permalink
Improve SpawnableTypes UI
Browse files Browse the repository at this point in the history
* Toggle Tag column visibility
* Add tooltips
  • Loading branch information
rvost committed Oct 27, 2022
1 parent a3340c8 commit f6add56
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace DayzServerTools.Application.ViewModels;

public partial class SpawnableTypesViewModel : ProjectFileViewModel<SpawnableTypes>,
public partial class SpawnableTypesViewModel : ProjectFileViewModel<SpawnableTypes>,
IImporter<IEnumerable<string>>, IDisposable
{
[ObservableProperty]
Expand All @@ -26,7 +26,8 @@ public partial class SpawnableTypesViewModel : ProjectFileViewModel<SpawnableTyp
[NotifyCanExecuteChangedFor(nameof(ExportToNewFileCommand),
nameof(SetMinDamageCommand), nameof(SetMaxDamageCommand))]
private IList selectedItems;

[ObservableProperty]
private bool showTagColumn = false;
public ObservableCollection<SpawnableTypeViewModel> Spawnables { get; set; } = new();

public IRelayCommand AddSpawnableTypeCommand { get; }
Expand Down Expand Up @@ -90,12 +91,12 @@ protected void ExportToNewFile(object cmdParam)
}
protected void SetMinDamage(double value)
{
if(SelectedItems is null)
if (SelectedItems is null)
{
return;
}
var viewModels = SelectedItems.Cast<SpawnableTypeViewModel>();
viewModels.AsParallel().ForAll(spawnable => spawnable.MinDamage=value);
viewModels.AsParallel().ForAll(spawnable => spawnable.MinDamage = value);
}
protected void SetMaxDamage(double value)
{
Expand Down
8 changes: 7 additions & 1 deletion src/DayzServerTools.Windows/Resources/Strings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
<system:String x:Key="ItemTypesCountInPlayerTooltip">Does the spawner count items in players inventory when setting items to nominal and minimum values.</system:String>
<system:String x:Key="ItemTypesCraftedTooltip">Mark player craftable items.</system:String>
<system:String x:Key="ItemTypesDelootTooltip">Mark dynamic event loot objects (e.g. in helicrashes).</system:String>


<system:String x:Key="SpawnableTypesNameTooltip">Item Class Name (as in types.xml)</system:String>
<system:String x:Key="SpawnableTypesHoarderTooltip">Whether the element is treated as a persistent container</system:String>
<system:String x:Key="SpawnableTypesMinDamageTooltip" xml:space="preserve">Minimum amount of damage dealt to an item upon spawning.&#13;The value NaN means that the default settings from globals.xml will be used.</system:String>
<system:String x:Key="SpawnableTypesMaxDamageTooltip" xml:space="preserve">Maximum amount of damage dealt to an item upon spawning.&#13;The value NaN means that the default settings from globals.xml will be used.</system:String>
<system:String x:Key="SpawnableTypesTagTooltip">Arcane parameter used only for one item in vanilla cfgspawnabletypes.xml</system:String>

<system:String x:Key="TraderItemNameTooltip">Item Class Name (as in types.xml)</system:String>
<system:String x:Key="TraderQuantityModifierTooltip" xml:space="preserve">Quantity Modifier:&#13;0..X - Number items in stack&#13;* - Maximum items in stack&#13;W - Weapon&#13;M - Weapon magazin&#13;S - Stack Meat&#13;V - Vehicle&#13;VNK - Vehicle without Key&#13;K - Key Duplication</system:String>
<system:String x:Key="TraderBuyPriceTooltip" xml:space="preserve">Buy price in currency units.&#13;-1 means item can not be bought.</system:String>
Expand Down
51 changes: 44 additions & 7 deletions src/DayzServerTools.Windows/Views/SpawnableTypesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<controls:BindableMultiSelectDataGrid Grid.Column="0" AutoGenerateColumns="False"
<CheckBox Grid.Row="0" IsChecked="{Binding ShowTagColumn}" Content="Show tag"
HorizontalAlignment="Right"/>
<!--Capture DataContext for DataGridTemplateColumn-->
<FrameworkElement x:Name="dummyElement" Visibility="Collapsed"/>
<controls:BindableMultiSelectDataGrid Grid.Row="1" Grid.Column="0" AutoGenerateColumns="False"
x:Name="datagrid" ItemsSource="{Binding Spawnables}"
SelectedItem="{Binding SelectedItem}"
SelectedItems="{Binding SelectedItems, Mode=OneWayToSource}">
Expand All @@ -27,15 +35,44 @@
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<DataGridCheckBoxColumn Header="Hoarder" Binding="{Binding Hoarder, Converter={StaticResource ObjectToBooleanConverter}}"/>
<DataGridTextColumn Header="Min Damage" Binding="{Binding MinDamage}"/>
<DataGridTextColumn Header="Max Damage" Binding="{Binding MaxDamage}"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ToolTip" Value="{StaticResource SpawnableTypesNameTooltip}" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridCheckBoxColumn Header="Hoarder" Binding="{Binding Hoarder, Converter={StaticResource ObjectToBooleanConverter}}">
<DataGridCheckBoxColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ToolTip" Value="{StaticResource SpawnableTypesHoarderTooltip}" />
</Style>
</DataGridCheckBoxColumn.HeaderStyle>
</DataGridCheckBoxColumn>
<DataGridTextColumn Header="Min Damage" Binding="{Binding MinDamage}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ToolTip" Value="{StaticResource SpawnableTypesMinDamageTooltip}" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Max Damage" Binding="{Binding MaxDamage}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ToolTip" Value="{StaticResource SpawnableTypesMaxDamageTooltip}" />
</Style>
</DataGridTextColumn.HeaderStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="Cargo Presets" IsReadOnly="True"
Binding="{Binding Cargo.Count, Mode=OneWay}"/>
<DataGridTextColumn Header="Attachments Presets" IsReadOnly="True"
Binding="{Binding Attachments.Count, Mode=OneWay}"/>
<DataGridTemplateColumn Header="Tag" SortMemberPath="Tag">
<DataGridTemplateColumn Header="Tag" SortMemberPath="Tag" Visibility="{Binding Source={x:Reference dummyElement}, Path=DataContext.ShowTagColumn, Converter={StaticResource boolToVisibilityConverter}}">
<DataGridTemplateColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="ToolTip" Value="{StaticResource SpawnableTypesTagTooltip}" />
</Style>
</DataGridTemplateColumn.HeaderStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Padding="2">
Expand All @@ -57,7 +94,7 @@
</DataGridTemplateColumn>
</DataGrid.Columns>
</controls:BindableMultiSelectDataGrid>
<ContentControl Grid.Column="1" Content="{Binding ElementName=datagrid, Path=SelectedItem}">
<ContentControl Grid.Row="1" Grid.Column="1" Content="{Binding ElementName=datagrid, Path=SelectedItem}">
<ContentControl.ContentTemplate>
<DataTemplate>
<Grid>
Expand Down

0 comments on commit f6add56

Please sign in to comment.