Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod Manager Lua engine integration and Presets #858

Merged
merged 40 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7b8a2c8
Added Presets.
shananas Aug 11, 2023
989ffb4
Update empty text box text
shananas Aug 11, 2023
bc83971
error msg if preset file not found. (can only happen if you run mod m…
shananas Aug 11, 2023
91007f0
Lua Engine Integration into mod manager.
shananas Aug 15, 2023
762bc78
Text Updates
shananas Aug 15, 2023
6e6982e
Grouped LuaEngine varibales closer together so its easier to see how …
shananas Aug 16, 2023
e395399
Replaced Regex with GetIncalidFIleNameChars() to allow letters and sy…
shananas Aug 18, 2023
1937e3c
Error handling for if the downloaded Lua Engine is not compressed as …
shananas Aug 18, 2023
603352b
Lua Engine update checker with basically no noticable performance dec…
shananas Aug 19, 2023
ef97e53
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Aug 19, 2023
4b1162b
Merge branch 'OpenKH:master' into master
shananas Aug 19, 2023
e8cc2a5
Merge branch 'master' into LuaEngineIntegration
shananas Aug 27, 2023
b467362
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Aug 30, 2023
d6b346f
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Aug 30, 2023
80d7bca
Merge branch 'master' into LuaEngineIntegration
shananas Sep 1, 2023
8e84468
Merge branch 'master' of https://github.com/shananas/OpenKh
shananas Sep 1, 2023
9f85507
Presets Menu
osdanova Sep 8, 2023
f868322
Presets quick redesgin
osdanova Sep 10, 2023
2d2ae46
Merge pull request #1 from osdanova/LuaEngineIntegration
shananas Sep 10, 2023
4ccc0eb
Added Confirmation box to delete preset and properly remove the prese…
shananas Sep 10, 2023
d33e932
Merge branch 'master' into LuaEngineIntegration
shananas Sep 17, 2023
00c2675
Panacea post copy for debug.
shananas Sep 17, 2023
cb8de96
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Sep 18, 2023
368bbb0
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Sep 20, 2023
813065c
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Sep 21, 2023
e83c8ed
Merge branch 'master' into LuaEngineIntegration
shananas Sep 27, 2023
2a7f13b
Fix the merge conflict fix
shananas Sep 28, 2023
82c5978
Dont add the same preset name twice to the preset list
shananas Sep 28, 2023
fc66a95
fix the merge conflict fix again
shananas Sep 28, 2023
4a8f6f8
Overwrite mod for Lua script install
shananas Sep 28, 2023
b811ca1
Merge branch 'master' into LuaEngineIntegration
shananas Sep 30, 2023
aa4045e
removed unusused added imports
shananas Sep 30, 2023
5b052a5
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Oct 1, 2023
5829fbd
Final LuaEngine name tm and proper version to github tag checking
shananas Oct 2, 2023
f8927ea
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Oct 2, 2023
44bf435
Merge branch 'master' into LuaEngineIntegration
shananas Oct 10, 2023
ed7fb6f
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Oct 13, 2023
f51f195
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Nov 14, 2023
aa705a1
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Nov 19, 2023
5471a58
Merge branch 'OpenKH:master' into LuaEngineIntegration
shananas Dec 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions OpenKh.Tools.ModsManager/Services/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ private class Config
public string OpenKhGameEngineLocation { get; internal set; }
public string Pcsx2Location { get; internal set; }
public string PcReleaseLocation { get; internal set; }
public string LuaEnginePath { get; internal set; }
public bool LuaEngineInstalled { get; internal set; }
public string PcReleaseLanguage { get; internal set; } = "en";
public int RegionId { get; internal set; }
public bool PanaceaInstalled { get; internal set; }
Expand Down Expand Up @@ -379,5 +381,23 @@ public static string LaunchGame
_config.Save(ConfigPath);
}
}
public static string LuaEngineLocation
{
get => _config.LuaEnginePath ?? Path.Combine(StoragePath, "LuaEngine");
set
{
_config.LuaEnginePath = value;
_config.Save(ConfigPath);
}
}
public static bool LuaEngineInstalled
{
get => _config.LuaEngineInstalled;
set
{
_config.LuaEngineInstalled = value;
_config.Save(ConfigPath);
}
}
}
}
44 changes: 31 additions & 13 deletions OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Octokit;
using OpenKh.Common;
using OpenKh.Tools.Common.Wpf;
using OpenKh.Tools.ModsManager.Models;
using OpenKh.Tools.ModsManager.Services;
using OpenKh.Tools.ModsManager.Views;
using OpenKh.Tools.ModsManager.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -28,7 +29,7 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState
private static Version _version = Assembly.GetEntryAssembly()?.GetName()?.Version;
private static string ApplicationName = Utilities.GetApplicationName();
private static string ApplicationVersion = Utilities.GetApplicationVersion();
private Window Window => Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
private Window Window => System.Windows.Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);

