public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterNearby clone = (ListFilterNearby)base.Clone(map, newOwner);

            clone.range = range;
            return(clone);
        }
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterInventory clone = (ListFilterInventory)base.Clone(map, newOwner);

            clone.parent = parent;
            return(clone);
        }
Esempio n. 3
0
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterTrait clone = (ListFilterTrait)base.Clone(map, newOwner);

            clone.traitDegree = traitDegree;
            return(clone);
        }
Esempio n. 4
0
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterNeed clone = (ListFilterNeed)base.Clone(map, newOwner);

            clone.needRange = needRange;
            return(clone);
        }
Esempio n. 5
0
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterSkill clone = (ListFilterSkill)base.Clone(map, newOwner);

            clone.skillRange = skillRange;
            return(clone);
        }
Esempio n. 6
0
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterThought clone = (ListFilterThought)base.Clone(map, newOwner);

            clone.stageRange = stageRange;
            return(clone);
        }
        public static void OpenWith(FindDescription desc)
        {
            MainTabWindow_List tab = ListDefOf.TD_List.TabWindow as MainTabWindow_List;

            tab.findDesc = desc;
            tab.RemakeList();
            Find.MainTabsRoot.SetCurrentTab(ListDefOf.TD_List);
        }
        public void Rename(string name, string newName)
        {
            FindDescription desc = savedFilters[name];

            desc.name             = newName;
            savedFilters[newName] = desc;
            savedFilters.Remove(name);
        }
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterSelection clone = (ListFilterSelection)base.Clone(map, newOwner);

            clone.sel = sel.Clone(map, newOwner);
            //clone.owner = newOwner; //No - MakeFilter sets it.

            return(clone);
        }
        public static ListFilter MakeFilter(ListFilterDef def, FindDescription owner)
        {
            ListFilter filter = (ListFilter)Activator.CreateInstance(def.filterClass);

            filter.def   = def;
            filter.owner = owner;
            filter.PostMake();
            return(filter);
        }
        public override ListFilter Clone(Map map, FindDescription newOwner)
        {
            ListFilterGroup clone = (ListFilterGroup)base.Clone(map, newOwner);

            clone.filters = filters.Select(f => f.Clone(map, newOwner)).ToList();
            clone.any     = any;
            //clone.owner = newOwner; //No - MakeFilter sets it.
            return(clone);
        }
        public static void AddFilterFloat(FindDescription owner, List <ListFilter> filters = null)
        {
            List <FloatMenuOption> options = new List <FloatMenuOption>();

            foreach (ListFilterDef def in DefDatabase <ListFilterDef> .AllDefs.Where(d => d.parent == null && (Prefs.DevMode || !d.devOnly)))
            {
                options.Add(new FloatMenuOption(def.LabelCap, () => (filters ?? owner.filters).Add(ListFilterMaker.MakeFilter(def, owner))));
            }
            DoFloatMenu(options);
        }
 public override void PreOpen()
 {
     base.PreOpen();
     if (findDesc == null)
     {
         findDesc = new FindDescription();
         findDesc.filters.Add(ListFilterMaker.NameFilter(findDesc));
     }
     RemakeList();
 }
Esempio n. 14
0
 //Ctrl-F handler
 public override void GameComponentOnGUI()
 {
     if (ListDefOf.OpenFindTab.IsDownEvent && Event.current.control)
     {
         FindDescription desc   = new FindDescription();
         ListFilter      filter = ListFilterMaker.NameFilter(desc);
         desc.filters.Add(filter);
         filter.Focus();
         MainTabWindow_List.OpenWith(desc);
     }
 }
        public void DoWindowContents(Rect inRect)
        {
            //Scrolling!
            Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, scrollViewHeight);

            Widgets.BeginScrollView(inRect, ref scrollPosition, viewRect);

            Rect   rowRect = viewRect; rowRect.height = RowHeight;
            string remove  = null;

            foreach (var kvp in savedFilters)
            {
                string          name = kvp.Key;
                FindDescription desc = kvp.Value;

                WidgetRow row = new WidgetRow(rowRect.x, rowRect.y, UIDirection.RightThenDown, rowRect.width);
                rowRect.y += RowHeight;

                row.Label(name, rowRect.width / 4);

                if (row.ButtonText("Rename".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_Name(newName => Rename(name, newName)));
                }

                if (Current.Game != null &&
                    row.ButtonText("Load".Translate()))
                {
                    MainTabWindow_List.OpenWith(desc.Clone(Find.CurrentMap));
                }

                if (row.ButtonText("Delete".Translate()))
                {
                    remove = name;
                }

                row.CheckboxLabeled("TD.AllMaps".Translate(), ref desc.allMaps);
            }
            scrollViewHeight = RowHeight * savedFilters.Count();
            Widgets.EndScrollView();

            if (remove != null)
            {
                if (Event.current.shift)
                {
                    savedFilters.Remove(remove);
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                                             "TD.Delete0".Translate(remove), () => savedFilters.Remove(remove)));
                }
            }
        }
