private static void Postfix(Rect rect)
        {
            var component = Current.Game.GetComponent <WorkManagerGameComponent>();

            CustomWidgets.ButtonImageToggle(ref component.Enabled, new Rect(rect.x + 175, rect.y + 88, 24, 24),
                                            Resources.Strings.GlobalDisableTooltip, Resources.Textures.GlobalToggleButtonEnabled,
                                            Resources.Strings.GlobalEnableTooltip, Resources.Textures.GlobalToggleButtonDisabled);
        }
        public static void DoWindowContentsPostfix(Rect rect)
        {
            var component = Current.Game.GetComponent <WorkManagerGameComponent>();

            CustomWidgets.ButtonImageToggle(ref component.Enabled, new Rect(rect.xMin, rect.yMin, 24, 24),
                                            Resources.Strings.GlobalDisableTooltip, Resources.Textures.GlobalToggleButtonEnabled,
                                            Resources.Strings.GlobalEnableTooltip, Resources.Textures.GlobalToggleButtonDisabled);
        }
Example #3
0
        private void DrawLoot()
        {
            // show loot overlay
            var showLootOverlay = _plugin.Configuration.ShowLootOverlay;

            if (ImGui.Checkbox(
                    Loc.Localize("ShowLootOverlay", "Show Loot Overlay") + "###Kapture_ShowLootOverlay_Checkbox",
                    ref showLootOverlay))
            {
                _plugin.Configuration.ShowLootOverlay = showLootOverlay;
                LootOverlayVisibilityUpdated?.Invoke(this, showLootOverlay);
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("ShowLootOverlay_HelpMarker",
                                                  "show loot overlay window"));
            ImGui.Spacing();

            // display mode
            ImGui.Text(Loc.Localize("LootDisplayMode", "Display Mode"));
            CustomWidgets.HelpMarker(Loc.Localize("LootDisplayMode_HelpMarker",
                                                  "when to show loot overlay"));
            ImGui.Spacing();
            var pluginLootDisplayMode = _plugin.Configuration.LootDisplayMode;

            if (ImGui.Combo("###Kapture_LootDisplayMode_Combo", ref pluginLootDisplayMode,
                            DisplayMode.DisplayModeNames.ToArray(),
                            DisplayMode.DisplayModeNames.Count))
            {
                _plugin.Configuration.LootDisplayMode = pluginLootDisplayMode;
                _plugin.SaveConfig();
            }

            ImGui.Spacing();

            // loot name format
            ImGui.Text(Loc.Localize("LootNameFormat", "Name Format"));
            CustomWidgets.HelpMarker(Loc.Localize("LootNameFormat_HelpMarker",
                                                  "how to display player names in the loot overlay"));
            ImGui.Spacing();
            var pluginLootNameFormat = _plugin.Configuration.LootNameFormat;

            if (ImGui.Combo("###Kapture_LootNameFormat_Combo", ref pluginLootNameFormat,
                            NameFormat.NameFormatNames.ToArray(),
                            NameFormat.NameFormatNames.Count))
            {
                _plugin.Configuration.LootNameFormat = pluginLootNameFormat;
                _plugin.SaveConfig();
            }
        }
Example #4
0
        private void DrawGeneral()
        {
            // plugin enabled
            var enabled = _plugin.Configuration.Enabled;

            if (ImGui.Checkbox(
                    Loc.Localize("PluginEnabled", "Plugin Enabled") + "###Kapture_PluginEnabled_Checkbox",
                    ref enabled))
            {
                _plugin.Configuration.Enabled = enabled;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("PluginEnabled_HelpMarker",
                                                  "toggle the plugin on/off"));
            ImGui.Spacing();

            // combat
            var restrictInCombat = _plugin.Configuration.RestrictInCombat;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictInCombat", "Don't process in combat") + "###Kapture_RestrictInCombat_Checkbox",
                    ref restrictInCombat))
            {
                _plugin.Configuration.RestrictInCombat = restrictInCombat;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("PluginEnabled_HelpMarker",
                                                  "stop processing data while in combat"));
            ImGui.Spacing();

            // language
            ImGui.Text(Loc.Localize("Language", "Language"));
            CustomWidgets.HelpMarker(Loc.Localize("Language_HelpMarker",
                                                  "use default or override plugin ui language"));
            ImGui.Spacing();
            var pluginLanguage = _plugin.Configuration.PluginLanguage;

            if (ImGui.Combo("###Kapture_Language_Combo", ref pluginLanguage,
                            PluginLanguage.LanguageNames.ToArray(),
                            PluginLanguage.LanguageNames.Count))
            {
                _plugin.Configuration.PluginLanguage = pluginLanguage;
                _plugin.SaveConfig();
                _plugin.Localization.SetLanguage(pluginLanguage);
            }
        }
