public LauncherItem(LauncherItemManager manager, IPetroglyhGameableObject gameObject) { Manager = manager; GameObject = gameObject; _commandHandler = new LauncherGameObjectCommandHandler(GameObject); SetNameAsync().Forget(); }
public LauncherItemEventSink(LauncherItemManager manager, IPetroglyhGameableObject gameObject) { Manager = manager; GameObject = gameObject; if (!(gameObject is IModContainer modContainer)) { return; } modContainer.ModCollectionModified += OnModsChanged; }
internal LauncherItem GetItemImpl(IPetroglyhGameableObject gameObject) { var item = TryGetItem(gameObject); if (item == null) { item = new LauncherItem(this, gameObject); AddItem(item); } return(item); }
private static void LaunchCore(IPetroglyhGameableObject gameObject, IReadOnlyList <IPetroglyhGameableObject>?linkedGameObjects = null) { if (gameObject is null) { throw new InvalidOperationException("No object to launch selected"); } IGame game; IMod? mod = null; switch (gameObject) { case IGame g: game = g; break; case IMod m: mod = m; game = mod.Game; break; default: throw new NotSupportedException("Selected object is not supported"); } if (game is null) { throw new InvalidOperationException("No game to launch."); } var gameOptions = LauncherGameOptions.Instance; var args = new GameCommandArguments(); gameOptions.FillArgs(args); if (mod != null) { var modList = GetAllMods(mod); if (!modList.Any()) { throw new InvalidOperationException("The selected mod object seems to be invalid."); } args.Mods = modList; } args.Language = gameOptions.GetLanguageFromOptions(gameObject); RunGame(game, args, gameObject.IconFile, gameOptions.UseDebugBuild); }
internal static bool Launch(IPetroglyhGameableObject gameObject, IReadOnlyList <IPetroglyhGameableObject>?linkedGameObjects = null) { try { LaunchCore(gameObject, linkedGameObjects); } catch (Exception e) { MessageBox.Show($"Unable to start {gameObject.Name}:\r\n" + e.Message, "FoC Launcher", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } return(true); }
public LauncherItem?TryGetItem(IPetroglyhGameableObject gameableObject) { return(_items.TryGetValue(gameableObject, out var item) ? item : null); }
public bool TryGetItem(IPetroglyhGameableObject gameObject, out ILauncherItem?item) { item = TryGetItem(gameObject); return(item != null); }
public ILauncherItem GetGameObjectItem(IPetroglyhGameableObject gameObject) { return(GetItemImpl(gameObject)); }
internal LauncherGameObjectCommandHandler(IPetroglyhGameableObject gameObject) { GameObject = gameObject; }