Skip to content

Commit

Permalink
Support all the maps
Browse files Browse the repository at this point in the history
Added each of the standard maps.
Added coordinate calibrations for each map that should be good, but are mostly untested.
When a development version is run there are now additional buttons for map calibration and dummy map points.
Loading species in the background is now more visible, with status bar text and showing the loading cog.
  • Loading branch information
coldino committed Jan 27, 2018
1 parent 6c8c289 commit f56c624
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 33 deletions.
11 changes: 8 additions & 3 deletions LarkatorGUI/ArkReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ArkReader
public int NumberOfSpecies { get { return ClassMapping.Count; } }
public bool Tamed { get; private set; }

public bool ForceNextConversion { get; set; }

Dictionary<string, string> ClassMapping = new Dictionary<string, string>();
private bool executing;
private string outputDir;
Expand All @@ -35,13 +37,14 @@ private void EnsureDirectory(string outputDir)
if (!Directory.Exists(outputDir)) Directory.CreateDirectory(outputDir);
}

public async Task PerformConversion(bool force = false)
public async Task PerformConversion(bool force, string dirName)
{
outputDir = Path.Combine(Properties.Settings.Default.OutputDir, Tamed ? "tamed" : "wild");
outputDir = Path.Combine(Properties.Settings.Default.OutputDir, dirName, Tamed ? "tamed" : "wild");
EnsureDirectory(outputDir);

if (force || IsConversionRequired())
if (force || ForceNextConversion || IsConversionRequired())
{
ForceNextConversion = false;
await RunArkTools();
}

Expand Down Expand Up @@ -116,8 +119,10 @@ private async Task LoadClassesJson()
.Where(m => !m.Cls.Contains("BP_Ocean_C"))
.ToDictionary(m => m.Name, m => m.Cls);

#if WARN_ON_EMPTY_CLASSES
if (ClassMapping.Count <= 0)
throw new ExternalToolsException("ARK Tools produced no classes output");
#endif
}

