Skip to content

Commit

Permalink
Updated ue4ss and refactored setup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TekkaGB committed Mar 1, 2024
1 parent 8545db8 commit 045676c
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 90 deletions.
Binary file removed Unverum/Assets/Icons/MV.jpg
Binary file not shown.
22 changes: 10 additions & 12 deletions Unverum/Dependencies/ue4ss/Mods/BPModLoaderMod/Scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local ModOrderList = {}

local DefaultModConfig = {}
DefaultModConfig.AssetName = "ModActor_C"
DefaultModConfig.AssetNameAsFName = FName("ModActor_C")
DefaultModConfig.AssetNameAsFName = UEHelpers.FindOrAddFName("ModActor_C")

-- Checks if the beginning of a string contains a certain pattern.
local function StartsWith(String, StringToCompare)
Expand Down Expand Up @@ -132,7 +132,7 @@ local function LoadModConfigs()
dofile(ModFile.__absolute_path)
if type(Mods[ModDirectoryName]) ~= "table" then break end
if not Mods[ModDirectoryName].AssetName then break end
Mods[ModDirectoryName].AssetNameAsFName = FName(Mods[ModDirectoryName].AssetName)
Mods[ModDirectoryName].AssetNameAsFName = UEHelpers.FindOrAddFName(Mods[ModDirectoryName].AssetName)
break
end
end
Expand Down Expand Up @@ -174,7 +174,7 @@ end
local AssetRegistryHelpers = nil
local AssetRegistry = nil

local function LoadMod(ModName, ModInfo, GameMode)
local function LoadMod(ModName, ModInfo, World)
if ModInfo.Priority ~= nil then
Log(string.format("Loading mod [Priority: #%i]: %s\n", ModInfo.Priority, ModName))
else
Expand All @@ -188,21 +188,19 @@ local function LoadMod(ModName, ModInfo, GameMode)
local AssetData = nil
if UnrealVersion.IsBelow(5, 1) then
AssetData = {
["ObjectPath"] = FName(string.format("%s.%s", ModInfo.AssetPath, ModInfo.AssetName), EFindName.FNAME_Add),
["ObjectPath"] = UEHelpers.FindOrAddFName(string.format("%s.%s", ModInfo.AssetPath, ModInfo.AssetName)),
}
else
AssetData = {
["PackageName"] = FName(ModInfo.AssetPath, EFindName.FNAME_Add),
["AssetName"] = FName(ModInfo.AssetName, EFindName.FNAME_Add),
["PackageName"] = UEHelpers.FindOrAddFName(ModInfo.AssetPath),
["AssetName"] = UEHelpers.FindOrAddFName(ModInfo.AssetName),
}
end

