Skip to content

Commit

Permalink
Reformat source
Browse files Browse the repository at this point in the history
  • Loading branch information
coldino committed Apr 3, 2021
1 parent bc96d4d commit 533521c
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 63 deletions.
2 changes: 1 addition & 1 deletion LarkatorGUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override void OnStartup(StartupEventArgs e)
RegisterExceptionHandlers();
#endif
}

private void RegisterExceptionHandlers()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Expand Down
7 changes: 3 additions & 4 deletions LarkatorGUI/ArkReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public void SetArkData(ArkData data)

private static Task<(GameObjectContainer gameObjects, float gameTime)> ReadSavegameFile(string fileName)
{
return Task.Run(() =>
{
return Task.Run(() => {
if (new FileInfo(fileName).Length > int.MaxValue)
throw new Exception("Input file is too large.");

Expand Down Expand Up @@ -109,7 +108,7 @@ public async Task PerformConversion(string saveFile)
// Read objects directly from the savegame
(GameObjectContainer gameObjectContainer, float gameTime) = await ReadSavegameFile(saveFile);

var containers = gameObjectContainer.Select(o => IdentifyCalibrationBox(o)).Where(v => v != null).Cast<(Position,string)>().ToList();
var containers = gameObjectContainer.Select(o => IdentifyCalibrationBox(o)).Where(v => v != null).Cast<(Position, string)>().ToList();

return containers;
}
Expand Down Expand Up @@ -160,7 +159,7 @@ private Dino ConvertCreature(GameObject obj)
Location = ConvertCoordsToLatLong(obj.Location),
WildLevels = new StatPoints(),
};

var status = obj.CharacterStatusComponent();
if (status != null)
{
Expand Down
16 changes: 9 additions & 7 deletions LarkatorGUI/CalibrationWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using System;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -45,15 +44,17 @@ private void Image_MouseDown(object sender, MouseButtonEventArgs e)

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

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

var img = (Image)sender;
var pos = Mouse.GetPosition(img);
Expand All @@ -73,7 +74,7 @@ private double UpdateBound(double cal, double mult, double x)

private void Filename_TextChanged(object sender, TextChangedEventArgs e)
{
calibration.Image = $"imgs\\map_{((TextBox)sender).Text}.jpg";
calibration.Image = $"imgs\\map_{((TextBox)sender).Text}.jpg";
}

private void UpdateOutput_TextChanged(object sender, TextChangedEventArgs e)
Expand Down Expand Up @@ -199,7 +200,7 @@ public string Output

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(""));

Expand All @@ -208,7 +209,8 @@ public string Output

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

var minX = Math.Min(Bounds.X1, Bounds.X2);
var minY = Math.Min(Bounds.Y1, Bounds.Y2);
Expand Down
13 changes: 9 additions & 4 deletions LarkatorGUI/Converters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Larkator.Common;

using System;
using System.Collections.Generic;
using System.Globalization;
Expand All @@ -11,8 +12,10 @@ public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool asBool) return asBool ? Visibility.Visible : Visibility.Collapsed;
if (value is int asInt) return asInt != 0 ? Visibility.Visible : Visibility.Collapsed;
if (value is bool asBool)
return asBool ? Visibility.Visible : Visibility.Collapsed;
if (value is int asInt)
return asInt != 0 ? Visibility.Visible : Visibility.Collapsed;
return Visibility.Collapsed;
}

Expand Down Expand Up @@ -83,7 +86,8 @@ public class GenderToImageConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool? gender = (bool?)value;
if (!gender.HasValue) return "imgs/nogender.png";
if (!gender.HasValue)
return "imgs/nogender.png";
if (gender.Value)
return "imgs/female.png";
else
Expand All @@ -101,7 +105,8 @@ public class GenderToLetterConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool? gender = (bool?)value;
if (!gender.HasValue) return "";
if (!gender.HasValue)
return "";
if (gender.Value)
return "F";
else
Expand Down
6 changes: 2 additions & 4 deletions LarkatorGUI/DebounceDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public void Debounce(int interval, Action<object> action,
// timer is recreated for each event and effectively
// resets the timeout. Action only fires after timeout has fully
// elapsed without other events firing in between
timer = new DispatcherTimer(TimeSpan.FromMilliseconds(interval), priority, (s, e) =>
{
timer = new DispatcherTimer(TimeSpan.FromMilliseconds(interval), priority, (s, e) => {
if (timer == null)
return;

Expand Down Expand Up @@ -97,8 +96,7 @@ public void Throttle(int interval, Action<object> action,
if (curTime.Subtract(timerStarted).TotalMilliseconds < interval)
interval -= (int)curTime.Subtract(timerStarted).TotalMilliseconds;

timer = new DispatcherTimer(TimeSpan.FromMilliseconds(interval), priority, (s, e) =>
{
timer = new DispatcherTimer(TimeSpan.FromMilliseconds(interval), priority, (s, e) => {
if (timer == null)
return;

Expand Down
1 change: 1 addition & 0 deletions LarkatorGUI/DinoViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Larkator.Common;

using System.Windows;
using System.Windows.Media;

Expand Down
1 change: 1 addition & 0 deletions LarkatorGUI/DummyMainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Larkator.Common;

using System;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down
9 changes: 6 additions & 3 deletions LarkatorGUI/FontSizeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ public sealed class FontSizeHelper

public static double GetRelativeFontSize(DependencyObject d)
{
if (d == null) throw new ArgumentNullException(nameof(d), "in GetRelativeFontSize");
if (d == null)
throw new ArgumentNullException(nameof(d), "in GetRelativeFontSize");

return (double)d.GetValue(RelativeFontSizeProperty);
}

public static void SetRelativeFontSize(DependencyObject d, double value)
{
if (d == null) throw new ArgumentNullException(nameof(d), "in SetRelativeFontSize");
if (d == null)
throw new ArgumentNullException(nameof(d), "in SetRelativeFontSize");

d.SetValue(RelativeFontSizeProperty, value);
}

private static void RelativeFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d == null) throw new ArgumentNullException(nameof(d), "in RelativeFontSizeChanged");
if (d == null)
throw new ArgumentNullException(nameof(d), "in RelativeFontSizeChanged");

d.ClearValue(TextBlock.FontSizeProperty);
var old = (double)d.GetValue(TextBlock.FontSizeProperty);
Expand Down
3 changes: 0 additions & 3 deletions LarkatorGUI/LinearRegression.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LarkatorGUI
{
Expand Down
Loading

0 comments on commit 533521c

Please sign in to comment.