示例#1
0
    public override void WindowGUI()
    {
        // clear substance highlight while properties panel is disabled
        EntityReferencePropertyManager.Reset(null);

        GUILayout.BeginHorizontal();
        SelectionGUI();
        GUILayout.FlexibleSpace();

        Vector3 selectionSize = voxelArray.selectionBounds.size;

        if (selectionSize == Vector3.zero)
        {
            ActionBarLabel("Select edges to bevel...");
        }
        else
        {
            ActionBarLabel(SelectionString(selectionSize));
        }

        GUILayout.FlexibleSpace();
        TutorialGUI.TutorialHighlight("bevel done");
        if (HighlightedActionBarButton(GUIIconSet.instance.done))
        {
            Destroy(this);
        }
        TutorialGUI.ClearHighlight();
        GUILayout.EndHorizontal();
    }
示例#2
0
    public override void WindowGUI()
    {
        string targetButtonText = "Target:  Self";

        if (targetEntityIsActivator)
        {
            targetButtonText = "Target:  Activators";
        }
        else if (targetEntity != null)
        {
            targetButtonText = "Target:  " + targetEntity.ToString();
        }
        TutorialGUI.TutorialHighlight("behavior target");
        if (GUIUtils.HighlightedButton(targetButtonText))
        {
            entityPicker = PropertyGUIs.BehaviorTargetPicker(gameObject, voxelArray, self, value =>
            {
                targetEntity            = value.targetEntity.entity;
                targetEntityIsActivator = value.targetEntityIsActivator;
                UpdateBehaviorList();
            });
        }
        TutorialGUI.ClearHighlight();
        if (typePicker != null)
        {
            typePicker.scroll = scroll;
            typePicker.WindowGUI();
            scroll = typePicker.scroll;
        }

        // prevent panel from closing when entity picker closes
        holdOpen = entityPicker != null;
    }
示例#3
0
    public override void WindowGUI()
    {
        GUILayout.BeginHorizontal();
        // overflow menu will not be cut off if the buttons can't fit
        GUILayout.BeginScrollView(Vector2.zero, GUIStyle.none);
        GUILayout.BeginHorizontal();

        if (ActionBarButton(GUIIconSet.instance.close))
        {
            editorFile.Close();
        }

        SelectionGUI();
        EditGUI();

        GUILayout.FlexibleSpace();

        if (ActionBarButton(GUIIconSet.instance.play))
        {
            editorFile.Play();
        }

        GUILayout.EndHorizontal();
        GUILayout.EndScrollView();

        TutorialGUI.TutorialHighlight("bevel");
        if (ActionBarButton(GUIIconSet.instance.overflow))
        {
            BuildOverflowMenu();
        }
        TutorialGUI.ClearHighlight();

        GUILayout.EndHorizontal();
    }
示例#4
0
 public static void BehaviorCondition(Property property)
 {
     var condition = (EntityBehavior.Condition)property.value;
     GUILayout.Label("When sensor is:");
     TutorialGUI.TutorialHighlight("behavior condition");
     property.value = (EntityBehavior.Condition)GUILayout.SelectionGrid(
         (int)condition, new string[] { "On", "Off", "Both" }, 3, GUI.skin.GetStyle("button_tab"));
     TutorialGUI.ClearHighlight();
 }
示例#5
0
    public override void WindowGUI()
    {
        if (voxelArray.selectionChanged)
        {
            voxelArray.selectionChanged = false;
            voxelEdge = voxelArray.GetSelectedBevel();
        }

        GUILayout.Label("Bevel:", GUIStyleSet.instance.labelTitle);

        if (!voxelArray.SomethingIsSelected())
        {
            GUILayout.Label("(none selected)");
            return;
        }

        TutorialGUI.TutorialHighlight("bevel shape");
        GUILayout.Label("Shape:");
        var newBevelType = (VoxelEdge.BevelType)GUILayout.SelectionGrid((int)voxelEdge.bevelType,
                                                                        new Texture[] {
            GUIIconSet.instance.no,
            GUIIconSet.instance.bevelIcons.flat,
            GUIIconSet.instance.bevelIcons.curve,
            GUIIconSet.instance.bevelIcons.square,
            GUIIconSet.instance.bevelIcons.stair2,
            GUIIconSet.instance.bevelIcons.stair4
        },
                                                                        3, GUIStyleSet.instance.buttonTab);

        TutorialGUI.ClearHighlight();

        TutorialGUI.TutorialHighlight("bevel size");
        GUILayout.Label("Size:");
        var newBevelSize = (VoxelEdge.BevelSize)GUILayout.SelectionGrid((int)voxelEdge.bevelSize,
                                                                        new Texture[] {
            GUIIconSet.instance.bevelIcons.quarter,
            GUIIconSet.instance.bevelIcons.half,
            GUIIconSet.instance.bevelIcons.full
        },
                                                                        3, GUIStyleSet.instance.buttonTab);

        TutorialGUI.ClearHighlight();

        if (newBevelType != voxelEdge.bevelType || newBevelSize != voxelEdge.bevelSize)
        {
            voxelEdge.bevelType = newBevelType;
            voxelEdge.bevelSize = newBevelSize;
            voxelArray.BevelSelectedEdges(voxelEdge);
        }
    }
