Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (!_updateRequired)
            {
                return;
            }

            _updateRequired = false;
            _backPanel.RemoveAllChildren();

            int i = 0;

            UIMessageBox AddMessageBox(string text)
            {
                var msgBox = new UIMessageBox(text)
                {
                    Width  = { Percent = 1f },
                    Height = { Percent = .2f },
                    Top    = { Percent = (i++) / 4f + 0.05f },
                }.WithPadding(6);

                _backPanel.Append(msgBox);
                msgBox.Activate();
                return(msgBox);
            }

            void AddButton(UIElement elem, string text, Action clickAction)
            {
                var button = new UITextPanel <string>(text)
                {
                    Top    = { Pixels = -2 },
                    Left   = { Pixels = -2 },
                    HAlign = 1,
                    VAlign = 1
                }.WithFadedMouseOver();

                button.OnClick += (evt, _) => clickAction();
                button.Activate();
                elem.Append(button);
            }

            bool frameworkCheck = ModCompile.RoslynCompatibleFrameworkCheck(out var dotNetMsg);

            if (monoStartScriptsUpdated)
            {
                dotNetMsg = Language.GetTextValue("tModLoader.DMScriptsRequireRestart");
            }

            var dotNetMsgBox = AddMessageBox(dotNetMsg);

            if (!frameworkCheck && !monoStartScriptsUpdated)
            {
                if (ModCompile.systemMonoSuitable)
                {
                    AddButton(dotNetMsgBox, Language.GetTextValue("tModLoader.DMUpdateScripts"), UpdateMonoStartScripts);
                }
                else if (FrameworkVersion.Framework == Framework.Mono)
                {
                    AddButton(dotNetMsgBox, Language.GetTextValue("tModLoader.MBDownload"), DownloadMono);
                }
                else
                {
                    AddButton(dotNetMsgBox, Language.GetTextValue("tModLoader.MBDownload"), DownloadDotNet);
                }
            }

            bool modCompileCheck = ModCompile.ModCompileVersionCheck(out var modCompileMsg);

            if (!modCompileCheck && !ModBrowser.UIModBrowser.PlatformSupportsTls12)
            {
                modCompileMsg = "tModLoader.DMUpdateMonoToDownloadModCompile";
            }
            var modCompileMsgBox = AddMessageBox(Language.GetTextValue(modCompileMsg));

#if !DEBUG
            if (!modCompileCheck && ModBrowser.UIModBrowser.PlatformSupportsTls12)
            {
                AddButton(modCompileMsgBox, Language.GetTextValue("tModLoader.MBDownload"), DownloadModCompile);
            }
#endif

            bool refAssemCheck  = ModCompile.ReferenceAssembliesCheck(out var refAssemMsg);
            var  refAssemMsgBox = AddMessageBox(refAssemMsg);

            if (!refAssemCheck)
            {
                if (ModCompile.PlatformSupportsVisualStudio)
                {
                    AddButton(refAssemMsgBox, Language.GetTextValue("tModLoader.DMVisualStudio"), DevelopingWithVisualStudio);
                }

                var icon = UICommon.ButtonExclamationTexture;
                _refAssemDirectDlButton = new UIHoverImage(icon, Language.GetTextValue("tModLoader.DMReferenceAssembliesDownload"))
                {
                    Left   = { Pixels = -1 },
                    Top    = { Pixels = -1 },
                    VAlign = 1,
                };
                _refAssemDirectDlButton.OnClick += (evt, _) => DirectDownloadRefAssemblies();
                refAssemMsgBox.Append(_refAssemDirectDlButton);
            }

            var tutorialMsgBox = AddMessageBox(Language.GetTextValue("tModLoader.DMTutorialWelcome"));
            AddButton(tutorialMsgBox, Language.GetTextValue("tModLoader.DMTutorial"), OpenTutorial);

            _allChecksSatisfied = frameworkCheck && modCompileCheck && refAssemCheck;
            _bottomButton.SetText(_allChecksSatisfied ? Language.GetTextValue("tModLoader.Continue") : Language.GetTextValue("UI.Back"));
        }