Example #5
0
        private void RestrictToContent()
        {
            var restrictToContent = _plugin.Configuration.RestrictToContent;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictToContent", "Content Only") + "###Kapture_RestrictToContent_Checkbox",
                    ref restrictToContent))
            {
                _plugin.Configuration.RestrictToContent = restrictToContent;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("RestrictToContent_HelpMarker",
                                                  "restrict to instanced content and exclude overworld encounters"));
            ImGui.Spacing();
        }
Example #6
0
        private void RestrictToHighEndDuty()
        {
            var restrictToHighEndDuty = _plugin.Configuration.RestrictToHighEndDuty;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictToHighEndDuty", "High-End Duty Only") +
                    "###Kapture_RestrictToHighEndDuty_Checkbox",
                    ref restrictToHighEndDuty))
            {
                _plugin.Configuration.RestrictToHighEndDuty = restrictToHighEndDuty;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("RestrictToHighEndDuty_HelpMarker",
                                                  "restrict to high-end duties only (e.g. savage)"));
            ImGui.Spacing();
        }
        private static void DoHeaderPostfix(PawnColumnWorker_WorkPriority __instance, Rect rect)
        {
            const int iconSize   = 16;
            var       buttonRect = new Rect(rect.center.x - iconSize / 2 + 1, rect.yMax - iconSize - 4, iconSize, iconSize);
            var       component  = Current.Game.GetComponent <WorkManagerGameComponent>();

            if (component.Enabled)
            {
                CustomWidgets.ButtonImageToggle(() => !component.DisabledWorkTypes.Contains(__instance.def.workType),
                                                newValue => component.SetWorkTypeEnabled(__instance.def.workType, newValue), buttonRect,
                                                Resources.Strings.WorkTypeDisableTooltip, Resources.Textures.WorkTypeToggleButtonEnabled,
                                                Resources.Strings.WorkTypeEnableTooltip, Resources.Textures.WorkTypeToggleButtonDisabled);
            }
            else
            {
                GUI.color = Color.white;
                GUI.DrawTexture(buttonRect, Resources.Textures.WorkTypeToggleButtonInactive);
            }
        }
Example #8
0
        public static void DoHeaderPrefix(PawnColumnWorker __instance, ref Rect rect)
        {
            const int iconSize   = 16;
            var       buttonRect = new Rect(rect.center.x - iconSize / 2, rect.yMax - iconSize - 4, iconSize, iconSize);
            var       component  = Current.Game.GetComponent <WorkManagerGameComponent>();

            if (component.Enabled)
            {
                CustomWidgets.ButtonImageToggle(() => component.GetWorkTypeEnabled(__instance.def.workType),
                                                newValue => component.SetWorkTypeEnabled(__instance.def.workType, newValue), buttonRect,
                                                Resources.Strings.WorkTypeDisableTooltip, Resources.Textures.WorkTypeToggleButtonEnabled,
                                                Resources.Strings.WorkTypeEnableTooltip, Resources.Textures.WorkTypeToggleButtonDisabled);
            }
            else
            {
                GUI.color = Color.white;
                GUI.DrawTexture(buttonRect, Resources.Textures.WorkTypeToggleButtonInactive);
            }
            rect = new Rect(rect.x, rect.y, rect.width, rect.height - 30);
        }