示例#6
0
    public override void WindowGUI()
    {
        TutorialGUI.TutorialHighlight("material type");
        if (colorOnly)
        {
            tab = 0;
        }
        else if (allowNullMaterial)
        {
            tab = GUILayout.SelectionGrid(tab, new string[] { "Color", "Texture", "None" }, 3);
        }
        else
        {
            tab = GUILayout.SelectionGrid(tab, new string[] { "Color", "Texture" }, 2);
        }
        TutorialGUI.ClearHighlight();

        if (tab == 0)
        {
            ColorTab();
        }
        else if (colorPicker != null)
        {
            Destroy(colorPicker);
        }
        if (tab == 1)
        {
            TextureTab();
        }
        else
        {
            scroll         = Vector2.zero;
            scrollVelocity = Vector2.zero;
            if (materialDirectory != rootDirectory)
            {
                materialDirectory = rootDirectory;
                UpdateMaterialDirectory();
            }
        }
        if (tab == 2)
        {
            NoneTab();
        }
    }
示例#7
0
    private void EntityPropertiesGUI()
    {
        Entity singleSelectedEntity = null;

        if (selectedEntities.Count == 1)
        {
            singleSelectedEntity = selectedEntities[0];
        }

        EntityReferencePropertyManager.Reset(singleSelectedEntity); // could be null and that's fine (?)

        GUILayout.BeginVertical(GUI.skin.box);
        PropertiesObjectGUI(editEntity);
        GUILayout.EndVertical();

        if (singleSelectedEntity != null && !(singleSelectedEntity is PlayerObject))
        {
            GUILayout.BeginHorizontal();
            if (GUIUtils.HighlightedButton("Clone"))
            {
                if (singleSelectedEntity is ObjectEntity)
                {
                    ObjectEntity clone     = (ObjectEntity)(singleSelectedEntity.Clone());
                    var          pickerGUI = gameObject.AddComponent <FacePickerGUI>();
                    pickerGUI.voxelArray = voxelArray;
                    pickerGUI.message    = "Tap to place clone";
                    pickerGUI.pickAction = () =>
                    {
                        if (!voxelArray.PlaceObject(clone))
                        {
                            DialogGUI.ShowMessageDialog(gameObject, ActionBarGUI.OBJECT_NO_ROOM_ERROR);
                        }
                    };
                }
                else if (singleSelectedEntity is Substance)
                {
                    Substance clone = (Substance)(singleSelectedEntity.Clone());
                    clone.defaultPaint                = voxelArray.GetSelectedPaint();
                    clone.defaultPaint.addSelected    = false;
                    clone.defaultPaint.storedSelected = false;
                    voxelArray.substanceToCreate      = clone;
                    var createGUI = gameObject.AddComponent <CreateSubstanceGUI>();
                    createGUI.voxelArray = voxelArray;
                }
            }
            if (GUIUtils.HighlightedButton("Delete"))
            {
                DeleteButton();
            }
            GUILayout.EndHorizontal();
        }
        if (selectedEntities.Count > 1)
        {
            if (GUIUtils.HighlightedButton("Delete"))
            {
                DeleteButton();
            }
        }

        TutorialGUI.TutorialHighlight("change sensor");
        if (GUILayout.Button("Change Sensor"))
        {
            TypePickerGUI sensorMenu = gameObject.AddComponent <TypePickerGUI>();
            sensorMenu.title      = "Change Sensor";
            sensorMenu.categories = new PropertiesObjectType[][] { GameScripts.sensors };
            sensorMenu.handler    = (PropertiesObjectType type) =>
            {
                foreach (Entity entity in selectedEntities)
                {
                    entity.sensor = (Sensor)type.Create();
                }
                voxelArray.unsavedChanges = true;
                UpdateEditEntity();
            };
        }
        TutorialGUI.ClearHighlight();
        GUILayout.BeginVertical(GUI.skin.box);
        PropertiesObjectGUI(editSensor, " Sensor");
        GUILayout.EndVertical();

        TutorialGUI.TutorialHighlight("add behavior");
        if (GUILayout.Button("Add Behavior"))
        {
            NewBehaviorGUI behaviorMenu = gameObject.AddComponent <NewBehaviorGUI>();
            behaviorMenu.title      = "Add Behavior";
            behaviorMenu.self       = singleSelectedEntity;
            behaviorMenu.voxelArray = voxelArray;
            behaviorMenu.handler    = (PropertiesObjectType behaviorType) =>
            {
                foreach (Entity entity in selectedEntities)
                {
                    EntityBehavior newBehavior = (EntityBehavior)behaviorType.Create();
                    // with multiple selected entities, NewBehaviorGUI doesn't check if behaviors
                    // are valid for the selected entities
                    if (newBehavior.targetEntity.entity == null && !newBehavior.targetEntityIsActivator &&
                        !newBehavior.BehaviorObjectType().rule(entity))
                    {
                        continue;
                    }
                    entity.behaviors.Add(newBehavior);
                    EntityPreviewManager.BehaviorUpdated(singleSelectedEntity, newBehavior);
                }
                voxelArray.unsavedChanges = true;
                UpdateEditEntity();
                scrollVelocity = new Vector2(0, 2000 * editBehaviors.Count); // scroll to bottom
            };
        }
        TutorialGUI.ClearHighlight();

        Color guiBaseColor = GUI.backgroundColor;
        StoredEntityBehavior behaviorToRemove = null;

        foreach (StoredEntityBehavior storedBehavior in editBehaviors)
        {
            TutorialGUI.TutorialHighlight("behaviors");
            Entity behaviorTarget = null;
            if (storedBehavior.sharedTarget)
            {
                behaviorTarget = storedBehavior.allBehaviors[0].targetEntity.entity;
            }
            if (behaviorTarget != null)
            {
                EntityReferencePropertyManager.Next(behaviorTarget);
                GUI.backgroundColor = guiBaseColor * EntityReferencePropertyManager.GetColor();
            }
            EntityReferencePropertyManager.SetBehaviorTarget(behaviorTarget);
            GUILayout.BeginVertical(GUI.skin.box);
            GUI.backgroundColor = guiBaseColor;
            PropertiesObjectGUI(storedBehavior, " Behavior",
                                () => EntityPreviewManager.BehaviorUpdated(singleSelectedEntity,
                                                                           storedBehavior.allBehaviors[0]));
            if (GUILayout.Button("Remove"))
            {
                behaviorToRemove = storedBehavior;
            }
            GUILayout.EndVertical();
            // clear this every time, in case the next target is the same
            EntityReferencePropertyManager.SetBehaviorTarget(null);
        }

        if (behaviorToRemove != null)
        {
            foreach (Entity entity in selectedEntities)
            {
                foreach (EntityBehavior remove in behaviorToRemove.allBehaviors)
                {
                    if (entity.behaviors.Remove(remove))
                    {
                        break;
                    }
                }
            }
            voxelArray.unsavedChanges = true;
            UpdateEditEntity();
            EntityPreviewManager.BehaviorUpdated(singleSelectedEntity, behaviorToRemove.allBehaviors[0]);
        }

        if (mismatchedSelectedBehaviorCounts)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Label("(other behaviors...)", GUIStyleSet.instance.labelTitle);
            GUILayout.EndVertical();
        }
    }