ExecuteInGameThread(function()
local ModClass = AssetRegistryHelpers:GetAsset(AssetData)
if not ModClass:IsValid() then error("ModClass is not valid") end

-- TODO: Use 'UEHelpers' to get the world.
local World = GameMode:GetWorld()
if not World:IsValid() then error("World is not valid") end

local Actor = World:SpawnActor(ModClass, {}, {})
Expand Down Expand Up @@ -240,11 +238,11 @@ end



local function LoadMods(GameMode)
local function LoadMods(World)
CacheAssetRegistry()
for _, ModInfo in ipairs(OrderedMods) do
if type(ModInfo) == "table" then
LoadMod(ModInfo.Name, ModInfo, GameMode)
LoadMod(ModInfo.Name, ModInfo, World)
end
end
end
Expand All @@ -253,8 +251,8 @@ local function LoadModsManual()
LoadMods(UEHelpers.GetWorld())
end

RegisterInitGameStatePostHook(function(ContextParam)
LoadMods(ContextParam:get())
RegisterLoadMapPostHook(function(Engine, World)
LoadMods(World:get())
end)

RegisterBeginPlayPostHook(function(ContextParam)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-- This is a custom implementation of UEs "obj dump <obj>" command.
-- It doesn't have a 1:1 feature set.

local UEHelpers = require("UEHelpers")

--[[
TODO: Expand on the console command format.
You should be able to specify a sub-object, sub-struct, sub-array, sub-map, etc.
Expand Down Expand Up @@ -141,7 +143,7 @@ local function GetObjectByName(ObjectName)
end

local function GetPropertyByName(ObjectIn, PropertyName)
local PropertyFName = FName(PropertyName)
local PropertyFName = UEHelpers.FindOrAddFName(PropertyName)
local Object = nil

if ObjectIn:IsA(UClassStaticClass) or ObjectIn:IsA(UScriptStructStaticClass) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local function RemapConsoleKeys()
local ConsoleKeys = InputSettings.ConsoleKeys

-- This sets the first console key to F10
ConsoleKeys[1].KeyName = FName("F10")
ConsoleKeys[1].KeyName = FName("F10", EFindName.FNAME_Find)

ConsoleKeys:ForEach(function(index, elem_wrapper)
local KeyStruct = elem_wrapper:get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ function UEHelpers.GetGameMapsSettings(ForceInvalidateCache)
return CacheDefaultObject("/Script/EngineSettings.Default__GameMapsSettings", "UEHelpers_GameMapsSettings", ForceInvalidateCache)
end

function UEHelpers.FindOrAddFName(Name)
local NameFound = FName(Name, EFindName.FNAME_Find)
if NameFound == NAME_None then
NameFound = FName(Name, EFindName.FNAME_Add)
end
return NameFound
end

-- Exported functions -> END

return UEHelpers
6 changes: 3 additions & 3 deletions Unverum/Dependencies/ue4ss/UE4SS-settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ SecondsToScanBeforeGivingUp = 30
; Whether to create UObject listeners in GUObjectArray to create a fast cache for use instead of iterating GUObjectArray.
; Setting this to false can help if you're experiencing a crash on startup.
; Default: true
bUseUObjectArrayCache = true
bUseUObjectArrayCache = false

[EngineVersionOverride]
MajorVersion = 4
MinorVersion = 17
MajorVersion =
MinorVersion =

[ObjectDumper]
; Whether to force all assets to be loaded before dumping objects
Expand Down
Binary file added Unverum/Dependencies/ue4ss/dwmapi.dll
Binary file not shown.
Binary file removed Unverum/Dependencies/ue4ss/opengl32.dll
Binary file not shown.
Binary file removed Unverum/Dependencies/ue4ss/patternsleuth_bind.dll
Binary file not shown.
Binary file modified Unverum/Dependencies/ue4ss/ue4ss.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Unverum/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool Restart(string path, string movies, string splash, string sou
var LogicModsFolder = $"{Path.GetDirectoryName(path)}{Global.s}LogicMods";
var Win64Folder = $"{Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(path)))}{Global.s}Binaries{Global.s}Win64";
var ue4ssModsFolder = $"{Win64Folder}{Global.s}Mods";
List<string> ue4ssFiles = new() { "opengl32.dll", "patternsleuth_bind.dll", "ue4ss.dll", "UE4SS-settings.ini" };
List<string> ue4ssFiles = new() { "opengl32.dll", "patternsleuth_bind.dll", "ue4ss.dll", "UE4SS-settings.ini", "dwmapi.dll" };
foreach (var ue4ssFile in ue4ssFiles)
{
var file = $"{Win64Folder}{Global.s}{ue4ssFile}";
Expand Down
62 changes: 10 additions & 52 deletions Unverum/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,57 +202,15 @@ public static bool GBVSR()
Global.logger.WriteLine($"Setup completed for {Global.config.CurrentGame}!", LoggerType.Info);
return true;
}
public static bool MHOJ2()
{
var defaultPath = @"C:\Program Files (x86)\Steam\steamapps\common\My Hero Ones Justice 2\HeroGame\Binaries\Win64\MHOJ2.exe";
try
{
var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 1058450");
if (!String.IsNullOrEmpty(key.GetValue("InstallLocation") as string))
defaultPath = $"{key.GetValue("InstallLocation") as string}{Global.s}MHOJ2.exe";
}
catch (Exception e)
{
}
if (!File.Exists(defaultPath))
{
Global.logger.WriteLine($"Couldn't find install path in registry, select path to exe instead", LoggerType.Warning);
OpenFileDialog dialog = new OpenFileDialog();
dialog.DefaultExt = ".exe";
dialog.Filter = $"Executable Files (MHOJ2.exe)|MHOJ2.exe";
dialog.Title = $"Select MHOJ2.exe from your Steam Install folder";
dialog.Multiselect = false;
dialog.InitialDirectory = Global.assemblyLocation;
dialog.ShowDialog();
if (!String.IsNullOrEmpty(dialog.FileName)
&& Path.GetFileName(dialog.FileName).Equals("MHOJ2.exe", StringComparison.InvariantCultureIgnoreCase))
defaultPath = dialog.FileName;
else if (!String.IsNullOrEmpty(dialog.FileName))
{
Global.logger.WriteLine($"Invalid .exe chosen", LoggerType.Error);
return false;
}
else
return false;
}
var parent = defaultPath.Replace($"{Global.s}HeroGame{Global.s}Binaries{Global.s}Win64{Global.s}MHOJ2.exe", String.Empty);
var paks = $"{parent}{Global.s}HeroGame{Global.s}Content{Global.s}Paks";
var ModsFolder = $"{paks}{Global.s}~mods";
Directory.CreateDirectory(ModsFolder);
Global.config.Configs[Global.config.CurrentGame].ModsFolder = ModsFolder;
Global.config.Configs[Global.config.CurrentGame].Launcher = defaultPath;
Global.UpdateConfig();
Global.logger.WriteLine($"Setup completed for {Global.config.CurrentGame}!", LoggerType.Info);
return true;
}
public static bool ToA()

public static bool Win64FolderSetup(string exe, string projectName, string gameName, string steamId)
{
var defaultPath = @"C:\Program Files (x86)\Steam\steamapps\common\Tales of Arise\Arise\Binaries\Win64\Tales of Arise.exe";
var defaultPath = $@"C:\Program Files (x86)\Steam\steamapps\common\{gameName}\{projectName}\Binaries\Win64\{exe}";
try
{
var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 740130");
var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App {steamId}");
if (!String.IsNullOrEmpty(key.GetValue("InstallLocation") as string))
defaultPath = $"{key.GetValue("InstallLocation") as string}{Global.s}Arise{Global.s}Binaries{Global.s}Win64{Global.s}Tales of Arise.exe";
defaultPath = $"{key.GetValue("InstallLocation") as string}{Global.s}{projectName}{Global.s}Binaries{Global.s}Win64{Global.s}{exe}";
}
catch (Exception e)
{
Expand All @@ -262,13 +220,13 @@ public static bool ToA()
Global.logger.WriteLine($"Couldn't find install path in registry, select path to exe instead", LoggerType.Warning);
OpenFileDialog dialog = new OpenFileDialog();
dialog.DefaultExt = ".exe";
dialog.Filter = $"Executable Files (Tales of Arise.exe)|Tales of Arise.exe";
dialog.Title = $"Select Tales of Arise.exe from your Steam Install folder";
dialog.Filter = $"Executable Files ({exe})|{exe}";
dialog.Title = $"Select {exe} from your Steam Install folder";
dialog.Multiselect = false;
dialog.InitialDirectory = Global.assemblyLocation;
dialog.ShowDialog();
if (!String.IsNullOrEmpty(dialog.FileName)
&& Path.GetFileName(dialog.FileName).Equals("Tales of Arise.exe", StringComparison.InvariantCultureIgnoreCase))
&& Path.GetFileName(dialog.FileName).Equals(exe, StringComparison.InvariantCultureIgnoreCase))
defaultPath = dialog.FileName;
else if (!String.IsNullOrEmpty(dialog.FileName))
{
Expand All @@ -278,8 +236,8 @@ public static bool ToA()
else
return false;
}
var parent = defaultPath.Replace($"{Global.s}Arise{Global.s}Binaries{Global.s}Win64{Global.s}Tales of Arise.exe", String.Empty);
var paks = $"{parent}{Global.s}Arise{Global.s}Content{Global.s}Paks";
var parent = defaultPath.Replace($"{Global.s}{projectName}{Global.s}Binaries{Global.s}Win64{Global.s}{exe}", String.Empty);
var paks = $"{parent}{Global.s}{projectName}{Global.s}Content{Global.s}Paks";
var ModsFolder = $"{paks}{Global.s}~mods";
Directory.CreateDirectory(ModsFolder);
Global.config.Configs[Global.config.CurrentGame].ModsFolder = ModsFolder;
Expand Down
6 changes: 0 additions & 6 deletions Unverum/UI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,6 @@
<TextBlock Text="DNF Duel" VerticalAlignment="Center" FontWeight="Medium"/>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="../Assets/Icons/MV.jpg" Width="27" Margin="4,0,10,0"/>
<TextBlock Text="MultiVersus" VerticalAlignment="Center" FontWeight="Medium"/>
</StackPanel>
</ComboBoxItem>
</ComboBox>
<ComboBox Margin="5,0,0,0" Grid.Column="1" IsEnabled="False" Name="FilterBox" Height="35" MinWidth="130" HorizontalAlignment="Stretch" FontSize="18" FontWeight="Medium" SelectionChanged="FilterSelectionChanged"/>
<ComboBox Margin="5,0,0,0" Grid.Column="2" IsEnabled="False" FontWeight="Medium" FontSize="18" Name="TypeBox" Height="35" HorizontalAlignment="Stretch" MinWidth="100" SelectionChanged="TypeFilterSelectionChanged">
Expand Down
7 changes: 2 additions & 5 deletions Unverum/UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private bool SetupGame()
case GameFilter.DBFZ:
return Setup.DBFZ();
case GameFilter.MHOJ2:
return Setup.MHOJ2();
return Setup.Win64FolderSetup("MHOJ2.exe", "HeroGame", "My Hero Ones Justice 2", "1058450");
case GameFilter.GBVS:
return Setup.Generic("GBVS.exe", "RED", @"C:\Program Files (x86)\Steam\steamapps\common\Granblue Fantasy Versus\GBVS.exe", steamId: "1090630");
case GameFilter.GBVSR:
Expand All @@ -352,7 +352,7 @@ private bool SetupGame()
case GameFilter.SN:
return Setup.Generic("ScarletNexus.exe", "ScarletNexus", @"C:\Program Files (x86)\Steam\steamapps\common\ScarletNexus\ScarletNexus.exe", steamId: "775500");
case GameFilter.ToA:
return Setup.ToA();
return Setup.Win64FolderSetup("Tales of Arise.exe", "Arise", "Tales of Arise", "740130");
case GameFilter.DS:
return Setup.Generic("APK.exe", "APK", @"C:\Program Files (x86)\Steam\steamapps\common\Demon Slayer\APK.exe", steamId: "1490890");
case GameFilter.IM:
Expand Down Expand Up @@ -644,9 +644,6 @@ private void Discord_Click(object sender, RoutedEventArgs e)
case 7:
discordLink = "https://discord.gg/Se2XTnA";
break;
case 13:
discordLink = "https://discord.gg/mT6NqRdfgr";
break;
default:
discordLink = "https://discord.gg/tgFrebr";
break;
Expand Down
13 changes: 4 additions & 9 deletions Unverum/Unverum.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\unverum.ico</ApplicationIcon>
<AssemblyName>Unverum</AssemblyName>
<AssemblyVersion>2.5.1.0</AssemblyVersion>
<AssemblyVersion>2.5.2.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,7 +29,6 @@
<None Remove="Assets\Icons\kh3.png" />
<None Remove="Assets\Icons\KOFXV.jpg" />
<None Remove="Assets\Icons\mhoj2.png" />
<None Remove="Assets\Icons\MV.jpg" />
<None Remove="Assets\Icons\smtv.png" />
<None Remove="Assets\Icons\sn.png" />
<None Remove="Assets\Icons\toa.png" />
Expand Down Expand Up @@ -97,7 +96,6 @@
<Resource Include="Assets\Icons\kh3.png" />
<Resource Include="Assets\Icons\KOFXV.jpg" />
<Resource Include="Assets\Icons\mhoj2.png" />
<Resource Include="Assets\Icons\MV.jpg" />
<Resource Include="Assets\Icons\smtv.png" />
<Resource Include="Assets\Icons\sn.png" />
<Resource Include="Assets\Icons\toa.png" />
Expand Down Expand Up @@ -148,6 +146,9 @@
<None Update="Dependencies\u4pak\u4pak.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Dependencies\ue4ss\dwmapi.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Dependencies\ue4ss\Mods\ActorDumperMod\Scripts\main.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -199,12 +200,6 @@
<None Update="Dependencies\ue4ss\Mods\SplitScreenMod\Scripts\main.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Dependencies\ue4ss\opengl32.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Dependencies\ue4ss\patternsleuth_bind.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Dependencies\ue4ss\UE4SS-settings.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down

0 comments on commit 045676c

Please sign in to comment.