-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
*.swp | ||
*.*~ | ||
project.lock.json | ||
.DS_Store | ||
*.pyc | ||
nupkg/ | ||
|
||
# Visual Studio Code | ||
.vscode/ | ||
|
||
# Rider | ||
.idea/ | ||
|
||
# Visual Studio | ||
.vs/ | ||
|
||
# Fleet | ||
.fleet/ | ||
|
||
# Code Rush | ||
.cr/ | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
x64/ | ||
x86/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
[Oo]ut/ | ||
msbuild.log | ||
msbuild.err | ||
msbuild.wrn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Diagnostics; | ||
using Vanara.PInvoke; | ||
|
||
namespace WO3U.Fix | ||
{ | ||
class Program | ||
{ | ||
private const string STEAM_RUN_CMD = @"steam://rungameid/1879330"; | ||
private const string PROCESS_NAME = @"WO3U"; | ||
|
||
private static void StartSteamGame() | ||
{ | ||
var startInfo = new ProcessStartInfo | ||
{ | ||
FileName = STEAM_RUN_CMD, | ||
UseShellExecute = true | ||
}; | ||
|
||
using (var process = new Process()) | ||
{ | ||
process.StartInfo = startInfo; | ||
process.Start(); | ||
|
||
process.WaitForExit(); | ||
} | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Trying to set RefreshRate to 60Hz..."); | ||
|
||
var devMode = new DEVMODE(); | ||
User32.EnumDisplaySettings(null, User32.ENUM_CURRENT_SETTINGS, ref devMode); | ||
|
||
uint defaultFrequency = devMode.dmDisplayFrequency; | ||
devMode.dmDisplayFrequency = 60; // Max FPS for Warriors Orochi 3 Ultimate | ||
|
||
int result = User32.ChangeDisplaySettings(in devMode, User32.ChangeDisplaySettingsFlags.CDS_DEFAULT); | ||
if (result != 0) | ||
{ | ||
Console.WriteLine("Oh no! :(" + Environment.NewLine + "Couldn't set DisplayFrequency."); | ||
return; | ||
} | ||
|
||
Console.WriteLine("RefreshRate got set. Starting Warriors Orochi 3 Ultimate..."); | ||
|
||
bool cancel = false; | ||
Console.CancelKeyPress += (sender, e) => { | ||
e.Cancel = true; | ||
cancel = true; | ||
}; | ||
|
||
try | ||
{ | ||
StartSteamGame(); | ||
Console.WriteLine("Waiting for the Game to run. Press Ctrl+C to abort."); | ||
|
||
Process? wo3uProcess = null; | ||
while (wo3uProcess is null) | ||
{ | ||
if (cancel) return; | ||
|
||
Console.WriteLine("Wait for WO3U.exe..."); | ||
Thread.Sleep(1000); | ||
wo3uProcess = Process.GetProcessesByName(PROCESS_NAME).FirstOrDefault(); | ||
} | ||
|
||
Console.WriteLine($"Found WO3U.exe with ProcessID {wo3uProcess.Id}"); | ||
|
||
wo3uProcess.WaitForExit(); | ||
Console.WriteLine("Game exited. Reset RefreshRate..."); | ||
} | ||
finally | ||
{ | ||
// Reset RefreshRate | ||
devMode.dmDisplayFrequency = defaultFrequency; | ||
User32.ChangeDisplaySettings(in devMode, User32.ChangeDisplaySettingsFlags.CDS_DEFAULT); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<SelfContained>false</SelfContained> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
<Nullable>enable</Nullable> | ||
<ApplicationIcon>1.ico</ApplicationIcon> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.17" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WO3U.Fix", "WO3U.Fix.csproj", "{EB66D68B-71A8-4A27-AF42-C462CEEB2ADA}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EB66D68B-71A8-4A27-AF42-C462CEEB2ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EB66D68B-71A8-4A27-AF42-C462CEEB2ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EB66D68B-71A8-4A27-AF42-C462CEEB2ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EB66D68B-71A8-4A27-AF42-C462CEEB2ADA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2A0DC39B-2E70-4FD7-8EF5-50232230F742} | ||
EndGlobalSection | ||
EndGlobal |