Beispiel #1
0
        private MultiCheckboxState AllowanceStateOf(EntityCategory cat)
        {
            int num  = 0;
            int num2 = 0;

            foreach (Thing current in cat.DescendantThings)
            {
                num++;
                if (this.filter.IsAllowed(current))
                {
                    num2++;
                }
            }
            foreach (SpecialEntityFilterDef current in cat.catDef.DescendantSpecialEntityFilterDefs)
            {
                num++;
                if (this.filter.IsAllowed(current))
                {
                    num2++;
                }
            }
            if (num2 == 0)
            {
                return(MultiCheckboxState.Off);
            }
            if (num == num2)
            {
                return(MultiCheckboxState.On);
            }
            return(MultiCheckboxState.Partial);
        }
 public virtual void UpdateForbiddenList(EntityCategory root)
 {
     this.allowedEntityList.RemoveWhere(thing => {
         return((thing == null) || thing.Destroyed);
     });
     this.forbiddenSpFilterList.RemoveWhere(spFilter => !root.catDef.DescendantSpecialEntityFilterDefs.Contains(spFilter));
 }
Beispiel #3
0
        private void DoCategory(EntityCategory node, int openMask, int indentLevel)
        {
            if (!node.DescendantThings.Any())
            {
                return;
            }
            base.OpenCloseWidget(node, indentLevel, openMask);
            base.LabelLeft(node.LabelCap, node.Description, indentLevel);
            MultiCheckboxState multiCheckboxState = this.AllowanceStateOf(node);

            if (Widgets.CheckboxMulti(new Vector2(this.LabelWidth, this.curY), multiCheckboxState, this.lineHeight))
            {
                bool allow = multiCheckboxState == MultiCheckboxState.Off;
                foreach (var thing in node.DescendantThings)
                {
                    this.filter.SetAllow(thing, allow);
                }
                foreach (var spFilter in node.catDef.DescendantSpecialEntityFilterDefs)
                {
                    this.filter.SetAllow(spFilter, allow);
                }
            }
            base.EndLine();
            if (node.IsOpen(openMask))
            {
                this.DoCurrent(node, openMask, indentLevel + 1);
            }
        }
Beispiel #4
0
 private void DoCurrent(EntityCategory current, int openMask, int indentLevel)
 {
     foreach (var curSpFilter in current.catDef.childSpecialEntityFilters)
     {
         this.DoSpecialFilter(curSpFilter, indentLevel);
     }
     foreach (var curChildCategory in current.childCategories)
     {
         this.DoCategory(curChildCategory, openMask, indentLevel);
     }
     foreach (var curThing in current.childThings)
     {
         this.DoThing(curThing, indentLevel);
     }
 }
Beispiel #5
0
        public static void DrawEntityListWindow(IEntityFilter filter, EntityCategory root, string label, string description, Rect baseRect, ref Vector2 scrollPosition, int count)
        {
            Widgets.DrawMenuSection(baseRect, true);

            TabRestrictUI.DrawDefaultSettingButton(filter, ref baseRect);
            TabRestrictUI.DrawHeadingCheckBox(filter, label, description, ref baseRect);

            Text.Font = GameFont.Tiny;

            float num         = baseRect.width - 2f;
            Rect  buttonRect1 = new Rect(baseRect.x + 1f, baseRect.y + 1f, num / 2f, 24f);

            if (Widgets.ButtonText(buttonRect1, "ClearAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(root, false);
            }
            Rect buttonRect2 = new Rect(buttonRect1.xMax + 1f, buttonRect1.y, baseRect.xMax - 1f - (buttonRect1.xMax + 1f), 24f);

            if (Widgets.ButtonText(buttonRect2, "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(root);
            }
            baseRect.yMin = buttonRect1.yMax;

            Text.Font = GameFont.Small;

            Rect viewRect = new Rect(0f, 0f, baseRect.width - 16f, TabRestrictUI.viewHeight[count]);

            Widgets.BeginScrollView(baseRect, ref scrollPosition, viewRect, true);
            float num2     = 2f;
            float num3     = num2;
            Rect  listRect = new Rect(0f, num2, viewRect.width, 9999f);

            Listing_EntityListUI entityListUI = new Listing_EntityListUI(filter);

            entityListUI.Begin(listRect);
            entityListUI.CreateCheckBoxUI(root, 8, 0);
            entityListUI.End();

            if (Event.current.type == EventType.Layout)
            {
                TabRestrictUI.viewHeight[count] = num3 + entityListUI.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
 public virtual void SetAllowAll(EntityCategory root, bool flag = true)
 {
     if (flag)
     {
         foreach (Thing t in root.DescendantThings)
         {
             this.allowedEntityList.Add(t);
         }
         this.forbiddenSpFilterList.Clear();
     }
     else
     {
         foreach (SpecialEntityFilterDef def in root.catDef.DescendantSpecialEntityFilterDefs)
         {
             this.forbiddenSpFilterList.Add(def);
         }
         this.allowedEntityList.Clear();
     }
 }
Beispiel #7
0
        public void UpdateThingsList()
        {
            EntityCategory root = entityCategoryRoot;

            foreach (var a in root.DescendantEntityCategoriesAndThis)
            {
                a.childThings = new List <Thing>();
                foreach (var b in a.catDef.childThingDefs)
                {
                    a.childThings.AddRange(Find.VisibleMap.listerThings.ThingsOfDef(b));
#if DEBUG
                    Log.Message(DebugLog.GetMethodName() + "Found Things.Count=" + a.childThings.Count);
#endif
                }
                if (a.catDef.Worker != null)
                {
                    foreach (var c in a.catDef.Worker)
                    {
                        a.childThings.RemoveAll(thing => !c.Matches(thing));
                    }
                }
            }
            this.filter.UpdateForbiddenList(root);
        }
Beispiel #8
0
 public void CreateCheckBoxUI(EntityCategory root, int openMask, int indentLevel)
 {
     DoCurrent(root, openMask, indentLevel);
 }
Beispiel #9
0
 private void CreateRootCategory()
 {
     this.entityCategoryRootInt = new EntityCategory(propDef.categoryRootDef);
 }