Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sefinek committed Jun 29, 2024
1 parent 7004cec commit e3bfcdc
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Build.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET "SOLUTION_PATH=.\Genshin FPS Unlocker.sln"
SET "SOLUTION_PATH=.\unlockfps_nc.sln"
SET "BIN_DIR=.\unlockfps_nc\bin"
SET "OBJ_DIR=.\unlockfps_nc\obj"
SET "RELEASE_DIR=.\unlockfps_nc\bin\Release"
Expand Down
Binary file added Dependencies/7z.dll
Binary file not shown.
Binary file added Dependencies/7z.exe
Binary file not shown.
90 changes: 90 additions & 0 deletions Dependencies/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Copyright (C) 1999-2023 Igor Pavlov.

The licenses for files are:

1) 7z.dll:
- The "GNU LGPL" as main license for most of the code
- The "GNU LGPL" with "unRAR license restriction" for some code
- The "BSD 3-clause License" for some code
2) All other files: the "GNU LGPL".

Redistributions in binary form must reproduce related license information from this file.

Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/




BSD 3-clause License
--------------------

The "BSD 3-clause License" is used for the code in 7z.dll that implements LZFSE data decompression.
That code was derived from the code in the "LZFSE compression library" developed by Apple Inc,
that also uses the "BSD 3-clause License":

----
Copyright (c) 2015-2016, Apple Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----




unRAR license restriction
-------------------------

The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.

The license for original unRAR code has the following restriction:

The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.


--
Igor Pavlov
18 changes: 17 additions & 1 deletion unlockfps_nc/Genshin FPS Unlocker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<StartupObject></StartupObject>
<StartupObject>unlockfps_nc.Program</StartupObject>
<AssemblyName>gen-fps-unlocker</AssemblyName>
<IsPublishable>False</IsPublishable>
<AssemblyVersion>3.2.2</AssemblyVersion>
<FileVersion>3.2.2</FileVersion>
<Version>3.2.2</Version>
<SignAssembly>False</SignAssembly>
<Company>Sefinek Inc.</Company>
<Authors>34736384</Authors>
<Title>Genshin FPS Unlocker</Title>
<Description>Genshin Impact FPS Unlocker</Description>
<RepositoryUrl>https://github.com/sefinek24/Genshin-FPS-Unlocker</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://stella.sefinek.net</PackageProjectUrl>
<Copyright>Copyright 2024 © by Sefinek. All Rights Reserved.</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RootNamespace>unlockfps_nc</RootNamespace>
</PropertyGroup>

Expand Down
32 changes: 15 additions & 17 deletions unlockfps_nc/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public partial class MainForm : Form
private Point _windowLocation;
private Size _windowSize;

