Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Tweak Display and Bugfixes #241

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions ModManager/Views/Components/ModTweaker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,29 @@
<DataTemplate>
<Border
Name="HoverBorder"
Margin="2"
Background="{DynamicResource ComponentColorBrush}">
Margin="0,4"
Background="{DynamicResource ComponentColorBrush}"
BorderThickness="1"
BorderBrush="{DynamicResource InteractiveComponentColorBrush_Light}"
CornerRadius="3">
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1.8*" />
<ColumnDefinition Width="35" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>

<TextBlock Text="{Binding ExposeID}"
Style="{StaticResource IMYA_TEXT}"
VerticalAlignment="Center"
Margin="10,0,0,0"
MinWidth="150"
FontWeight="SemiBold"/>
Margin="3"
FontWeight="SemiBold"
TextWrapping="Wrap"/>
<TextBox Grid.Column="1"
Style="{StaticResource IMYA_TEXTBOX}"
Text="{Binding Value, Mode=TwoWay}"
Expand All @@ -128,7 +132,8 @@
Visibility="{Binding IsSimpleValue, Converter={StaticResource VisibleOnTrue}}"
IsEnabled="{Binding DataContext.GameSetup.IsGameRunning, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NegateBool}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ModTweaker}}}"/>
<ComboBox Grid.Column="1"
Margin="0,0,4,0"
Height="36"
Margin="0,0,0,4"
Style="{StaticResource IMYA_COMBOBOX}"
Background="{DynamicResource InteractiveComponentColorBrush}"
ItemsSource="{Binding PredefinedValues}"
Expand Down Expand Up @@ -188,6 +193,7 @@
Style="{StaticResource IMYA_TOGGLESWITCH}"
Initialized="CheckBox_Initialized"
Checked="OnValueChanged"
HorizontalAlignment="Right"
Unchecked="OnValueChanged"
IsEnabled="{Binding DataContext.GameSetup.IsGameRunning, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NegateBool}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ModTweaker}}}">
</CheckBox>
Expand All @@ -208,12 +214,18 @@
</materialDesign:PackIcon.ToolTip>
</materialDesign:PackIcon>

<Rectangle Height="1"
Fill="{DynamicResource ComponentColorBrush_Inactive}"
Grid.Row="1"
Grid.ColumnSpan="3"
Visibility="{Binding Description, Converter={StaticResource CollapsedOnEmpty}}"></Rectangle>

<!-- description -->
<TextBlock
Grid.Row="1"
Grid.Row="2"
Grid.ColumnSpan="3"
Margin="10,2,0,5"
TextWrapping="WrapWithOverflow"
Margin="4,7,0,5"
TextWrapping="Wrap"
Visibility="{Binding Description, Converter={StaticResource CollapsedOnEmpty}}"
Style="{StaticResource IMYA_TEXT}"
Text="{Binding Description}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.XPath;

namespace Imya.Models.ModTweaker.DataModel.Tweaking
{
Expand All @@ -19,6 +20,16 @@ public class ExposedModValueFactory
Expose.TryGetAttribute(TweakerConstants.DESCRIPTION, out string? description);
Expose.TryGetAttribute(TweakerConstants.TOOLTIP, out string? tooltip);

try
{
var checkPath = XPathExpression.Compile(Path);
}
catch (XPathException e)
{
Console.WriteLine($"Invalid XPath: {ExposeID} - {Path}");
return null;
}

ExposedModValueType type = ExposedModValueType.SimpleValue;
Expose.TryGetAttribute(TweakerConstants.KIND, out string? Kind);
if (Kind is string valid_kind && Enum.TryParse<ExposedModValueType>(valid_kind, out var _val))
Expand Down