private DebuggingWindow _debuggingWindow = new DebuggingWindow();
private ModViewModel _selectedValue;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState
public static bool overwriteMod = false;
public string Title => ApplicationName;
public string CurrentVersion => ApplicationVersion;
public static Release releases = new GitHubClient(new ProductHeaderValue("LuaEngine.exe")).Repository.Release.GetLatest(owner: "TopazTK", name: "LuaEngine").Result;
public ObservableCollection<ModViewModel> ModsList { get; set; }
public ObservableCollection<string> PresetList { get; set; }
public RelayCommand ExitCommand { get; set; }
Expand Down Expand Up @@ -267,7 +269,7 @@ public bool IsBuilding
set
{
_isBuilding = value;
Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
OnPropertyChanged(nameof(BuildCommand));
OnPropertyChanged(nameof(BuildAndRunCommand));
Expand Down Expand Up @@ -320,7 +322,7 @@ public MainViewModel()
var name = view.RepositoryName;
var isZipFile = view.IsZipFile;
var isLuaFile = view.IsLuaFile;
progressWindow = Application.Current.Dispatcher.Invoke(() =>
progressWindow = System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
var progressWindow = new InstallModProgressWindow
{
Expand All @@ -333,14 +335,14 @@ public MainViewModel()
});
await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
{
Application.Current.Dispatcher.Invoke(() => progressWindow.ProgressText = progress);
System.Windows.Application.Current.Dispatcher.Invoke(() => progressWindow.ProgressText = progress);
}, nProgress =>
{
Application.Current.Dispatcher.Invoke(() => progressWindow.ProgressValue = nProgress);
System.Windows.Application.Current.Dispatcher.Invoke(() => progressWindow.ProgressValue = nProgress);
});
var actualName = isZipFile || isLuaFile ? Path.GetFileNameWithoutExtension(name) : name;
var mod = ModsService.GetMods(new string[] { actualName }).First();
Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
progressWindow.Close();
if (overwriteMod)
Expand All @@ -360,7 +362,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
}
finally
{
Application.Current.Dispatcher.Invoke(() => progressWindow?.Close());
System.Windows.Application.Current.Dispatcher.Invoke(() => progressWindow?.Close());
}
});
}, _ => true);
Expand Down Expand Up @@ -447,6 +449,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
ConfigRegionId = ConfigurationService.RegionId,
ConfigPanaceaInstalled = ConfigurationService.PanaceaInstalled,
ConfigIsEGSVersion = ConfigurationService.IsEGSVersion,
ConfigLuaEngineLocation = ConfigurationService.LuaEngineLocation,
};
if (dialog.ShowDialog() == true)
{
Expand All @@ -460,6 +463,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
ConfigurationService.PanaceaInstalled = dialog.ConfigPanaceaInstalled;
ConfigurationService.IsEGSVersion = dialog.ConfigIsEGSVersion;
ConfigurationService.WizardVersionNumber = _wizardVersionNumber;
ConfigurationService.LuaEngineLocation = dialog.ConfigLuaEngineLocation;

const int EpicGamesPC = 2;
if (ConfigurationService.GameEdition == EpicGamesPC &&
Expand Down Expand Up @@ -512,7 +516,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
public void CloseAllWindows()
{
CloseRunningProcess();
Application.Current.Dispatcher.Invoke(_debuggingWindow.Close);
System.Windows.Application.Current.Dispatcher.Invoke(_debuggingWindow.Close);
}

public void CloseRunningProcess()
Expand All @@ -531,9 +535,9 @@ public void CloseRunningProcess()
private void ResetLogWindow()
{
if (_debuggingWindow != null)
Application.Current.Dispatcher.Invoke(_debuggingWindow.Close);
System.Windows.Application.Current.Dispatcher.Invoke(_debuggingWindow.Close);
_debuggingWindow = new DebuggingWindow();
Application.Current.Dispatcher.Invoke(_debuggingWindow.Show);
System.Windows.Application.Current.Dispatcher.Invoke(_debuggingWindow.Show);
_debuggingWindow.ClearLogs();
}

Expand Down Expand Up @@ -613,6 +617,20 @@ private Task RunGame()
}
Process.Start(processStartInfo);
CloseAllWindows();
if(ConfigurationService.LuaEngineInstalled)
{
string startFile = ConfigurationService.LuaEngineLocation + "/LuaEngine-REBORN.exe";
if(File.Exists(startFile))
{
processStartInfo = new ProcessStartInfo
{
FileName = startFile,
WorkingDirectory = ConfigurationService.LuaEngineLocation,
UseShellExecute = false,
};
Process.Start(processStartInfo);
}
}
return Task.CompletedTask;
default:
return Task.CompletedTask;
Expand Down Expand Up @@ -934,7 +952,7 @@ private async Task FetchUpdates()
if (mod == null)
continue;

Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
mod.UpdateCount = modUpdate.UpdateCount);
}
if (AutoUpdateMods)
Expand Down
Loading
Loading