Skip to content

Commit

Permalink
First iteration of the launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed Apr 21, 2021
1 parent 9478abe commit a0d89c3
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 0 deletions.
25 changes: 25 additions & 0 deletions GenshinLauncher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenshinLauncher", "GenshinLauncher\GenshinLauncher.csproj", "{1FD9D824-ABEC-4E60-A3E1-549EE95A4EF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1FD9D824-ABEC-4E60-A3E1-549EE95A4EF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FD9D824-ABEC-4E60-A3E1-549EE95A4EF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FD9D824-ABEC-4E60-A3E1-549EE95A4EF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FD9D824-ABEC-4E60-A3E1-549EE95A4EF3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BAFD00F7-07BB-4242-8643-2F64B50D0C0C}
EndGlobalSection
EndGlobal
41 changes: 41 additions & 0 deletions GenshinLauncher/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Application x:Class="GenshinLauncher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GenshinLauncher"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:ui="http://schemas.modernwpf.com/2019">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

<s:ApplicationLoader>
<s:ApplicationLoader.Bootstrapper>
<local:Bootstrapper />
</s:ApplicationLoader.Bootstrapper>
</s:ApplicationLoader>

<ui:ThemeResources />
<ui:XamlControlsResources />

<ui:IntellisenseResources Source="/ModernWpf;component/DesignTime/DesignTimeResources.xaml" />

</ResourceDictionary.MergedDictionaries>

<Style TargetType="ui:SimpleStackPanel">
<Setter Property="Spacing" Value="10" />
<Style.Resources>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="MinWidth" Value="200" />
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="MinWidth" Value="200" />
</Style>
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="MinWidth" Value="125" />
</Style>
</Style.Resources>
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions GenshinLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Windows;

namespace GenshinLauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions GenshinLauncher/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
28 changes: 28 additions & 0 deletions GenshinLauncher/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Navigation;
using GenshinLauncher.ViewModels;
using Stylet;

namespace GenshinLauncher
{
public class Bootstrapper : Bootstrapper<MainWindowViewModel>
{
protected override void Configure()
{
// Make Hyperlinks handle themselves
EventManager.RegisterClassHandler(
typeof(Hyperlink), Hyperlink.RequestNavigateEvent,
new RequestNavigateEventHandler((_, e) =>
{
var url = e.Uri.ToString();
Process.Start(new ProcessStartInfo(url)
{
UseShellExecute = true
});
})
);
}
}
}
3 changes: 3 additions & 0 deletions GenshinLauncher/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
74 changes: 74 additions & 0 deletions GenshinLauncher/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Binary file added GenshinLauncher/GenshinImpactIcon.ico
Binary file not shown.
31 changes: 31 additions & 0 deletions GenshinLauncher/GenshinLauncher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<LangVersion>latest</LangVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Authors>sabihoshi</Authors>
<Copyright />
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageProjectUrl></PackageProjectUrl>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLauncher</RepositoryUrl>
<Description>A Genshin Impact launcher with more options in Modern Fluent UI.</Description>
<ApplicationIcon>GenshinImpactIcon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.3.2" />
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
<PackageReference Include="PropertyChanged.Fody" Version="3.3.3" />
<PackageReference Include="Stylet" Version="1.3.6" />
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE.md">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions GenshinLauncher/Models/Quality.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace GenshinLauncher.Models
{
public enum Quality
{
Default,
Fastest,
Fast,
Simple,
Good,
Beautiful,
Fantastic,
Console
}
}
54 changes: 54 additions & 0 deletions GenshinLauncher/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Linq;
using System.Threading.Tasks;
using CliWrap;
using Stylet;

namespace GenshinLauncher.ViewModels
{
public class MainWindowViewModel : Screen
{
public MainWindowViewModel()
{
Quality = new();
Resolution = Resolution.Presets.Last();
}

public bool Fullscreen { get; set; } = true;

public bool Borderless { get; set; }

public Command Client => Cli.Wrap(GenshinLocation);

public QualityViewModel Quality { get; }

public Resolution Resolution { get; set; }

public string Title { get; } = "Genshin Impact Launcher";

public string GenshinLocation { get; set; } =
@"C:\Program Files\Genshin Impact\Genshin Impact Game\GenshinImpact.exe";

public async Task<CommandResult> LaunchSelector() =>
await Client.WithArguments("-show-screen-selector")
.ExecuteAsync();

public void LaunchGame()
{
var client = Client
.WithArguments(args => args
.Add("-screen-width").Add(Resolution.Width)
.Add("-screen-height").Add(Resolution.Height)
.Add("-screen-fullscreen").Add(Fullscreen ? 1 : 0));

if (Borderless)
client = client.WithArguments(args => args
.Add("-popupwindow"));

if (Quality.SelectedQuality != Models.Quality.Default)
client = client.WithArguments(args => args
.Add("-screen-quality").Add(Quality.SelectedQuality));

_ = client.ExecuteAsync();
}
}
}
15 changes: 15 additions & 0 deletions GenshinLauncher/ViewModels/QualityViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GenshinLauncher.Models;
using Stylet;

namespace GenshinLauncher.ViewModels
{
public class QualityViewModel : Screen
{
public IEnumerable<Quality> Qualities { get; } = Enum.GetValues(typeof(Quality)).Cast<Quality>();

public Quality SelectedQuality { get; set; } = Quality.Default;
}
}
37 changes: 37 additions & 0 deletions GenshinLauncher/ViewModels/Resolution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;

namespace GenshinLauncher.ViewModels
{
public class Resolution
{
public static List<Resolution> Presets = new()
{
new(640, 480),
new(720, 400),
new(720, 480),
new(800, 600),
new(1024, 768),
new(1152, 864),
new(1280, 720),
new(1280, 800),
new(1280, 960),
new(1280, 1024),
new(1336, 768),
new(1600, 900),
new(1680, 1050),
new(1920, 1080)
};

public Resolution(int width, int height)
{
Width = width;
Height = height;
}

public int Width { get; set; }

public int Height { get; set; }

public override string ToString() => $"{Width}x{Height}";
}
}
Loading

0 comments on commit a0d89c3

Please sign in to comment.