Skip to content

Commit

Permalink
SeventhHeavenUI: Enable native Steam edition support
Browse files Browse the repository at this point in the history
Launching the Steam edition of the game will no more require a conversion.
Additionally, launching 1998 edition will now require the official disk.

Every other way is not officially supported starting now.
  • Loading branch information
julianxhokaxhiu committed Apr 15, 2024
1 parent 2a4b93e commit 101a0f8
Show file tree
Hide file tree
Showing 37 changed files with 548 additions and 1,032 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 7th-Heaven

run-name: 3.5.1.${{ github.run_number }}
run-name: 3.9.9.${{ github.run_number }}

on:
workflow_dispatch:
Expand All @@ -20,7 +20,7 @@ env:
_RELEASE_VERSION: v0
_RELEASE_CONFIGURATION: Release
_BUILD_BRANCH: "${{ github.ref }}"
_BUILD_VERSION: "3.5.1.${{ github.run_number }}"
_BUILD_VERSION: "3.9.9.${{ github.run_number }}"
_CHANGELOG_VERSION: "0"
# VCPKG: Enable Binary Caching
VCPKG_BINARY_SOURCES: clear;nuget,github,readwrite
Expand All @@ -40,7 +40,9 @@ jobs:
git config --global core.filemode false
git config --global core.longpaths true
- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare Environment
run: ".github/workflows/prepare.ps1"
shell: pwsh
Expand All @@ -55,7 +57,7 @@ jobs:
- name: Restore NuGet Packages
run: nuget restore ${{ github.workspace }}\${{ env._RELEASE_NAME }}.sln
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.3.2
uses: microsoft/setup-msbuild@v1
- name: Run MSBuild
run: msbuild ${{ github.workspace }}\${{ env._RELEASE_NAME }}.sln /p:WindowsTargetPlatformVersion=10.0.19041.0 /m -p:Configuration=${{ env._RELEASE_CONFIGURATION }} -p:Platform="Any CPU"
- name: Prepare Installer
Expand Down Expand Up @@ -90,7 +92,7 @@ jobs:
return ret;
- name: Publish PR artifacts
if: env._IS_GITHUB_RELEASE == 'false' && success()
uses: actions/upload-artifact@v4.0.0
uses: actions/upload-artifact@v4
with:
name: "${{ env._RELEASE_NAME }}-${{ env._RELEASE_VERSION }}"
path: ".dist/*"
Expand Down
13 changes: 0 additions & 13 deletions 7thHeaven.Code/LaunchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@