示例#8
0
    public override void WindowGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.Box("", GUIStyle.none, GUILayout.Width(PREVIEW_SIZE), GUILayout.Height(PREVIEW_SIZE));
        DrawPaint(paint, GUILayoutUtility.GetLastRect());
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        TutorialGUI.TutorialHighlight("paint transform");
        if (GUILayout.Button(GUIIconSet.instance.rotateLeft, GUIStyleSet.instance.buttonSmall, GUILayout.ExpandWidth(false)))
        {
            Orient(3);
        }
        if (GUILayout.Button(GUIIconSet.instance.rotateRight, GUIStyleSet.instance.buttonSmall, GUILayout.ExpandWidth(false)))
        {
            Orient(1);
        }
        TutorialGUI.ClearHighlight();
        GUILayout.FlexibleSpace();

        foreach (VoxelFace recentPaint in recentPaints)
        {
            GUILayout.Box("", previewBoxStyle.Value,
                          GUILayout.Width(RECENT_PREVIEW_SIZE), GUILayout.Height(RECENT_PREVIEW_SIZE));
            Rect buttonRect = GUILayoutUtility.GetLastRect();
            Rect paintRect  = new Rect(
                buttonRect.xMin + RECENT_MARGIN, buttonRect.yMin + RECENT_MARGIN,
                buttonRect.width - RECENT_MARGIN * 2, buttonRect.height - RECENT_MARGIN * 2);
            if (GUI.Button(buttonRect, ""))
            {
                paint = recentPaint;
                handler(paint);
                UpdateMaterialSelector();
            }
            DrawPaint(recentPaint, paintRect);
        }

        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Done"))
        {
            Destroy(this);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        TutorialGUI.TutorialHighlight("paint transform");
        if (GUILayout.Button(GUIIconSet.instance.flipHorizontal, GUIStyleSet.instance.buttonSmall, GUILayout.ExpandWidth(false)))
        {
            Orient(5);
        }
        if (GUILayout.Button(GUIIconSet.instance.flipVertical, GUIStyleSet.instance.buttonSmall, GUILayout.ExpandWidth(false)))
        {
            Orient(7);
        }
        TutorialGUI.ClearHighlight();
        int oldSelectedLayer = selectedLayer;

        TutorialGUI.TutorialHighlight("paint layer");
        selectedLayer = GUILayout.SelectionGrid(
            selectedLayer, new string[] { "Material", "Overlay" }, 2);
        TutorialGUI.ClearHighlight();
        if (oldSelectedLayer != selectedLayer)
        {
            UpdateMaterialSelector();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        if (materialSelector != null)
        {
            materialSelector.scroll = scroll;
            materialSelector.WindowGUI();
            scroll = materialSelector.scroll;
        }
    }
示例#9
0
    protected void EditGUI()
    {
        if (!voxelArray.FacesAreSelected())
        {
            return;
        }

        TutorialGUI.TutorialHighlight("paint");
        if (ActionBarButton(GUIIconSet.instance.paint))
        {
            PaintGUI paintGUI = gameObject.AddComponent <PaintGUI>();
            paintGUI.title   = "Paint Faces";
            paintGUI.handler = (VoxelFace paint) =>
            {
                voxelArray.PaintSelectedFaces(paint);
            };
            paintGUI.paint = voxelArray.GetSelectedPaint();
        }
        TutorialGUI.ClearHighlight();

        TutorialGUI.TutorialHighlight("create object");
        if (ActionBarButton(GUIIconSet.instance.create))
        {
            TypePickerGUI picker = gameObject.AddComponent <TypePickerGUI>();
            picker.title      = "Create";
            picker.categories = new PropertiesObjectType[][] {
                GameScripts.entityTemplates, GameScripts.objectTemplates
            };
            picker.categoryNames = new string[] { "Substance", "Object" };
            picker.handler       = (PropertiesObjectType type) =>
            {
                if (typeof(Substance).IsAssignableFrom(type.type))
                {
                    Substance substance = (Substance)type.Create();
                    voxelArray.substanceToCreate = substance;
                    var createGUI = gameObject.AddComponent <CreateSubstanceGUI>();
                    createGUI.voxelArray = voxelArray;
                }
                else if (typeof(ObjectEntity).IsAssignableFrom(type.type))
                {
                    ObjectEntity obj = (ObjectEntity)type.Create();
                    if (!voxelArray.PlaceObject(obj))
                    {
                        DialogGUI.ShowMessageDialog(gameObject, OBJECT_NO_ROOM_ERROR);
                    }
                }
            };
        }
        TutorialGUI.ClearHighlight();

        GUILayout.FlexibleSpace();
        int moveCount = 0;

        if (touchListener.currentTouchOperation == TouchListener.TouchOperation.MOVE &&
            touchListener.movingAxis is MoveAxis)
        {
            moveCount = Mathf.Abs(((MoveAxis)touchListener.movingAxis).moveCount);
        }
        if (moveCount != 0)
        {
            ActionBarLabel(moveCount.ToString());
        }
        else
        {
            ActionBarLabel(SelectionString(voxelArray.selectionBounds.size));
        }
    }