Пример #1
0
        private static void GetWeaponData([NotNull] Pawn pawn, ICollection <string> parts)
        {
            List <Thing>          sidearms       = SimpleSidearms.GetSidearms(pawn)?.ToList();
            var                   weapons        = new List <string>();
            List <ThingWithComps> equipment      = pawn.equipment?.AllEquipmentListForReading ?? new List <ThingWithComps>();
            int                   equipmentCount = equipment.Count;
            List <Thing>          inventory      = pawn.inventory.innerContainer.InnerListForReading ?? new List <Thing>();
            var                   usedInventory  = new List <Thing>();

            if (sidearms?.Count > 0)
            {
                GetSidearmData(sidearms, equipmentCount, equipment, weapons, inventory, usedInventory);
            }
            else
            {
                Pawn_EquipmentTracker e = pawn.equipment;

                if (e?.AllEquipmentListForReading?.Count > 0)
                {
                    IEnumerable <string> equip = e.AllEquipmentListForReading.Select(eq => RichTextHelper.StripTags(eq.LabelCap));

                    weapons.AddRange(equip);
                }
            }

            if (weapons.Count <= 0)
            {
                return;
            }

            string section = "Stat_Weapon_Name".Localize();

            parts.Add($"{(weapons.Count > 1 ? section.Pluralize() : section)}: {weapons.SectionJoin()}");
        }
Пример #2
0
        public static bool CustomDrawer_ButtonExportConfig(Rect rect, string label, SimpleSidearms instance, Color background)
        {
            drawBackground(rect, background);
            Rect buttonRect = new Rect(rect);

            buttonRect.position = new Vector2(buttonRect.position.x + buttonRect.width - 200, buttonRect.position.y);
            buttonRect.width    = 200;
            Color keptColor = GUI.color;

            GUI.color = Color.cyan;
            bool clicked = Widgets.ButtonText(buttonRect, label.Translate());

            if (clicked)
            {
                UnsafeUtilities.ExportConfigViaReflection(instance);
            }
            GUI.color = keptColor;
            return(false);
        }
Пример #3
0
        internal static void presetChanged(Globals.Preset preset, SimpleSidearms mod)
        {
            //Log.Message("Switching to preset " + preset.ToString());
            switch (preset)
            {
            case Globals.Preset.Custom:
                SimpleSidearms.ActivePreset.Value = preset;
                return;

            case Globals.Preset.Disabled:
                mod.UpdateConfig(Preset_Disabled, true);
                break;

            case Globals.Preset.Lite:
                mod.UpdateConfig(Preset_Lite, true);
                break;

            case Globals.Preset.LoadoutOnly:
                mod.UpdateConfig(Preset_LoadoutOnly, true);
                break;

            case Globals.Preset.Basic:
                mod.UpdateConfig(Preset_Basic, true);
                break;

            case Globals.Preset.Advanced:
                mod.UpdateConfig(Preset_Advanced, true);
                break;

            case Globals.Preset.Excessive:
                mod.UpdateConfig(Preset_Excessive, true);
                break;

            case Globals.Preset.Brawler:
                mod.UpdateConfig(Preset_Brawler, true);
                break;
            }
            SimpleSidearms.ActivePreset.Value = preset;
            SimpleSidearms.ActiveTab.Value    = SimpleSidearms.OptionsTab.Presets;
            HugsLibController.SettingsManager.SaveChanges();
        }
Пример #4
0
        public static void ExportConfigViaReflection(SimpleSidearms mod)
        {
            ModSettingsPack pack = HugsLibController.SettingsManager.GetModSettings(mod.ModIdentifier);

            if (pack == null)
            {
                return;
            }
            XElement root = new XElement("root");

            pack.CallByReflection("WriteXml", root);
            //should only have one
            Log.Message("Exporting current config!");
            StringBuilder builder = new StringBuilder();

            foreach (XElement child in root.Elements())
            {
                builder.AppendLine(child.ToString());
            }
            HugsLibUtility.CopyToClipboard(builder.ToString());
        }
Пример #5
0
        public static bool CustomDrawer_ButtonLoadConfig(Rect rect, SettingHandle <Preset> setting, string label, SimpleSidearms instance, Color background)
        {
            drawBackground(rect, background);
            Rect buttonRect = new Rect(rect);

            buttonRect.width = 50;
            Color keptColor = GUI.color;

            if (SimpleSidearms.ActivePreset.Value == setting.Value)
            {
                GUI.color = SelectedOptionColor;
            }
            bool clicked = Widgets.ButtonText(buttonRect, label.Translate());

            if (clicked)
            {
                Presets.presetChanged(setting.Value, instance);
            }
            GUI.color = keptColor;
            return(clicked);
        }