Example #9
0
        private void DrawLog()
        {
            // logging enabled
            var loggingEnabled = _plugin.Configuration.LoggingEnabled;

            if (ImGui.Checkbox(
                    Loc.Localize("LoggingEnabled", "Enable Loot Logging") +
                    "###Kapture_LoggingEnabled_Checkbox",
                    ref loggingEnabled))
            {
                _plugin.Configuration.LoggingEnabled = loggingEnabled;
                _plugin.SaveConfig();
                if (loggingEnabled)
                {
                    _plugin.LootLogger.SetLogFormat();
                }
            }

            CustomWidgets.HelpMarker(Loc.Localize("LoggingEnabled_HelpMarker",
                                                  "save your loot messages to a file in config (see links)"));
            ImGui.Spacing();

            // log format
            ImGui.Text(Loc.Localize("LogFormat", "Log Format"));
            CustomWidgets.HelpMarker(Loc.Localize("LogFormat_HelpMarker",
                                                  "set format for log file with loot info"));
            ImGui.Spacing();
            var pluginLogFormat = _plugin.Configuration.LogFormat;

            if (ImGui.Combo("###Kapture_LogFormat_Combo", ref pluginLogFormat,
                            LogFormat.LogFormatNames.ToArray(),
                            LogFormat.LogFormatNames.Count))
            {
                _plugin.Configuration.LogFormat = pluginLogFormat;
                _plugin.SaveConfig();
                _plugin.LootLogger.SetLogFormat();
            }
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (pawn.Dead || pawn.workSettings == null || !pawn.workSettings.EverWork)
            {
                return;
            }
            var component = Current.Game.GetComponent <WorkManagerGameComponent>();

            if (component.Enabled)
            {
                CustomWidgets.ButtonImageToggle(() => component.GetPawnEnabled(pawn),
                                                newValue => component.SetPawnEnabled(pawn, newValue),
                                                new Rect(rect.center.x - 8, rect.center.y - 8, 16, 16), Resources.Strings.PawnDisableTooltip,
                                                Resources.Textures.PawnToggleButtonEnabled, Resources.Strings.PawnEnableTooltip,
                                                Resources.Textures.PawnToggleButtonDisabled);
            }
            else
            {
                GUI.color = Color.white;
                GUI.DrawTexture(new Rect(rect.center.x - 8, rect.center.y - 8, 16, 16),
                                Resources.Textures.PawnToggleButtonInactive);
            }
        }
