コード例 #1
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(inRect.AtZero());
            listing_Standard.ColumnWidth = 240f;
            foreach (DefPackage current in this.mod.GetDefPackagesInFolder(this.relFolder))
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.fileName);
                if (listing_Standard.ButtonText(fileNameWithoutExtension, null))
                {
                    this.setPackageCallback(current);
                    this.Close(true);
                }
            }
            listing_Standard.End();
        }
コード例 #2
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(inRect.AtZero());
            listing_Standard.ColumnWidth = 240f;
            foreach (DefPackage item in mod.GetDefPackagesInFolder(relFolder))
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item.fileName);
                if (listing_Standard.ButtonText(fileNameWithoutExtension))
                {
                    setPackageCallback(item);
                    Close();
                }
            }
            listing_Standard.End();
        }
コード例 #3
0
        public override void DoWindowContents(Rect inRect)
        {
            if (KeyBindingDefOf.Dev_ToggleDebugInspector.KeyDownEvent)
            {
                Event.current.Use();
                Close();
            }
            Text.Font = GameFont.Tiny;
            WidgetRow widgetRow = new WidgetRow(0f, 0f);

            widgetRow.ToggleableIcon(ref fullMode, TexButton.InspectModeToggle, "Toggle deep inspection mode for things on the map.");
            widgetRow.ToggleableIcon(ref DebugViewSettings.writeCellContents, TexButton.InspectModeToggle, "Toggle shallow inspection for things on the map.");
            if (widgetRow.ButtonText("Visibility", "Toggle what information should be reported by the inspector."))
            {
                Find.WindowStack.Add(new Dialog_DebugSettingsMenu());
            }
            if (widgetRow.ButtonText("Column Width +", "Make the columns wider."))
            {
                columnWidth += 20f;
                columnWidth  = Mathf.Clamp(columnWidth, 200f, 1600f);
            }
            if (widgetRow.ButtonText("Column Width -", "Make the columns narrower."))
            {
                columnWidth -= 20f;
                columnWidth  = Mathf.Clamp(columnWidth, 200f, 1600f);
            }
            inRect.yMin += 30f;
            Listing_Standard listing_Standard = new Listing_Standard(GameFont.Tiny);

            listing_Standard.ColumnWidth = Mathf.Min(columnWidth, inRect.width);
            listing_Standard.Begin(inRect);
            string[] array  = debugStringBuilder.ToString().Split('\n');
            string[] array2 = array;
            foreach (string label in array2)
            {
                listing_Standard.Label(label);
                listing_Standard.Gap(-9f);
            }
            listing_Standard.End();
            if (Event.current.type == EventType.Repaint)
            {
                debugStringBuilder = new StringBuilder();
                debugStringBuilder.Append(CurrentDebugString());
            }
        }
コード例 #4
0
        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();
        }