namespace _7thHeaven.Code
{
public enum MountDiscOption
{
Unknown = -1,
MountWithPowerShell = 0,
MountWithWinCDEmu = 1,
DoNotMount =2,
}

[Serializable]
public class LaunchSettings
{
public bool AutoMountGameDisc { get; set; }
public bool AutoUnmountGameDisc { get; set; }
public bool AutoUpdateDiscPath { get; set; }
public MountDiscOption MountingOption { get; set; }

public bool DisableReunionOnLaunch { get; set; }

Expand Down Expand Up @@ -49,8 +39,6 @@ public static LaunchSettings DefaultSettings()
{
return new LaunchSettings()
{
AutoMountGameDisc = true,
AutoUnmountGameDisc = true,
AutoUpdateDiscPath = true,
DisableReunionOnLaunch = true,
SelectedSoundDevice = Guid.Empty,
Expand All @@ -62,7 +50,6 @@ public static LaunchSettings DefaultSettings()
HasDisplayedOggMusicWarning = false,
HasDisplayedMovieWarning = false,
EnablePs4ControllerService = false,
MountingOption = MountDiscOption.MountWithPowerShell,
EnableGamepadPolling = false,
};
}
Expand Down
8 changes: 6 additions & 2 deletions 7thHeaven.Code/RegistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public static class RegistryHelper

private static List<string> transaction = new();

public const string SteamKeyPath64Bit = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 39140";
public const string SteamKeyPath64Bit = @"HKEY_CURRENT_USER\Software\Wow6432Node\Valve\Steam";

public const string SteamKeyPath32Bit = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 39140";
public const string SteamKeyPath32Bit = @"HKEY_CURRENT_USER\Software\Valve\Steam";

public const string FF7SteamKeyPath64Bit = @"HKEY_CURRENT_USER\Software\Wow6432Node\Valve\Steam\Apps\39140";

public const string FF7SteamKeyPath32Bit = @"HKEY_CURRENT_USER\Software\Valve\Steam\Apps\39140";

public const string RereleaseKeyPath64Bit = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{141B8BA9-BFFD-4635-AF64-078E31010EC3}_is1";

Expand Down
10 changes: 9 additions & 1 deletion 7thHeaven.Code/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The original developer is Iros <[email protected]>

namespace Iros._7th.Workshop {

public enum FF7Version
{
Unknown = -1,
Steam,
ReRelease,
Original98
}

public enum GeneralOptions {
None = 0,
Expand Down Expand Up @@ -105,6 +112,7 @@ public List<string> SubscribedUrls
public string FF7Exe { get; set; }
[System.Xml.Serialization.XmlElement("AlsoLaunch")]
public List<ProgramLaunchInfo> ProgramsToLaunchPrior { get; set; }
public FF7Version FF7InstalledVersion { get; set; }
public FFNxUpdateChannelOptions FFNxUpdateChannel { get; set; }
public AppUpdateChannelOptions AppUpdateChannel { get; set; }
public DateTime LastUpdateCheck { get; set; }
Expand Down Expand Up @@ -202,7 +210,7 @@ public static Settings UseDefaultSettings()
/// <param name="pathToFf7Install"></param>
public void SetPathsFromInstallationPath(string pathToFf7Install)
{
FF7Exe = Path.Combine(pathToFf7Install, "FF7.exe");
FF7Exe = Sys.Settings.FF7InstalledVersion == FF7Version.Original98 ? Path.Combine(pathToFf7Install, "FF7.exe") : Path.Combine(pathToFf7Install, "ff7_en.exe");
LibraryLocation = Path.Combine(pathToFf7Install, "mods", @"7th Heaven");

LogAndCreateFolderIfNotExists(LibraryLocation);
Expand Down
1 change: 1 addition & 0 deletions 7thHeaven.Code/StringKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public enum StringKey
DeletingTemporaryFiles,
BeginningToPollForGamePadInput,
FoundLanguageInstalledCreatingEnglishGameFiles,
ErrorOnlyEnglishLanguageSupported,
Ff7IsCurrentlyInstalledInASystemFolder,
CanNotContinueDueToFf7nstalledInProtectedFolder,
CannotContinue,
Expand Down
1 change: 0 additions & 1 deletion 7thHeaven.Code/Sys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The original developer is Iros <[email protected]>

namespace Iros._7th.Workshop
{

public class ModStatusEventArgs : EventArgs
{
public ModStatus OldStatus { get; set; }
Expand Down
14 changes: 14 additions & 0 deletions 7thHeaven.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "7thWrapperLoader", "7thWrap
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "7thWrapperProxy", "7thWrapperProxy\7thWrapperProxy.csproj", "{F955F161-A47E-4399-9FD2-DB0D83E6461A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FF7_Launcher", "FF7_Launcher\FF7_Launcher.vcxproj", "{E9DF030F-3113-46CD-81EB-DDEC52A7C926}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -109,6 +111,18 @@ Global
{F955F161-A47E-4399-9FD2-DB0D83E6461A}.Release|x64.Build.0 = Release|Any CPU
{F955F161-A47E-4399-9FD2-DB0D83E6461A}.Release|x86.ActiveCfg = Release|Any CPU
{F955F161-A47E-4399-9FD2-DB0D83E6461A}.Release|x86.Build.0 = Release|Any CPU
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|Any CPU.ActiveCfg = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|Any CPU.Build.0 = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|x64.ActiveCfg = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|x64.Build.0 = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|x86.ActiveCfg = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Debug|x86.Build.0 = Debug|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|Any CPU.ActiveCfg = Release|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|Any CPU.Build.0 = Release|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|x64.ActiveCfg = Release|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|x64.Build.0 = Release|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|x86.ActiveCfg = Release|win32
{E9DF030F-3113-46CD-81EB-DDEC52A7C926}.Release|x86.Build.0 = Release|win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions 7thWrapperLib/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public IEnumerable<ProgramInfo> GetLoadPrograms()
public static bool DirExists(string dir)
{
bool exist = System.IO.Directory.Exists(dir);
DebugLogger.DetailedWriteLine($"MOD: Check if directory exists {dir}: {exist}");
//DebugLogger.DetailedWriteLine($"MOD: Check if directory exists {dir}: {exist}");
return exist;
}

Expand Down Expand Up @@ -350,7 +350,7 @@ private bool FileExists(string file)
exist = System.IO.File.Exists(file);
if (exist) _activated.Add(file);
}
DebugLogger.DetailedWriteLine($"MOD: Check if file exists {file}: {exist}");
//DebugLogger.DetailedWriteLine($"MOD: Check if file exists {file}: {exist}");
return exist;
}

Expand Down
52 changes: 35 additions & 17 deletions 7thWrapperLib/Wrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static void MonitorThread(object rpo)

do
{
DebugLogger.WriteLine("MONITOR:");
DebugLogger.WriteLine(">> MONITOR:");
for (int i = 0; i < accessors.Count; i++)
{
int value;
Expand Down Expand Up @@ -85,16 +85,29 @@ public static void Run(Process currentProcess, string profileFile = ".7thWrapper
}
}

DebugLogger.WriteLine($"Wrap run... PName: {_process.ProcessName} PID: {_process.Id} Path: {_profile.ModPath} Capture: {String.Join(", ", _profile.MonitorPaths)}");
DebugLogger.WriteLine($"Starting wrapper now:");

DebugLogger.WriteLine($">> PName: {_process.ProcessName}");
DebugLogger.WriteLine($">> PID: {_process.Id}");
DebugLogger.WriteLine($">> FF7Path: {_profile.FF7Path}");
DebugLogger.WriteLine($">> ModPath: {_profile.ModPath}");
DebugLogger.WriteLine($">> MonitorPaths:");
foreach(string monPath in _profile.MonitorPaths)
DebugLogger.WriteLine($" - {monPath}");
for (int i = _profile.MonitorPaths.Count - 1; i >= 0; i--) {
if (!_profile.MonitorPaths[i].EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
_profile.MonitorPaths[i] += System.IO.Path.DirectorySeparatorChar;
if (String.IsNullOrWhiteSpace(_profile.MonitorPaths[i])) _profile.MonitorPaths.RemoveAt(i);
}

DebugLogger.WriteLine($"\nLoading mods:");

foreach (var item in _profile.Mods) {
DebugLogger.WriteLine($" Mod: {item.BaseFolder} has {item.Conditionals.Count} conditionals");
DebugLogger.WriteLine(" Additional paths: " + String.Join(", ", item.ExtraFolders));
DebugLogger.WriteLine($">> Mod: {item.BaseFolder}");
DebugLogger.WriteLine($" - Conditionals: {item.Conditionals.Count}");
DebugLogger.WriteLine($" - Extra Folders:");
foreach (string extraFolder in item.ExtraFolders)
DebugLogger.WriteLine($" - {extraFolder}");
item.Startup();
}

Expand All @@ -119,6 +132,8 @@ public static void Run(Process currentProcess, string profileFile = ".7thWrapper
}
}

DebugLogger.WriteLine($"\nLoading hext patches:");

foreach (var mod in _profile.Mods.AsEnumerable().Reverse()) {
foreach (string file in mod.GetPathOverrideNames("hext")) {
foreach (var of in mod.GetOverrides("hext\\" + file)) {
Expand All @@ -128,11 +143,11 @@ public static void Run(Process currentProcess, string profileFile = ".7thWrapper
} else {
s = of.Archive.GetData(of.File);
}
DebugLogger.WriteLine($"Applying hext patch {file} from mod {mod.BaseFolder}");
DebugLogger.WriteLine($">> Applying hext patch {file} from mod {mod.BaseFolder}");
try {
HexPatch.Apply(s);
} catch (Exception ex) {
DebugLogger.WriteLine("Error applying patch: " + ex.Message);
DebugLogger.WriteLine(" - Error applying patch: " + ex.Message);
}
}
}
Expand Down Expand Up @@ -167,6 +182,9 @@ public static void Run(Process currentProcess, string profileFile = ".7thWrapper
AddIROFilesToMappedFiles("", null, archive);
}
}

DebugLogger.WriteLine($"\nWrapper startup complete.");
DebugLogger.WriteLine($"\nListening for game actions...");
} catch (Exception e) {
DebugLogger.WriteLine(e.ToString());
return;
Expand Down Expand Up @@ -262,7 +280,7 @@ public static int HCloseHandle(IntPtr hObject)
if (_varchives.ContainsKey(hObject))
{
_varchives.Remove(hObject);
DebugLogger.WriteLine($"Closing dummy handle {hObject}");
DebugLogger.WriteLine($">> Closing dummy handle {hObject}");
}

return ret;
Expand All @@ -272,7 +290,7 @@ public static uint HGetFileType(IntPtr hFile)
{
uint ret = 0;

DebugLogger.DetailedWriteLine($"GetFileType on {hFile}");
DebugLogger.DetailedWriteLine($">> GetFileType on {hFile}");
if (_varchives.ContainsKey(hFile))
{
//DebugLogger.WriteLine(" ---faking dummy file");
Expand Down Expand Up @@ -319,7 +337,7 @@ public static int HReadFile(IntPtr handle, IntPtr bytes, uint numBytesToRead, In
public static IntPtr CreateVA(OverrideFile of) {
VArchiveData va = new VArchiveData(of.Archive.GetBytes(of.File));
IntPtr dummy = of.Archive.GetDummyHandle(_process);
DebugLogger.WriteLine($"Creating dummy file handle {dummy} to access {of.Archive}{of.File}");
DebugLogger.WriteLine($">> Creating dummy file handle {dummy} to access {of.Archive}{of.File}");
_varchives[dummy] = va;

return dummy;
Expand Down Expand Up @@ -348,7 +366,7 @@ public static IntPtr HCreateFileW(
if (isFF7GameFile)
{
lpFileName = lpFileName.Replace("\\/", "\\").Replace("/", "\\").Replace("\\\\", "\\");
DebugLogger.DetailedWriteLine($"CreateFileW for {lpFileName}...");
DebugLogger.DetailedWriteLine($">> CreateFileW for {lpFileName}...");
if (lpFileName.IndexOf('\\') < 0)
{
//DebugLogger.WriteLine("No path: curdir is {0}", System.IO.Directory.GetCurrentDirectory(), 0);
Expand All @@ -375,7 +393,7 @@ public static IntPtr HCreateFileW(

if (mapped != null)
{
DebugLogger.WriteLine($"Remapping {lpFileName} to {mapped.File} [ Matched: '{match}' ]");
DebugLogger.WriteLine($" - Remapping {lpFileName} to {mapped.File} [ Matched: '{match}' ]");

if (mapped.Archive == null)
{
Expand All @@ -391,7 +409,7 @@ public static IntPtr HCreateFileW(
}
}
else
DebugLogger.DetailedWriteLine($"Skipped file {lpFileName}");
DebugLogger.DetailedWriteLine($">> Skipped file {lpFileName}");

if (ret == IntPtr.Zero)
ret = Win32.CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
Expand All @@ -403,7 +421,7 @@ public static IntPtr HCreateFileW(

public static IntPtr HFindFirstFileW(string lpFileName, IntPtr lpFindFileData)
{
DebugLogger.WriteLine("FindFirstFile for " + lpFileName);
DebugLogger.WriteLine(">> FindFirstFile for " + lpFileName);

return IntPtr.Zero;
}
Expand All @@ -419,7 +437,7 @@ public static int HGetFileInformationByHandle(IntPtr hFile, IntPtr lpFileInforma

if (result && _varchives.ContainsKey(hFile))
{
DebugLogger.DetailedWriteLine($"Overriding GetFileInformationByHandle for dummy file {hFile}");
DebugLogger.DetailedWriteLine($">> Overriding GetFileInformationByHandle for dummy file {hFile}");
_lpFileInformation.FileSizeHigh = (uint)(_varchives[hFile].Size >> 32);
_lpFileInformation.FileSizeLow = (uint)(_varchives[hFile].Size & 0xffffffff);

Expand All @@ -438,7 +456,7 @@ public static int HDuplicateHandle(IntPtr hSourceProcessHandle, IntPtr hSourceHa
if (_varchives.ContainsKey(hSourceHandle))
{
_varchives[lpTargetHandle] = _varchives[hSourceHandle];
DebugLogger.DetailedWriteLine($"Duplicating dummy handle {hSourceHandle} to {lpTargetHandle}");
DebugLogger.DetailedWriteLine($">> Duplicating dummy handle {hSourceHandle} to {lpTargetHandle}");
}

return 1;
Expand All @@ -450,7 +468,7 @@ public static uint HGetFileSize(IntPtr hFile, IntPtr lpFileSizeHigh)

if (_varchives.ContainsKey(hFile))
{
DebugLogger.WriteLine($"GetFileSize on dummy handle {hFile}");
DebugLogger.WriteLine($">> GetFileSize on dummy handle {hFile}");
ret = _varchives[hFile].GetFileSize(lpFileSizeHigh);
}

Expand All @@ -463,7 +481,7 @@ public static int HGetFileSizeEx(IntPtr hFile, IntPtr lpFileSize)

if (_varchives.ContainsKey(hFile))
{
DebugLogger.WriteLine($"GetFileSizeEx on dummy handle {hFile}");
DebugLogger.WriteLine($">> GetFileSizeEx on dummy handle {hFile}");
byte[] tmp = BitConverter.GetBytes(_varchives[hFile].Size);
Util.CopyToIntPtr(tmp, lpFileSize, tmp.Length);

Expand Down
27 changes: 27 additions & 0 deletions FF7_Launcher/FF7_Launcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// FF7_Launcher.cpp : Defines the entry point for the application.
//

#include <windows.h>
#include "Resource.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Initialize the process start information
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

// Start the process
if (!CreateProcess(L"ff7_en.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) return 1;

// Wait for the process to finish
WaitForSingleObject(pi.hProcess, INFINITE);

// Close process and thread handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

return 0;
}
3 changes: 3 additions & 0 deletions FF7_Launcher/FF7_Launcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include "resource.h"
Binary file added FF7_Launcher/FF7_Launcher.ico
Binary file not shown.
Binary file added FF7_Launcher/FF7_Launcher.rc
Binary file not shown.
Loading

0 comments on commit 101a0f8

Please sign in to comment.