Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
        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)));
                }
            }
        }
Exemplo n.º 3
0
        public override Rect DrawAt(float topY, bool minimized)
        {
            Text.Font = GameFont.Small;
            string label  = this.GetLabel();
            float  height = Text.CalcHeight(label, Alert.Width - 6);            //Alert.TextWidth = 148f
            Rect   rect   = new Rect((float)UI.screenWidth - Alert.Width, topY, Alert.Width, height);

            //if (this.alertBounce != null)
            //rect.x -= this.alertBounce.CalculateHorizontalOffset();
            if (Event.current.button == 1 && Widgets.ButtonInvisible(rect, false))
            {
                MainTabWindow_List.OpenWith(alertData.desc.Clone(Find.CurrentMap));

                Event.current.Use();
            }
            return(base.DrawAt(topY, minimized));
        }
        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)));
                }
            }
        }