Skip to content

Commit 44d62f0

Browse files
author
Andreas Kurka
committed
Renamed ProjectSettingsControl to CompilationSettingsControl
Created a dedicated tab for MapInformation Added reload and save funktionality for MapInformation aka mapinfo.lua
1 parent 414d8b7 commit 44d62f0

File tree

7 files changed

+180
-61
lines changed

7 files changed

+180
-61
lines changed

MapCreationTool/MapCreationTool/Controls/ProjectSettingsControl.xaml renamed to MapCreationTool/MapCreationTool/Controls/CompilationSettingsControl.xaml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,19 @@
1-
<UserControl x:Class="MapCreationTool.Controls.ProjectSettingsControl"
1+
<UserControl x:Class="MapCreationTool.Controls.CompilationSettingsControl"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:MapCreationTool.Controls"
77
xmlns:compile="clr-namespace:MapCreationTool.Controls.CompileSettings"
8-
xmlns:wnd="clr-namespace:MapCreationTool.Windows"
98
xmlns:models="clr-namespace:MapCreationTool.Models"
109
mc:Ignorable="d"
11-
d:DesignHeight="450" d:DesignWidth="800"
1210
d:DataContext="{d:DesignInstance models:ProjectSettings, IsDesignTimeCreatable=true}"
13-
DataContext="{Binding Path=ProjectSettings}">
11+
DataContext="{Binding Path=ProjectSettings}"
12+
d:DesignHeight="450" d:DesignWidth="800">
1413
<Grid>
15-
<ScrollViewer VerticalScrollBarVisibility="Auto">
16-
<StackPanel>
17-
<StackPanel Orientation="Vertical">
18-
<Label>Mapinfo</Label>
19-
<compile:ValueCompileSetting SettingName="Name" SettingDescription="mapinfo.name" DataContext="{Binding MapInformation}"
20-
SettingIsEnabled="True" SettingEnabledLocked="True"
21-
SettingValue="{Binding Path=Name, Mode=TwoWay}"></compile:ValueCompileSetting>
22-
<compile:ValueCompileSetting SettingName="Short Name" SettingDescription="mapinfo.shortname" DataContext="{Binding MapInformation}"
23-
SettingIsEnabled="True" SettingEnabledLocked="True"
24-
SettingValue="{Binding Path=ShortName, Mode=TwoWay}"></compile:ValueCompileSetting>
25-
<compile:ValueCompileSetting SettingName="Author" SettingDescription="mapinfo.author" DataContext="{Binding MapInformation}"
26-
SettingIsEnabled="True" SettingEnabledLocked="True"
27-
SettingValue="{Binding Path=Author, Mode=TwoWay}"></compile:ValueCompileSetting>
28-
<compile:ValueCompileSetting SettingName="Version" SettingDescription="mapinfo.version" DataContext="{Binding MapInformation}"
29-
SettingIsEnabled="True" SettingEnabledLocked="True"
30-
SettingValue="{Binding Path=Version, Mode=TwoWay}"></compile:ValueCompileSetting>
31-
<compile:ValueCompileSetting SettingName="MapHardness" SettingDescription="mapinfo.maphardness" DataContext="{Binding MapInformation}"
32-
SettingIsEnabled="True" SettingEnabledLocked="True"
33-
SettingValue="{Binding Path=MapHardness, Mode=TwoWay}"></compile:ValueCompileSetting>
34-
<compile:ValueCompileSetting SettingName="Gravity" SettingDescription="mapinfo.gravity" DataContext="{Binding MapInformation}"
35-
SettingIsEnabled="True" SettingEnabledLocked="True"
36-
SettingValue="{Binding Path=Gravity, Mode=TwoWay}"></compile:ValueCompileSetting>
37-
<compile:ValueCompileSetting SettingName="Max Metal" SettingDescription="mapinfo.maxMetal" DataContext="{Binding MapInformation}"
38-
SettingIsEnabled="True" SettingEnabledLocked="True"
39-
SettingValue="{Binding Path=MaxMetal, Mode=TwoWay}"></compile:ValueCompileSetting>
40-
<compile:ValueCompileSetting SettingName="Extractor Radius" SettingDescription="mapinfo.extractorRadius" DataContext="{Binding MapInformation}"
41-
SettingIsEnabled="True" SettingEnabledLocked="True"
42-
SettingValue="{Binding Path=ExtractorRadius, Mode=TwoWay}"></compile:ValueCompileSetting>
43-
</StackPanel>
4414

4515
<StackPanel Orientation="Vertical">
46-
<Label>Compilation</Label>
16+
4717
<compile:ValueCompileSetting SettingName="Output file" SettingDescription="The output smf file to create. E.g Zero-Prime.smf (REQUIRED)" DataContext="{Binding CompilationSettings}"
4818
SettingDialogType="Save" FileDialogFilter="smf files (*.smf)|*.smt|All files (*.*)|*.*"
4919
SettingEnabledLocked="true" SettingIsEnabled="True"
@@ -98,7 +68,5 @@
9868

