Esempio n. 1
0
        public bool ButtonText(string label, string tooltip = null, GameFont?font = null, bool enabled = true)
        {
            var result = GUIPlus.DrawButton(GetRect(GUIPlus.ButtonHeight), label, tooltip, font, enabled);

            Gap(verticalSpacing);
            return(result);
        }
Esempio n. 2
0
        protected override void DrawContent(Rect rect)
        {
            var l = new ListingPlus();

            l.Begin(rect);
            _includeDocked   = l.CheckboxLabeled(Lang.Get("Dialog_SavePreset.IncludeDocked"), _includeDocked, enabled: !_includeDocked || _includeFloating);
            _includeFloating = l.CheckboxLabeled(Lang.Get("Dialog_SavePreset.IncludeFloating"), _includeFloating, enabled: !_includeFloating || _includeDocked);
            l.GapLine();
            _includeHeight = l.CheckboxLabeled(Lang.Get("Dialog_SavePreset.IncludeHeight"), _includeHeight);
            _includeWidth  = l.CheckboxLabeled(Lang.Get("Dialog_SavePreset.IncludeWidth"), _includeWidth);
            _includeTabs   = l.CheckboxLabeled(Lang.Get("Dialog_SavePreset.IncludeTabs"), _includeTabs, enabled: _includeDocked);

            l.GapLine();
            l.Label(Lang.Get("Dialog_SavePreset.Name"));
            GUI.SetNextControlName(NameControl);
            _name = l.TextEntry(_name);
            GUI.FocusControl(NameControl);
            l.Gap();

            var buttonGrid = l.GetButtonGrid(-1f, -1f);

            if (GUIPlus.DrawButton(buttonGrid[1], Lang.Get("Button.Save"), enabled: Persistent.IsValidFilename(_name)))
            {
                Save();
            }
            if (GUIPlus.DrawButton(buttonGrid[2], Lang.Get("Button.Cancel")))
            {
                Close();
            }
            l.End();
        }
Esempio n. 3
0
        public override void DoWindowContents(Rect inRect)
        {
            var listing = new ListingPlus();

            listing.Begin(inRect);
            listing.Label("RimHUD has automatically deactivated due to the following error(s):".Bold());
            listing.Label(_info.Message);
            if (_info.IsExternalError)
            {
                listing.Label(_info.PossibleMod == null ? "The error appears to be from outside RimHUD." : $"The error appears to be have been caused by the mod '{_info.PossibleMod.Bold()}'.", color: Color.yellow);
            }
            listing.Gap();
            listing.Label("Stacktrace:".Bold(), font: GameFont.Tiny);
            listing.End();

            var grid = inRect.GetVGrid(0f, listing.CurHeight, -1f, GUIPlus.SmallButtonHeight + GUIPlus.MediumPadding);

            Widgets.DrawMenuSection(grid[2]);

            var stacktraceRect = grid[2].ContractedBy(GUIPlus.SmallPadding);
            var stacktraceList = new ListingPlus();

            stacktraceList.BeginScrollView(stacktraceRect, ref _scrollPosition, ref _scrollView);
            stacktraceList.Label(_info.StackTrace, font: GameFont.Tiny);
            stacktraceList.EndScrollView(ref _scrollView);

            grid[3].yMin += GUIPlus.MediumPadding;
            var buttonGrid = grid[3].GetHGrid(GUIPlus.MediumPadding, ButtonWidth, -1f, ButtonWidth, ButtonWidth);

            if (GUIPlus.DrawButton(buttonGrid[1], "Copy to clipboard", font: GameFont.Tiny))
            {
                GUIUtility.systemCopyBuffer = $"[[RimHUD Auto-deactivation report]]\n{_info.Text}";
                Mod.Message("RimHUD Auto-deactivation details copied to clipboard");
            }
            if (GUIPlus.DrawButton(buttonGrid[3], "Reactivate", font: GameFont.Tiny))
            {
                Close();
                State.Activated = true;
            }
            if (GUIPlus.DrawButton(buttonGrid[4], "Close", font: GameFont.Tiny))
            {
                Close();
            }
        }
