Skip to content

Commit 485e693

Browse files
committed
better formatting
1 parent bc50dcd commit 485e693

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

FF4MapEdit/FF4MapEdit.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<Generator>MSBuild:Compile</Generator>
6464
<SubType>Designer</SubType>
6565
</ApplicationDefinition>
66+
<Compile Include="HexValueConverter.cs" />
6667
<Compile Include="WorldMapTriggersWindow.xaml.cs">
6768
<DependentUpon>WorldMapTriggersWindow.xaml</DependentUpon>
6869
</Compile>

FF4MapEdit/HexValueConverter.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Data;
8+
9+
namespace FF4MapEdit
10+
{
11+
public class HexValueConverter : IValueConverter
12+
{
13+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14+
{
15+
if (value is byte byteValue)
16+
return byteValue.ToString("X2");
17+
18+
return null;
19+
}
20+
21+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
if (value is string stringValue)
24+
return byte.Parse(stringValue, NumberStyles.HexNumber);
25+
26+
return null;
27+
}
28+
}
29+
}

FF4MapEdit/WorldMapTriggersWindow.xaml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,43 @@
1515
<x:Type Type="ff4:FacingDirection"/>
1616
</ObjectDataProvider.MethodParameters>
1717
</ObjectDataProvider>
18+
<local:HexValueConverter x:Key="HexValueConverter"/>
1819
<local:WorldMapTriggerDataTemplateSelector x:Key="WorldMapTriggerDataTemplateSelector"/>
1920
<DataTemplate x:Key="WorldMapTeleportTemplate" DataType="{x:Type ff4:WorldMapTeleport}">
2021
<StackPanel Orientation="Horizontal">
21-
<Label>Coords:</Label>
22-
<TextBox Text="{Binding X}"/>
23-
<TextBox Text="{Binding Y}"/>
24-
<Label>Map:</Label>
25-
<TextBox Text="{Binding DestinationMap}"/>
26-
<Label>Dest:</Label>
27-
<TextBox Text="{Binding DestinationX}"/>
28-
<TextBox Text="{Binding DestinationY}"/>
29-
<Label>Facing:</Label>
30-
<ComboBox SelectedValue="{Binding FacingDirection}" ItemsSource="{Binding Source={StaticResource facingDirection}}"></ComboBox>
22+
<Label Margin="20,0,0,0">Coords:</Label>
23+
<TextBox Width="24" Text="{Binding X, Converter={StaticResource HexValueConverter}}"/>
24+
<TextBox Width="24" Text="{Binding Y, Converter={StaticResource HexValueConverter}}"/>
25+
<Label Margin="20,0,0,0">Map:</Label>
26+
<TextBox Width="24" Text="{Binding DestinationMap, Converter={StaticResource HexValueConverter}}"/>
27+
<Label Margin="20,0,0,0">Dest:</Label>
28+
<TextBox Width="24" Text="{Binding DestinationX, Converter={StaticResource HexValueConverter}}"/>
29+
<TextBox Width="24" Text="{Binding DestinationY, Converter={StaticResource HexValueConverter}}"/>
30+
<Label Margin="20,0,0,0">Facing:</Label>
31+
<ComboBox Width="60" SelectedValue="{Binding FacingDirection}" ItemsSource="{Binding Source={StaticResource facingDirection}}"></ComboBox>
3132
</StackPanel>
3233
</DataTemplate>
3334
<DataTemplate x:Key="WorldMapEventTemplate" DataType="{x:Type ff4:WorldMapEvent}">
3435
<StackPanel Orientation="Horizontal">
35-
<Label>Coords:</Label>
36-
<TextBox Text="{Binding X}"/>
37-
<TextBox Text="{Binding Y}"/>
38-
<Label>Event Call:</Label>
39-
<TextBox Text="{Binding EventCall}"/>
36+
<Label Margin="20,0,0,0">Coords:</Label>
37+
<TextBox Width="24" Text="{Binding X, Converter={StaticResource HexValueConverter}}"/>
38+
<TextBox Width="24" Text="{Binding Y, Converter={StaticResource HexValueConverter}}"/>
39+
<Label Margin="20,0,0,0">Event Call:</Label>
40+
<TextBox Width="24" Text="{Binding EventCall, Converter={StaticResource HexValueConverter}}"/>
4041
</StackPanel>
4142
</DataTemplate>
43+
<ControlTemplate x:Key="NoScroll">
44+
<ItemsPresenter></ItemsPresenter>
45+
</ControlTemplate>
4246
</Window.Resources>
4347
<ScrollViewer>
4448
<StackPanel VerticalAlignment="Top">
4549
<Label Margin="10,15,0,0">Overworld</Label>
46-
<ListView x:Name="OverworldListView" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
50+
<ListView x:Name="OverworldListView" Template="{StaticResource NoScroll}" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
4751
<Label Margin="10,15,0,0">Underworld</Label>
48-
<ListView x:Name="UnderworldListView" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
52+
<ListView x:Name="UnderworldListView" Template="{StaticResource NoScroll}" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
4953
<Label Margin="10,15,0,0">Moon</Label>
50-
<ListView x:Name="MoonListView" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
54+
<ListView x:Name="MoonListView" Template="{StaticResource NoScroll}" ItemTemplateSelector="{StaticResource WorldMapTriggerDataTemplateSelector}"/>
5155
</StackPanel>
5256
</ScrollViewer>
5357
</Window>

0 commit comments

Comments
 (0)