mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-15 15:19:57 +00:00
Minimap improvements (#189)
Closes #187 Closes #188 Minimap performance improvements Add context menues for main player and living entities
This commit is contained in:
+5
-2
@@ -6,8 +6,8 @@ csharp_indent_labels = one_less_than_current
|
||||
csharp_using_directive_placement = outside_namespace:error
|
||||
csharp_prefer_simple_using_statement = true:error
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_style_namespace_declarations = block_scoped:silent
|
||||
csharp_style_prefer_method_group_conversion = true:silent
|
||||
csharp_style_namespace_declarations = file_scoped:error
|
||||
csharp_style_prefer_method_group_conversion = true:suggestion
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
@@ -46,6 +46,9 @@ csharp_style_prefer_extended_property_pattern = true:suggestion
|
||||
csharp_style_var_for_built_in_types = false:silent
|
||||
csharp_style_var_when_type_is_apparent = false:silent
|
||||
csharp_style_var_elsewhere = false:silent
|
||||
csharp_style_prefer_top_level_statements = true:suggestion
|
||||
csharp_style_prefer_utf8_string_literals = true:suggestion
|
||||
csharp_style_prefer_readonly_struct = true:suggestion
|
||||
|
||||
[*.{cs,vb}]
|
||||
#### Naming styles ####
|
||||
|
||||
@@ -22,10 +22,23 @@
|
||||
</ControlTemplate>
|
||||
</ContextMenu.Template>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="MainPlayerContextMenu">
|
||||
<ContextMenu.Template>
|
||||
<ControlTemplate>
|
||||
<local:MainPlayerContextMenu DataContext="{Binding DataContext, RelativeSource={RelativeSource TemplatedParent}}"></local:MainPlayerContextMenu>
|
||||
</ControlTemplate>
|
||||
</ContextMenu.Template>
|
||||
</ContextMenu>
|
||||
<ContextMenu x:Key="LivingEntityContextMenu">
|
||||
<ContextMenu.Template>
|
||||
<ControlTemplate>
|
||||
<local:LivingEntityContextMenu DataContext="{Binding DataContext, RelativeSource={RelativeSource TemplatedParent}}"></local:LivingEntityContextMenu>
|
||||
</ControlTemplate>
|
||||
</ContextMenu.Template>
|
||||
</ContextMenu>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Image x:Name="MapDrawingHost" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="None">
|
||||
</Image>
|
||||
<Image x:Name="MapDrawingHost" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="Fill"/>
|
||||
<Image x:Name="EntitiesDrawingHost" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
|
||||
<Grid Background="#F0212121"
|
||||
VerticalAlignment="Bottom"
|
||||
|
||||
@@ -16,26 +16,30 @@ using System.Linq;
|
||||
|
||||
namespace Daybreak.Controls;
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "Using source generators to autoimplement dependency properties")]
|
||||
/// <summary>
|
||||
/// Interaction logic for GuildwarsMinimap.xaml
|
||||
/// </summary>
|
||||
public partial class GuildwarsMinimap : UserControl
|
||||
{
|
||||
private const int MapDownscaleFactor = 10;
|
||||
private const int EntitySize = 100;
|
||||
private const float PositionRadius = 150;
|
||||
|
||||
private readonly List<Position> mainPlayerPositionHistory = new();
|
||||
private readonly IGuildwarsEntityDebouncer guildwarsEntityDebouncer;
|
||||
private readonly Color positionHistoryColor = Color.FromArgb(155, Colors.Red.R, Colors.Red.G, Colors.Red.B);
|
||||
|
||||
private bool resizeEntities;
|
||||
private bool dragging;
|
||||
private double mapMinWidth;
|
||||
private double mapMinHeight;
|
||||
private double mapVirtualMinWidth;
|
||||
private double mapVirtualMinHeight;
|
||||
private double mapWidth;
|
||||
private double mapHeight;
|
||||
private Point originPoint = new(0, 0);
|
||||
private Vector originOffset = new(0, 0);
|
||||
private Point initialClickPoint = new(0, 0);
|
||||
private DebounceResponse? cachedDebounceResponse;
|
||||
private List<Position> mainPlayerPositionHistory = new();
|
||||
|
||||
[GenerateDependencyProperty]
|
||||
private PathingData pathingData = new();
|
||||
@@ -81,7 +85,6 @@ public partial class GuildwarsMinimap : UserControl
|
||||
else if (e.Property == ZoomProperty)
|
||||
{
|
||||
this.UpdateGameData();
|
||||
this.DrawMap();
|
||||
}
|
||||
else if (e.Property == GameDataProperty &&
|
||||
this.GameData.Valid)
|
||||
@@ -100,8 +103,8 @@ public partial class GuildwarsMinimap : UserControl
|
||||
var debounceResponse = this.guildwarsEntityDebouncer.DebounceEntities(this.GameData);
|
||||
if (!double.IsFinite(this.mapWidth) ||
|
||||
!double.IsFinite(this.mapHeight) ||
|
||||
!double.IsFinite(this.mapMinWidth) ||
|
||||
!double.IsFinite(this.mapMinHeight))
|
||||
!double.IsFinite(this.mapVirtualMinWidth) ||
|
||||
!double.IsFinite(this.mapVirtualMinHeight))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -113,12 +116,14 @@ public partial class GuildwarsMinimap : UserControl
|
||||
position.X - (screenVirtualWidth / 2) - (this.originOffset.X / this.Zoom),
|
||||
position.Y + (screenVirtualHeight / 2) + (this.originOffset.Y / this.Zoom));
|
||||
|
||||
var adjustedPosition = new Point((int)((position.X - this.mapMinWidth / this.Zoom) * this.Zoom), (int)(this.mapHeight / this.Zoom - position.Y + this.mapMinHeight / this.Zoom) * this.Zoom);
|
||||
var adjustedPosition = new Point((int)((position.X - this.mapVirtualMinWidth) * this.Zoom), (int)(this.mapHeight - position.Y + this.mapVirtualMinHeight) * this.Zoom);
|
||||
this.MapDrawingHost.Margin = new Thickness(
|
||||
(-adjustedPosition.X + this.ActualWidth / 2) + this.originOffset.X,
|
||||
(-adjustedPosition.Y + this.ActualHeight / 2) + this.originOffset.Y,
|
||||
-adjustedPosition.X + (this.ActualWidth / 2) + this.originOffset.X,
|
||||
-adjustedPosition.Y + (this.ActualHeight / 2) + this.originOffset.Y,
|
||||
0,
|
||||
0);
|
||||
this.MapDrawingHost.Height = this.mapHeight * this.Zoom;
|
||||
this.MapDrawingHost.Width = this.mapWidth * this.Zoom;
|
||||
this.ManageMainPlayerPositionHistory();
|
||||
this.DrawEntities(debounceResponse);
|
||||
this.cachedDebounceResponse = debounceResponse;
|
||||
@@ -132,7 +137,7 @@ public partial class GuildwarsMinimap : UserControl
|
||||
}
|
||||
|
||||
var currentPosition = this.cachedDebounceResponse.MainPlayer.Position ?? throw new InvalidOperationException("Unexpected main player null position");
|
||||
if (this.mainPlayerPositionHistory.Any(oldPosition => this.PositionsCollide(oldPosition, currentPosition)))
|
||||
if (this.mainPlayerPositionHistory.Any(oldPosition => PositionsCollide(oldPosition, currentPosition)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -186,10 +191,10 @@ public partial class GuildwarsMinimap : UserControl
|
||||
|
||||
var width = maxWidth - minWidth;
|
||||
var height = maxHeight - minHeight;
|
||||
this.mapMinHeight = minHeight * this.Zoom;
|
||||
this.mapMinWidth = minWidth * this.Zoom;
|
||||
this.mapWidth = width * this.Zoom;
|
||||
this.mapHeight = height * this.Zoom;
|
||||
this.mapVirtualMinHeight = minHeight;
|
||||
this.mapVirtualMinWidth = minWidth;
|
||||
this.mapWidth = width;
|
||||
this.mapHeight = height;
|
||||
|
||||
if (width <= 0 || height <= 0 ||
|
||||
!double.IsFinite(width) ||
|
||||
@@ -198,20 +203,20 @@ public partial class GuildwarsMinimap : UserControl
|
||||
return;
|
||||
}
|
||||
|
||||
var bitmap = BitmapFactory.New((int)(width * this.Zoom), (int)(height * this.Zoom));
|
||||
var bitmap = BitmapFactory.New((int)(width / MapDownscaleFactor), (int)(height / MapDownscaleFactor));
|
||||
this.MapDrawingHost.Source = bitmap;
|
||||
this.MapDrawingHost.Width = width * this.Zoom;
|
||||
this.MapDrawingHost.Height = height * this.Zoom;
|
||||
this.MapDrawingHost.Width = width / MapDownscaleFactor;
|
||||
this.MapDrawingHost.Height = height / MapDownscaleFactor;
|
||||
|
||||
using var bitmapContext = bitmap.GetBitmapContext();
|
||||
bitmap.Clear(Colors.Transparent);
|
||||
foreach (var trapezoid in this.PathingData.Trapezoids!)
|
||||
{
|
||||
var a = new Point((int)((trapezoid.XTL - minWidth) * this.Zoom), (int)((height - trapezoid.YT + minHeight) * this.Zoom));
|
||||
var b = new Point((int)((trapezoid.XTR - minWidth) * this.Zoom), (int)((height - trapezoid.YT + minHeight) * this.Zoom));
|
||||
var c = new Point((int)((trapezoid.XBR - minWidth) * this.Zoom), (int)((height - trapezoid.YB + minHeight) * this.Zoom));
|
||||
var d = new Point((int)((trapezoid.XBL - minWidth) * this.Zoom), (int)((height - trapezoid.YB + minHeight) * this.Zoom));
|
||||
var e = new Point((int)((trapezoid.XTL - minWidth) * this.Zoom), (int)((height - trapezoid.YT + minHeight) * this.Zoom));
|
||||
var a = new Point((int)((trapezoid.XTL - minWidth) / MapDownscaleFactor), (int)((height - trapezoid.YT + minHeight) / MapDownscaleFactor));
|
||||
var b = new Point((int)((trapezoid.XTR - minWidth) / MapDownscaleFactor), (int)((height - trapezoid.YT + minHeight) / MapDownscaleFactor));
|
||||
var c = new Point((int)((trapezoid.XBR - minWidth) / MapDownscaleFactor), (int)((height - trapezoid.YB + minHeight) / MapDownscaleFactor));
|
||||
var d = new Point((int)((trapezoid.XBL - minWidth) / MapDownscaleFactor), (int)((height - trapezoid.YB + minHeight) / MapDownscaleFactor));
|
||||
var e = new Point((int)((trapezoid.XTL - minWidth) / MapDownscaleFactor), (int)((height - trapezoid.YT + minHeight) / MapDownscaleFactor));
|
||||
|
||||
bitmap.FillPolygon(new int[] { (int)a.X, (int)a.Y, (int)b.X, (int)b.Y, (int)c.X, (int)c.Y, (int)d.X, (int)d.Y, (int)e.X, (int)e.Y, (int)a.X, (int)a.Y }, Colors.White);
|
||||
}
|
||||
@@ -233,17 +238,17 @@ public partial class GuildwarsMinimap : UserControl
|
||||
|
||||
this.FillEllipse(debounceResponse.MainPlayer.Position, bitmap, Colors.Green);
|
||||
|
||||
foreach (var partyMember in debounceResponse.Party)
|
||||
foreach (var partyMember in debounceResponse.Party.Where(p => IsValidEntity(p)))
|
||||
{
|
||||
this.FillEllipse(partyMember.Position, bitmap, Colors.Green);
|
||||
}
|
||||
|
||||
foreach (var player in debounceResponse.WorldPlayers)
|
||||
foreach (var player in debounceResponse.WorldPlayers.Where(p => IsValidEntity(p)))
|
||||
{
|
||||
this.FillEllipse(player.Position, bitmap, Colors.CornflowerBlue);
|
||||
}
|
||||
|
||||
foreach (var livingEntity in debounceResponse.LivingEntities)
|
||||
foreach (var livingEntity in debounceResponse.LivingEntities.Where(p => IsValidEntity(p)))
|
||||
{
|
||||
if (livingEntity.State is LivingEntityState.ToBeCleanedUp)
|
||||
{
|
||||
@@ -263,7 +268,7 @@ public partial class GuildwarsMinimap : UserControl
|
||||
}
|
||||
else if (livingEntity.Allegiance is LivingEntityAllegiance.Neutral)
|
||||
{
|
||||
this.FillEllipse(livingEntity.Position, bitmap, Colors.Gray);
|
||||
this.FillEllipse(livingEntity.Position, bitmap, Colors.LightSteelBlue);
|
||||
}
|
||||
else if (livingEntity.Allegiance is LivingEntityAllegiance.Enemy)
|
||||
{
|
||||
@@ -320,8 +325,8 @@ public partial class GuildwarsMinimap : UserControl
|
||||
bitmap.FillEllipseCentered(
|
||||
x,
|
||||
y,
|
||||
(int)(100 * this.Zoom),
|
||||
(int)(100 * this.Zoom),
|
||||
(int)(EntitySize * this.Zoom),
|
||||
(int)(EntitySize * this.Zoom),
|
||||
color);
|
||||
}
|
||||
|
||||
@@ -341,12 +346,12 @@ public partial class GuildwarsMinimap : UserControl
|
||||
}
|
||||
|
||||
bitmap.FillTriangle(
|
||||
(int)((position.Value.X - this.originPoint.X - 100) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y + 100) * this.Zoom),
|
||||
(int)((position.Value.X - this.originPoint.X - EntitySize) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y + EntitySize) * this.Zoom),
|
||||
(int)((position.Value.X - this.originPoint.X) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y - 100) * this.Zoom),
|
||||
(int)((position.Value.X - this.originPoint.X + 100) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y + 100) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y - EntitySize) * this.Zoom),
|
||||
(int)((position.Value.X - this.originPoint.X + EntitySize) * this.Zoom),
|
||||
0 - (int)((position.Value.Y - this.originPoint.Y + EntitySize) * this.Zoom),
|
||||
color);
|
||||
}
|
||||
|
||||
@@ -355,15 +360,7 @@ public partial class GuildwarsMinimap : UserControl
|
||||
var x = (int)((entity.Position!.Value.X - this.originPoint.X) * this.Zoom);
|
||||
var y = 0 - (int)((entity.Position!.Value.Y - this.originPoint.Y) * this.Zoom);
|
||||
|
||||
return Math.Pow(mousePosition.X - x, 2) + Math.Pow(mousePosition.Y - y, 2) < Math.Pow(100 * this.Zoom, 2);
|
||||
}
|
||||
|
||||
private bool PositionsCollide(Position position1, Position position2)
|
||||
{
|
||||
var a = PositionRadius + PositionRadius;
|
||||
var dx = position1.X - position2.X;
|
||||
var dy = position1.Y - position2.Y;
|
||||
return a * a > ((dx * dx) + (dy * dy));
|
||||
return Math.Pow(mousePosition.X - x, 2) + Math.Pow(mousePosition.Y - y, 2) < Math.Pow(EntitySize * this.Zoom, 2);
|
||||
}
|
||||
|
||||
private void DragMinimap()
|
||||
@@ -414,6 +411,15 @@ public partial class GuildwarsMinimap : UserControl
|
||||
|
||||
private void GuildwarsMinimap_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (this.CheckMouseOverEntity(Enumerable.Repeat(this.GameData.MainPlayer.As<IEntity>(), 1)) is MainPlayerInformation &&
|
||||
this.TryFindResource("MainPlayerContextMenu") is ContextMenu mainPlayerContextMenu)
|
||||
{
|
||||
this.ContextMenu = mainPlayerContextMenu;
|
||||
this.ContextMenu.DataContext = this.GameData.MainPlayer;
|
||||
this.ContextMenu.IsOpen = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var maybeWorldPlayer = this.CheckMouseOverEntity(this.GameData.WorldPlayers!.OfType<IEntity>());
|
||||
if (maybeWorldPlayer is WorldPlayerInformation worldPlayerInformation &&
|
||||
this.TryFindResource("WorldPlayerContextMenu") is ContextMenu worldPlayerContextMenu)
|
||||
@@ -424,6 +430,16 @@ public partial class GuildwarsMinimap : UserControl
|
||||
return;
|
||||
}
|
||||
|
||||
var maybeLivingEntity = this.CheckMouseOverEntity(this.GameData.LivingEntities!.OfType<IEntity>());
|
||||
if (maybeLivingEntity is LivingEntity livingEntity &&
|
||||
this.TryFindResource("LivingEntityContextMenu") is ContextMenu livingEntityContextMenu)
|
||||
{
|
||||
this.ContextMenu = livingEntityContextMenu;
|
||||
this.ContextMenu.DataContext = livingEntity;
|
||||
this.ContextMenu.IsOpen = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.ContextMenu = default;
|
||||
}
|
||||
|
||||
@@ -439,7 +455,20 @@ public partial class GuildwarsMinimap : UserControl
|
||||
}
|
||||
|
||||
this.DragMinimap();
|
||||
this.CheckMouseOverEntity(this.GameData.WorldPlayers!.OfType<IEntity>());
|
||||
if (this.CheckMouseOverEntity(this.GameData.WorldPlayers!.OfType<IEntity>()) is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.CheckMouseOverEntity(Enumerable.Repeat(this.GameData.MainPlayer.As<IEntity>(), 1)) is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.CheckMouseOverEntity(this.GameData.LivingEntities!.OfType<IEntity>()) is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void GuildwarsMinimap_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
@@ -456,4 +485,23 @@ public partial class GuildwarsMinimap : UserControl
|
||||
mouseButtonEventArgs.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool PositionsCollide(Position position1, Position position2)
|
||||
{
|
||||
var a = PositionRadius + PositionRadius;
|
||||
var dx = position1.X - position2.X;
|
||||
var dy = position1.Y - position2.Y;
|
||||
return a * a > ((dx * dx) + (dy * dy));
|
||||
}
|
||||
|
||||
private static bool IsValidEntity(IEntity entity)
|
||||
{
|
||||
if (entity.Position?.X == 0 &&
|
||||
entity.Position?.Y == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<UserControl x:Class="Daybreak.Controls.LivingEntityContextMenu"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:guildwars="clr-namespace:Daybreak.Models.Guildwars"
|
||||
mc:Ignorable="d"
|
||||
Background="#F0212121"
|
||||
d:DataContext="{d:DesignInstance Type=guildwars:LivingEntity, IsDesignTimeCreatable=True}"
|
||||
d:DesignHeight="300" d:DesignWidth="100">
|
||||
<StackPanel Margin="5, 0, 5, 0">
|
||||
<TextBlock
|
||||
Text="{Binding Allegiance, Mode=OneWay}" FontSize="16" Foreground="White"></TextBlock>
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Lvl: " Foreground="White"></TextBlock>
|
||||
<TextBlock Text="{Binding Level, Mode=OneWay}" Foreground="White"></TextBlock>
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Daybreak.Controls;
|
||||
/// <summary>
|
||||
/// Interaction logic for LivingEntityContextMenu.xaml
|
||||
/// </summary>
|
||||
public partial class LivingEntityContextMenu : UserControl
|
||||
{
|
||||
public LivingEntityContextMenu()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<UserControl x:Class="Daybreak.Controls.MainPlayerContextMenu"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Daybreak.Controls"
|
||||
xmlns:guildwars="clr-namespace:Daybreak.Models.Guildwars"
|
||||
mc:Ignorable="d"
|
||||
Background="#F0212121"
|
||||
d:DataContext="{d:DesignInstance Type=guildwars:MainPlayerInformation, IsDesignTimeCreatable=True}"
|
||||
d:DesignHeight="300" d:DesignWidth="100">
|
||||
<StackPanel Margin="5, 0, 5, 0">
|
||||
<TextBlock
|
||||
Text="{Binding Name, Mode=OneWay}" FontSize="16" Foreground="White"></TextBlock>
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Lvl: " Foreground="White"></TextBlock>
|
||||
<TextBlock Text="{Binding Level, Mode=OneWay}" Foreground="White"></TextBlock>
|
||||
</WrapPanel>
|
||||
<WrapPanel>
|
||||
<TextBlock Text="{Binding PrimaryProfession.Alias, Mode=OneWay}" Foreground="White"></TextBlock>
|
||||
<TextBlock Text="/" Foreground="White"></TextBlock>
|
||||
<TextBlock Text="{Binding SecondaryProfession.Alias, Mode=OneWay}" Foreground="White"></TextBlock>
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Daybreak.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainPlayerContextMenu.xaml
|
||||
/// </summary>
|
||||
public partial class MainPlayerContextMenu : UserControl
|
||||
{
|
||||
public MainPlayerContextMenu()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Daybreak.Controls
|
||||
namespace Daybreak.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for WorldPlayerContextMenu.xaml
|
||||
/// </summary>
|
||||
public partial class WorldPlayerContextMenu : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WorldPlayerContextMenu.xaml
|
||||
/// </summary>
|
||||
public partial class WorldPlayerContextMenu : UserControl
|
||||
{
|
||||
public WorldPlayerContextMenu()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
|
||||
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
|
||||
<Version>0.9.8.21</Version>
|
||||
<Version>0.9.8.22</Version>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
|
||||
@@ -320,6 +320,6 @@ public partial class MainWindow : Window
|
||||
double R = color.ScR;
|
||||
double G = color.ScG;
|
||||
double B = color.ScB;
|
||||
return 0.299 * R + 0.587 * G + 0.114 * B;
|
||||
return (0.299 * R) + (0.587 * G) + (0.114 * B);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public readonly struct PathingTrapezoid
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4)]
|
||||
public readonly int[] AdjacentPathingTrapezoids;
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Used for proper padding")]
|
||||
private readonly uint H0014;
|
||||
|
||||
public readonly float XTL;
|
||||
|
||||
@@ -18,6 +18,6 @@ public readonly struct ProfessionsContext
|
||||
|
||||
public bool ProfessionUnlocked(int professionId)
|
||||
{
|
||||
return (this.UnlockedProfessionsFlags & 1U << professionId) != 0;
|
||||
return (this.UnlockedProfessionsFlags & (1U << professionId)) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,12 +147,7 @@ public class ApplicationLauncher : IApplicationLauncher
|
||||
|
||||
private async Task<Process?> LaunchGuildwarsProcess(string email, Models.SecureString password, string character)
|
||||
{
|
||||
var executable = this.liveOptions.Value.GuildwarsPaths.Where(path => path.Default).FirstOrDefault();
|
||||
if (executable is null)
|
||||
{
|
||||
throw new ExecutableNotFoundException($"No executable selected");
|
||||
}
|
||||
|
||||
var executable = this.liveOptions.Value.GuildwarsPaths.Where(path => path.Default).FirstOrDefault() ?? throw new ExecutableNotFoundException($"No executable selected");
|
||||
if (File.Exists(executable.Path) is false)
|
||||
{
|
||||
throw new ExecutableNotFoundException($"Guildwars executable doesn't exist at {executable}");
|
||||
@@ -255,12 +250,7 @@ public class ApplicationLauncher : IApplicationLauncher
|
||||
|
||||
private void SetRegistryGuildwarsPath()
|
||||
{
|
||||
var path = this.liveOptions.Value.GuildwarsPaths.Where(path => path.Default).FirstOrDefault();
|
||||
if (path is null)
|
||||
{
|
||||
throw new ExecutableNotFoundException("No executable currently selected");
|
||||
}
|
||||
|
||||
var path = this.liveOptions.Value.GuildwarsPaths.Where(path => path.Default).FirstOrDefault() ?? throw new ExecutableNotFoundException("No executable currently selected");
|
||||
var gamePath = path.Path;
|
||||
try
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ public sealed class ExperienceCalculator : IExperienceCalculator
|
||||
else
|
||||
{
|
||||
var experienceOverThreshold = currentTotalExperience - ExperienceCalculationThreshold;
|
||||
var currentExperience = (experienceOverThreshold % MaxExperienceRequirement);
|
||||
var currentExperience = experienceOverThreshold % MaxExperienceRequirement;
|
||||
return currentExperience;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Daybreak.Services.Monitoring
|
||||
|
||||
var endCpuUsage = this.currentProcess.TotalProcessorTime;
|
||||
var elapsedTicks = stopwatch.ElapsedTicks;
|
||||
var usage = ((double)(endCpuUsage - startCpuUsage).Ticks / (double)elapsedTicks) / this.processorCount * 100d;
|
||||
var usage = (double)(endCpuUsage - startCpuUsage).Ticks / (double)elapsedTicks / this.processorCount * 100d;
|
||||
|
||||
this.processorTimeHistogram.Record(usage);
|
||||
_ = Task.Run(this.PeriodicallyCheckCPU);
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed class MutexHandler : IMutexHandler
|
||||
NativeMethods.SystemHandleInformation currentHandleInfo;
|
||||
for (int i = 0; i < Marshal.ReadInt32(systemHandle); i++)
|
||||
{
|
||||
var currentOffset = IntPtr.Size + i * Marshal.SizeOf(typeof(NativeMethods.SystemHandleInformation));
|
||||
var currentOffset = IntPtr.Size + (i * Marshal.SizeOf(typeof(NativeMethods.SystemHandleInformation)));
|
||||
currentHandleInfo = (NativeMethods.SystemHandleInformation)Marshal.PtrToStructure(new IntPtr(basePointer + currentOffset), typeof(NativeMethods.SystemHandleInformation))!;
|
||||
if (currentHandleInfo.OwnerPID == (uint)targetProcess.Id)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ internal static class EncryptionHelper
|
||||
{
|
||||
var saltBytes = new byte[Aes.BlockSize / 8];
|
||||
var ivBytes = new byte[Aes.BlockSize / 8];
|
||||
var cipherBytes = new byte[bytes.Length - Aes.BlockSize / 4];
|
||||
var cipherBytes = new byte[bytes.Length - (Aes.BlockSize / 4)];
|
||||
|
||||
using var encryptedStream = new MemoryStream(bytes);
|
||||
encryptedStream.Read(saltBytes, 0, saltBytes.Length);
|
||||
|
||||
Reference in New Issue
Block a user