Beispiel #1
0
        // Token: 0x0600001B RID: 27 RVA: 0x0000294C File Offset: 0x00000B4C
        public static bool CustomDrawer_Filter(Rect rect, SettingHandle <float> slider, bool def_isPercentage, float def_min, float def_max, Color background)
        {
            DrawUtility.drawBackground(rect, background);
            int  num   = 50;
            Rect rect2 = new Rect(rect);

            rect2.width -= (float)num;
            Rect rect3 = new Rect(rect);

            rect3.width    = (float)num;
            rect3.position = new Vector2(rect2.position.x + rect2.width + 5f, rect2.position.y + 4f);
            rect2          = GenUI.ContractedBy(rect2, 2f);
            if (def_isPercentage)
            {
                Widgets.Label(rect3, Mathf.Round(slider.Value * 100f).ToString("F0") + "%");
            }
            else
            {
                Widgets.Label(rect3, slider.Value.ToString("F2"));
            }
            float num2   = Widgets.HorizontalSlider(rect2, slider.Value, def_min, def_max, true, null, null, null, -1f);
            bool  result = false;
            bool  flag   = slider.Value != num2;

            if (flag)
            {
                result = true;
            }
            slider.Value = num2;
            return(result);
        }
Beispiel #2
0
        // Token: 0x0600001A RID: 26 RVA: 0x00002768 File Offset: 0x00000968
        private static bool DrawIconForWeapon(ThingDef weapon, KeyValuePair <string, WeaponRecord> item, Rect contentRect, Vector2 iconOffset, int buttonID)
        {
            Texture2D uiIcon  = weapon.uiIcon;
            Color     color   = DrawUtility.getColor(weapon);
            Color     color2  = DrawUtility.getColor(weapon);
            Graphic   graphic = null;
            bool      flag    = weapon.graphicData != null && weapon.graphicData.Graphic != null;

            if (flag)
            {
                Graphic graphic2 = weapon.graphicData.Graphic;
                graphic = weapon.graphicData.Graphic.GetColoredVersion(graphic2.Shader, color, color2);
            }
            Rect rect  = new Rect(contentRect.x + iconOffset.x, contentRect.y + iconOffset.y, 32f, 32f);
            bool flag2 = !contentRect.Contains(rect);
            bool result;

            if (flag2)
            {
                result = false;
            }
            else
            {
                string label = weapon.label;
                TooltipHandler.TipRegion(rect, label);
                MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
                bool flag3 = Mouse.IsOver(rect);
                if (flag3)
                {
                    GUI.color = DrawUtility.iconMouseOverColor;
                    GUI.DrawTexture(rect, ContentFinder <Texture2D> .Get("square", true));
                }
                else
                {
                    bool isException = item.Value.isException;
                    if (isException)
                    {
                        GUI.color = DrawUtility.iconMouseOverColor;
                        GUI.DrawTexture(rect, ContentFinder <Texture2D> .Get("square", true));
                    }
                    else
                    {
                        GUI.color = DrawUtility.iconBaseColor;
                        GUI.DrawTexture(rect, ContentFinder <Texture2D> .Get("square", true));
                    }
                }
                bool    flag4 = !weapon.uiIconPath.NullOrEmpty();
                Texture texture;
                if (flag4)
                {
                    texture = weapon.uiIcon;
                }
                else
                {
                    bool flag5 = graphic != null;
                    if (flag5)
                    {
                        texture = graphic.MatSingle.mainTexture;
                    }
                    else
                    {
                        texture = new Texture2D((int)graphic.drawSize.x, (int)graphic.drawSize.y);
                    }
                }
                GUI.color = color;
                GUI.DrawTexture(rect, texture);
                GUI.color = Color.white;
                bool flag6 = Widgets.ButtonInvisible(rect, true);
                if (flag6)
                {
                    Event.current.button = buttonID;
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Beispiel #3
0
        // Token: 0x0600001E RID: 30 RVA: 0x00002D0C File Offset: 0x00000F0C
        internal static bool CustomDrawer_MatchingWeapons_active(Rect wholeRect, SettingHandle <DictWeaponRecordHandler> setting, List <ThingDef> allWeapons, SettingHandle <float> filter = null, string yesText = "Light weapon", string noText = "Heavy weapon")
        {
            DrawUtility.drawBackground(wholeRect, DrawUtility.background);
            GUI.color = Color.white;
            Rect rect = new Rect(wholeRect);

            rect.width    = rect.width;
            rect.height   = wholeRect.height - 20f + 2f;
            rect.position = new Vector2(rect.position.x - 275f, rect.position.y);
            Rect rect2 = new Rect(wholeRect);

            rect2.width    = rect2.width;
            rect.height    = wholeRect.height - 20f + 2f;
            rect2.position = new Vector2(rect2.position.x - 275f + rect.width, rect2.position.y);
            DrawUtility.DrawLabel(yesText, rect, 20f);
            DrawUtility.DrawLabel(noText, rect2, 20f);
            rect.position  = new Vector2(rect.position.x, rect.position.y + 20f);
            rect2.position = new Vector2(rect2.position.x, rect2.position.y + 20f);
            int  num  = (int)(rect.width / 33f);
            bool flag = false;
            int  num2 = 0;

            DrawUtility.filterWeapons(ref setting, allWeapons, filter);
            Dictionary <string, WeaponRecord> innerList = setting.Value.InnerList;

            foreach (KeyValuePair <string, WeaponRecord> keyValuePair in innerList)
            {
                bool isSelected = keyValuePair.Value.isSelected;
                if (isSelected)
                {
                    num2++;
                }
            }
            int num3 = Math.Max(num2 / num, (innerList.Count - num2) / num) + 1;

            setting.CustomDrawerHeight = (float)num3 * 32f + (float)num3 * 1f + 20f;
            Dictionary <string, ThingDef> dictionary = allWeapons.ToDictionary((ThingDef o) => o.defName, (ThingDef o) => o);
            int num4 = 0;
            int num5 = 0;

            foreach (KeyValuePair <string, WeaponRecord> item in innerList)
            {
                Rect contentRect = item.Value.isSelected ? rect2 : rect;
                int  num6        = item.Value.isSelected ? num5 : num4;
                bool isSelected2 = item.Value.isSelected;
                if (isSelected2)
                {
                    num5++;
                }
                else
                {
                    num4++;
                }
                int      num7   = num6 % num;
                int      num8   = num6 / num;
                ThingDef weapon = null;
                bool     flag2  = dictionary.TryGetValue(item.Key, out weapon);
                bool     flag3  = false;
                bool     flag4  = flag2;
                if (flag4)
                {
                    flag3 = DrawUtility.DrawIconForWeapon(weapon, item, contentRect, new Vector2(32f * (float)num7 + (float)num7 * 1f, 32f * (float)num8 + (float)num8 * 1f), num6);
                }
                bool flag5 = flag3;
                if (flag5)
                {
                    flag = true;
                    item.Value.isSelected  = !item.Value.isSelected;
                    item.Value.isException = !item.Value.isException;
                }
            }
            bool flag6 = flag;

            if (flag6)
            {
                setting.Value.InnerList = innerList;
            }
            return(flag);
        }