Example #11
0
        private void DrawItems()
        {
            var offset = 110f * Scale;

            var restrictToCustomItemsList = _plugin.Configuration.RestrictToCustomItems;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictToCustomItems", "Restrict to Following Items") +
                    "###Kapture_RestrictToCustomItems_Checkbox",
                    ref restrictToCustomItemsList))
            {
                _plugin.Configuration.RestrictToCustomItems = restrictToCustomItemsList;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("RestrictToCustomItems_HelpMarker",
                                                  "add item to list by using dropdown or remove by clicking on them"));

            ImGui.SameLine();
            if (ImGui.SmallButton(Loc.Localize("Reset", "Reset") + "###Kapture_CustomItemReset_Button"))
            {
                _selectedItemIndex             = 0;
                _selectedItemCategoryItemIndex = 0;
                UpdateItemList();
                _plugin.Configuration.PermittedItems = new List <uint>();
                _plugin.SaveConfig();
            }

            ImGui.Spacing();

            // select category by item ui category
            ImGui.Text(Loc.Localize("SelectCategory", "Select Category"));
            ImGui.SameLine(offset);
            ImGui.SetNextItemWidth(ImGui.GetWindowSize().X / 2 * Scale);
            if (ImGui.Combo("###Kapture_ItemCategoryItems_Combo", ref _selectedItemCategoryItemIndex,
                            _plugin.ItemCategoryNames, _plugin.ItemCategoryIds.Length))
            {
                UpdateItemList();
            }

            // select item based on category
            ImGui.Text(Loc.Localize("SelectItem", "Select Item"));
            ImGui.SameLine(offset);
            ImGui.SetNextItemWidth(ImGui.GetWindowSize().X / 2 * Scale);
            ImGui.Combo("###Kapture_ItemItems_Combo", ref _selectedItemIndex,
                        ItemNames, ItemIds.Length);
            ImGui.SameLine();
            if (ImGui.SmallButton(Loc.Localize("Add", "Add") + "###Kapture_AddItemItem_Button"))
            {
                if (_plugin.Configuration.PermittedItems.Contains(
                        ItemIds[_selectedItemIndex]))
                {
                    ImGui.OpenPopup("###Kapture_DupeCustomItem_Popup");
                }
                else
                {
                    _plugin.Configuration.PermittedItems.Add(
                        ItemIds[_selectedItemIndex]);
                    _plugin.SaveConfig();
                }
            }

            // dupe popup
            if (ImGui.BeginPopup("###Kapture_DupeCustomItem_Popup"))
            {
                ImGui.Text(Loc.Localize("DupeCustomItem", "This item is already added!"));
                ImGui.EndPopup();
            }

            ImGui.Spacing();

            // item list
            ImGui.Text(Loc.Localize("PermittedItems", "Permitted Items"));
            ImGui.SameLine(offset - 5f * Scale);
            ImGui.Indent(offset - 5f * Scale);
            if (_plugin.Configuration.PermittedItems != null &&
                _plugin.Configuration.PermittedItems.Count > 0)
            {
                foreach (var permittedItem in _plugin.Configuration.PermittedItems.ToList())
                {
                    var index = Array.IndexOf(_plugin.ItemIds, permittedItem);
                    ImGui.Text(_plugin.ItemNames[index]);
                    if (ImGui.IsItemClicked())
                    {
                        _plugin.Configuration.PermittedItems.Remove(permittedItem);
                        _plugin.SaveConfig();
                    }
                }
            }
            else
            {
                ImGui.Text(Loc.Localize("NoPermittedItems", "None"));
            }


            ImGui.Spacing();
        }
Example #12
0
        private void RestrictToCustom()
        {
            var restrictToCustomList = _plugin.Configuration.RestrictToCustomContent;

            if (ImGui.Checkbox(
                    Loc.Localize("RestrictToCustom", "Restrict to Following Content") +
                    "###Kapture_RestrictToCustom_Checkbox",
                    ref restrictToCustomList))
            {
                _plugin.Configuration.RestrictToCustomContent = restrictToCustomList;
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("RestrictToCustom_HelpMarker",
                                                  "add content to list by using dropdown or remove by clicking on them"));
            ImGui.Spacing();

            ImGui.SetNextItemWidth(ImGui.GetWindowSize().X / 2 * Scale);
            ImGui.Combo("###Kapture_Content_Combo", ref _selectedContentIndex,
                        ContentNames, ContentIds.Length);
            ImGui.SameLine();

            if (ImGui.SmallButton(Loc.Localize("Add", "Add") + "###Kapture_ContentAdd_Button"))
            {
                if (_plugin.Configuration.PermittedContent.Contains(
                        ContentIds[_selectedContentIndex]))
                {
                    ImGui.OpenPopup("###Kapture_DupeContent_Popup");
                }
                else
                {
                    _plugin.Configuration.PermittedContent.Add(
                        ContentIds[_selectedContentIndex]);
                    _plugin.SaveConfig();
                }
            }

            ImGui.SameLine();
            if (ImGui.SmallButton(Loc.Localize("Reset", "Reset") + "###Kapture_ContentReset_Button"))
            {
                _selectedContentIndex = 0;
                _plugin.Configuration.PermittedContent = new List <uint>();
                _plugin.SaveConfig();
            }

            if (ImGui.BeginPopup("###Kapture_DupeContent_Popup"))
            {
                ImGui.Text(Loc.Localize("DupeContent", "This content is already added!"));
                ImGui.EndPopup();
            }

            ImGui.Spacing();

            foreach (var permittedContent in _plugin.Configuration.PermittedContent.ToList())
            {
                var index = Array.IndexOf(ContentIds, permittedContent);
                ImGui.Text(ContentNames[index]);
                if (ImGui.IsItemClicked())
                {
                    _plugin.Configuration.PermittedContent.Remove(permittedContent);
                    _plugin.SaveConfig();
                }
            }

            ImGui.Spacing();
        }
