Esempio n. 1
0
        /// <summary>
        /// <para>Called from within the game's code. Notifying all enabled mods that it can draw custom gui elements</para>
        /// <para>Do not call this manually</para>
        /// </summary>
        public void __OnGui()
        {
            if (_FirstPass)
            {
                _FirstPass   = false;
                _debugWindow = new GUI.Window(ModGUI.GetWindowIndex(), "Mod Debug")
                {
                    Visible = false, IsDraggable = true, IsResizeable = true
                };
                _debugWindow.Rect = new UnityEngine.Rect((UnityEngine.Screen.width - 400) / 2, (UnityEngine.Screen.height - 400) / 2, 400, 400);
                _debugWindow.Items.Add(new GUI.TextArea()
                {
                    IsRichText = true, IsEditable = false
                });
                GUI.Button closeDebugBtn = new GUI.Button("Close");
                closeDebugBtn.Clicked += CloseDebugBtn_Clicked;
                _debugWindow.Items.Add(new GUI.FlexibleSpace());
                _debugWindow.Items.Add(closeDebugBtn);

                if (_errorBeforeLoad.Count > 0)
                {
                    ShowError(_errorBeforeLoad[0].ModName, _errorBeforeLoad[0].ModVersion, _errorBeforeLoad[0].Error, _errorBeforeLoad[0].Where);
                }
            }

            _debugWindow.__Draw();

            if (ManagerMenu.mainMenuActive)
            {
                if (!_ModAreaResized)
                {
                    _ModAreaResized = true;
                }

                _ModListButtonArea.__Draw();
            }
        }
        private void SetupGUI(GameObject mainMenuRight)
        {
            _SelectedScenario = null;

            _ScenarioWindow = new GUI.Window(ModGUI.GetWindowIndex(), "Scenarios")
            {
                IsDraggable  = true,
                IsResizeable = true,
                IsCloseable  = true,
                Rect         = new Rect((Screen.width / 2) - 200, (Screen.height / 2) - 200, 400, 400),
                Visible      = false,
                MinWidth     = 200,
                MinHeight    = 200
            };

            _ScenarioWindow.WindowClosed += _ScenarioWindow_WindowClosed;

            GUI.Group group = new GUI.Group(GUI.GUIItem.Direction.Vertical);
            _ScenarioWindow.Items.Add(group);

            GUI.Group group1 = new GUI.Group(GUI.GUIItem.Direction.Horizontal);
            group.Items.Add(group1);

            lstScenarios = new GUI.Group(GUI.GUIItem.Direction.Vertical);
            group1.Items.Add(lstScenarios);

            foreach (Scenario scenario in Scenarios)
            {
                GUI.Button btn = new GUI.Button(scenario.Name)
                {
                    Tag = scenario
                };
                btn.Clicked += ScenarioBtn_Clicked;
                lstScenarios.Items.Add(btn);
            }

            _ScenarioInfo = new GUI.Group(GUI.GUIItem.Direction.Vertical)
            {
                Visible = false
            };
            group1.Items.Add(_ScenarioInfo);

            _Name = new GUI.Label("");
            _ScenarioInfo.Items.Add(_Name);

            _Desc = new GUI.TextArea("")
            {
                IsEditable = false,
                IsRichText = true
            };
            _ScenarioInfo.Items.Add(_Desc);

            _ThumbNail = new GUI.Box("")
            {
                Visible   = false,
                MaxWidth  = 200,
                MaxHeight = 200
            };
            _ScenarioInfo.Items.Add(_ThumbNail);

            GUI.Group btnGroup = new GUI.Group(GUI.GUIItem.Direction.Horizontal);
            group.Items.Add(btnGroup);

            _CancelBtn          = new GUI.Button("Cancel");
            _CancelBtn.Clicked += CancelBtn_Clicked;
            btnGroup.Items.Add(_CancelBtn);

            btnGroup.Items.Add(new GUI.FlexibleSpace());

            _LoadBtn = new GUI.Button("Load")
            {
                IsEnabled = false
            };
            _LoadBtn.Clicked += LoadBtn_Clicked;
            btnGroup.Items.Add(_LoadBtn);
        }