Esempio n. 16
0
        public void AddAlert(string name, FindDescription desc)
        {
            desc.name = name;             //Remember for current copy

            Map map = desc.allMaps ? null : Find.CurrentMap;

            //Save two FindDescriptions: One to be scribed with ref string, other put in alert with real refs
            //This was a good idea at one point but now I don't care to consolidate them into one ist
            FindDescription refDesc = desc.Clone(null);             //This one has ref string

            refDesc.name = name;
            FindDescription alertDesc = refDesc.Clone(map);             //This one re-resolves reference for this map.

            AlertByFind.AddAlert(new FindAlertData(map, alertDesc), okAction: () => savedAlerts[name] = new FindAlertData(map, refDesc));
        }
Esempio n. 17
0
        public virtual FindDescription Clone(Map map)
        {
            FindDescription newDesc = new FindDescription()
            {
                baseType         = baseType,
                name             = name,
                alertPriority    = alertPriority,
                ticksToShowAlert = ticksToShowAlert,
                countToAlert     = countToAlert,
                countComp        = countComp,
                allMaps          = allMaps,
                locked           = locked
            };

            newDesc.filters = filters.Select(f => f.Clone(map, newDesc)).ToList();
            return(newDesc);
        }
        public void Save(string name, FindDescription desc, bool overwrite = false)
        {
            if (!overwrite && Has(name))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                                         "TD.OverwriteSavedFilter".Translate(),
                                         () => Save(name, desc, true)));
            }
            else
            {
                desc.name = name;                       //Remember for current copy

                FindDescription newDesc = desc.Clone(null);
                newDesc.name       = name;
                savedFilters[name] = newDesc;
            }
            Write();
        }
        public static void DrawAddRow(Listing_StandardIndent listing, FindDescription owner, List <ListFilter> filters = null)
        {
            Rect addRow = listing.GetRect(Text.LineHeight);

            listing.Gap(listing.verticalSpacing);

            Rect butRect = addRow; butRect.width = Text.LineHeight;

            Widgets.DrawTextureFitted(butRect, TexButton.Plus, 1.0f);

            Rect textRect = addRow; textRect.xMin += Text.LineHeight + WidgetRow.DefaultGap;

            Widgets.Label(textRect, "TD.AddNewFilter...".Translate());

            Widgets.DrawHighlightIfMouseover(addRow);

            if (Widgets.ButtonInvisible(addRow))
            {
                AddFilterFloat(owner, filters);
            }
        }
