Skip to content

Commit

Permalink
Release 0.9.9.10 (#550)
Browse files Browse the repository at this point in the history
* Release 0.9.9.10
Option to rotate minimap with the camera
Fix launch button not disabling properly when launching
Remove minimap id overlay
Closes #549
Closes #533
Closes #532

* Increment version

* Increment Daybreak.GWCA version
  • Loading branch information
AlexMacocian authored Jan 28, 2024
1 parent a65f375 commit d9aa760
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Daybreak.GWCA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
set(VERSION_MAJOR 0)
set(VERSION_MINOR 9)
set(VERSION_PATCH 9)
set(VERSION_TWEAK 6)
set(VERSION_TWEAK 10)

set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)
Expand Down
14 changes: 14 additions & 0 deletions Daybreak.GWCA/header/payloads/Camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#include <cstdint>
#include <json.hpp>

using json = nlohmann::json;

namespace Daybreak {
struct Camera {
float Yaw;
float Pitch;
};

void to_json(json& j, const Camera& p);
}
2 changes: 2 additions & 0 deletions Daybreak.GWCA/header/payloads/GameStatePayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <cstdint>
#include <json.hpp>
#include <payloads/StatePayload.h>
#include <payloads/Camera.h>

using json = nlohmann::json;

namespace Daybreak {
struct GameStatePayload {
Camera Camera;
std::list<StatePayload> States;
};

Expand Down
8 changes: 8 additions & 0 deletions Daybreak.GWCA/source/GameStateModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include "GameStateModule.h"
#include <GWCA/Managers/GameThreadMgr.h>
#include <GWCA/Managers/AgentMgr.h>
#include <GWCA/Managers/CameraMgr.h>
#include <GWCA/GameEntities/Agent.h>
#include <GWCA/GameEntities/Camera.h>
#include <GWCA/Managers/MapMgr.h>
#include <future>
#include <payloads/GameStatePayload.h>
Expand Down Expand Up @@ -64,6 +66,12 @@ namespace Daybreak::Modules::GameStateModule {

auto states = GetStates(agents);
gamePayload.States = states;

auto camera = GW::CameraMgr::GetCamera();
Daybreak::Camera cameraPayload{};
cameraPayload.Pitch = camera->pitch;
cameraPayload.Yaw = camera->yaw;
gamePayload.Camera = cameraPayload;
return gamePayload;
}

Expand Down
16 changes: 16 additions & 0 deletions Daybreak.GWCA/source/payloads/Camera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include <payloads/Camera.h>
#include <cstdint>
#include <json.hpp>

using json = nlohmann::json;

namespace Daybreak {
void to_json(json& j, const Camera& p) {
j = json
{
{"Yaw", p.Yaw},
{"Pitch", p.Pitch}
};
}
}
1 change: 1 addition & 0 deletions Daybreak.GWCA/source/payloads/GameStatePayload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Daybreak {
void to_json(json& j, const GameStatePayload& p) {
j = json
{
{"Camera", p.Camera},
{"States", p.States},
};
}
Expand Down
4 changes: 4 additions & 0 deletions Daybreak/Configuration/Options/FocusViewOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public sealed class FocusViewOptions
[OptionName(Name = "Energy Display Mode", Description = "Sets how should the energy display show the information")]
public PointsDisplay EnergyDisplay { get; set; }

[JsonProperty(nameof(MinimapRotationEnabled))]
[OptionName(Name = "Minimap Rotation", Description = "When enabled, the minimap will rotate according to the player camera")]
public bool MinimapRotationEnabled { get; set; } = true;

[JsonProperty(nameof(BrowserHistory))]
[OptionIgnore]
public BrowserHistory BrowserHistory { get; set; } = new();
Expand Down
19 changes: 7 additions & 12 deletions Daybreak/Controls/Minimap/GuildwarsMinimap.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@
</ContextMenu>
</UserControl.Resources>
<Grid>
<Image x:Name="MapDrawingHost" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="Fill"/>
<Image x:Name="EntitiesDrawingHost" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Grid RenderTransformOrigin="0.5 0.5">
<Grid.RenderTransform>
<RotateTransform Angle="{Binding ElementName=_this, Path=Angle, Mode=OneWay}"/>
</Grid.RenderTransform>
<Image x:Name="MapDrawingHost" VerticalAlignment="Top" HorizontalAlignment="Left" Stretch="Fill" />
<Image x:Name="EntitiesDrawingHost" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>
<Grid Background="{DynamicResource Daybreak.Brushes.Background}"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Expand All @@ -79,15 +84,5 @@
Clicked="MaximizeButton_Clicked"
ToolTip="Maximize"/>
</Grid>
<WrapPanel Background="{DynamicResource Daybreak.Brushes.Background}"
VerticalAlignment="Top"
HorizontalAlignment="Right" >
<TextBlock Text="{Binding ElementName=_this, Path=TargetEntityId, Mode=OneWay}" Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"
FontSize="16" Padding="5" />
<TextBlock Text=" - " Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"
FontSize="16" Padding="5" />
<TextBlock Text="{Binding ElementName=_this, Path=TargetEntityModelId, Mode=OneWay}" Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"
FontSize="16" Padding="5" />
</WrapPanel>
</Grid>
</UserControl>
7 changes: 7 additions & 0 deletions Daybreak/Controls/Minimap/GuildwarsMinimap.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Diagnostics;
using Daybreak.Models.FocusView;
using Daybreak.Models.LaunchConfigurations;
using System.Configuration;

namespace Daybreak.Controls.Minimap;

Expand Down Expand Up @@ -78,6 +79,10 @@ public partial class GuildwarsMinimap : UserControl
[GenerateDependencyProperty]
private bool controlsVisible;
[GenerateDependencyProperty]
private bool canRotate;
[GenerateDependencyProperty]
private double angle;
[GenerateDependencyProperty]
private int targetEntityId;
[GenerateDependencyProperty]
private int targetEntityModelId;
Expand Down Expand Up @@ -187,6 +192,8 @@ this.GameData is null ||
entity.Health = state?.Health ?? 0;
entity.Energy = state?.Energy ?? 0;
}

this.Angle = this.CanRotate ? (this.GameState.Camera.Yaw - (Math.PI / 2)) * (180 / Math.PI) : 0;
}

