Beispiel #1
0
        /// <summary>
        /// Called when a game level is loaded. If applicable, activates the Real Time mod for the loaded level.
        /// </summary>
        /// <param name="mode">The <see cref="LoadMode"/> a game level is loaded in.</param>
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (string.IsNullOrEmpty(modPath))
            {
                MessageBox.Show("Sorry", NoWorkshopMessage);
                return;
            }

            switch (mode)
            {
            case LoadMode.LoadGame:
            case LoadMode.NewGame:
            case LoadMode.LoadScenario:
            case LoadMode.NewGameFromScenario:
                break;

            default:
                return;
            }

            Log.Info($"The 'Real Time' mod starts, game mode {mode}.");
            if (core != null)
            {
                core.Stop();
            }

            core = RealTimeCore.Run(configProvider, modPath, localizationProvider);
            if (core == null)
            {
                Log.Warning("Showing a warning message to user because the mod isn't working");
                MessageBox.Show(
                    localizationProvider.Translate(TranslationKeys.Warning),
                    localizationProvider.Translate(TranslationKeys.ModNotWorkingMessage));
            }
            else
            {
                string restricted = core.IsRestrictedMode
                    ? localizationProvider.Translate(TranslationKeys.RestrictedMode)
                    : null;

                bool showMessage = core.IsRestrictedMode;
                if (configProvider.Configuration.ShowIncompatibilityNotifications)
                {
                    showMessage = Compatibility.CheckAndNotify(Name, localizationProvider, restricted) && core.IsRestrictedMode;
                }

                if (showMessage)
                {
                    Compatibility.Notify(Name + " - " + localizationProvider.Translate(TranslationKeys.Warning), restricted);
                }
            }
        }
Beispiel #2
0
        private void CheckCompatibility()
        {
            if (core == null)
            {
                return;
            }

            string restrictedText = core.IsRestrictedMode
                ? localizationProvider.Translate(TranslationKeys.RestrictedMode)
                : null;

            if (configProvider.Configuration.ShowIncompatibilityNotifications &&
                !Compatibility.Check(Name, localizationProvider, restrictedText))
            {
                return;
            }

            if (core.IsRestrictedMode)
            {
                Compatibility.Notify(Name + " - " + localizationProvider.Translate(TranslationKeys.Warning), restrictedText);
            }
        }