public MainForm(
ConfigService configService,
ProcessService processService)
public MainForm(ConfigService configService, ProcessService processService)
{
InitializeComponent();
_configService = configService;
Expand All @@ -29,7 +27,7 @@ public MainForm(

private void SettingsMenuItem_Click(object sender, EventArgs e)
{
SettingsForm settingsForm = Program.ServiceProvider.GetRequiredService<SettingsForm>();
SettingsForm settingsForm = Program.ServiceProvider!.GetRequiredService<SettingsForm>();
settingsForm.ShowDialog();
}

Expand All @@ -44,34 +42,35 @@ private void MainForm_Load(object sender, EventArgs e)
{
_windowLocation = Location;
_windowSize = Size;
if (_config.AutoStart)
BtnStartGame_Click(null, null);
if (_config!.AutoStart) BtnStartGame_Click(null, null);

Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
}

private void SetupBindings()
{
InputFPS.DataBindings.Add("Value", _config, "FPSTarget", true, DataSourceUpdateMode.OnPropertyChanged);
SliderFPS.DataBindings.Add("Value", _config, "FPSTarget", true, DataSourceUpdateMode.OnPropertyChanged);
CBAutoStart.DataBindings.Add("Checked", _config, "AutoStart", true, DataSourceUpdateMode.OnPropertyChanged);
InputFPS.DataBindings.Add("Value", _config!, "FPSTarget", true, DataSourceUpdateMode.OnPropertyChanged);
SliderFPS.DataBindings.Add("Value", _config!, "FPSTarget", true, DataSourceUpdateMode.OnPropertyChanged);
CBAutoStart.DataBindings.Add("Checked", _config!, "AutoStart", true, DataSourceUpdateMode.OnPropertyChanged);
}

private void SetupMenuItem_Click(object sender, EventArgs e)
{
ShowSetupForm();
}

private void BtnStartGame_Click(object sender, EventArgs e)
private void BtnStartGame_Click(object? sender, EventArgs? e)
{
if (!File.Exists(_config.GamePath))
if (!File.Exists(_config!.GamePath))
ShowSetupForm();

if (_processService.Start())
if (File.Exists(_config!.GamePath) && _processService.Start())
WindowState = FormWindowState.Minimized;
}

private void ShowSetupForm()
private static void ShowSetupForm()
{
SetupForm setupForm = Program.ServiceProvider.GetRequiredService<SetupForm>();
SetupForm setupForm = Program.ServiceProvider!.GetRequiredService<SetupForm>();
setupForm.ShowDialog();
}

Expand All @@ -82,14 +81,13 @@ private void ExitMenuItem_Click(object sender, EventArgs e)

private void MainForm_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
NotifyAndHide();
if (WindowState == FormWindowState.Minimized) NotifyAndHide();
}

private void NotifyAndHide()
{
NotifyIconMain.Visible = true;
NotifyIconMain.Text = $@"FPS Unlocker (FPS: {_config.FPSTarget})";
NotifyIconMain.Text = string.Format(Resources.MainForm_GenshinFPSUnlocker_CurrentLimit, _config!.FPSTarget);
NotifyIconMain.ShowBalloonTip(500);

ShowInTaskbar = false;
Expand Down
9 changes: 5 additions & 4 deletions unlockfps_nc/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Runtime.InteropServices;
using Microsoft.Extensions.DependencyInjection;
using unlockfps_nc.Properties;
using unlockfps_nc.Service;
using unlockfps_nc.Utility;

Expand All @@ -9,25 +10,25 @@ internal static class Program
{
private static IntPtr MutexHandle = IntPtr.Zero;
public static readonly string RegistryPath = @"Software\Stella Mod Launcher";
public static IServiceProvider ServiceProvider { get; private set; }
public static IServiceProvider? ServiceProvider { get; private set; }

[STAThread]
private static void Main()
{
if (File.Exists("YuanShen.exe") || File.Exists("GenshinImpact.exe"))
{
MessageBox.Show(@"Do not place the unlocker in the game folder.", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(@"Do not place the unlocker in the game folder!", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

MutexHandle = Native.CreateMutex(IntPtr.Zero, true, @"GenshinFPSUnlocker");
if (Marshal.GetLastWin32Error() == 183)
{
MessageBox.Show(@"Another unlocker is already running.", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(Resources.Program_AnotherUnlockerIsAlreadyRunning, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

ServiceCollection services = new();
ServiceCollection services = [];
services.AddTransient<MainForm>();
services.AddTransient<SettingsForm>();
services.AddTransient<SetupForm>();
Expand Down
6 changes: 3 additions & 3 deletions unlockfps_nc/Service/ConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ConfigService()
Sanitize();
}

public Config? Config { get; private set; } = new();
public Config Config { get; private set; } = new();

private void Load()
{
Expand All @@ -24,7 +24,7 @@ private void Load()
try
{
string json = File.ReadAllText(CONFIG_NAME);
Config = JsonConvert.DeserializeObject<Config>(json);
Config = JsonConvert.DeserializeObject<Config>(json)!;
}
catch (Exception ex)
{
Expand All @@ -36,7 +36,7 @@ private void Load()

private void Sanitize()
{
Config!.FPSTarget = Math.Clamp(Config.FPSTarget, 1, 420);
Config.FPSTarget = Math.Clamp(Config.FPSTarget, 1, 420);
Config.Priority = Math.Clamp(Config.Priority, 0, 5);
Config.CustomResX = Math.Clamp(Config.CustomResX, 200, 7680);
Config.CustomResY = Math.Clamp(Config.CustomResY, 200, 4320);
Expand Down
27 changes: 12 additions & 15 deletions unlockfps_nc/SettingsForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection.PortableExecutable;
using unlockfps_nc.Model;
using unlockfps_nc.Properties;
using unlockfps_nc.Service;

namespace unlockfps_nc;
Expand Down Expand Up @@ -53,8 +54,7 @@ private void RefreshDllList()

private void UpdateControlState()
{
if (_config.PopupWindow) // they can't coexist (?) so disable the other
_config.Fullscreen = false;
if (_config!.PopupWindow) _config.Fullscreen = false; // They can't coexist (?) so disable the other

CBPopup.Enabled = !_config.Fullscreen;
CBFullscreen.Enabled = !_config.PopupWindow;
Expand All @@ -80,18 +80,17 @@ private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)

private void BtnAddDll_Click(object sender, EventArgs e)
{
if (DllAddDialog.ShowDialog() != DialogResult.OK)
return;
if (DllAddDialog.ShowDialog() != DialogResult.OK) return;

List<string> selectedFiles = DllAddDialog.FileNames.ToList();
List<string> selectedFiles = [.. DllAddDialog.FileNames];
selectedFiles = selectedFiles
.Where(x => VerifyDll(x) || MessageBox.Show(
$@"Invalid File: {Environment.NewLine}{x}{Environment.NewLine}{Environment.NewLine}Only native x64 dlls are supported",
@"Error", MessageBoxButtons.OK, MessageBoxIcon.Error) != DialogResult.OK)
.Where(x => !_config.DllList.Contains(x))
string.Format(Resources.SettingsForm_InvaildFile, x),
Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error) != DialogResult.OK)
.Where(x => _config!.DllList.Contains(x))
.ToList();

_config.DllList.AddRange(selectedFiles);
_config!.DllList.AddRange(selectedFiles);
RefreshDllList();
}

Expand All @@ -117,20 +116,18 @@ private void ListBoxDlls_Format(object sender, ListControlConvertEventArgs e)
private void ListBoxDlls_MouseMove(object sender, MouseEventArgs e)
{
int index = ListBoxDlls.IndexFromPoint(e.Location);
if (index == -1)
return;
if (index == -1) return;

string toolTipText = _config.DllList[index];
string toolTipText = _config!.DllList[index];
ToolTipSettings.SetToolTip(ListBoxDlls, toolTipText);
}

private void BtnRemoveDll_Click(object sender, EventArgs e)
{
int selectedIndex = ListBoxDlls.SelectedIndex;
if (selectedIndex == -1)
return;
if (selectedIndex == -1) return;

_config.DllList.RemoveAt(selectedIndex);
_config!.DllList.RemoveAt(selectedIndex);
RefreshDllList();
}
}
Loading

0 comments on commit e3bfcdc

Please sign in to comment.