private void UpdateGameData()
Expand Down
2 changes: 1 addition & 1 deletion Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.9.9</Version>
<Version>0.9.9.10</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
7 changes: 7 additions & 0 deletions Daybreak/Models/Guildwars/Camera.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Daybreak.Models.Guildwars;

public sealed class Camera
{
public float Yaw { get; set; }
public float Pitch { get; set; }
}
1 change: 1 addition & 0 deletions Daybreak/Models/Guildwars/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
namespace Daybreak.Models.Guildwars;
public sealed class GameState
{
public Camera Camera { get; init; }
public List<EntityGameState>? States { get; init; }
}
2 changes: 1 addition & 1 deletion Daybreak/Services/Scanner/GWCAMemoryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public async Task EnsureInitialized(uint processId, CancellationToken cancellati
};
}).ToList();

return new GameState { States = states };
return new GameState { States = states, Camera = new Camera { Pitch = gameStatePayload.Camera?.Pitch ?? 0, Yaw = gameStatePayload.Camera?.Yaw ?? 0 }, };
}
catch (Exception ex)
{
Expand Down
6 changes: 6 additions & 0 deletions Daybreak/Services/Scanner/Models/CameraPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Daybreak.Services.Scanner.Models;
internal sealed class CameraPayload
{
public float Yaw { get; set; }
public float Pitch { get; set; }
}
1 change: 1 addition & 0 deletions Daybreak/Services/Scanner/Models/GameStatePayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
namespace Daybreak.Services.Scanner.Models;
internal sealed class GameStatePayload
{
public CameraPayload? Camera { get; set; }
public List<StatePayload>? States { get; set; }
}
1 change: 1 addition & 0 deletions Daybreak/Views/FocusView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
GameData="{Binding ElementName=_this, Path=GameData, Mode=OneWay}"
GameState="{Binding ElementName=_this, Path=GameState, Mode=OneWay}"
PathingData="{Binding ElementName=_this, Path=PathingData, Mode=OneWay}"
CanRotate="{Binding ElementName=_this, Path=CanRotateMinimap, Mode=OneWay}"
Zoom="0.04"
ControlsVisible="True"
MaximizeClicked="GuildwarsMinimap_MaximizeClicked"
Expand Down
5 changes: 4 additions & 1 deletion Daybreak/Views/FocusView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Core.Extensions;
using System.Extensions;
using System.Linq;
using System.Logging;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -76,6 +75,9 @@ public partial class FocusView : UserControl
[GenerateDependencyProperty]
private bool minimapVisible;

[GenerateDependencyProperty]
private bool canRotateMinimap;

private bool browserMaximized = false;
private bool minimapMaximized = false;
private bool inventoryMaximized = false;
Expand Down Expand Up @@ -239,6 +241,7 @@ await Task.WhenAll(
}

this.GameState = maybeGameState;
this.CanRotateMinimap = this.liveUpdateableOptions.Value.MinimapRotationEnabled;
}
catch (InvalidOperationException ex)
{
Expand Down
29 changes: 18 additions & 11 deletions Daybreak/Views/LauncherView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public partial class LauncherView : UserControl
private readonly ILiveOptions<FocusViewOptions> focusViewOptions;
private readonly CancellationTokenSource cancellationTokenSource = new();

private bool launching;

[GenerateDependencyProperty]
private LauncherViewContext latestConfiguration = default!;

Expand Down Expand Up @@ -97,7 +99,11 @@ private async void PeriodicallyCheckSelectedConfigState()
{
while (!this.cancellationTokenSource.IsCancellationRequested)
{
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = this.LatestConfiguration?.CanLaunch ?? false);
if (!this.launching)
{
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = this.LatestConfiguration?.CanLaunch ?? false);
}

await Task.Delay(TimeSpan.FromSeconds(1), this.cancellationTokenSource.Token);
}
}
Expand Down Expand Up @@ -139,14 +145,8 @@ private async void DropDownButton_SelectionChanged(object _, object e)

private async void DropDownButton_Clicked(object _, object e)
{
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = true);
if (this.LatestConfiguration is null ||
this.LatestConfiguration.CanLaunch is false)
{
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = false);
return;
}

this.launching = true;
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = false);
var launchingTask = await new TaskFactory().StartNew(async () =>
{
var latestConfig = await this.Dispatcher.InvokeAsync(() => this.LatestConfiguration);
Expand Down Expand Up @@ -186,7 +186,14 @@ private async void DropDownButton_Clicked(object _, object e)
}
}, TaskCreationOptions.LongRunning);

await launchingTask;
await this.Dispatcher.InvokeAsync(() => this.CanLaunch = false);
try
{
await launchingTask;
}
catch
{
}

this.launching = false;
}
}

0 comments on commit d9aa760

Please sign in to comment.