Ejemplo n.º 1
0
 private void ControlButtonsRight(TreeNode_Editor node, WidgetRow widgetRow)
 {
     if (node.HasNewButton && widgetRow.ButtonIcon(TexButton.NewItem))
     {
         Action <object> addAction = delegate(object o)
         {
             node.owningField.SetValue(node.ParentObj, o);
             ((TreeNode_Editor)node.parentNode).RebuildChildNodes();
         };
         MakeCreateNewObjectMenu(node, node.owningField, node.owningField.FieldType, addAction);
     }
     if (node.nodeType == EditTreeNodeType.ListRoot && widgetRow.ButtonIcon(TexButton.Add))
     {
         Type            baseType   = node.obj.GetType().GetGenericArguments()[0];
         Action <object> addAction2 = delegate(object o)
         {
             node.obj.GetType().GetMethod("Add").Invoke(node.obj, new object[1]
             {
                 o
             });
         };
         MakeCreateNewObjectMenu(node, node.owningField, baseType, addAction2);
     }
     if (node.HasDeleteButton && widgetRow.ButtonIcon(TexButton.DeleteX, null, GenUI.SubtleMouseoverColor))
     {
         node.Delete();
     }
 }
Ejemplo n.º 2
0
        public Rect GetScenPartRect(ScenPart part, float height)
        {
            string label = part.Label;
            Rect   rect  = GetRect(height);

            Widgets.DrawBoxSolid(rect, new Color(1f, 1f, 1f, 0.08f));
            WidgetRow widgetRow = new WidgetRow(rect.x, rect.y, UIDirection.RightThenDown, 72f, 0f);

            if (part.def.PlayerAddRemovable && widgetRow.ButtonIcon(TexButton.DeleteX, null, GenUI.SubtleMouseoverColor))
            {
                scen.RemovePart(part);
                SoundDefOf.Click.PlayOneShotOnCamera();
            }
            if (scen.CanReorder(part, ReorderDirection.Up) && widgetRow.ButtonIcon(TexButton.ReorderUp))
            {
                scen.Reorder(part, ReorderDirection.Up);
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }
            if (scen.CanReorder(part, ReorderDirection.Down) && widgetRow.ButtonIcon(TexButton.ReorderDown))
            {
                scen.Reorder(part, ReorderDirection.Down);
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
            }
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect2 = rect.LeftPart(0.5f).Rounded();

            rect2.xMax -= 4f;
            Widgets.Label(rect2, label);
            Text.Anchor = TextAnchor.UpperLeft;
            Gap(4f);
            return(rect.RightPart(0.5f).Rounded());
        }
Ejemplo n.º 3
0
        public override void DoWindowContents(Rect inRect)
        {
            WidgetRow widgetRow = new WidgetRow(0f, 0f);

            if (widgetRow.ButtonIcon(TexButton.CenterOnPointsTex, "Center view around points."))
            {
                curve.View.SetViewRectAround(curve);
            }
            if (widgetRow.ButtonIcon(TexButton.CurveResetTex, "Reset to growth from 0 to 1."))
            {
                List <CurvePoint> points = new List <CurvePoint>
                {
                    new CurvePoint(0f, 0f),
                    new CurvePoint(1f, 1f)
                };
                curve.SetPoints(points);
                curve.View.SetViewRectAround(curve);
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor1Tex, "Reset horizontal zoom to 0-1"))
            {
                curve.View.rect.xMin = 0f;
                curve.View.rect.xMax = 1f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor100Tex, "Reset horizontal zoom to 0-100"))
            {
                curve.View.rect.xMin = 0f;
                curve.View.rect.xMax = 100f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor20kTex, "Reset horizontal zoom to 0-20,000"))
            {
                curve.View.rect.xMin = 0f;
                curve.View.rect.xMax = 20000f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer1Tex, "Reset vertical zoom to 0-1"))
            {
                curve.View.rect.yMin = 0f;
                curve.View.rect.yMax = 1f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer100Tex, "Reset vertical zoom to 0-100"))
            {
                curve.View.rect.yMin = 0f;
                curve.View.rect.yMax = 100f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer20kTex, "Reset vertical zoom to 0-20,000"))
            {
                curve.View.rect.yMin = 0f;
                curve.View.rect.yMax = 20000f;
            }
            Rect screenRect = new Rect(inRect.AtZero());

            screenRect.yMin += 26f;
            screenRect.yMax -= 24f;
            DoCurveEditor(screenRect);
        }
