Skip to content

Commit

Permalink
Add my local commit
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jan 11, 2022
1 parent 2f938c1 commit 64ba40e
Show file tree
Hide file tree
Showing 37 changed files with 1,448 additions and 358 deletions.
20 changes: 18 additions & 2 deletions CollapseLauncher.Invoker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public static void Main (string[] args)
case "migrate":
DoMigration();
break;
case "applygamesettings":
DoApplyGameSettings();
break;
case "loadgamesettings":
DoLoadGameSettings();
break;
default:
Console.WriteLine($"Invalid argument!");
break;
Expand All @@ -32,20 +38,30 @@ public static void Main (string[] args)
}
}

static void DoApplyGameSettings()
{

}

static void DoLoadGameSettings()
{

}

static void DoMigration()
{
string source = argument[1];
string target = argument[2];

string sourceGame, targetGame = Path.Combine(target, "Games");
string sourceGame, targetGame;

IniFile iniFile = new IniFile();

if (File.Exists(Path.Combine(source, "config.ini")))
{
iniFile.Load(Path.Combine(source, "config.ini"));
sourceGame = ConverterTool.NormalizePath(iniFile["launcher"]["game_install_path"].ToString());

targetGame = Path.Combine(target, Path.GetFileName(sourceGame));
Console.WriteLine($"Moving From:\r\n\t{source}\r\nTo Destination:\r\n\t{target}");
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion CollapseLauncher.Invoker/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"CollapseLauncher.Invoker": {
"commandName": "Project",
"commandLineArgs": "migrate \"C:\\Program Files\\Honkai Impact 3rd glb\" \"C:\\Users\\neon-nyan\\AppData\\LocalLow\\CollapseLauncher\\GameFolder\\Hi3Global\""
"commandLineArgs": "applygamesettings"
}
}
}
2 changes: 1 addition & 1 deletion CollapseLauncher.Invoker/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges>
</security>
</trustInfo>
Expand Down
4 changes: 3 additions & 1 deletion CollapseLauncher/CollapseLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

using Hi3Helper;

using static CollapseLauncher.LauncherConfig;
using static Hi3Helper.Shared.Region.LauncherConfig;
using static CollapseLauncher.InvokeProp;

