예제 #1
0
 public void DoEditWidgets(WidgetRow widgetRow)
 {
     if (this.testSustainer == null)
     {
         if (widgetRow.ButtonIcon(TexButton.Play, null))
         {
             this.ResolveReferences();
             SoundInfo info;
             if (this.HasSubSoundsInWorld)
             {
                 IntVec3 mapPosition = Find.CameraDriver.MapPosition;
                 info = SoundInfo.InMap(new TargetInfo(mapPosition, Find.VisibleMap, false), MaintenanceType.PerFrame);
                 for (int i = 0; i < 5; i++)
                 {
                     MoteMaker.ThrowDustPuff(mapPosition, Find.VisibleMap, 1.5f);
                 }
             }
             else
             {
                 info = SoundInfo.OnCamera(MaintenanceType.PerFrame);
             }
             info.testPlay = true;
             if (this.sustain)
             {
                 this.testSustainer = this.TrySpawnSustainer(info);
             }
             else
             {
                 this.PlayOneShot(info);
             }
         }
     }
     else
     {
         this.testSustainer.Maintain();
         if (widgetRow.ButtonIcon(TexButton.Stop, null))
         {
             this.testSustainer.End();
             this.testSustainer = null;
         }
     }
 }
예제 #2
0
 private void ControlButtonsRight(TreeNode_Editor node, WidgetRow widgetRow)
 {
     if (node.HasNewButton)
     {
         if (widgetRow.ButtonIcon(TexButton.NewItem, null, null))
         {
             Action <object> addAction = delegate(object o)
             {
                 node.owningField.SetValue(node.ParentObj, o);
                 ((TreeNode_Editor)node.parentNode).RebuildChildNodes();
             };
             this.MakeCreateNewObjectMenu(node, node.owningField, node.owningField.FieldType, addAction);
         }
     }
     if (node.nodeType == EditTreeNodeType.ListRoot)
     {
         if (widgetRow.ButtonIcon(TexButton.Add, null, null))
         {
             Type            baseType   = node.obj.GetType().GetGenericArguments()[0];
             Action <object> addAction2 = delegate(object o)
             {
                 node.obj.GetType().GetMethod("Add").Invoke(node.obj, new object[]
                 {
                     o
                 });
             };
             this.MakeCreateNewObjectMenu(node, node.owningField, baseType, addAction2);
         }
     }
     if (node.HasDeleteButton)
     {
         Texture2D deleteX        = TexButton.DeleteX;
         Color?    mouseoverColor = new Color?(GenUI.SubtleMouseoverColor);
         if (widgetRow.ButtonIcon(deleteX, null, mouseoverColor))
         {
             node.Delete();
         }
     }
 }
예제 #3
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 widgetRow2     = widgetRow;
                Texture2D deleteX        = TexButton.DeleteX;
                Color?    mouseoverColor = GenUI.SubtleMouseoverColor;
                if (widgetRow2.ButtonIcon(deleteX, null, mouseoverColor))
                {
                    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());
        }
 public void DoSpecialPreElements(Listing_TreeDefs listing)
 {
     if (this.obj != null)
     {
         if (this.editWidgetsMethod != null)
         {
             WidgetRow widgetRow = listing.StartWidgetsRow(this.nestDepth);
             this.editWidgetsMethod.Invoke(this.obj, new object[]
             {
                 widgetRow
             });
         }
         Editable editable = this.obj as Editable;
         if (editable != null)
         {
             GUI.color = new Color(1f, 0.5f, 0.5f, 1f);
             foreach (string text in editable.ConfigErrors())
             {
                 listing.InfoText(text, this.nestDepth);
             }
             GUI.color = Color.white;
         }
     }
 }
        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();
        }