Skip to content

Commit 53c04f3

Browse files
committed
Add project files.
1 parent 104792b commit 53c04f3

25 files changed

+1435
-0
lines changed

AnnoMapEditor.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32526.322
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnnoMapEditor", "AnnoMapEditor\AnnoMapEditor.csproj", "{4CA72037-B2D3-42B3-BCEC-70D4CBE1134F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4CA72037-B2D3-42B3-BCEC-70D4CBE1134F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4CA72037-B2D3-42B3-BCEC-70D4CBE1134F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4CA72037-B2D3-42B3-BCEC-70D4CBE1134F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4CA72037-B2D3-42B3-BCEC-70D4CBE1134F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {417E4BBE-1275-4EA3-94BC-0F9EBE630CD1}
24+
EndGlobalSection
25+
EndGlobal

AnnoMapEditor/AnnoMapEditor.csproj

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net6.0-windows7.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWPF>true</UseWPF>
8+
<StartupObject>AnnoMapEditor.App</StartupObject>
9+
<PlatformTarget>x64</PlatformTarget>
10+
<LangVersion>9</LangVersion>
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
13+
<!-- <GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute> -->
14+
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
15+
<GenerateAssemblyInformationalVersionAttribute>true</GenerateAssemblyInformationalVersionAttribute>
16+
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
17+
</PropertyGroup>
18+
19+
<!-- use git describe to set assembly version -->
20+
<Target Name="SetGitVersion" BeforeTargets="InitializeSourceControlInformation">
21+
<Exec Command="git describe --tags" ConsoleToMSBuild="True" IgnoreExitCode="True">
22+
<Output PropertyName="GitDescribe" TaskParameter="ConsoleOutput" />
23+
</Exec>
24+
<PropertyGroup>
25+
<!-- <AssemblyVersion>$(GitDescribe)</AssemblyVersion> -->
26+
<FileVersion>$(GitDescribe)</FileVersion>
27+
<InformationalVersion>$(GitDescribe)</InformationalVersion>
28+
</PropertyGroup>
29+
</Target>
30+
<ItemGroup>
31+
<Content Include="Assets\app.ico" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<Reference Include="FileDBSerializer">
40+
<HintPath>External\FileDBSerializer.dll</HintPath>
41+
</Reference>
42+
</ItemGroup>
43+
44+
<ItemGroup>
45+
<Compile Update="Utils\UserSettings.Designer.cs">
46+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
47+
<AutoGen>True</AutoGen>
48+
<DependentUpon>UserSettings.settings</DependentUpon>
49+
</Compile>
50+
</ItemGroup>
51+
52+
<ItemGroup>
53+
<None Update="Utils\UserSettings.settings">
54+
<Generator>SettingsSingleFileGenerator</Generator>
55+
<LastGenOutput>UserSettings.Designer.cs</LastGenOutput>
56+
</None>
57+
</ItemGroup>
58+
59+
</Project>

AnnoMapEditor/App.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="AnnoMapEditor.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:AnnoMapEditor"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

AnnoMapEditor/App.xaml.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System.Windows;
2+
3+
namespace AnnoMapEditor
4+
{
5+
public partial class App : Application
6+
{
7+
}
8+
}

AnnoMapEditor/AssemblyInfo.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

AnnoMapEditor/Assets/app.ico

83.2 KB
Binary file not shown.

AnnoMapEditor/Controls/MapObject.xaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<UserControl
2+
x:Class="AnnoMapEditor.Controls.MapObject"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
mc:Ignorable="d"
8+
Width="1"
9+
Height="1">
10+
11+
<Grid>
12+
<Grid.ColumnDefinitions>
13+
<ColumnDefinition />
14+
</Grid.ColumnDefinitions>
15+
<Canvas Name="canvas" Grid.Column="0" />
16+
<Border Name="titleBackground" Grid.Column="0"
17+
CornerRadius="10"
18+
Padding="4,0,4,0"
19+
Background="#80000000"
20+
VerticalAlignment="Center" HorizontalAlignment="Center"
21+
RenderTransformOrigin=".5,.5">
22+
<Border.RenderTransform>
23+
<RotateTransform Angle="45" />
24+
</Border.RenderTransform>
25+
<TextBlock Foreground="White" Name="title" FontSize="50" TextAlignment="Center" />
26+
</Border>
27+
</Grid>
28+
</UserControl>
+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Numerics;
4+
using System.Windows.Controls;
5+
using System.Windows.Media;
6+
using System.Windows;
7+
using System.Windows.Shapes;
8+
using System.Windows.Media.Imaging;
9+
using AnnoMapEditor.Models;
10+
11+
namespace AnnoMapEditor.Controls
12+
{
13+
public partial class MapObject : UserControl
14+
{
15+
static readonly Dictionary<string, SolidColorBrush> MapObjectColors = new()
16+
{
17+
["Normal"] = new(Color.FromArgb(255, 8, 172, 137)),
18+
["Starter"] = new(Color.FromArgb(255, 130, 172, 8)),
19+
["ThirdParty"] = new(Color.FromArgb(255, 189, 73, 228)),
20+
["Decoration"] = new(Color.FromArgb(255, 151, 162, 125)),
21+
["PirateIsland"] = new(Color.FromArgb(255, 186, 0, 36)),
22+
["Cliff"] = new(Color.FromArgb(255, 103, 105, 114))
23+
};
24+
static readonly Dictionary<IslandType, int> ZIndex = new()
25+
{
26+
[IslandType.Normal] = 3,
27+
[IslandType.Starter] = 2,
28+
[IslandType.ThirdParty] = 4,
29+
[IslandType.Decoration] = 1,
30+
[IslandType.PirateIsland] = 4,
31+
[IslandType.Cliff] = 0
32+
};
33+
static readonly SolidColorBrush White = new(Color.FromArgb(255, 255, 255, 255));
34+
static readonly SolidColorBrush Yellow = new(Color.FromArgb(255, 234, 224, 83));
35+
readonly Session session;
36+
37+
public MapObject(Session session)
38+
{
39+
InitializeComponent();
40+
41+
this.session = session;
42+
DataContextChanged += MapObject_DataContextChanged;
43+
}
44+
45+
private async void MapObject_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
46+
{
47+
if (DataContext is not Island island)
48+
return;
49+
50+
if (island.ElementType == 2)
51+
{
52+
var circle = new Ellipse()
53+
{
54+
Width = 20,
55+
Height = 20,
56+
Fill = Yellow,
57+
};
58+
59+
Canvas.SetLeft(circle, -10);
60+
Canvas.SetTop(circle, -10);
61+
canvas.Children.Add(circle);
62+
63+
Width = 1;
64+
Height = 1;
65+
Canvas.SetLeft(this, island.Position.X);
66+
Canvas.SetTop(this, session.Size.Y - island.Position.Y);
67+
Panel.SetZIndex(this, 100);
68+
return;
69+
}
70+
else
71+
{
72+
73+
Width = island.SizeInTiles;
74+
Height = island.SizeInTiles;
75+
Canvas.SetLeft(this, island.Position.X);
76+
Canvas.SetTop(this, session.Size.Y - island.Position.Y - island.SizeInTiles);
77+
Panel.SetZIndex(this, ZIndex[island.Type]);
78+
79+
Image? image = null;
80+
if (island.ImageFile != null)
81+
{
82+
image = new();
83+
BitmapImage? png = null;
84+
await System.Threading.Tasks.Task.Run(() =>
85+
{
86+
png = new();
87+
try
88+
{
89+
using var stream = File.OpenRead(island.ImageFile);
90+
png.BeginInit();
91+
png.StreamSource = stream;
92+
png.CacheOption = BitmapCacheOption.OnLoad;
93+
png.EndInit();
94+
png.Freeze();
95+
}
96+
catch
97+
{
98+
png = null;
99+
}
100+
});
101+
102+
image.Width = island.SizeInTiles;
103+
image.Height = island.SizeInTiles;
104+
image.RenderTransform = new RotateTransform(island.Rotation * -90);
105+
image.RenderTransformOrigin = new Point(0.5, 0.5);
106+
image.Source = png;
107+
canvas.Children.Add(image);
108+
}
109+
110+
111+
Rectangle rect = new();
112+
if (image is not null)
113+
{
114+
rect.Stroke = MapObjectColors[island.Type.ToString()];
115+
rect.StrokeThickness = 5;
116+
}
117+
else
118+
{
119+
rect.Fill = MapObjectColors[island.Type.ToString()];
120+
}
121+
rect.Width = island.SizeInTiles;
122+
rect.Height = island.SizeInTiles;
123+
canvas.Children.Add(rect);
124+
125+
var circle = new Ellipse()
126+
{
127+
Width = 10,
128+
Height = 10,
129+
Fill = White,
130+
};
131+
132+
Canvas.SetLeft(circle, 0);
133+
Canvas.SetTop(circle, island.SizeInTiles - 10);
134+
canvas.Children.Add(circle);
135+
136+
if (!string.IsNullOrEmpty(island.Label))
137+
title.Text = island.Label;
138+
else if (island.Type == IslandType.PirateIsland)
139+
title.Text = "Pirate";
140+
else if (island.Type == IslandType.ThirdParty)
141+
title.Text = "3rd";
142+
else if (island.IsPool)
143+
{
144+
title.Text = island.Size.ToString();
145+
if (island.Type == IslandType.Starter)
146+
title.Text = "Starter\n" + title.Text;
147+
}
148+
else
149+
title.Text = "";
150+
151+
titleBackground.Visibility = title.Text == "" ? Visibility.Collapsed : Visibility.Visible;
152+
}
153+
}
154+
}
155+
}

AnnoMapEditor/Controls/MapView.xaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<UserControl
2+
x:Class="AnnoMapEditor.Controls.MapView"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:AnnoMapEditor.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d">
9+
10+
<Grid Width="auto" Height="auto" VerticalAlignment="Center" HorizontalAlignment="Center">
11+
<Canvas Name="rotationCanvas" RenderTransformOrigin="0.5, 0.5" Width="0" Height="0">
12+
<Canvas.RenderTransform>
13+
<RotateTransform Angle="-45"/>
14+
</Canvas.RenderTransform>
15+
<Canvas Name="sessionCanvas" Width="0" Height="0" />
16+
</Canvas>
17+
</Grid>
18+
</UserControl>

0 commit comments

Comments
 (0)