9969
</StackPanel>
10070

101-
</StackPanel>
102-
</ScrollViewer>
10371
</Grid>
10472
</UserControl>

MapCreationTool/MapCreationTool/Controls/ProjectSettingsControl.xaml.cs renamed to MapCreationTool/MapCreationTool/Controls/CompilationSettingsControl.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace MapCreationTool.Controls
1919
/// <summary>
2020
/// Interaction logic for MapSettingsControl.xaml
2121
/// </summary>
22-
public partial class ProjectSettingsControl : UserControl
22+
public partial class CompilationSettingsControl : UserControl
2323
{
2424
public ProjectSettings ProjectSettings
2525
{
@@ -30,12 +30,12 @@ public ProjectSettings ProjectSettings
3030
public static readonly DependencyProperty ProjectSettingsProperty = DependencyProperty.Register(
3131
nameof(ProjectSettings),
3232
typeof(ProjectSettings),
33-
typeof(ProjectSettingsControl),
33+
typeof(CompilationSettingsControl),
3434
new PropertyMetadata(null)
3535
);
3636

3737

38-
public ProjectSettingsControl()
38+
public CompilationSettingsControl()
3939
{
4040
InitializeComponent();
4141
}

MapCreationTool/MapCreationTool/Controls/EditMapControl.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
d:DesignHeight="450" d:DesignWidth="800">
1010
<Grid>
1111
<TabControl TabStripPlacement="Left" >
12-
<TabItem Header="Map Settings" FontSize="16">
13-
<local:ProjectSettingsControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:ProjectSettingsControl>
12+
<TabItem Header="MapInfo.lua" FontSize="16">
13+
<local:MapInfoSettingsControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:MapInfoSettingsControl>
1414
</TabItem>
1515
<TabItem Header="Terrain" FontSize="16">
1616
<local:TerrainControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:TerrainControl>
@@ -21,6 +21,9 @@
2121
<TabItem Header="Start-Zones" FontSize="16">
2222
<local:EditStartZonesControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:EditStartZonesControl>
2323
</TabItem>
24+
<TabItem Header="Compile Settings" FontSize="16">
25+
<local:CompilationSettingsControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:CompilationSettingsControl>
26+
</TabItem>
2427
<TabItem Header="Compile" FontSize="16">
2528
<local:CompileMapControl Margin="10, 10" ProjectSettings="{Binding Path=ViewModel.SelectedTab.ProjectSettings, RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindow }}}"></local:CompileMapControl>
2629
</TabItem>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<UserControl x:Class="MapCreationTool.Controls.MapInfoSettingsControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MapCreationTool.Controls"
7+
xmlns:compile="clr-namespace:MapCreationTool.Controls.CompileSettings"
8+
xmlns:models="clr-namespace:MapCreationTool.Models"
9+
mc:Ignorable="d"
10+
d:DataContext="{d:DesignInstance models:ProjectSettings, IsDesignTimeCreatable=true}"
11+
DataContext="{Binding Path=ProjectSettings}"
12+
d:DesignHeight="450" d:DesignWidth="800">
13+
<Grid>
14+
<StackPanel Orientation="Vertical">
15+
<Label>Mapinfo.lua</Label>
16+
<compile:ValueCompileSetting SettingName="Name" SettingDescription="mapinfo.name" DataContext="{Binding MapInformation}"
17+
SettingIsEnabled="True" SettingEnabledLocked="True"
18+
SettingValue="{Binding Path=Name, Mode=TwoWay}"></compile:ValueCompileSetting>
19+
<compile:ValueCompileSetting SettingName="Short Name" SettingDescription="mapinfo.shortname" DataContext="{Binding MapInformation}"
20+
SettingIsEnabled="True" SettingEnabledLocked="True"
21+
SettingValue="{Binding Path=ShortName, Mode=TwoWay}"></compile:ValueCompileSetting>
22+
<compile:ValueCompileSetting SettingName="Description" SettingDescription="mapinfo.description" DataContext="{Binding MapInformation}"
23+
SettingIsEnabled="True" SettingEnabledLocked="True"
24+
SettingValue="{Binding Path=Description, Mode=TwoWay}"></compile:ValueCompileSetting>
25+
<compile:ValueCompileSetting SettingName="Author" SettingDescription="mapinfo.author" DataContext="{Binding MapInformation}"
26+
SettingIsEnabled="True" SettingEnabledLocked="True"
27+
SettingValue="{Binding Path=Author, Mode=TwoWay}"></compile:ValueCompileSetting>
28+
<compile:ValueCompileSetting SettingName="Version" SettingDescription="mapinfo.version" DataContext="{Binding MapInformation}"
29+
SettingIsEnabled="True" SettingEnabledLocked="True"
30+
SettingValue="{Binding Path=Version, Mode=TwoWay}"></compile:ValueCompileSetting>
31+
<compile:ValueCompileSetting SettingName="MapHardness" SettingDescription="mapinfo.maphardness" DataContext="{Binding MapInformation}"
32+
SettingIsEnabled="True" SettingEnabledLocked="True"
33+
SettingValue="{Binding Path=MapHardness, Mode=TwoWay}"></compile:ValueCompileSetting>
34+
<compile:ValueCompileSetting SettingName="Gravity" SettingDescription="mapinfo.gravity" DataContext="{Binding MapInformation}"
35+
SettingIsEnabled="True" SettingEnabledLocked="True"
36+
SettingValue="{Binding Path=Gravity, Mode=TwoWay}"></compile:ValueCompileSetting>
37+
<compile:ValueCompileSetting SettingName="Max Metal" SettingDescription="mapinfo.maxMetal" DataContext="{Binding MapInformation}"
38+
SettingIsEnabled="True" SettingEnabledLocked="True"
39+
SettingValue="{Binding Path=MaxMetal, Mode=TwoWay}"></compile:ValueCompileSetting>
40+
<compile:ValueCompileSetting SettingName="Extractor Radius" SettingDescription="mapinfo.extractorRadius" DataContext="{Binding MapInformation}"
41+
SettingIsEnabled="True" SettingEnabledLocked="True"
42+
SettingValue="{Binding Path=ExtractorRadius, Mode=TwoWay}"></compile:ValueCompileSetting>
43+
<Separator>
44+
</Separator>
45+
<Grid>
46+
<Grid.ColumnDefinitions>
47+
<ColumnDefinition Width="80"></ColumnDefinition>
48+
<ColumnDefinition></ColumnDefinition>
49+
<ColumnDefinition Width="80"></ColumnDefinition>
50+
51+
</Grid.ColumnDefinitions>
52+
<Grid.RowDefinitions>
53+
<RowDefinition></RowDefinition>
54+
</Grid.RowDefinitions>
55+
<Button Height="40" Grid.Column="0" Grid.Row="0" Name="btnReload" Click="btnReload_Click">Reload</Button>
56+
<Button Height="40" Grid.Column="2" Grid.Row="0" Name="btnSave" Click="btnSave_Click">Save</Button>
57+
</Grid>
58+
59+
</StackPanel>
60+
61+
</Grid>
62+
</UserControl>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using MapCreationTool.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using System.Windows.Documents;
11+
using System.Windows.Input;
12+
using System.Windows.Media;
13+
using System.Windows.Media.Imaging;
14+
using System.Windows.Navigation;
15+
using System.Windows.Shapes;
16+
17+
namespace MapCreationTool.Controls
18+
{
19+
/// <summary>
20+
/// Interaction logic for MapInfoSettings.xaml
21+
/// </summary>
22+
public partial class MapInfoSettingsControl : UserControl
23+
{
24+
public ProjectSettings ProjectSettings
25+
{
26+
get { return (ProjectSettings)GetValue(ProjectSettingsProperty); }
27+
set { SetValue(ProjectSettingsProperty, value); }
28+
}
29+
30+
public static readonly DependencyProperty ProjectSettingsProperty = DependencyProperty.Register(
31+
nameof(ProjectSettings),
32+
typeof(ProjectSettings),
33+
typeof(MapInfoSettingsControl),
34+
new PropertyMetadata(null)
35+
);
36+
37+
public MapInfoSettingsControl()
38+
{
39+
InitializeComponent();
40+
}
41+
42+
private void btnReload_Click(object sender, RoutedEventArgs e)
43+
{
44+
ProjectSettings.MapInformation = MapInformation.LoadFrom(ProjectSettings.MapPathInformation.mapInfoPath);
45+
}
46+
47+
private void btnSave_Click(object sender, RoutedEventArgs e)
48+
{
49+
ProjectSettings.MapInformation.SaveAs(ProjectSettings.MapPathInformation.mapInfoPath);
50+
}
51+
}
52+
}

MapCreationTool/MapCreationTool/Models/MapInformation.cs

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ namespace MapCreationTool.Models
1010
{
1111
public class MapInformation
1212
{
13-
internal LuaEditor editor;
13+
private const string AUTHOR = "author";
14+
private const string VERSION = "version";
15+
private const string SHORTNAME = "shortname";
16+
private const string NAME = "name";
17+
private const string MAX_METAL = "maxMetal";
18+
private const string MAP_HARDNESS = "maphardness";
19+
private const string GRAVITY = "gravity";
20+
private const string EXTRACTOR_RADIUS = "extractorRadius";
21+
private const string DESCRIPTION = "description";
22+
private LuaEditor editor;
1423

1524
public MapInformation()
1625
{
@@ -46,23 +55,41 @@ public static MapInformation LoadFrom(string mapInfoPath)
4655
{
4756
MapInformation result = new MapInformation();
4857
result.editor.Load(mapInfoPath);
49-
result.ReadValues();
58+
result.GetValues();
5059

5160
return result;
5261
}
62+
internal void SaveAs(string mapInfoPath)
63+
{
64+
SetValues();
65+
editor.Save(mapInfoPath);
66+
}
5367

54-
private void ReadValues()
68+
private void GetValues()
5569
{
56-
Author = editor.GetValue<string>("author");
57-
Description = editor.GetValue<string>("description");
58-
ExtractorRadius = editor.GetValue<double>("extractorRadius");
59-
Gravity = editor.GetValue<int>("gravity");
60-
MapHardness = editor.GetValue<int>("maphardness");
61-
MaxMetal = editor.GetValue<double>("maxMetal");
62-
Name = editor.GetValue<string>("name");
63-
ShortName = editor.GetValue<string>("shortname");
64-
Version = editor.GetValue<string>("version");
70+
Author = editor.GetValue<string>(AUTHOR);
71+
Description = editor.GetValue<string>(DESCRIPTION);
72+
ExtractorRadius = editor.GetValue<double>(EXTRACTOR_RADIUS);
73+
Gravity = editor.GetValue<int>(GRAVITY);
74+
MapHardness = editor.GetValue<int>(MAP_HARDNESS);
75+
MaxMetal = editor.GetValue<double>(MAX_METAL);
76+
Name = editor.GetValue<string>(NAME);
77+
ShortName = editor.GetValue<string>(SHORTNAME);
78+
Version = editor.GetValue<string>(VERSION);
6579
}
80+
private void SetValues()
81+
{
82+
editor.SetValue(AUTHOR, Author);
83+
editor.SetValue(DESCRIPTION, Description);
84+
editor.SetValue(EXTRACTOR_RADIUS, ExtractorRadius);
85+
editor.SetValue(GRAVITY, Gravity);
86+
editor.SetValue(MAP_HARDNESS, MapHardness);
87+
editor.SetValue(MAX_METAL, MaxMetal);
88+
editor.SetValue(NAME, Name);
89+
editor.SetValue(SHORTNAME, ShortName);
90+
editor.SetValue(VERSION, Version);
91+
}
92+
6693

6794
}
6895
}

MapCreationTool/MapCreationTool/Models/ProjectSettings.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using MapCreationTool.Configuration;
22
using MapCreationTool.Helpers;
3+
using MapCreationTool.WPF;
34
using System;
45
using System.Collections.Generic;
56
using System.IO;
@@ -10,23 +11,29 @@
1011

1112
namespace MapCreationTool.Models
1213
{
13-
public class ProjectSettings
14+
public class ProjectSettings : PropertyChangedBase
1415
{
1516
public const string DEFAULT_FILE_NAME = "MapCreationTool.xml";
1617
public const string GEO_VENT_FILE_NAME = "geovent.bmp";
1718

1819
private string startLocations;
20+
private MapPathInformation mapPathInformation;
1921
private MapSizeDefinition mapSizeDefinition;
22+
private MapInformation mapInformation;
23+
private CompilationSettings compilationSettings;
2024

21-
public string StartLocations { get => startLocations; set => startLocations = value; }
25+
public string StartLocations { get => startLocations; set { startLocations = value; OnPropertyChanged(); } }
26+
public MapPathInformation MapPathInformation { get => mapPathInformation; set { mapPathInformation = value; OnPropertyChanged(); } }
27+
public MapSizeDefinition MapSizeDefinition { get => mapSizeDefinition; set { mapSizeDefinition = value; OnPropertyChanged(); } }
28+
public CompilationSettings CompilationSettings { get => compilationSettings; set { compilationSettings = value; OnPropertyChanged(); } }
2229

23-
public MapSizeDefinition MapSizeDefinition { get => mapSizeDefinition; set => mapSizeDefinition = value; }
24-
25-
public MapPathInformation MapPathInformation { get; set; }
26-
public CompilationSettings CompilationSettings { get; set; }
27-
30+
/// <summary>
31+
/// Contains the information of mapinfo.lua
32+
/// </summary>
33+
/// <remarks>Not intended to be serialized with project settings, because it has it's own file: mapinfo.lua</remarks>
2834
[XmlIgnore]
29-
public MapInformation MapInformation { get; set; }
35+
public MapInformation MapInformation { get => mapInformation; set { mapInformation = value; OnPropertyChanged(); } }
36+
3037

3138
internal static ProjectSettings OpenOrCreateDefault(MapPathInformation mapPathInfo)
3239
{

0 commit comments

Comments
 (0)