private async Task LoadSpecies(string speciesName)
Expand Down
58 changes: 58 additions & 0 deletions LarkatorGUI/CalibrationWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Window x:Class="LarkatorGUI.CalibrationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LarkatorGUI"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:Calibration, IsDesignTimeCreatable=True}"
Title="CalibrationWindow" SizeToContent="WidthAndHeight">
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Canvas Grid.Row="0" Panel.ZIndex="100">
<Line StrokeThickness="2" Stroke="HotPink" X1="0" X2="1000" Y1="{Binding Bounds.Y1}" Y2="{Binding Bounds.Y1}"/>
<Line StrokeThickness="2" Stroke="HotPink" X1="0" X2="1000" Y1="{Binding Bounds.Y2}" Y2="{Binding Bounds.Y2}"/>
<Line StrokeThickness="2" Stroke="HotPink" Y1="0" Y2="1000" X1="{Binding Bounds.X1}" X2="{Binding Bounds.X1}"/>
<Line StrokeThickness="2" Stroke="HotPink" Y1="0" Y2="1000" X1="{Binding Bounds.X2}" X2="{Binding Bounds.X2}"/>
</Canvas>
<Image x:Name="img" Grid.Row="0" Source="{Binding Image}" Height="1000" Width="1000" Stretch="Uniform" MouseDown="Image_MouseDown" MouseUp="Image_MouseUp" MouseMove="Image_MouseMove"/>
<Grid Grid.Row="1" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Margin="8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="X1" Margin="8,2"/>
<TextBox Text="{Binding Bounds.X1, Mode=TwoWay}" Width="64"/>
<TextBlock Text="X2" Margin="8,2"/>
<TextBox Text="{Binding Bounds.X2, Mode=TwoWay}" Width="64"/>
<TextBlock Text="Y1" Margin="8,2"/>
<TextBox Text="{Binding Bounds.Y1, Mode=TwoWay}" Width="64"/>
<TextBlock Text="Y1" Margin="8,2"/>
<TextBox Text="{Binding Bounds.Y2, Mode=TwoWay}" Width="64"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="ARK filename" Margin="8,2"/>
<TextBox Text="{Binding Filename, Mode=TwoWay}" Width="100"/>
<TextBlock Text="Image" Margin="8,2"/>
<TextBox Text="{Binding Image, Mode=TwoWay}" Width="100"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="+X" Margin="8,2"/>
<TextBox Text="{Binding OffsetX}" Width="32"/>
<TextBlock Text="+Y" Margin="8,2"/>
<TextBox Text="{Binding OffsetY}" Width="32"/>
<TextBlock Text="*X" Margin="8,2"/>
<TextBox Text="{Binding ScaleX}" Width="64"/>
<TextBlock Text="*Y" Margin="8,2"/>
<TextBox Text="{Binding ScaleY}" Width="64"/>
</StackPanel>
</StackPanel>
<TextBox Grid.Column="1" Text="{Binding Output}" Margin="8" MinWidth="300" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" IsReadOnly="True"/>
</Grid>
</Grid>
</Window>
219 changes: 219 additions & 0 deletions LarkatorGUI/CalibrationWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
using Newtonsoft.Json;
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace LarkatorGUI
{
/// <summary>
/// Interaction logic for CalibrationWindow.xaml
/// </summary>
public partial class CalibrationWindow : Window
{
private bool dragging;
private Bounds boundsMult;
private Calibration calibration;

public CalibrationWindow(Calibration calibration)
{
DataContext = calibration;
this.calibration = calibration;

InitializeComponent();
}

private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{
var img = (Image)sender;
var pos = Mouse.GetPosition(img);
pos.X /= img.ActualWidth;
pos.Y /= img.ActualHeight;

dragging = true;
boundsMult = new Bounds
{
X1 = pos.X < 0.5 ? 1 : 0,
X2 = pos.X > 0.5 ? 1 : 0,
Y1 = pos.Y < 0.5 ? 1 : 0,
Y2 = pos.Y > 0.5 ? 1 : 0
};

img.CaptureMouse();
}

private void Image_MouseUp(object sender, MouseButtonEventArgs e)
{
if (!dragging) return;
var img = (Image)sender;
img.ReleaseMouseCapture();
dragging = false;
}

private void Image_MouseMove(object sender, MouseEventArgs e)
{
if (!dragging) return;

var img = (Image)sender;
var pos = Mouse.GetPosition(img);

calibration.Bounds.X1 = UpdateBound(calibration.Bounds.X1, boundsMult.X1, pos.X);
calibration.Bounds.X2 = UpdateBound(calibration.Bounds.X2, boundsMult.X2, pos.X);
calibration.Bounds.Y1 = UpdateBound(calibration.Bounds.Y1, boundsMult.Y1, pos.Y);
calibration.Bounds.Y2 = UpdateBound(calibration.Bounds.Y2, boundsMult.Y2, pos.Y);

calibration.Recalculate();
}

private double UpdateBound(double cal, double mult, double x)
{
return cal * (1 - mult) + x * mult;
}
}

public class ExampleCalibration : Calibration
{
public ExampleCalibration()
{
Bounds = new Bounds { X1 = 100, X2 = 800, Y1 = 150, Y2 = 750 };
}
}

[DataContract]
public class Calibration : DependencyObject
{
[JsonIgnore]
public Bounds Bounds
{
get { return (Bounds)GetValue(BoundsProperty); }
set { SetValue(BoundsProperty, value); }
}

[DataMember]
public string Filename
{
get { return (string)GetValue(FilenameProperty); }
set { SetValue(FilenameProperty, value); }
}

[DataMember]
public double OffsetX
{
get { return (double)GetValue(OffsetXProperty); }
set { SetValue(OffsetXProperty, value); }
}

[DataMember]
public double OffsetY
{
get { return (double)GetValue(OffsetYProperty); }
set { SetValue(OffsetYProperty, value); }
}

[DataMember]
public double ScaleX
{
get { return (double)GetValue(ScaleXProperty); }
set { SetValue(ScaleXProperty, value); }
}

[DataMember]
public double ScaleY
{
get { return (double)GetValue(ScaleYProperty); }
set { SetValue(ScaleYProperty, value); }
}

[JsonIgnore]
public string Output
{
get { return (string)GetValue(OutputProperty); }
set { SetValue(OutputProperty, value); }
}

public static readonly DependencyProperty OutputProperty =
DependencyProperty.Register("Output", typeof(string), typeof(Calibration), new PropertyMetadata(""));

public static readonly DependencyProperty ScaleYProperty =
DependencyProperty.Register("ScaleY", typeof(double), typeof(Calibration), new PropertyMetadata(0.0));

public static readonly DependencyProperty ScaleXProperty =
DependencyProperty.Register("ScaleX", typeof(double), typeof(Calibration), new PropertyMetadata(0.0));

public static readonly DependencyProperty OffsetYProperty =
DependencyProperty.Register("OffsetY", typeof(double), typeof(Calibration), new PropertyMetadata(0.0));

public static readonly DependencyProperty OffsetXProperty =
DependencyProperty.Register("OffsetX", typeof(double), typeof(Calibration), new PropertyMetadata(0.0));

public static readonly DependencyProperty ImageProperty =
DependencyProperty.Register("Image", typeof(string), typeof(Calibration), new PropertyMetadata(""));

public static readonly DependencyProperty FilenameProperty =
DependencyProperty.Register("Filename", typeof(string), typeof(Calibration), new PropertyMetadata(""));

public static readonly DependencyProperty BoundsProperty =
DependencyProperty.Register("Bounds", typeof(Bounds), typeof(Calibration), new PropertyMetadata(null));

public void Recalculate()
{
if (Bounds == null) return;

var minX = Math.Min(Bounds.X1, Bounds.X2);
var minY = Math.Min(Bounds.Y1, Bounds.Y2);
var maxX = Math.Max(Bounds.X1, Bounds.X2);
var maxY = Math.Max(Bounds.Y1, Bounds.Y2);

ScaleX = (maxX - minX) / 80.0;
ScaleY = (maxY - minY) / 80.0;

OffsetX = minX - ScaleX * 10;
OffsetY = minY - ScaleY * 10;

Output = JsonConvert.SerializeObject(this, Formatting.Indented);
}
}

[DebuggerDisplay("X={X1}-{X2}, Y={Y1}-{Y2}")]
public class Bounds : DependencyObject
{
public double X1
{
get { return (double)GetValue(X1Property); }
set { SetValue(X1Property, value); }
}

public double X2
{
get { return (double)GetValue(X2Property); }
set { SetValue(X2Property, value); }
}

public double Y1
{
get { return (double)GetValue(Y1Property); }
set { SetValue(Y1Property, value); }
}

public double Y2
{
get { return (double)GetValue(Y2Property); }
set { SetValue(Y2Property, value); }
}

public static readonly DependencyProperty Y2Property =
DependencyProperty.Register("Y2", typeof(double), typeof(Bounds), new PropertyMetadata(0.0));

public static readonly DependencyProperty Y1Property =
DependencyProperty.Register("Y1", typeof(double), typeof(Bounds), new PropertyMetadata(0.0));

public static readonly DependencyProperty X2Property =
DependencyProperty.Register("X2", typeof(double), typeof(Bounds), new PropertyMetadata(0.0));

public static readonly DependencyProperty X1Property =
DependencyProperty.Register("X1", typeof(double), typeof(Bounds), new PropertyMetadata(0.0));
}

}
24 changes: 21 additions & 3 deletions LarkatorGUI/LarkatorGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\program files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.Serialization.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand All @@ -116,6 +121,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ArkReader.cs" />
<Compile Include="CalibrationWindow.xaml.cs">
<DependentUpon>CalibrationWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DinoViewModel.cs" />
<Compile Include="ExternalToolsException.cs" />
<Compile Include="DirectoryEntryBox.xaml.cs">
Expand All @@ -129,6 +137,7 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converters.cs" />
<Compile Include="MapPositionConverter.cs" />
<Compile Include="NumericEntryControl.xaml.cs">
<DependentUpon>NumericEntryControl.xaml</DependentUpon>
</Compile>
Expand All @@ -143,6 +152,10 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="WindowAspectRatio.cs" />
<Page Include="CalibrationWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="DirectoryEntryBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -189,6 +202,7 @@
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="calibrations.json" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand All @@ -215,9 +229,6 @@
<ItemGroup>
<Resource Include="imgs\nogender.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="imgs\hires_map.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="compass.ico" />
</ItemGroup>
Expand All @@ -233,5 +244,12 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="imgs\map_Aberration.jpg" />
<Resource Include="imgs\map_Ragnarok.jpg" />
<Resource Include="imgs\map_ScorchedEarth.jpg" />
<Resource Include="imgs\map_TheCenter.jpg" />
<Resource Include="imgs\map_TheIsland.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading

0 comments on commit f56c624

Please sign in to comment.