Example #1
0
        /*********
        ** Public methods
        *********/
        /// <summary>The main entry point which hooks into and launches the game.</summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += Program.CurrentDomain_AssemblyResolve;
#if SMAPI_FOR_MOBILE
                Program.AssertAndroidGameVersion();
#else
                Program.AssertGamePresent();
                Program.AssertGameVersion();
                Program.Start(args);
#endif
            }
            catch (BadImageFormatException ex) when(ex.FileName == "StardewValley" || ex.FileName == "Stardew Valley")  // don't use EarlyConstants.GameAssemblyName, since we want to check both possible names
            {
#if SMAPI_FOR_MOBILE
                SAlertDialogUtil.AlertMessage(
                    $"SMAPI failed to initialize because your game's {ex.FileName}.exe seems to be invalid.\nThis may be a pirated version which modified the executable in an incompatible way; if so, you can try a different download or buy a legitimate version.\n\nTechnical details:\n{ex}",
                    callback: type => { SMainActivity.Instance.Finish(); });
#else
                Console.WriteLine($"SMAPI failed to initialize because your game's {ex.FileName}.exe seems to be invalid.\nThis may be a pirated version which modified the executable in an incompatible way; if so, you can try a different download or buy a legitimate version.\n\nTechnical details:\n{ex}");
#endif
            }
            catch (Exception ex)
            {
#if SMAPI_FOR_MOBILE
                SAlertDialogUtil.AlertMessage($"SMAPI failed to initialize: {ex}",
                                              callback: type => { SMainActivity.Instance.Finish(); });
#else
                Console.WriteLine($"SMAPI failed to initialize: {ex}");
                Program.PressAnyKeyToExit(true);
#endif
            }
        }
Example #2
0
        /*********
        ** Private methods
        *********/
#if SMAPI_FOR_MOBILE
        private static void AssertAndroidGameVersion()
        {
            if (Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion))
            {
                SAlertDialogUtil.AlertMessage($"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI.",
                                              callback: type => SMainActivity.Instance.Finish());
            }
        }