Commit existing code

TODO:
- Design Linux launcher as the glade layout file is currently empty
- Resolve all warnings (icky code)
This commit is contained in:
rjindael 2023-06-13 00:25:06 -07:00
parent 28a1c1ac23
commit 134839b924
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
20 changed files with 453 additions and 70 deletions

2
.gitignore vendored
View File

@ -184,7 +184,7 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
# *.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to

View File

@ -0,0 +1,88 @@
using Newtonsoft.Json;
namespace Kiseki.Launcher.Core
{
public enum ProgressBarState
{
Normal,
Marquee
}
public class Controller
{
private readonly string BaseURL;
private readonly string[] Arguments;
public event EventHandler<string> PageHeadingChanged;
public event EventHandler<int> ProgressBarChanged;
public event EventHandler<ProgressBarState> ProgressBarStateChanged;
public event EventHandler Launched;
public Controller(string BaseURL, string[] Arguments)
{
this.BaseURL = BaseURL;
this.Arguments = Arguments;
}
public async void Start()
{
this.OnPageHeadingChange("Connecting to Kiseki...");
bool marquee = true;
await foreach (int progressValue in StreamBackgroundOperationProgressAsync())
{
if (marquee)
{
this.OnPageHeadingChange("Downloading Kiseki...");
this.OnProgressBarStateChanged(ProgressBarState.Normal);
marquee = false;
}
this.OnProgressBarChange(progressValue);
}
static async IAsyncEnumerable<int> StreamBackgroundOperationProgressAsync()
{
await Task.Delay(2800);
for (int i = 0; i <= 100; i += 4)
{
yield return i;
await Task.Delay(200);
}
}
this.OnPageHeadingChange("Installing Kiseki...");
this.OnProgressBarStateChanged(ProgressBarState.Marquee);
await Task.Delay(2200);
this.OnPageHeadingChange("Configuring Kiseki...");
await Task.Delay(1200);
this.OnPageHeadingChange("Launching Kiseki...");
await Task.Delay(3000);
this.OnLaunched();
}
protected virtual void OnPageHeadingChange(string Heading)
{
PageHeadingChanged.Invoke(this, Heading);
}
protected virtual void OnProgressBarChange(int Value)
{
ProgressBarChanged.Invoke(this, Value);
}
protected virtual void OnProgressBarStateChanged(ProgressBarState State)
{
ProgressBarStateChanged.Invoke(this, State);
}
protected virtual void OnLaunched()
{
Launched.Invoke(this, EventArgs.Empty);
}
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>9da0f813-6151-496b-b907-c94a7b6a3889</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Kiseki.Launcher.Core</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Controller.cs" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>9da0f813-6151-496b-b907-c94a7b6a3889</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Kiseki.Launcher.Core.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GtkSharp" Version="3.24.24.95" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<Import Project="..\Kiseki.Launcher.Core\Kiseki.Launcher.Core.projitems" Label="Shared" />
</Project>

View File

@ -0,0 +1,32 @@
using Gtk;
using Kiseki.Launcher.Core;
using UI = Gtk.Builder.ObjectAttribute;
namespace Kiseki.Launcher.Linux
{
public class MainWindow : Window
{
[UI] private readonly Image Logo = null;
[UI] private readonly ProgressBar ProgressBar = null;
[UI] private readonly Label PageHeading = null;
[UI] private readonly Button CancelButton = null;
private readonly Controller Controller;
public MainWindow() : this(new Builder("MainWindow.glade")) { }
private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow"))
{
builder.Autoconnect(this);
DeleteEvent += Window_DeleteEvent;
CancelButton.Clicked += Window_DeleteEvent;
}
private void Window_DeleteEvent(object? sender, EventArgs? e)
{
Application.Quit();
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.18"/>
<object class="GtkWindow" id="MainWindow">
<!-- TODO -->
</object>
</interface>

View File

@ -0,0 +1,22 @@
using Gtk;
namespace Kiseki.Launcher.Linux
{
public class Program
{
[STAThread]
public static void Main(string[] args)
{
Application.Init();
var app = new Application("org.Kiseki.Launcher", GLib.ApplicationFlags.None);
app.Register(GLib.Cancellable.Current);
var window = new MainWindow();
app.AddWindow(window);
window.Show();
Application.Run();
}
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>..\bin\Release\linux-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\IconKiseki.ico</ApplicationIcon>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.0</Version>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyName>Kiseki.Launcher</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="..\Kiseki.Launcher.Core\Kiseki.Launcher.Core.projitems" Label="Shared" />
</Project>

View File

@ -0,0 +1,77 @@
using Kiseki.Launcher.Windows.Properties;
using Kiseki.Launcher.Core;
namespace Kiseki.Launcher.Windows
{
[System.ComponentModel.DesignerCategory("")]
public class MainWindow : Form
{
private readonly TaskDialogButton CloseButton;
private readonly TaskDialogPage Page;
private readonly Controller Controller;
public MainWindow(string[] args)
{
this.CloseButton = TaskDialogButton.Close;
this.Page = new TaskDialogPage()
{
Caption = "Kiseki",
AllowMinimize = true,
ProgressBar = new TaskDialogProgressBar()
{
State = TaskDialogProgressBarState.Marquee
},
Buttons = { this.CloseButton }
};
this.Controller = new Controller("kiseki.lol", args);
this.Controller.PageHeadingChanged += Controller_PageHeadingChanged;
this.Controller.ProgressBarChanged += Controller_ProgressBarChanged;
this.Controller.ProgressBarStateChanged += Controller_ProgressBarStateChanged;
this.Controller.Launched += Controller_Launched;
this.ShowProgressDialog();
}
private void Controller_PageHeadingChanged(object sender, string Heading)
{
this.Page.Heading = Heading;
}
private void Controller_ProgressBarChanged(object sender, int Value)
{
this.Page.ProgressBar.Value = Value;
}
private void Controller_ProgressBarStateChanged(object sender, ProgressBarState State)
{
this.Page.ProgressBar.State = State switch
{
ProgressBarState.Normal => TaskDialogProgressBarState.Normal,
ProgressBarState.Marquee => TaskDialogProgressBarState.Marquee,
_ => throw new NotImplementedException()
};
}
private void Controller_Launched(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void ShowProgressDialog()
{
TaskDialogIcon logo = new(Resources.IconKiseki);
this.Page.Icon = logo;
this.Page.Created += (s, e) =>
{
this.Controller.Start();
};
TaskDialog.ShowDialog(this.Page);
}
}
}

View File

@ -1,4 +1,4 @@
namespace Kiseki.Launcher
namespace Kiseki.Launcher.Windows
{
internal static class Program
{
@ -6,12 +6,12 @@ namespace Kiseki.Launcher
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new MainWindow(args));
}
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>..\bin\Release\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kiseki.Launcher.Windows.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kiseki.Launcher.Windows.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon IconKiseki {
get {
object obj = ResourceManager.GetObject("IconKiseki", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@ -117,4 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="IconKiseki" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\IconKiseki.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33712.159
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kiseki.Launcher", "Kiseki.Launcher\Kiseki.Launcher.csproj", "{BE53015E-6EB9-42F7-BA80-887D0A5F9977}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kiseki.Launcher.Windows", "Kiseki.Launcher.Windows\Kiseki.Launcher.Windows.csproj", "{38AAA6A8-C482-4F17-816F-E0A42B065033}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kiseki.Launcher.Linux", "Kiseki.Launcher.Linux\Kiseki.Launcher.Linux.csproj", "{40AB861A-C06C-4279-86F6-EC60BEC2C690}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Kiseki.Launcher.Core", "Kiseki.Launcher.Core\Kiseki.Launcher.Core.shproj", "{9DA0F813-6151-496B-B907-C94A7B6A3889}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +15,24 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BE53015E-6EB9-42F7-BA80-887D0A5F9977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE53015E-6EB9-42F7-BA80-887D0A5F9977}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE53015E-6EB9-42F7-BA80-887D0A5F9977}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE53015E-6EB9-42F7-BA80-887D0A5F9977}.Release|Any CPU.Build.0 = Release|Any CPU
{38AAA6A8-C482-4F17-816F-E0A42B065033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38AAA6A8-C482-4F17-816F-E0A42B065033}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38AAA6A8-C482-4F17-816F-E0A42B065033}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38AAA6A8-C482-4F17-816F-E0A42B065033}.Release|Any CPU.Build.0 = Release|Any CPU
{40AB861A-C06C-4279-86F6-EC60BEC2C690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40AB861A-C06C-4279-86F6-EC60BEC2C690}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40AB861A-C06C-4279-86F6-EC60BEC2C690}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40AB861A-C06C-4279-86F6-EC60BEC2C690}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E283B6E8-7F09-414D-AA9C-0725447DC36B}
SolutionGuid = {E7B8D704-EF09-4D85-998B-ED22ECD4D09F}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Kiseki.Launcher.Core\Kiseki.Launcher.Core.projitems*{38aaa6a8-c482-4f17-816f-e0a42b065033}*SharedItemsImports = 5
Kiseki.Launcher.Core\Kiseki.Launcher.Core.projitems*{40ab861a-c06c-4279-86f6-ec60bec2c690}*SharedItemsImports = 5
Kiseki.Launcher.Core\Kiseki.Launcher.Core.projitems*{9da0f813-6151-496b-b907-c94a7b6a3889}*SharedItemsImports = 13
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
namespace Kiseki.Launcher
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace Kiseki.Launcher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>