Added auto detection for the standalone launcher version of Tower of Fantasy

This commit is contained in:
Shimizu Izumi 2022-09-14 14:48:24 +02:00
parent 1684dfdfcc
commit a7dc54b48d
3 changed files with 41 additions and 6 deletions

View File

@ -92,7 +92,9 @@ public enum FGame
[Description("Sea of Thieves")]
Athena,
[Description("Your Beloved ™ Panda")]
PandaGame
PandaGame,
[Description("Tower of Fantasy")]
Hotta,
}
public enum ELoadingMode

View File

@ -283,7 +283,8 @@ namespace FModel.Settings
{FGame.PortalWars, Constants._NO_PRESET_TRIGGER},
{FGame.Gameface, Constants._NO_PRESET_TRIGGER},
{FGame.Athena, Constants._NO_PRESET_TRIGGER},
{FGame.PandaGame, Constants._NO_PRESET_TRIGGER}
{FGame.PandaGame, Constants._NO_PRESET_TRIGGER},
{FGame.Hotta, Constants._NO_PRESET_TRIGGER},
};
public IDictionary<FGame, string> Presets
{
@ -312,7 +313,8 @@ namespace FModel.Settings
{FGame.PortalWars, EGame.GAME_UE4_LATEST},
{FGame.Gameface, EGame.GAME_GTATheTrilogyDefinitiveEdition},
{FGame.Athena, EGame.GAME_SeaOfThieves},
{FGame.PandaGame, EGame.GAME_UE4_26}
{FGame.PandaGame, EGame.GAME_UE4_26},
{FGame.Hotta, EGame.GAME_TowerOfFantasy}
};
public IDictionary<FGame, EGame> OverridedGame
{
@ -341,7 +343,8 @@ namespace FModel.Settings
{FGame.PortalWars, null},
{FGame.Gameface, null},
{FGame.Athena, null},
{FGame.PandaGame, null}
{FGame.PandaGame, null},
{FGame.Hotta, null},
};
public IDictionary<FGame, List<FCustomVersion>> OverridedCustomVersions
{
@ -370,7 +373,8 @@ namespace FModel.Settings
{FGame.PortalWars, null},
{FGame.Gameface, null},
{FGame.Athena, null},
{FGame.PandaGame, null}
{FGame.PandaGame, null},
{FGame.Hotta, null},
};
public IDictionary<FGame, Dictionary<string, bool>> OverridedOptions
{
@ -405,7 +409,12 @@ namespace FModel.Settings
{FGame.PortalWars, new FEndpoint[]{new (), new ()}},
{FGame.Gameface, new FEndpoint[]{new (), new ()}},
{FGame.Athena, new FEndpoint[]{new (), new ()}},
{FGame.PandaGame, new FEndpoint[]{new (), new ()}}
{FGame.PandaGame, new FEndpoint[]{new (), new ()}},
{FGame.Hotta, new []
{
new FEndpoint("https://shimizu-izumi.github.io/fmodel/api/v1/aes/hotta.json", "$.['mainKey']")
}
}
};
public IDictionary<FGame, FEndpoint[]> CustomEndpoints
{
@ -482,6 +491,7 @@ namespace FModel.Settings
{FGame.Gameface, new List<CustomDirectory>()},
{FGame.Athena, new List<CustomDirectory>()},
{FGame.PandaGame, new List<CustomDirectory>()},
{FGame.Hotta, new List<CustomDirectory>()},
};
public IDictionary<FGame, IList<CustomDirectory>> CustomDirectories
{

View File

@ -120,6 +120,7 @@ public class GameSelectorViewModel : ViewModel
yield return GetRockstarGamesGame("GTA III - Definitive Edition", "\\Gameface\\Content\\Paks");
yield return GetRockstarGamesGame("GTA San Andreas - Definitive Edition", "\\Gameface\\Content\\Paks");
yield return GetRockstarGamesGame("GTA Vice City - Definitive Edition", "\\Gameface\\Content\\Paks");
yield return GetLevelInfiniteGame("tof_launcher", "\\Hotta\\Content\\Paks");
}
private LauncherInstalled _launcherInstalled;
@ -199,6 +200,28 @@ public class GameSelectorViewModel : ViewModel
return null;
}
private DetectedGame GetLevelInfiniteGame(string key, string pakDirectory)
{
var installLocation = string.Empty;
var displayName = string.Empty;
try
{
installLocation = App.GetRegistryValue($@"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{key}", "GameInstallPath", RegistryHive.CurrentUser);
displayName = App.GetRegistryValue($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{key}", "DisplayName", RegistryHive.CurrentUser);
}
catch
{
// ignored
}
if (!string.IsNullOrEmpty(installLocation))
return new DetectedGame { GameName = displayName, GameDirectory = $"{installLocation}{pakDirectory}" };
Log.Warning("Could not find {GameName} in the registry", key);
return null;
}
private T GetDriveLauncherInstalls<T>(string jsonFile)
{
foreach (var drive in DriveInfo.GetDrives())