mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-09-16 05:19:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b6d6cf651 | ||
|
|
4af457710f | ||
|
|
f4dc05d7d0 |
@@ -6,6 +6,8 @@ namespace Daybreak.Configuration
|
||||
{
|
||||
[JsonProperty("GamePath")]
|
||||
public string GamePath { get; set; }
|
||||
[JsonProperty("ToolboxPath")]
|
||||
public string ToolboxPath { get; set; }
|
||||
[JsonProperty("CharacterName")]
|
||||
public string CharacterName { get; set; }
|
||||
[JsonProperty("LeftBrowserDefault")]
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Daybreak.Configuration
|
||||
{
|
||||
viewProducer.ThrowIfNull(nameof(viewProducer));
|
||||
|
||||
viewProducer.RegisterView<StartupView>();
|
||||
viewProducer.RegisterView<MainView>();
|
||||
viewProducer.RegisterView<SettingsView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
|
||||
<Version>0.1.2</Version>
|
||||
<Version>0.1.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Daybreak.Launch
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.viewManager.ShowView<StartupView>();
|
||||
this.viewManager.ShowView<MainView>();
|
||||
this.SetupImageCycle();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,14 @@ namespace Daybreak.Services.ApplicationDetection
|
||||
{
|
||||
public class ApplicationDetector : IApplicationDetector
|
||||
{
|
||||
private const string ToolboxProcessName = "GWToolbox";
|
||||
private const string ProcessName = "gw";
|
||||
|
||||
private readonly IConfigurationManager configurationManager;
|
||||
private readonly ICredentialManager credentialManager;
|
||||
|
||||
public bool IsGuildwarsRunning => GuildwarsProcessDetected();
|
||||
public bool IsToolboxRunning => GuildwarsToolboxProcessDetected();
|
||||
|
||||
public ApplicationDetector(
|
||||
IConfigurationManager configurationManager,
|
||||
@@ -46,7 +48,7 @@ namespace Daybreak.Services.ApplicationDetection
|
||||
{
|
||||
if (Process.Start(executable, new List<string> { "-email", credentials.Username, "-password", credentials.Password, "-character", configuration.CharacterName }) is null)
|
||||
{
|
||||
throw new InvalidOperationException($"Unable to launch executable");
|
||||
throw new InvalidOperationException($"Unable to launch {executable}");
|
||||
}
|
||||
},
|
||||
onNone: () =>
|
||||
@@ -55,10 +57,29 @@ namespace Daybreak.Services.ApplicationDetection
|
||||
});
|
||||
}
|
||||
|
||||
public void LaunchGuildwarsToolbox()
|
||||
{
|
||||
var configuration = this.configurationManager.GetConfiguration();
|
||||
var executable = configuration.ToolboxPath;
|
||||
if (File.Exists(executable) is false)
|
||||
{
|
||||
throw new InvalidOperationException($"Guildwars executable doesn't exist at {executable}");
|
||||
}
|
||||
|
||||
if (Process.Start(executable) is null)
|
||||
{
|
||||
throw new InvalidOperationException($"Unable to launch {executable}");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool GuildwarsProcessDetected()
|
||||
{
|
||||
var process = Process.GetProcessesByName(ProcessName).FirstOrDefault();
|
||||
return process is not null;
|
||||
return Process.GetProcessesByName(ProcessName).FirstOrDefault() is not null;
|
||||
}
|
||||
|
||||
private static bool GuildwarsToolboxProcessDetected()
|
||||
{
|
||||
return Process.GetProcessesByName(ToolboxProcessName).FirstOrDefault() is not null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
public interface IApplicationDetector
|
||||
{
|
||||
bool IsGuildwarsRunning { get; }
|
||||
bool IsToolboxRunning { get; }
|
||||
void LaunchGuildwars();
|
||||
void LaunchGuildwarsToolbox();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="Daybreak.Views.StartupView"
|
||||
<UserControl x:Class="Daybreak.Views.MainView"
|
||||
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"
|
||||
@@ -25,9 +25,13 @@
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<controls:OpaqueButton Text="Launch game" Highlight="White" TransparentBackground="Black" HighlightOpacity="0.3" BackgroundOpacity="0.2"
|
||||
Foreground="White" FontSize="36" Width="250" Height="60" VerticalAlignment="Bottom" Margin="0, 0, 0, 30"
|
||||
Foreground="White" FontSize="36" Width="250" Height="60" VerticalAlignment="Bottom"
|
||||
IsEnabled="{Binding ElementName=_this, Path=LaunchButtonEnabled, Mode=OneWay}"
|
||||
Clicked="OpaqueButton_Clicked" Grid.Row="1" Grid.ColumnSpan="3"></controls:OpaqueButton>
|
||||
Clicked="LaunchButton_Clicked" Grid.Row="0" Grid.ColumnSpan="3"></controls:OpaqueButton>
|
||||
<controls:OpaqueButton Text="Launch toolbox" Highlight="White" TransparentBackground="Black" HighlightOpacity="0.3" BackgroundOpacity="0.2"
|
||||
Foreground="White" FontSize="24" Width="200" Height="40" Margin="0, 10, 0, 10"
|
||||
IsEnabled="{Binding ElementName=_this, Path=LaunchToolboxButtonEnabled, Mode=OneWay}"
|
||||
Clicked="LaunchToolboxButton_Clicked" Grid.Row="1" Grid.ColumnSpan="3"></controls:OpaqueButton>
|
||||
<Grid x:Name="RightContainer" Grid.Column="2" Margin="10">
|
||||
<controls:ChromiumBrowserWrapper Address="{Binding ElementName=_this, Path=RightBrowserAddress, Mode=OneWay}"
|
||||
Foreground="White" FavoriteUriChanged="RightBrowser_FavoriteUriChanged"
|
||||
@@ -14,18 +14,20 @@ namespace Daybreak.Views
|
||||
/// <summary>
|
||||
/// Interaction logic for StartupView.xaml
|
||||
/// </summary>
|
||||
public partial class StartupView : UserControl
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty LaunchButtonEnabledProperty =
|
||||
DependencyPropertyExtensions.Register<StartupView, bool>(nameof(LaunchButtonEnabled));
|
||||
DependencyPropertyExtensions.Register<MainView, bool>(nameof(LaunchButtonEnabled));
|
||||
public static readonly DependencyProperty LaunchToolboxButtonEnabledProperty =
|
||||
DependencyPropertyExtensions.Register<MainView, bool>(nameof(LaunchToolboxButtonEnabled));
|
||||
public static readonly DependencyProperty RightBrowserAddressProperty =
|
||||
DependencyPropertyExtensions.Register<StartupView, string>(nameof(RightBrowserAddress));
|
||||
DependencyPropertyExtensions.Register<MainView, string>(nameof(RightBrowserAddress));
|
||||
public static readonly DependencyProperty LeftBrowserAddressProperty =
|
||||
DependencyPropertyExtensions.Register<StartupView, string>(nameof(LeftBrowserAddress));
|
||||
DependencyPropertyExtensions.Register<MainView, string>(nameof(LeftBrowserAddress));
|
||||
public static readonly DependencyProperty RightBrowserFavoriteAddressProperty =
|
||||
DependencyPropertyExtensions.Register<StartupView, string>(nameof(RightBrowserFavoriteAddress));
|
||||
DependencyPropertyExtensions.Register<MainView, string>(nameof(RightBrowserFavoriteAddress));
|
||||
public static readonly DependencyProperty LeftBrowserFavoriteAddressProperty =
|
||||
DependencyPropertyExtensions.Register<StartupView, string>(nameof(LeftBrowserFavoriteAddress));
|
||||
DependencyPropertyExtensions.Register<MainView, string>(nameof(LeftBrowserFavoriteAddress));
|
||||
|
||||
private readonly IApplicationDetector applicationDetector;
|
||||
private readonly IViewManager viewManager;
|
||||
@@ -60,8 +62,13 @@ namespace Daybreak.Views
|
||||
get => this.GetTypedValue<bool>(LaunchButtonEnabledProperty);
|
||||
set => this.SetTypedValue(LaunchButtonEnabledProperty, value);
|
||||
}
|
||||
public bool LaunchToolboxButtonEnabled
|
||||
{
|
||||
get => this.GetTypedValue<bool>(LaunchToolboxButtonEnabledProperty);
|
||||
set => this.SetTypedValue(LaunchToolboxButtonEnabledProperty, value);
|
||||
}
|
||||
|
||||
public StartupView(
|
||||
public MainView(
|
||||
IApplicationDetector applicationDetector,
|
||||
IViewManager viewManager,
|
||||
IConfigurationManager configurationManager)
|
||||
@@ -90,14 +97,8 @@ namespace Daybreak.Views
|
||||
|
||||
private void CheckGameState()
|
||||
{
|
||||
if (applicationDetector.IsGuildwarsRunning)
|
||||
{
|
||||
this.LaunchButtonEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LaunchButtonEnabled = true;
|
||||
}
|
||||
this.LaunchButtonEnabled = applicationDetector.IsGuildwarsRunning is false;
|
||||
this.LaunchToolboxButtonEnabled = applicationDetector.IsToolboxRunning is false;
|
||||
}
|
||||
|
||||
private void StartupView_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -109,7 +110,7 @@ namespace Daybreak.Views
|
||||
this.cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
private void OpaqueButton_Clicked(object sender, EventArgs e)
|
||||
private void LaunchButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -121,6 +122,18 @@ namespace Daybreak.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchToolboxButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.applicationDetector.LaunchGuildwarsToolbox();
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.viewManager.ShowView<SettingsView>();
|
||||
}
|
||||
}
|
||||
|
||||
private void LeftBrowser_FavoriteUriChanged(object sender, string e)
|
||||
{
|
||||
var config = this.configurationManager.GetConfiguration();
|
||||
@@ -16,6 +16,7 @@
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||
@@ -39,9 +40,15 @@
|
||||
x:Name="GamePathTextbox" FontSize="22" Margin="0, 0, 30, 0" Background="Transparent" Foreground="White"></TextBox>
|
||||
<controls:FilePickerGlyph Grid.Row="4" Grid.Column="1" Height="30" Width="30" HorizontalAlignment="Right"
|
||||
Foreground="White" BorderBrush="Gray" BorderThickness="1"
|
||||
Clicked="FilePickerGlyph_Clicked"></controls:FilePickerGlyph>
|
||||
<TextBlock Text="Address bar readonly: " FontSize="22" Foreground="White" Grid.Row="5"/>
|
||||
Clicked="GameFilePickerGlyph_Clicked"></controls:FilePickerGlyph>
|
||||
<TextBlock Text="Toolbox path: " FontSize="22" Foreground="White" Grid.Row="5"></TextBlock>
|
||||
<TextBox Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Grid.Row="5"
|
||||
x:Name="ToolboxPathTextbox" FontSize="22" Margin="0, 0, 30, 0" Background="Transparent" Foreground="White"></TextBox>
|
||||
<controls:FilePickerGlyph Grid.Row="5" Grid.Column="1" Height="30" Width="30" HorizontalAlignment="Right"
|
||||
Foreground="White" BorderBrush="Gray" BorderThickness="1"
|
||||
Clicked="ToolboxFilePickerGlyph_Clicked"></controls:FilePickerGlyph>
|
||||
<TextBlock Text="Address bar readonly: " FontSize="22" Foreground="White" Grid.Row="6"/>
|
||||
<TextBox Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Grid.Row="6"
|
||||
x:Name="AddressBarReadonlyTextbox" FontSize="22" Background="Transparent" Foreground="White"></TextBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Daybreak.Views
|
||||
this.AddressBarReadonlyTextbox.Text = config.AddressBarReadonly.ToString();
|
||||
this.CharacterTextbox.Text = config.CharacterName;
|
||||
this.GamePathTextbox.Text = config.GamePath;
|
||||
this.ToolboxPathTextbox.Text = config.ToolboxPath;
|
||||
}
|
||||
|
||||
private void SaveButton_Clicked(object sender, System.EventArgs e)
|
||||
@@ -50,6 +51,7 @@ namespace Daybreak.Views
|
||||
var currentConfig = this.configurationManager.GetConfiguration();
|
||||
currentConfig.CharacterName = this.CharacterTextbox.Text;
|
||||
currentConfig.GamePath = this.GamePathTextbox.Text;
|
||||
currentConfig.ToolboxPath = this.ToolboxPathTextbox.Text;
|
||||
if (bool.TryParse(this.AddressBarReadonlyTextbox.Text, out var addressBarReadonly))
|
||||
{
|
||||
currentConfig.AddressBarReadonly = addressBarReadonly;
|
||||
@@ -57,10 +59,10 @@ namespace Daybreak.Views
|
||||
|
||||
this.configurationManager.SaveConfiguration(currentConfig);
|
||||
this.credentialManager.StoreCredentials(new LoginCredentials { Username = this.UsernameTextbox.Text, Password = this.PasswordBox.Password });
|
||||
this.viewManager.ShowView<StartupView>();
|
||||
this.viewManager.ShowView<MainView>();
|
||||
}
|
||||
|
||||
private void FilePickerGlyph_Clicked(object sender, System.EventArgs e)
|
||||
private void GameFilePickerGlyph_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
var filePicker = new OpenFileDialog()
|
||||
{
|
||||
@@ -75,9 +77,24 @@ namespace Daybreak.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void ToolboxFilePickerGlyph_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
var filePicker = new OpenFileDialog()
|
||||
{
|
||||
CheckFileExists = true,
|
||||
CheckPathExists = true,
|
||||
DefaultExt = "exe",
|
||||
Multiselect = false
|
||||
};
|
||||
if (filePicker.ShowDialog() is true)
|
||||
{
|
||||
this.ToolboxPathTextbox.Text = filePicker.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private void BackButton_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
this.viewManager.ShowView<StartupView>();
|
||||
this.viewManager.ShowView<MainView>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ Custom client for Guildwars.
|
||||
Requires standalone version https://developer.microsoft.com/microsoft-edge/webview2.
|
||||
|
||||

|
||||

|
||||
|
||||
## Features
|
||||
Automatically detect if guildwars is running or not. Includes the ability to launch guildwars from the client.
|
||||
|
||||
Reference in New Issue
Block a user