コード例 #1
0
        public void RenameAlert(string name, string newName)
        {
            FindAlertData findAlert = savedAlerts[name];

            AlertByFind.RenameAlert(name, newName, okAction:
                                    () =>
            {
                findAlert.desc.name  = newName;
                savedAlerts[newName] = findAlert;
                savedAlerts.Remove(name);
            });
        }
コード例 #2
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));
        }
コード例 #3
0
        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)));
                }
            }
        }
コード例 #4
0
 public Alert_Find(FindAlertData d) : this()
 {
     defaultLabel    = d.desc.name;
     defaultPriority = d.desc.alertPriority;
     alertData       = d;
 }