Esempio n. 4
0
        public void Draw(Rect rect)
        {
            if (_tabs.Length == 0)
            {
                return;
            }

            var vGrid = rect.GetVGrid(TabPadding, _tabHeight, -1f);
            var hGrid = vGrid[1].GetHGrid(TabPadding, Enumerable.Repeat(_tabWidth, _tabs.Length).ToArray());

            for (var index = 0; index < _tabs.Length; index++)
            {
                var tab = _tabs[index];
                GUIPlus.SetColor(tab == _selected ? GUIPlus.ButtonSelectedColor : (Color?)null);
                if (GUIPlus.DrawButton(hGrid[index + 1], tab.Label, tab.Tooltip, enabled: tab.Enabled))
                {
                    _selected = tab;
                }
                GUIPlus.ResetColor();
            }

            _selected.Draw(vGrid[2]);
        }
Esempio n. 5
0
        protected override void DrawContent(Rect rect)
        {
            var vGrid = rect.GetVGrid(GUIPlus.LargePadding, -1f, 70f);
            var l     = new ListingPlus();

            l.BeginScrollView(vGrid[1], ref _scrollPosition, ref _scrollView);

            foreach (var preset in LayoutPreset.UserList)
            {
                if (_selected == null)
                {
                    _selected = preset;
                }
                if (l.RadioButton_NewTemp(preset.Label, _selected == preset))
                {
                    _selected = preset;
                }
            }

            l.EndScrollView(ref _scrollView);

            l.Begin(vGrid[2]);

            var buttonGrid = l.GetButtonGrid(-1f, -1f);

            if (GUIPlus.DrawButton(buttonGrid[1], Lang.Get("Dialog_Presets.Delete"), enabled: _selected?.IsUserMade ?? false))
            {
                ConfirmDelete();
            }
            if (GUIPlus.DrawButton(buttonGrid[2], Lang.Get("Button.Close")))
            {
                Close();
            }

            l.End();
        }
