示例#1
0
 public static void Reset()
 {
     LatestVersion.Reset();
 }
示例#2
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            inRect.yMin += 20;
            inRect.yMax -= 20;
            Listing_Standard list  = new Listing_Standard();
            Rect             rect  = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
            Rect             rect2 = new Rect(0f, 0f, inRect.width - 30f, inRect.height * 2 + ammunitionSettings.WeaponViewHeight);
            Rect             rect3 = new Rect(0f, 0f, inRect.width - 30f, ammunitionSettings.WeaponViewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, rect2, true);
            list.Begin(rect2);
            if (list.ButtonText("Default Settings"))
            {
                ammunitionSettings.Reset();
            }
            ;
            list.CheckboxLabeled("Is ammo required to fire weapons?", ref ammunitionSettings.NeedAmmo);
            list.Label(string.Format("Desired carried ammo. {0}", ammunitionSettings.DesiredAmmo));
            ammunitionSettings.DesiredAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.DesiredAmmo, 1, 100));
            list.Label(string.Format("Least ammo to fetch. {0}", ammunitionSettings.LeastAmmoFetch));
            ammunitionSettings.LeastAmmoFetch = (int)Mathf.Round(list.Slider(ammunitionSettings.LeastAmmoFetch, 1, 10));
            list.CheckboxLabeled("NPC needs ammo.", ref ammunitionSettings.NPCNeedAmmo);
            if (ammunitionSettings.NPCNeedAmmo)
            {
                list.Label(string.Format("NPC's spawn if appliable with a minumum of {0} ammo up to the maximum set in the following option.", ammunitionSettings.NPCMinAmmo));
                ammunitionSettings.NPCMinAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.NPCMinAmmo, 1, 100));
                list.Label(string.Format("NPC's spawn/respawn if appliable with maxmimum {0} of extra ammo.", ammunitionSettings.NPCMaxAmmo));
                ammunitionSettings.NPCMaxAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.NPCMaxAmmo, ammunitionSettings.NPCMinAmmo, 200));
            }
            list.GapLine();
            if (ammunitionSettings.AssociationDictionary != null)
            {
                list.Label(string.Format("Ammunition used for weapons."));
                list.Label(string.Format("({0}) Height.", ammunitionSettings.WeaponViewHeight));
                ammunitionSettings.WeaponViewHeight = (int)Mathf.Round(list.Slider(ammunitionSettings.WeaponViewHeight, 1, 2500));
                ammunitionSettings.Filter           = list.TextEntryLabeled("Filter:", ammunitionSettings.Filter, 1);
                Listing_Standard list2 = list.BeginSection(ammunitionSettings.WeaponViewHeight);
                list2.ColumnWidth = (rect2.width - 50) / 3;
                foreach (ThingDef weapon in Utility.AvailableWeapons)
                {
                    if (SettingsHelper.LatestVersion.AssociationDictionary.ContainsKey(weapon.defName) &&
                        weapon.defName.ToUpper().Contains(ammunitionSettings.Filter.ToUpper()))
                    {
                        float      lineHeight = Text.LineHeight;
                        Rect       innerRect  = list2.GetRect(lineHeight);
                        TextAnchor anchor     = Text.Anchor;
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Widgets.Label(innerRect, weapon.label);
                        if (Widgets.ButtonInvisible(innerRect))
                        {
                            SettingsHelper.LatestVersion.AssociationDictionary[weapon.defName]++;
                            if (SettingsHelper.LatestVersion.AssociationDictionary[weapon.defName] > ammoType.battery)
                            {
                                SettingsHelper.LatestVersion.AssociationDictionary[weapon.defName] = 0;
                            }
                        }
                        Rect position = new Rect(innerRect.x + list2.ColumnWidth - 24f, innerRect.y, 24f, 24f);
                        Widgets.DrawTextureFitted(position, Utility.ImageAssociation(SettingsHelper.LatestVersion.AssociationDictionary[weapon.defName]), 1);
                        Text.Anchor = anchor;
                    }
                }
                list.EndSection(list2);
            }

            list.End();
            Widgets.EndScrollView();
            ammunitionSettings.Write();
        }
        public override void DoSettingsWindowContents(Rect inRect)
        {
            inRect.yMin += 20;
            inRect.yMax -= 20;
            Listing_Standard list  = new Listing_Standard();
            Rect             rect  = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
            Rect             rect2 = new Rect(0f, 0f, inRect.width - 30f, inRect.height * 2 + ammunitionSettings.WeaponViewHeight);
            Rect             rect3 = new Rect(0f, 0f, inRect.width - 30f, ammunitionSettings.WeaponViewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, rect2, true);
            list.Begin(rect2);
            if (list.ButtonText("Default Settings"))
            {
                ammunitionSettings.Reset();
            }
            ;
            list.CheckboxLabeled("Is ammo required to fire weapons?", ref ammunitionSettings.NeedAmmo);
            list.CheckboxLabeled("Mod Compatibility Mode", ref ammunitionSettings.CompatibilityMode, "Any weapon not covered by this mod should default to use Industrial Ammo.");
            list.CheckboxLabeled("Should a pawn actively search for ammo?", ref ammunitionSettings.FetchAmmo);
            if (ammunitionSettings.FetchAmmo)
            {
                list.Label(string.Format("Desired carried ammo. {0}", ammunitionSettings.DesiredAmmo));
                ammunitionSettings.DesiredAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.DesiredAmmo, 1, 100));
                list.Label(string.Format("Least ammo to fetch. {0}", ammunitionSettings.LeastAmmoFetch));
                ammunitionSettings.LeastAmmoFetch = (int)Mathf.Round(list.Slider(ammunitionSettings.LeastAmmoFetch, 1, 10));
            }
            list.CheckboxLabeled("NPC needs ammo.", ref ammunitionSettings.NPCNeedAmmo);
            if (ammunitionSettings.NPCNeedAmmo)
            {
                list.Label(string.Format("NPC's spawn if appliable with a minumum of {0} ammo.", ammunitionSettings.NPCMinAmmo));
                ammunitionSettings.NPCMinAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.NPCMinAmmo, 1, 100));
                list.Label(string.Format("NPC's spawn if appliable with a maxmimum of {0} ammo.", ammunitionSettings.NPCMaxAmmo));
                ammunitionSettings.NPCMaxAmmo = (int)Mathf.Round(list.Slider(ammunitionSettings.NPCMaxAmmo, ammunitionSettings.NPCMinAmmo, 200));
            }
            list.GapLine();
            if (ammunitionSettings.AvailableWeapons != null && ammunitionSettings.AvailableWeapons.Count() > 0)
            {
                list.Label(string.Format("Exclude weapons from ammunition check."));
                list.Label(string.Format("({0}) Height.", ammunitionSettings.WeaponViewHeight));
                ammunitionSettings.WeaponViewHeight = (int)Mathf.Round(list.Slider(ammunitionSettings.WeaponViewHeight, 1, 2500));
                ammunitionSettings.Filter           = list.TextEntryLabeled("Filter:", ammunitionSettings.Filter, 1);
                Listing_Standard list2 = list.BeginSection(ammunitionSettings.WeaponViewHeight);
                list2.ColumnWidth = (rect2.width - 50) / 3;
                foreach (ThingDef def in ammunitionSettings.AvailableWeapons)
                {
                    if (def.defName.ToUpper().Contains(ammunitionSettings.Filter.ToUpper()))
                    {
                        bool contains = ammunitionSettings.WeaponExclusion.Contains(def.defName);
                        list2.CheckboxLabeled(def.defName, ref contains);
                        if (contains == false && ammunitionSettings.WeaponExclusion.Contains(def.defName))
                        {
                            ammunitionSettings.WeaponExclusion.Remove(def.defName);
                        }
                        else if (contains == true && !ammunitionSettings.WeaponExclusion.Contains(def.defName))
                        {
                            ammunitionSettings.WeaponExclusion.Add(def.defName);
                        }
                    }
                }
                list.EndSection(list2);
            }

            list.End();
            Widgets.EndScrollView();
            ammunitionSettings.Write();
        }