using static Hi3Helper.Logger;
Expand All @@ -40,6 +40,7 @@ namespace CollapseLauncher
/// </summary>
public partial class App : Application
{
public static bool IsAppKilled = false;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand Down Expand Up @@ -73,6 +74,7 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
var windowNative = m_window.As<IWindowNative>();
m_windowHandle = windowNative.WindowHandle;
m_window.Activate();
LogWriteLine($"WindowID IntPtr: {m_windowHandle}");

SetWindowSize(m_windowHandle, 1280, 730);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
using Hi3Helper.Data;
using Hi3Helper.Preset;

using static Hi3Helper.Shared.Region.LauncherConfig;
using Hi3Helper.Shared.ClassStruct;

using static Hi3Helper.Logger;
using static CollapseLauncher.LauncherConfig;

namespace CollapseLauncher
{
Expand All @@ -39,7 +41,7 @@ private void ChangeBackgroundImageAsRegion()
{
try
{
httpClient = new HttpClientTool();
httpClient = new HttpClientTool(true);

if (startUp)
{
Expand Down Expand Up @@ -212,20 +214,4 @@ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
}
}
}

public class RegionBackgroundProp
{
public RegionBackgroundProp_data data { get; set; }
public string imgLocalPath { get; set; } = string.Empty;
}

public class RegionBackgroundProp_data
{
public RegionBackgroundProp_data_adv adv { get; set; }
}
public class RegionBackgroundProp_data_adv
{
public string background { get; set; }
public string bg_checksum { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

using Hi3Helper.Data;
using Hi3Helper.Preset;
using Hi3Helper.Shared.ClassStruct;

using static Hi3Helper.Logger;
using static CollapseLauncher.LauncherConfig;
using static Hi3Helper.Shared.Region.LauncherConfig;

namespace CollapseLauncher
{
Expand All @@ -47,27 +48,4 @@ public void FetchLauncherResourceAsRegion()
}
}
}

public class RegionResourceProp
{
public RegionResourceGame data { get; set; }
}
public class RegionResourceGame
{
public RegionResourceLatest game { get; set; }
public RegionResourceLatest pre_download_game { get; set; }
}

public class RegionResourceLatest
{
public RegionResourceVersion latest { get; set; }
}

public class RegionResourceVersion
{
public string version { get; set; }
public string path { get; set; }
public string size { get; set; }
public string md5 { get; set; }
}
}
125 changes: 2 additions & 123 deletions CollapseLauncher/CollapseLauncher/Classes/Properties/GameConfig.cs
Original file line number Diff line number Diff line change
@@ -1,131 +1,10 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Windowing;

using Windows.UI.ViewManagement;
using Windows.Graphics.Display;

using Hi3Helper.Preset;
using Hi3Helper.Data;
using Hi3Helper.Screen;

using static Hi3Helper.Preset.ConfigStore;
using Microsoft.UI.Windowing;

namespace CollapseLauncher
{
public struct AppIniStruct
{
public IniFile Profile;
public Stream ProfileStream;
public string ProfilePath;
}

public enum GameInstallStateEnum
{
Installed = 0,
InstalledHavePreload = 1,
NotInstalled = 2,
NeedsUpdate = 3,
GameBroken = 4,
}

public static class LauncherConfig
public static class AppConfig
{
public static AppWindow _apw;
public static OverlappedPresenter _presenter;

public static string startupBackgroundPath;
public static RegionBackgroundProp regionBackgroundProp = new RegionBackgroundProp();
public static RegionResourceProp regionResourceProp = new RegionResourceProp();
public static PresetConfigClasses CurrentRegion = new PresetConfigClasses();
public static List<string> GameConfigName = new List<string>();
public static List<string> ScreenResolutionsList = new List<string>();

public static AppIniStruct appIni = new AppIniStruct();

public static string AppFolder = AppDomain.CurrentDomain.BaseDirectory;
public static string AppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "CollapseLauncher");
public static string AppGameFolder = Path.Combine(AppDataFolder, "GameFolder");
public static string AppConfigFile = Path.Combine(AppDataFolder, "config.ini");

public static bool RequireAdditionalDataDownload;
public static bool IsThisRegionInstalled;
public static GameInstallStateEnum GameInstallationState = GameInstallStateEnum.NotInstalled;

public static void LoadGamePreset()
{
AppGameFolder = Path.Combine(GetAppConfigValue("GameFolder").ToString());
LoadConfigFromFile(Path.Combine(AppFolder, "config", "fileconfig.json"));
GameConfigName = Config.Select(x => x.ZoneName).ToList();
}

public static void GetScreenResolutionString()
{
foreach (ScreenResolution res in ScreenProp.screenResolutions)
ScreenResolutionsList.Add(res.ToString());
}

public static void LoadAppPreset()
{
ScreenProp.InitScreenResolution();
GetCurrentScreenResolution();
GetScreenResolutionString();
if (!Directory.Exists(AppDataFolder))
Directory.CreateDirectory(AppDataFolder);

appIni.Profile = new IniFile();
appIni.ProfilePath = AppConfigFile;

if (!File.Exists(appIni.ProfilePath))
{
PrepareAppInstallation();
SaveAppConfig();
}

LoadAppConfig();
startupBackgroundPath = GetAppConfigValue("CurrentBackground").ToString();
}

private static void GetCurrentScreenResolution()
{
var bounds = ApplicationView.GetForCurrentView().VisibleBounds;
var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
var size = new Size((int)((double)bounds.Width * scaleFactor), (int)((double)bounds.Height * scaleFactor));
}

public static IniValue GetAppConfigValue(string key) => appIni.Profile["app"][key];

public static void LoadAppConfig() => appIni.Profile.Load(appIni.ProfileStream = new FileStream(appIni.ProfilePath, FileMode.Open, FileAccess.Read));
public static void SaveAppConfig() => appIni.Profile.Save(appIni.ProfileStream = new FileStream(appIni.ProfilePath, FileMode.OpenOrCreate, FileAccess.Write));

public static void PrepareAppInstallation() => BuildAppIniProfile();

static void BuildAppIniProfile()
{
appIni.Profile.Add("app", new Dictionary<string, IniValue>
{
{ "CurrentRegion", new IniValue(0) },
{ "CurrentBackground", new IniValue(@"Assets\BG\default_bg.png") },
{ "DownloadThread", new IniValue(16) },
{ "GameFolder", new IniValue(AppGameFolder) }
});

SaveAppConfig();
}
}

public partial class MainPage : Page
{
public void LoadConfig()
{
ComboBoxGameRegion.ItemsSource = LauncherConfig.GameConfigName;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
using Hi3Helper.Data;

using static Hi3Helper.Logger;
using static Hi3Helper.Data.ConverterTool;
using static CollapseLauncher.LauncherConfig;
using static CollapseLauncher.Region.InstallationManagement;
using static Hi3Helper.Shared.Region.LauncherConfig;
using static Hi3Helper.Shared.Region.InstallationManagement;

namespace CollapseLauncher
{
Expand Down
Binary file modified CollapseLauncher/CollapseLauncher/CollapseLauncher.Invoker.exe
Binary file not shown.
9 changes: 8 additions & 1 deletion CollapseLauncher/CollapseLauncher/CollapseLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<None Remove="Pages\CutscenesPage.xaml" />
<None Remove="Pages\GameSettingsPage.xaml" />
<None Remove="Pages\SettingsPage.xaml" />
<None Remove="Pages\UnavailablePage.xaml" />
<None Remove="ResourceDictionary.xaml" />
</ItemGroup>
<ItemGroup>
Expand All @@ -43,7 +44,10 @@
</ItemGroup>

<ItemGroup>
<Content Update="Assets\BG\default_bg.png">
<Content Update="Assets\BG\default.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="Assets\BG\default.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand All @@ -52,6 +56,9 @@
<Page Update="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Pages\UnavailablePage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Pages\CutscenesPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
Expand Down
9 changes: 5 additions & 4 deletions CollapseLauncher/CollapseLauncher/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness>
</Page.Resources>
<Grid x:Name="MainPageGrid">
<Image x:Name="BackgroundBack" Source="Assets\BG\default_bg.png" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.40"/>
<Image x:Name="BackgroundBack" Source="Assets\BG\default.png" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.40"/>
<Border x:Name="AppTitleBar"
IsHitTestVisible="True"
VerticalAlignment="Top"
Expand Down Expand Up @@ -55,8 +55,9 @@
</ComboBox>
</StackPanel>
<NavigationView x:Name="NavigationViewControl"
IsTitleBarAutoPaddingEnabled="False"
IsBackButtonVisible="Collapsed"
IsTitleBarAutoPaddingEnabled="False"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="false"
Header=""
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
Canvas.ZIndex="0" Visibility="Visible" IsPaneOpen="False" Background="{StaticResource NavigationBarBrush}"
Expand All @@ -67,7 +68,7 @@
</NavigationView.MenuItems>

<Grid Margin="0,0,0,0">
<Image x:Name="BackgroundFront" Source="Assets\BG\default_bg.png" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image x:Name="BackgroundFront" Source="Assets\BG\default.png" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image.RenderTransform>
<TranslateTransform />
</Image.RenderTransform>
Expand Down
Loading

0 comments on commit 64ba40e

Please sign in to comment.