Ejemplo n.º 1
0
 private static void RunGame(IGame game, GameCommandArguments arguments, string?iconFile, bool debug)
 {
     if (debug && game is IDebugable debugable)
     {
         debugable.DebugGame(arguments, iconFile);
     }
     else
     {
         game.PlayGame(arguments, iconFile);
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        internal void ShowArgs()
        {
            if (!(GameObject is IMod mod))
            {
                return;
            }
            var traverser = new ModDependencyTraverser(mod);
            var gameArgs  = new GameCommandArguments {
                Mods = traverser.Traverse()
            };
            var args    = gameArgs.ToArgs();
            var message = $"Launch Arguments for Mod {GameObject.Name}:\r\n\r\n{args}\r\n\r\nMod's location: '{mod.Identifier}'";

            Task.Run(() => MessageBox.Show(message, "FoC Launcher", MessageBoxButton.OK)).Forget();
        }