diff --git a/Game/Game-csharp.sln b/Game/Game-csharp.sln
index 0b8e34b..f6c3fb1 100644
--- a/Game/Game-csharp.sln
+++ b/Game/Game-csharp.sln
@@ -23,7 +23,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
+ GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1
diff --git a/Game/Game.sln b/Game/Game.sln
index 692a937..4d128e6 100644
--- a/Game/Game.sln
+++ b/Game/Game.sln
@@ -29,7 +29,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
+ GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1
diff --git a/Game/Library/assetDatabase3 b/Game/Library/assetDatabase3
index 20387a4..6a11755 100644
Binary files a/Game/Library/assetDatabase3 and b/Game/Library/assetDatabase3 differ
diff --git a/Game/Library/metadata/00/00000000000000004000000000000000 b/Game/Library/metadata/00/00000000000000004000000000000000
index 54446c0..fb06d6e 100644
Binary files a/Game/Library/metadata/00/00000000000000004000000000000000 and b/Game/Library/metadata/00/00000000000000004000000000000000 differ
diff --git a/Game/UnityVS.Game.CSharp.csproj b/Game/UnityVS.Game.CSharp.csproj
index d0fa6ec..261e377 100644
--- a/Game/UnityVS.Game.CSharp.csproj
+++ b/Game/UnityVS.Game.CSharp.csproj
@@ -7,14 +7,16 @@
2.0
{02576F1D-BE9C-CFA7-763D-1EBF63B36977}
Library
-
+
+
Assembly-CSharp
512
{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
.NETFramework
v3.5
Unity Subset v3.5
-
+
+
Game:1
StandaloneWindows:5
5.0.0f4
@@ -86,8 +88,10 @@
-
+
+ Designer
+
-
+
\ No newline at end of file
diff --git a/Game/UnityVS.Game.v11.suo b/Game/UnityVS.Game.v11.suo
index 1a79273..d93e2be 100644
Binary files a/Game/UnityVS.Game.v11.suo and b/Game/UnityVS.Game.v11.suo differ
diff --git a/Tools/MapViewer/MapViewer/Business/MapRenderer.cs b/Tools/MapViewer/MapViewer/Business/MapRenderer.cs
index 7ece64c..5b405f3 100644
--- a/Tools/MapViewer/MapViewer/Business/MapRenderer.cs
+++ b/Tools/MapViewer/MapViewer/Business/MapRenderer.cs
@@ -41,7 +41,7 @@ namespace TransportGame.MapViewer
private readonly Color WaterColor = Colors.Navy;
private readonly Color ElevationTerrainColor = Colors.White;
- private readonly Color TerrainColor = Colors.White;
+ private readonly Color TerrainColor = Colors.Gray;
public MapRenderer()
{
diff --git a/Tools/MapViewer/MapViewer/MainWindow.xaml b/Tools/MapViewer/MapViewer/MainWindow.xaml
index ab0ca83..391c093 100644
--- a/Tools/MapViewer/MapViewer/MainWindow.xaml
+++ b/Tools/MapViewer/MapViewer/MainWindow.xaml
@@ -22,20 +22,16 @@
- Zoom:
-
-
-
-
-
+
+
+
+
- 00%
+ 00%
@@ -62,19 +58,14 @@
- Elevation
+ (All)
+ Elevation
Roads
Buildings
Vegetation
-
-
-
-
-
-
-
-
+
+
diff --git a/Tools/MapViewer/MapViewer/MainWindow.xaml.cs b/Tools/MapViewer/MapViewer/MainWindow.xaml.cs
index e4f2bd9..b14b3e4 100644
--- a/Tools/MapViewer/MapViewer/MainWindow.xaml.cs
+++ b/Tools/MapViewer/MapViewer/MainWindow.xaml.cs
@@ -15,12 +15,19 @@ namespace TransportGame.MapViewer
///
public partial class MainWindow : Window, INotifyPropertyChanged
{
+ private MapRenderer.Layers _layers = MapRenderer.Layers.All;
+
public event PropertyChangedEventHandler PropertyChanged;
+ #region Public properties
+
#region Map property
private Map _map;
+ ///
+ /// Gets the map displayed by the map viewer.
+ ///
public Map Map
{
get
@@ -42,6 +49,9 @@ namespace TransportGame.MapViewer
private string _loadedFile;
+ ///
+ /// Gets the path of the currently loaded map file.
+ ///
public string LoadedFile
{
get
@@ -63,6 +73,9 @@ namespace TransportGame.MapViewer
private BitmapSource _renderedMap;
+ ///
+ /// Gets the rendered map bitmap
+ ///
public BitmapSource RenderedMap
{
get
@@ -81,8 +94,85 @@ namespace TransportGame.MapViewer
#endregion
+ ///
+ /// Gets the map renderer
+ ///
public MapRenderer Renderer { get; private set; }
+ #region Renderer layers
+
+ ///
+ /// Gets or sets all the layers
+ ///
+ public bool? LayersAll
+ {
+ get
+ {
+ if (LayerElevation)
+ return true;
+
+ if (!LayerElevation)
+ return false;
+
+ return null;
+ }
+ set
+ {
+ if (value.HasValue)
+ {
+ LayerElevation = value.Value;
+ }
+ }
+ }
+
+ ///
+ /// Gets or sets the layer elevation layer flag
+ ///
+ public bool LayerElevation
+ {
+ get
+ {
+ return _layers.HasFlag(MapRenderer.Layers.Elevation);
+ }
+ set
+ {
+ if (value) _layers |= MapRenderer.Layers.Elevation;
+ else _layers &= ~MapRenderer.Layers.Elevation;
+
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs("LayerElevation"));
+ PropertyChanged(this, new PropertyChangedEventArgs("LayersAll"));
+ }
+ }
+ }
+
+ #endregion
+
+ ///
+ /// Gets or sets the zoom level
+ ///
+ public int ZoomLevel
+ {
+ get
+ {
+ return Renderer.Scale;
+ }
+ set
+ {
+ Renderer.Scale = value;
+ if (PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs("ZoomLevel"));
+ }
+ }
+
+ #endregion
+
+ #region Constructor
+
+ ///
+ /// Initializes the main window
+ ///
public MainWindow()
{
InitializeComponent();
@@ -92,12 +182,121 @@ namespace TransportGame.MapViewer
DataContext = this;
}
+ #endregion
+
private async Task OpenMapFile(string filename)
{
await LoadMap(filename);
await RenderMap();
}
+ private async Task LoadMap(string filename)
+ {
+ progress.Visibility = System.Windows.Visibility.Visible;
+ progressText.Text = "Loading map...";
+
+ try
+ {
+ Map = await Task.Run(() => MapStorage.Read(filename));
+ LoadedFile = filename;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error");
+ }
+
+ progress.Visibility = System.Windows.Visibility.Hidden;
+ }
+
+ private async Task RenderMap()
+ {
+ progress.Visibility = System.Windows.Visibility.Visible;
+ progressText.Text = "Rendering map...";
+
+ try
+ {
+ RenderedMap = await Renderer.RenderToImageSource(Map, _layers);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error");
+ }
+
+ progress.Visibility = System.Windows.Visibility.Hidden;
+ }
+
+ #region UI Event handlers
+
+ private async void buttonOpen_Click(object sender, RoutedEventArgs e)
+ {
+ // Open dialog
+ string filename;
+
+ if (!ShowOpenMapDialog(out filename))
+ return;
+
+ // Load file and generate image
+ await OpenMapFile(filename);
+ }
+
+ private void buttonSave_Click(object sender, RoutedEventArgs e)
+ {
+ // Show save dialog
+ string filename;
+ if (!ShowSaveMapDialog(out filename))
+ return;
+
+ // Save to filename
+ var encoder = new PngBitmapEncoder();
+ encoder.Frames.Add(BitmapFrame.Create(RenderedMap));
+
+ using (var writer = File.OpenWrite(filename))
+ {
+ encoder.Save(writer);
+ writer.Close();
+ }
+ }
+
+ private async void buttonZoomIn_Click(object sender, RoutedEventArgs e)
+ {
+ // Zoom
+ ZoomLevel++;
+
+ // Update IsEnabled
+ if (ZoomLevel >= 10)
+ buttonZoomIn.IsEnabled = false;
+ buttonZoomOut.IsEnabled = true;
+
+ // Render
+ if (Map != null)
+ await RenderMap();
+ }
+
+ private async void buttonZoomOut_Click(object sender, RoutedEventArgs e)
+ {
+ // Zoom
+ ZoomLevel--;
+
+ // Update IsEnabled
+ if (ZoomLevel <= 1)
+ buttonZoomOut.IsEnabled = false;
+ buttonZoomIn.IsEnabled = true;
+
+ // Render
+ if (Map != null)
+ await RenderMap();
+ }
+
+ private async void buttonRender_Click(object sender, RoutedEventArgs e)
+ {
+ if (Map != null)
+ await RenderMap();
+ }
+
+ #endregion
+
+ #region Helper static functions
+
private static bool ShowOpenMapDialog(out string filename)
{
OpenFileDialog dialog = new OpenFileDialog();
@@ -134,69 +333,7 @@ namespace TransportGame.MapViewer
return true;
}
- private async Task LoadMap(string filename)
- {
- progress.Visibility = System.Windows.Visibility.Visible;
- progressText.Text = "Loading map...";
+ #endregion
- try
- {
- Map = await Task.Run(() => MapStorage.Read(filename));
- LoadedFile = filename;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error");
- }
-
- progress.Visibility = System.Windows.Visibility.Hidden;
- }
-
- private async Task RenderMap()
- {
- progress.Visibility = System.Windows.Visibility.Visible;
- progressText.Text = "Rendering map...";
-
- try
- {
- RenderedMap = await Renderer.RenderToImageSource(Map);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error");
- }
-
- progress.Visibility = System.Windows.Visibility.Hidden;
- }
-
- private async void buttonOpen_Click(object sender, RoutedEventArgs e)
- {
- // Open dialog
- string filename;
-
- if (!ShowOpenMapDialog(out filename))
- return;
-
- // Load file and generate image
- await OpenMapFile(filename);
- }
-
- private void buttonSave_Click(object sender, RoutedEventArgs e)
- {
- var encoder = new PngBitmapEncoder();
- encoder.Frames.Add(BitmapFrame.Create(RenderedMap));
-
- using (var writer = File.OpenWrite(LoadedFile + ".png"))
- {
- encoder.Save(writer);
- writer.Close();
- }
- }
-
- private async void zoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (Map != null)
- await RenderMap();
- }
}
}
diff --git a/Tools/MapViewer/MapViewer/MapViewer.csproj b/Tools/MapViewer/MapViewer/MapViewer.csproj
index 53a03d3..36bc59c 100644
--- a/Tools/MapViewer/MapViewer/MapViewer.csproj
+++ b/Tools/MapViewer/MapViewer/MapViewer.csproj
@@ -110,6 +110,10 @@
+
+
+
+