Example #13
0
        private void DrawRolls()
        {
            // show roll overlay
            var showRollOverlay = _plugin.Configuration.ShowRollMonitorOverlay;

            if (ImGui.Checkbox(
                    Loc.Localize("ShowRollOverlay", "Show Roll Monitor Overlay") + "###Kapture_ShowRollOverlay_Checkbox",
                    ref showRollOverlay))
            {
                _plugin.Configuration.ShowRollMonitorOverlay = showRollOverlay;
                RollMonitorOverlayVisibilityUpdated?.Invoke(this, showRollOverlay);
                _plugin.SaveConfig();
            }

            CustomWidgets.HelpMarker(Loc.Localize("ShowRollOverlay_HelpMarker",
                                                  "show roll monitor overlay window"));
            ImGui.Spacing();

            // display mode
            ImGui.Text(Loc.Localize("RollDisplayMode", "Display Mode"));
            CustomWidgets.HelpMarker(Loc.Localize("RollDisplayMode_HelpMarker",
                                                  "when to show roll monitor overlay"));
            ImGui.Spacing();
            var pluginRollDisplayMode = _plugin.Configuration.RollDisplayMode;

            if (ImGui.Combo("###Kapture_RollDisplayMode_Combo", ref pluginRollDisplayMode,
                            DisplayMode.DisplayModeNames.ToArray(),
                            DisplayMode.DisplayModeNames.Count))
            {
                _plugin.Configuration.RollDisplayMode = pluginRollDisplayMode;
                _plugin.SaveConfig();
            }

            ImGui.Spacing();

            // roll name format
            ImGui.Text(Loc.Localize("RollNameFormat", "Name Format"));
            CustomWidgets.HelpMarker(Loc.Localize("RollNameFormat_HelpMarker",
                                                  "how to display player names in the roll monitor overlay"));
            ImGui.Spacing();
            var pluginRollNameFormat = _plugin.Configuration.RollNameFormat;

            if (ImGui.Combo("###Kapture_RollNameFormat_Combo", ref pluginRollNameFormat,
                            NameFormat.NameFormatNames.ToArray(),
                            NameFormat.NameFormatNames.Count))
            {
                _plugin.Configuration.RollNameFormat = pluginRollNameFormat;
                _plugin.SaveConfig();
            }

            ImGui.Spacing();

            // roll timeout
            ImGui.Text(Loc.Localize("RollMonitorAddedTimeout", "Show Added Items (minutes)"));
            CustomWidgets.HelpMarker(Loc.Localize("RollMonitorAddedTimeout_HelpMarker",
                                                  "amount of time before removing added items from roll monitor"));
            var RollMonitorAddedTimeout =
                _plugin.Configuration.RollMonitorAddedTimeout.FromMillisecondsToMinutes();

            if (ImGui.SliderInt("###PlayerTrack_RollMonitorAddedTimeout_Slider", ref RollMonitorAddedTimeout, 5, 60))
            {
                _plugin.Configuration.RollMonitorAddedTimeout =
                    RollMonitorAddedTimeout.FromMinutesToMilliseconds();
                _plugin.SaveConfig();
            }

            ImGui.Spacing();

            // roll timeout
            ImGui.Text(Loc.Localize("RollMonitorObtainedTimeout", "Show Obtained Items (seconds)"));
            CustomWidgets.HelpMarker(Loc.Localize("RollMonitorObtainedTimeout_HelpMarker",
                                                  "amount of time before removing obtained/lost items from roll monitor"));
            var RollMonitorObtainedTimeout =
                _plugin.Configuration.RollMonitorObtainedTimeout.FromMillisecondsToSeconds();

            if (ImGui.SliderInt("###PlayerTrack_RollMonitorObtainedTimeout_Slider", ref RollMonitorObtainedTimeout, 5, 300))
            {
                _plugin.Configuration.RollMonitorObtainedTimeout =
                    RollMonitorObtainedTimeout.FromSecondsToMilliseconds();
                _plugin.SaveConfig();
            }

            ImGui.Spacing();
        }