Ejemplo n.º 4
0
 public void DoEditWidgets(WidgetRow widgetRow)
 {
     if (testSustainer == null)
     {
         if (!widgetRow.ButtonIcon(TexButton.Play))
         {
             return;
         }
         ResolveReferences();
         SoundInfo info;
         if (HasSubSoundsInWorld)
         {
             IntVec3 mapPosition = Find.CameraDriver.MapPosition;
             info = SoundInfo.InMap(new TargetInfo(mapPosition, Find.CurrentMap), MaintenanceType.PerFrame);
             for (int i = 0; i < 5; i++)
             {
                 MoteMaker.ThrowDustPuff(mapPosition, Find.CurrentMap, 1.5f);
             }
         }
         else
         {
             info = SoundInfo.OnCamera(MaintenanceType.PerFrame);
         }
         info.testPlay = true;
         if (sustain)
         {
             testSustainer = this.TrySpawnSustainer(info);
         }
         else
         {
             this.PlayOneShot(info);
         }
     }
     else
     {
         testSustainer.Maintain();
         if (widgetRow.ButtonIcon(TexButton.Stop))
         {
             testSustainer.End();
             testSustainer = null;
         }
     }
 }
Ejemplo n.º 5
0
        public override void DoWindowContents(Rect inRect)
        {
            WidgetRow widgetRow = new WidgetRow(0f, 0f, UIDirection.RightThenUp, 99999f, 4f);

            if (widgetRow.ButtonIcon(TexButton.CenterOnPointsTex, "Center view around points."))
            {
                this.curve.View.SetViewRectAround(this.curve);
            }
            if (widgetRow.ButtonIcon(TexButton.CurveResetTex, "Reset to growth from 0 to 1."))
            {
                List <CurvePoint> list = new List <CurvePoint>();
                list.Add(new CurvePoint(0f, 0f));
                list.Add(new CurvePoint(1f, 1f));
                this.curve.SetPoints(list);
                this.curve.View.SetViewRectAround(this.curve);
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor1Tex, "Reset horizontal zoom to 0-1"))
            {
                this.curve.View.rect.xMin = 0f;
                this.curve.View.rect.xMax = 1f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor100Tex, "Reset horizontal zoom to 0-100"))
            {
                this.curve.View.rect.xMin = 0f;
                this.curve.View.rect.xMax = 100f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomHor20kTex, "Reset horizontal zoom to 0-20,000"))
            {
                this.curve.View.rect.xMin = 0f;
                this.curve.View.rect.xMax = 20000f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer1Tex, "Reset vertical zoom to 0-1"))
            {
                this.curve.View.rect.yMin = 0f;
                this.curve.View.rect.yMax = 1f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer100Tex, "Reset vertical zoom to 0-100"))
            {
                this.curve.View.rect.yMin = 0f;
                this.curve.View.rect.yMax = 100f;
            }
            if (widgetRow.ButtonIcon(TexButton.QuickZoomVer20kTex, "Reset vertical zoom to 0-20,000"))
            {
                this.curve.View.rect.yMin = 0f;
                this.curve.View.rect.yMax = 20000f;
            }
            Rect screenRect = new Rect(inRect.AtZero());

            screenRect.yMin += 26f;
            screenRect.yMax -= 24f;
            this.DoCurveEditor(screenRect);
        }
Ejemplo n.º 6
0
        private void DrawButtons()
        {
            WidgetRow widgetRow = new WidgetRow();

            if (widgetRow.ButtonIcon(TexButton.ToggleLog, "Open the debug log."))
            {
                ToggleLogWindow();
            }
            if (widgetRow.ButtonIcon(TexButton.ToggleTweak, "Open tweakvalues menu.\n\nThis lets you change internal values."))
            {
                ToggleTweakValuesMenu();
            }
            if (widgetRow.ButtonIcon(TexButton.OpenPackageEditor, "Open the package editor.\n\nThis lets you edit game data while the game is running."))
            {
                OpenPackageEditor();
            }
            if (widgetRow.ButtonIcon(TexButton.OpenInspectSettings, "Open the view settings.\n\nThis lets you see special debug visuals."))
            {
                ToggleDebugSettingsMenu();
            }
            if (widgetRow.ButtonIcon(TexButton.OpenDebugActionsMenu, "Open debug actions menu.\n\nThis lets you spawn items and force various events."))
            {
                ToggleDebugActionsMenu();
            }
            if (widgetRow.ButtonIcon(TexButton.OpenDebugActionsMenu, "Open debug logging menu."))
            {
                ToggleDebugLogMenu();
            }
            if (widgetRow.ButtonIcon(TexButton.OpenInspector, "Open the inspector.\n\nThis lets you inspect what's happening in the game, down to individual variables."))
            {
                ToggleDebugInspector();
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                if (widgetRow.ButtonIcon(TexButton.ToggleGodMode, "Toggle god mode.\n\nWhen god mode is on, you can build stuff instantly, for free, and sell things that aren't yours."))
                {
                    ToggleGodMode();
                }
                if (DebugSettings.godMode)
                {
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(new Rect(0f, 25f, 200f, 100f), "God mode");
                }
                bool toggleable = Prefs.PauseOnError;
                widgetRow.ToggleableIcon(ref toggleable, TexButton.TogglePauseOnError, "Pause the game when an error is logged.");
                Prefs.PauseOnError = toggleable;
            }
        }
        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();
        }