Esempio n. 6
0
        public override void Draw(Rect rect)
        {
            var l     = new ListingPlus();
            var hGrid = rect.GetHGrid(GUIPlus.LargePadding, -1f, EditorWidth);

            l.Begin(hGrid[1]);
            l.Label(Lang.Get("Dialog_Config.Tab.Content.Editor", GetMode()).Bold());
            var editorRect = l.GetRemaining();

            _editor.Draw(editorRect);
            l.End();

            l.Begin(hGrid[2]);

            l.Label(Lang.Get("Dialog_Config.Tab.Content.Layout").Bold());
            DrawModeSelector(l);
            l.Gap();
            DrawPresetSelector(l);

            var importExportGrid = l.GetButtonGrid(-1f, -1f);

            if (GUIPlus.DrawButton(importExportGrid[1], Lang.Get("Dialog_Config.Tab.Content.Layout.SavePreset")))
            {
                Dialog_SavePreset.Open();
            }
            if (GUIPlus.DrawButton(importExportGrid[2], Lang.Get("Dialog_Config.Tab.Content.Layout.ManagePresets")))
            {
                Dialog_Presets.Open();
            }

            l.Gap();

            var canAddContainer = _editor.CanAddContainer;
            var canAddRow       = _editor.CanAddRow;
            var canAddElement   = _editor.CanAddElement;
            var hasSelected     = _editor.HasSelected;

            l.Label(Lang.Get("Dialog_Config.Tab.Content.Component").Bold());
            var moveButtonsGrid = l.GetButtonGrid(-1f, -1f);

            if (GUIPlus.DrawButton(moveButtonsGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.MoveUp"), enabled: hasSelected && _editor.Selected.CanMoveUp))
            {
                _editor.Selected.MoveUp();
            }
            if (GUIPlus.DrawButton(moveButtonsGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.MoveDown"), enabled: hasSelected && _editor.Selected.CanMoveDown))
            {
                _editor.Selected.MoveDown();
            }

            if (l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Remove"), enabled: hasSelected && _editor.Selected.CanRemove))
            {
                _editor.Selected.Remove();
                return;
            }

            if (canAddContainer && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Stack"), Lang.Get("Dialog_Config.Tab.Content.Component.StackDesc")))
            {
                HudModel.StackComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }
            if (canAddContainer && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Panel"), Lang.Get("Dialog_Config.Tab.Content.Component.PanelDesc")))
            {
                _editor.Add(HudModel.PanelComponent);
            }
            if (canAddRow && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Row"), Lang.Get("Dialog_Config.Tab.Content.Component.RowDesc")))
            {
                _editor.Add(HudModel.RowComponent);
            }
            if (canAddElement && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Element"), Lang.Get("Dialog_Config.Tab.Content.Component.ElementDesc")))
            {
                HudModel.ElementComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }

            var statRecordGrid = l.GetButtonGrid(-1f, -1f);

            if (canAddElement && GUIPlus.DrawButton(statRecordGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.Stat"), enabled: HudModel.StatComponents.Length > 0))
            {
                HudModel.StatComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }
            if (canAddElement && GUIPlus.DrawButton(statRecordGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.Record"), enabled: HudModel.RecordComponents.Length > 0))
            {
                HudModel.RecordComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }

            var customButtonsGrid = l.GetButtonGrid(-1f, -1f);

            if (canAddElement && GUIPlus.DrawButton(customButtonsGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.Need"), enabled: HudModel.NeedComponents.Length > 0))
            {
                HudModel.NeedComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }
            if (canAddElement && GUIPlus.DrawButton(customButtonsGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.SkillOrTraining"), enabled: HudModel.SkillAndTrainingComponents.Length > 0))
            {
                HudModel.SkillAndTrainingComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu();
            }

            l.End();

            if (!hasSelected || _editor.Selected.IsRoot)
            {
                return;
            }

            var selectedRect = hGrid[2].GetVGrid(GUIPlus.MediumPadding, -1f, SelectedHeight)[2];

            l.Begin(selectedRect);
            l.Label(Lang.Get("Dialog_Config.Tab.Content.Selected").Bold() + _editor.Selected.Label.Bold().Italic());

            var targets = HudTarget.None;

            if (l.CheckboxLabeled(Lang.Get("Model.Target.PlayerHumanlike"), _editor.Selected.Targets.HasTarget(HudTarget.PlayerHumanlike), enabled: _editor.Selected.Targets != HudTarget.PlayerHumanlike))
            {
                targets |= HudTarget.PlayerHumanlike;
            }
            if (l.CheckboxLabeled(Lang.Get("Model.Target.PlayerCreature"), _editor.Selected.Targets.HasTarget(HudTarget.PlayerCreature), enabled: _editor.Selected.Targets != HudTarget.PlayerCreature))
            {
                targets |= HudTarget.PlayerCreature;
            }
            if (l.CheckboxLabeled(Lang.Get("Model.Target.OtherHumanlike"), _editor.Selected.Targets.HasTarget(HudTarget.OtherHumanlike), enabled: _editor.Selected.Targets != HudTarget.OtherHumanlike))
            {
                targets |= HudTarget.OtherHumanlike;
            }
            if (l.CheckboxLabeled(Lang.Get("Model.Target.OtherCreature"), _editor.Selected.Targets.HasTarget(HudTarget.OtherCreature), enabled: _editor.Selected.Targets != HudTarget.OtherCreature))
            {
                targets |= HudTarget.OtherCreature;
            }

            _editor.Selected.Targets = targets;

            if (_editor.Selected.Type == LayoutItemType.Stack || _editor.Selected.Type == LayoutItemType.Panel)
            {
                _editor.Selected.FillHeight = l.CheckboxLabeled(Lang.Get("Dialog_Config.Tab.Content.Selected.Filled"), _editor.Selected.FillHeight, Lang.Get("Dialog_Config.Tab.Content.Selected.FilledDesc"));
            }

            l.End();
        }