Esempio n. 20
0
 public FindAlertData(Map m, FindDescription d)
 {
     map  = m;
     desc = d;
 }
 public static ListFilter NameFilter(FindDescription owner) =>
 ListFilterMaker.MakeFilter(ListFilterMaker.Filter_Name, owner);
        public override void DoWindowContents(Rect inRect)
        {
            //Title
            var listing = new Listing_Standard();

            listing.Begin(inRect);
            Text.Font = GameFont.Medium;
            listing.Label("TD.CustomAlerts".Translate());
            Text.Font = GameFont.Small;
            listing.GapLine();
            listing.End();

            //Check off
            Rect enableRect = inRect.RightHalf().TopPartPixels(Text.LineHeight);

            Widgets.CheckboxLabeled(enableRect, "Enable Alerts", ref Alert_Find.enableAll);

            //Margin
            inRect.yMin += listing.CurHeight;

            //Useful things:
            Map map = Find.CurrentMap;
            ListEverythingGameComp comp = Current.Game.GetComponent <ListEverythingGameComp>();
            string remove = null;

            //Scrolling!
            Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, scrollViewHeight);

            Widgets.BeginScrollView(inRect, ref scrollPosition, viewRect);

            Rect rowRect = viewRect; rowRect.height = RowHeight;

            foreach (string name in comp.AlertNames())
            {
                FindAlertData   alert = comp.GetAlert(name);
                FindDescription desc  = alert.desc;
                WidgetRow       row   = new WidgetRow(rowRect.x, rowRect.y, UIDirection.RightThenDown, rowRect.width);
                rowRect.y += RowHeight;

                row.Label(alert.Label, rowRect.width / 4);

                if (row.ButtonText("Rename".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_Name(newName => comp.RenameAlert(name, newName)));
                }

                if (row.ButtonText("Load".Translate()))
                {
                    MainTabWindow_List.OpenWith(desc.Clone(map));
                }

                if (row.ButtonText("Delete".Translate()))
                {
                    remove = name;
                }

                bool crit = desc.alertPriority == AlertPriority.Critical;
                row.ToggleableIcon(ref crit, TexButton.PassionMajorIcon, "TD.CriticalAlert".Translate());
                comp.SetPriority(name, crit ? AlertPriority.Critical : AlertPriority.Medium);

                row.Label("TD.SecondsUntilShown".Translate());
                int    sec      = desc.ticksToShowAlert / 60;
                string secStr   = sec.ToString();
                Rect   textRect = row.GetRect(64); textRect.height -= 4; textRect.width -= 4;
                Widgets.TextFieldNumeric(textRect, ref sec, ref secStr, 0, 999999);
                TooltipHandler.TipRegion(textRect, "TD.Tip1000SecondsInARimworldDay".Translate());
                comp.SetTicks(name, sec * 60);

                row.Label("TD.ShowWhen".Translate());
                if (row.ButtonIcon(TexFor(desc.countComp)))
                {
                    comp.SetComp(name, (CompareType)((int)(desc.countComp + 1) % 3));
                }

                int    count    = desc.countToAlert;
                string countStr = count.ToString();
                textRect = row.GetRect(64); textRect.height -= 4; textRect.width -= 4;
                Widgets.TextFieldNumeric(textRect, ref count, ref countStr, 0, 999999);
                comp.SetCount(name, count);
            }


            scrollViewHeight = RowHeight * comp.AlertNames().Count();
            Widgets.EndScrollView();

            if (remove != null)
            {
                if (Event.current.shift)
                {
                    comp.RemoveAlert(remove);
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                                             "TD.Delete0".Translate(remove), () => comp.RemoveAlert(remove)));
                }
            }
        }
        //Draw Filters
        public void DoFilter(Rect rect)
        {
            bool changed = false;

            Text.Font = GameFont.Medium;
            Rect headerRect = rect.TopPartPixels(Text.LineHeight);
            Rect filterRect = rect.BottomPartPixels(rect.height - Text.LineHeight);

            //Header
            Rect headerButRect = headerRect.RightPartPixels(Text.LineHeight).ContractedBy(2f);
            Rect labelRect     = new Rect(headerRect.x, headerRect.y, headerRect.width - Text.LineHeight * 2, headerRect.height);

            if (Widgets.ButtonImage(headerButRect, TexButton.CancelTex))
            {
                findDesc = new FindDescription();
                changed  = true;
            }
            TooltipHandler.TipRegion(headerButRect, "ClearAll".Translate().CapitalizeFirst());

            headerButRect.x -= Text.LineHeight;
            if (Widgets.ButtonImage(headerButRect, findDesc.locked ? TexButton.LockOn : TexButton.LockOff))
            {
                findDesc.locked = !findDesc.locked;
            }
            TooltipHandler.TipRegion(headerButRect, "TD.LockEditing".Translate());

            //Header Title
            Widgets.Label(labelRect, "TD.Listing".Translate() + findDesc.baseType.TranslateEnum());
            Widgets.DrawHighlightIfMouseover(labelRect);
            if (Widgets.ButtonInvisible(labelRect))
            {
                List <FloatMenuOption> types = new List <FloatMenuOption>();
                foreach (BaseListType type in Prefs.DevMode ? Enum.GetValues(typeof(BaseListType)) : BaseListNormalTypes.normalTypes)
                {
                    types.Add(new FloatMenuOption(type.TranslateEnum(), () => findDesc.baseType = type));
                }

                Find.WindowStack.Add(new FloatMenu(types)
                {
                    onCloseCallback = RemakeList
                });
            }

            Listing_StandardIndent listing = new Listing_StandardIndent()
            {
                maxOneColumn = true
            };

            listing.Begin(filterRect);

            /* maybe don't show name box
             * //Filter Name
             * Rect nameRect = listing.GetRect(Text.LineHeight);
             * WidgetRow nameRow = new WidgetRow(nameRect.x, nameRect.y);
             * nameRow.Label("TD.Name".Translate());
             * nameRect.xMin = nameRow.FinalX;
             * findDesc.name = Widgets.TextField(nameRect, findDesc.name);
             * listing.Gap();
             */
            listing.GapLine();


            //Draw Filters!!!
            Rect listRect = listing.GetRect(500);
            Listing_StandardIndent filterListing = new Listing_StandardIndent()
            {
                maxOneColumn = true
            };

            float viewWidth = listRect.width;

            if (scrollViewHeightFilt > listRect.height)
            {
                viewWidth -= 16f;
            }

            Rect viewRect = new Rect(0f, 0f, viewWidth, scrollViewHeightFilt);

            //Lock out input to filters.
            if (findDesc.locked &&
                Event.current.type != EventType.Repaint &&
                Event.current.type != EventType.Layout &&
                Event.current.type != EventType.Ignore &&
                Event.current.type != EventType.Used &&
                Mouse.IsOver(viewRect))
            {
                Event.current.Use();
            }

            filterListing.BeginScrollView(listRect, ref scrollPositionFilt, viewRect);

            //Draw Scrolling list:
            if (DoFilters(filterListing, findDesc.filters))
            {
                changed = true;
            }

            if (!findDesc.locked)
            {
                DrawAddRow(filterListing, findDesc);
            }

            filterListing.EndScrollView(ref viewRect);
            scrollViewHeightFilt = viewRect.height;


            //Extra options:
            bool newMaps = findDesc.allMaps;

            listing.CheckboxLabeled(
                "TD.AllMaps".Translate(),
                ref newMaps,
                "TD.CertainFiltersDontWorkForAllMaps-LikeZonesAndAreasThatAreObviouslySpecificToASingleMap".Translate());
            if (findDesc.allMaps != newMaps)
            {
                findDesc.allMaps = newMaps;
                changed          = true;
            }

            listing.GapLine();

            //Manage/Save/Load Buttons
            Rect savedRect = listing.GetRect(Text.LineHeight);

            savedRect = savedRect.LeftPart(0.25f);

            //Saved Filters
            if (Widgets.ButtonText(savedRect, "SaveButton".Translate()))
            {
                Find.WindowStack.Add(new Dialog_Name(findDesc.name, name => Settings.Get().Save(name, findDesc)));
            }

            savedRect.x += savedRect.width;
            if (Settings.Get().SavedNames().Count() > 0 &&
                Widgets.ButtonText(savedRect, "Load".Translate()))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (string name in Settings.Get().SavedNames())
                {
                    options.Add(new FloatMenuOption(name, () => findDesc = Settings.Get().Load(name)));
                }

                DoFloatMenu(options);
            }

            savedRect.x += savedRect.width * 2;
            if (Widgets.ButtonText(savedRect, "TD.ManageSaved".Translate()))
            {
                Find.WindowStack.Add(new Dialog_ManageSavedLists());
            }

            //Alerts
            Rect alertsRect = listing.GetRect(Text.LineHeight);

            alertsRect = alertsRect.LeftPart(0.25f);

            var comp = Current.Game.GetComponent <ListEverythingGameComp>();

            if (Widgets.ButtonText(alertsRect, "TD.MakeAlert".Translate()))
            {
                Find.WindowStack.Add(new Dialog_Name(findDesc.name,
                                                     name => comp.AddAlert(name, findDesc)));
            }

            alertsRect.x += alertsRect.width;
            if (comp.AlertNames().Count() > 0 &&
                Widgets.ButtonText(alertsRect, "TD.LoadAlert".Translate()))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (string name in comp.AlertNames())
                {
                    options.Add(new FloatMenuOption(name, () => findDesc = comp.LoadAlert(name)));
                }

                DoFloatMenu(options);
            }

            alertsRect.x += alertsRect.width * 2;
            if (Widgets.ButtonText(alertsRect, "TD.ManageAlerts".Translate()))
            {
                Find.WindowStack.Add(new AlertByFindDialog());
            }



            //Global Options
            listing.CheckboxLabeled(
                "TD.OnlyShowFilterOptionsForAvailableThings".Translate(),
                ref ContentsUtility.onlyAvailable,
                "TD.ForExampleDontShowTheOptionMadeFromPlasteelIfNothingIsMadeFromPlasteel".Translate());

            listing.End();

            //Update if needed
            if (changed)
            {
                RemakeList();
            }
        }