Exemple #1
0
        public override void OpenLetter()
        {
            Pawn   targetPawn = this.lookTargets.TryGetPrimaryTarget().Thing as Pawn;
            string text       = this.text;
            string text2      = (from entry in (from entry in (from battle in Find.BattleLog.Battles
                                                               where battle.Concerns(targetPawn)
                                                               select battle).SelectMany((Battle battle) => from entry in battle.Entries
                                                                                         where entry.Concerns(targetPawn) && entry.ShowInCompactView()
                                                                                         select entry)
                                                orderby entry.Age
                                                select entry).Take(5).Reverse <LogEntry>()
                                 select "  " + entry.ToGameStringFromPOV(null, false)).ToLineList("");

            if (text2.Length > 0)
            {
                text = string.Format("{0}\n\n{1}\n{2}", text, "LastEventsInLife".Translate(new object[]
                {
                    targetPawn.LabelDefinite()
                }) + ":", text2);
            }
            DiaNode diaNode = new DiaNode(text);

            diaNode.options.AddRange(this.Choices);
            WindowStack windowStack    = Find.WindowStack;
            DiaNode     nodeRoot       = diaNode;
            Faction     relatedFaction = this.relatedFaction;
            bool        radioMode      = this.radioMode;

            windowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, relatedFaction, false, radioMode, this.title));
        }
        public override void OpenLetter()
        {
            DiaNode diaNode = new DiaNode(this.text);

            diaNode.options.AddRange(this.Choices);
            WindowStack windowStack = Find.WindowStack;
            DiaNode     nodeRoot    = diaNode;
            bool        flag        = this.radioMode;

            windowStack.Add(new Dialog_NodeTree(nodeRoot, false, flag, this.title));
        }
 public static void DelayedErrorWindowRequestOnGUI()
 {
     try
     {
         for (int i = 0; i < DelayedErrorWindowRequest.requests.Count; i++)
         {
             WindowStack windowStack = Find.WindowStack;
             string      text        = DelayedErrorWindowRequest.requests[i].text;
             string      buttonAText = "OK".Translate();
             string      title       = DelayedErrorWindowRequest.requests[i].title;
             windowStack.Add(new Dialog_MessageBox(text, buttonAText, null, null, null, title, false, null, null));
         }
     }
     finally
     {
         DelayedErrorWindowRequest.requests.Clear();
     }
 }
Exemple #4
0
 private void DoListChangedNotifications()
 {
     if (Find.WindowStack != null)
     {
         WindowStack windowStack = Find.WindowStack;
         for (int i = 0; i < windowStack.Count; i++)
         {
             MainTabWindow_PawnTable mainTabWindow_PawnTable = windowStack[i] as MainTabWindow_PawnTable;
             if (mainTabWindow_PawnTable != null)
             {
                 mainTabWindow_PawnTable.Notify_PawnsChanged();
             }
         }
     }
     if (Find.ColonistBar != null)
     {
         Find.ColonistBar.MarkColonistsDirty();
     }
 }
        public override void DoWindowContents(Rect selectorInner)
        {
            Profiler.BeginSample("PackageEditorOnGUI");
            Text.Font = GameFont.Tiny;
            float  width = (selectorInner.width - 4f) / 2f;
            Rect   rect  = new Rect(0f, 0f, width, 24f);
            string str   = this.curMod.ToString();

            if (Widgets.ButtonText(rect, "Editing: " + str, true, false, true))
            {
                Messages.Message("Mod changing not implemented - it's always Core for now.", MessageTypeDefOf.RejectInput, false);
            }
            TooltipHandler.TipRegion(rect, "Change the mod being edited.");
            Rect   rect2 = new Rect(rect.xMax + 4f, 0f, width, 24f);
            string label = "No package loaded";

            if (this.curPackage != null)
            {
                label = this.curPackage.fileName;
            }
            if (Widgets.ButtonText(rect2, label, true, false, true))
            {
                Find.WindowStack.Add(new Dialog_PackageSelector(delegate(DefPackage pack)
                {
                    if (pack != this.curPackage)
                    {
                        this.curPackage = pack;
                    }
                }, this.curMod, this.relFolder));
            }
            TooltipHandler.TipRegion(rect2, "Open a Def package for editing.");
            WidgetRow widgetRow = new WidgetRow(0f, 28f, UIDirection.RightThenUp, 99999f, 4f);

            if (widgetRow.ButtonIcon(TexButton.NewFile, "Create a new Def package.", null))
            {
                string     name       = DefPackage.UnusedPackageName(this.relFolder, this.curMod);
                DefPackage defPackage = new DefPackage(name, this.relFolder);
                this.curMod.AddDefPackage(defPackage);
                this.curPackage = defPackage;
            }
            if (this.curPackage != null)
            {
                if (widgetRow.ButtonIcon(TexButton.Save, "Save the current Def package.", null))
                {
                    this.curPackage.SaveIn(this.curMod);
                }
                if (widgetRow.ButtonIcon(TexButton.RenameDev, "Rename the current Def package.", null))
                {
                    Find.WindowStack.Add(new Dialog_RenamePackage(this.curPackage));
                }
            }
            float num   = 56f;
            Rect  rect3 = new Rect(0f, num, selectorInner.width, selectorInner.height - num);
            Rect  rect4 = new Rect(0f, 0f, rect3.width - 16f, this.viewHeight);

            Widgets.DrawMenuSection(rect3);
            Widgets.BeginScrollView(rect3, ref this.scrollPosition, rect4, true);
            Rect rect5 = rect4.ContractedBy(4f);

            rect5.height = 9999f;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect5);
            Text.Font = GameFont.Tiny;
            if (this.curPackage == null)
            {
                listing_Standard.Label("(no package open)", -1f, null);
            }
            else
            {
                if (this.curPackage.defs.Count == 0)
                {
                    listing_Standard.Label("(package is empty)", -1f, null);
                }
                else
                {
                    Def deletingDef = null;
                    using (List <Def> .Enumerator enumerator = this.curPackage.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Def def = enumerator.Current;
                            if (listing_Standard.SelectableDef(def.defName, false, delegate
                            {
                                deletingDef = def;
                            }))
                            {
                                bool        flag        = false;
                                WindowStack windowStack = Find.WindowStack;
                                for (int i = 0; i < windowStack.Count; i++)
                                {
                                    EditWindow_DefEditor editWindow_DefEditor = windowStack[i] as EditWindow_DefEditor;
                                    if (editWindow_DefEditor != null && editWindow_DefEditor.def == def)
                                    {
                                        flag = true;
                                    }
                                }
                                if (!flag)
                                {
                                    Find.WindowStack.Add(new EditWindow_DefEditor(def));
                                }
                            }
                        }
                    }
                    if (deletingDef != null)
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("Really delete Def " + deletingDef.defName + "?", delegate
                        {
                            this.curPackage.RemoveDef(deletingDef);
                        }, true, null));
                    }
                }
                if (listing_Standard.ButtonImage(TexButton.Add, 24f, 24f))
                {
                    Def def2 = Activator.CreateInstance <TNewDef>();
                    def2.defName = "New" + typeof(TNewDef).Name;
                    this.curPackage.AddDef(def2);
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                this.viewHeight = listing_Standard.CurHeight;
            }
            listing_Standard.End();
            Widgets.EndScrollView();
            Profiler.EndSample();
        }