Example #14
0
        /// <summary>
        /// Fills the bottom left corner of the window
        /// </summary>
        /// <param name="rect">The rect to draw into</param>
        private static void DoBottomLeftWindowContents(Rect rect)
        {
            // Backup Button
            Rect BackupRect = new Rect((rect.xMin - 1) + BottomLeftContentOffset, rect.yMax - 37f, ButtonBigWidth, BottomHeight);

            TooltipHandler.TipRegion(BackupRect, "Button_Backup_Tooltip".Translate());
            if (Widgets.ButtonText(BackupRect, "Button_Backup_Text".Translate()))
            {
                BackupModList();
            }

            // '>>' Label
            Text.Anchor = TextAnchor.MiddleCenter;
            Rect toRect = new Rect(BackupRect.xMax + Padding, BackupRect.y, LabelWidth, BottomHeight);

            Widgets.Label(toRect, ">>");

            // State button and Float menu
            Rect StateRect = new Rect(toRect.xMax + Padding, BackupRect.y, ButtonSmallWidth, BottomHeight);

            TooltipHandler.TipRegion(StateRect, "Button_State_Select_Tooltip".Translate());
            if (Widgets.ButtonText(StateRect, string.Format("{0}{1}", selectedState.ToString(), (ModsConfigHandler.StateIsSet(selectedState)) ? null : "*")))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();

                for (int i = 1; i <= Globals.STATE_LIMIT; i++)
                {
                    //set a new variable here, otherwise the selected state and button text will change when int i next iterates
                    int n = i;
                    options.Add(new FloatMenuOption(GetStateName(i), (Action)(() => { selectedState = n; }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null));
                }

                options.Add(new FloatMenuOption("Edit Names...", (Action)(() => { Find.WindowStack.Add(new Dialogs.Dialog_EditNames()); }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0f, null, null));

                Find.WindowStack.Add((Window) new FloatMenu(options));
            }

            // '<<' Label
            Rect fromRect = new Rect(StateRect.xMax + Padding, StateRect.y, LabelWidth, BottomHeight);

            Widgets.Label(fromRect, "<<");

            // Restore Button
            Rect RestoreRect = new Rect(fromRect.xMax + Padding, StateRect.y, ButtonBigWidth, BottomHeight);

            TooltipHandler.TipRegion(RestoreRect, "Button_Restore_Tooltip".Translate());
            if (Widgets.ButtonText(RestoreRect, "Button_Restore_Text".Translate()))
            {
                RestoreModList();
            }

            // Undo Button
            Rect UndoRect = new Rect(RestoreRect.xMax + Padding, RestoreRect.y, ButtonSmallWidth, BottomHeight);

            TooltipHandler.TipRegion(UndoRect, "Button_Undo_Tooltip".Translate());
            if (CustomWidgets.ButtonImage(UndoRect, Textures.Undo))
            {
                if (ModsConfigHandler.CanUndo)
                {
                    if (ModsConfigHandler.DoUndoAction())
                    {
                        SetStatus("Status_Message_Undone".Translate());
                    }
                }
            }

            // Status Label
            UpdateStatus();
            Text.Font = GameFont.Tiny;
            Rect StatusRect = new Rect(StateRect.x - 25f, StateRect.yMax - 58f, LabelStatusWidth, LabelStatusHeight);

            Widgets.Label(StatusRect, StatusMessage);

            //Reset text
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
        }
 public void AddItem(CustomWidgets.ListItem item)
 {
     this.listView.AddItem(item);
 }