Exemplo n.º 1
0
    private void DrawFrameSelection()
    {
        if (viewModel.Animation == null)
        {
            return;
        }

        NPVoxFrame[] frames = viewModel.Frames;

        GUILayout.BeginHorizontal();

        if (frames.Length == 0)
        {
            if (GUILayout.Button(new GUIContent("++", "Create Frame at Position 0")))
            {
                viewModel.AddFrameAt(0);
            }
        }
        else
        {
            if (NPVoxGUILayout.HotkeyButton(new GUIContent("<", "Select frame " + viewModel.GetPreviousFrameIndex() + "(" + HOTKEY_PREVIOUS_FRAME + ")"), HOTKEY_PREVIOUS_FRAME, false, false, true))
            {
                viewModel.SelectFrame(viewModel.GetPreviousFrameIndex());
            }
            else if (NPVoxGUILayout.HotkeyButton(new GUIContent(">", "Select frame " + viewModel.GetNextFrameIndex() + "(" + HOTKEY_PREVIOUS_FRAME + ")"), HOTKEY_NEXT_FRAME, false, false, true))
            {
                viewModel.SelectFrame(viewModel.GetNextFrameIndex());
            }

            if (viewModel.SelectedFrameIndex < 0 && frames.Length > 0)
            {
                viewModel.SelectFrame(0, true);
            }
            if (viewModel.SelectedFrameIndex >= frames.Length && frames.Length > 0)
            {
                viewModel.SelectFrame(frames.Length - 1, true);
            }

            string[] labels = new string[frames.Length];
            for (int i = 0; i < frames.Length; i++)
            {
                labels[i] = (i + 1) + "";
            }

            int newIndex = -1;
            if (viewModel.SelectedFrameIndex != (newIndex = GUILayout.Toolbar(viewModel.SelectedFrameIndex, labels)))
            {
                viewModel.SelectFrame(newIndex);
            }

            DrawFrameCreationTools();
        }

        GUILayout.EndHorizontal();


        // GUILayout.EndArea();
    }
    private void DrawCameraToolbar()
    {
        GNCameraSetups.CameraMode previousMode = GNCameraSetups.GetCameraMode();
        GNCameraSetups.CameraMode mode;
        if (previousMode != (mode = NPVoxGUILayout.HotkeyToolbar <GNCameraSetups.CameraMode>(
                                 new string[] { "Top", "Ingame", "Front" },
                                 new GNCameraSetups.CameraMode[] { GNCameraSetups.CameraMode.TOP, GNCameraSetups.CameraMode.INGAME, GNCameraSetups.CameraMode.FRONT },
                                 new KeyCode[] { KeyCode.A, KeyCode.S, KeyCode.D },
                                 previousMode,
                                 true, false, true
                                 )))
        {
            GNCameraSetups.SetCameraMode(mode);
        }

        if (NPVoxGUILayout.HotkeyButton("Center", HOTKEY_FOCUS_CAMERA))
        {
            SceneView.lastActiveSceneView.LookAt(viewModel.FullMapExtends().center, Quaternion.Euler(-45f, 0f, 0f), 20f);
        }
    }
    private void DrawPaintMode()
    {
        GNBlockMapEditorVM.PaintMode mode = viewModel.CurrentPaintMode;
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Paint Mode (p): ", EditorStyles.whiteBoldLabel);
        if (viewModel.SetCurrentPaintMode(NPVoxGUILayout.HotkeyToggleBar <GNBlockMapEditorVM.PaintMode>(
                                              new string[] { "Brush", "Random" },
                                              new GNBlockMapEditorVM.PaintMode[] {
            GNBlockMapEditorVM.PaintMode.BRUSH,
            GNBlockMapEditorVM.PaintMode.RANDOM
        },
                                              KeyCode.P,
                                              mode,
                                              true
                                              )))
        {
            SceneView.RepaintAll();
        }
        GUILayout.EndHorizontal();

        // if (viewModel.CurrentPaintMode == GNBlockMapEditorVM.PaintMode.RANDOM) // this leads to exception
        {
            GUILayout.BeginHorizontal();
            GNBlockMapEditorVM.RandomBrushFlags flags = (GNBlockMapEditorVM.RandomBrushFlags)EditorGUILayout.MaskField(
                new GUIContent("Options"),
                (int)viewModel.CurrentRandomBrushFlags,
                new string[] { "Prefab", "Rotate X", "Rotate Y", "Rotate Z", "Flip X", "Flip Y", "Flip Z" });
            if (flags != viewModel.CurrentRandomBrushFlags)
            {
                viewModel.CurrentRandomBrushFlags = flags;
                SceneView.RepaintAll();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.EndVertical();
        DrawBrushSetup();
        GUILayout.EndHorizontal();
    }
Exemplo n.º 4
0
    private void DrawPreview()
    {
        if (!viewModel || !viewModel.Animation)
        {
            return;
        }
        EditorGUILayout.BeginVertical();

        EditorGUILayout.BeginHorizontal();
        viewModel.SetPingPong(EditorGUILayout.Toggle("PingPong", viewModel.Animation.PingPong));
        viewModel.SetLoop(EditorGUILayout.Toggle("Loop", viewModel.Animation.Loop));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        viewModel.SetFPS(Mathf.Max(EditorGUILayout.IntField("FPS", viewModel.Animation.FPS), 1));

        if (!viewModel.IsPlaying && NPVoxGUILayout.HotkeyButton("Preview", HOTKEY_PREVIEW))
        {
            Preview();
        }
        if (viewModel.IsPlaying && NPVoxGUILayout.HotkeyButton("Stop", HOTKEY_PREVIEW))
        {
            viewModel.StopPreview();
        }
        if (viewModel.IsPlaying)
        {
            double timeForFrame  = (viewModel.SelectedFrame.Duration / (double)viewModel.Animation.FPS);
            double thisFrameTime = EditorApplication.timeSinceStartup;
            accumAnimTime += thisFrameTime - lastFrameTime;
            while (accumAnimTime > timeForFrame && viewModel.IsPlaying)
            {
                accumAnimTime -= timeForFrame;
                viewModel.UpdatePreview();
            }
            lastFrameTime = thisFrameTime;
            Repaint();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
    }
 private void DrawShowLayerMode()
 {
     GNBlockMapEditorVM.ShowLayerMode mode = viewModel.CurrentShowLayerMode;
     GUILayout.BeginHorizontal();
     GUILayout.Label("Layer Mode (z/y): ", EditorStyles.whiteBoldLabel);
     if (viewModel.SetCurrentShowLayerMode(NPVoxGUILayout.HotkeyToggleBar <GNBlockMapEditorVM.ShowLayerMode>(
                                               new string[] { "Active", "Below", "All" },
                                               new GNBlockMapEditorVM.ShowLayerMode[] {
         GNBlockMapEditorVM.ShowLayerMode.ACTIVE,
         GNBlockMapEditorVM.ShowLayerMode.BELOW,
         GNBlockMapEditorVM.ShowLayerMode.ALL
     },
                                               //    KeyCode.Z,
                                               KeyCode.None,
                                               mode,
                                               true
                                               )))
     {
         SceneView.RepaintAll();
     }
     GUILayout.EndHorizontal();
 }
Exemplo n.º 6
0
    override public bool DrawInspector(NPipeEditFlags flags)
    {
        bool changed = base.DrawInspector(flags);

        if (Input != null)
        {
            string newInputValue = NPVoxGUILayout.DrawSocketSelector("Input Socket", InputSocketName, Input as NPVoxIModelFactory);
            if (newInputValue != InputSocketName)
            {
                InputSocketName = newInputValue;
                changed         = true;
            }
            string newTargetValue = NPVoxGUILayout.DrawSocketSelector("Target Socket", TargetSocketName, Target as NPVoxIModelFactory);
            if (newTargetValue != TargetSocketName)
            {
                TargetSocketName = newTargetValue;
                changed          = true;
            }
        }

        return(changed);
    }
 private void DrawBoxTools()
 {
     //       GNBlockMapEditorVM.PaintMode mode = viewModel.CurrentPaintMode;
     GUILayout.BeginHorizontal();
     GUILayout.Label("Box Tools: ", EditorStyles.whiteBoldLabel);
     if (viewModel.ApplyBoxTool(NPVoxGUILayout.HotkeyToolbar <GNBlockMapEditorVM.BoxTool>(
                                    new string[] { "Paint", "Erase", "Transform" },
                                    new GNBlockMapEditorVM.BoxTool[] {
         GNBlockMapEditorVM.BoxTool.PAINT,
         GNBlockMapEditorVM.BoxTool.ERASE,
         GNBlockMapEditorVM.BoxTool.TRANSFORM
     },
                                    new KeyCode[] { KeyCode.None, KeyCode.None, KeyCode.None },
                                    GNBlockMapEditorVM.BoxTool.NONE,
                                    false,
                                    false,
                                    true
                                    )))
     {
         SceneView.RepaintAll();
     }
     GUILayout.EndHorizontal();
 }
Exemplo n.º 8
0
    private void DrawModeToolbar()
    {
        GUILayout.BeginHorizontal();

        GUILayout.Label("Brightenmod (V): ");
        NPVoxAnimationEditorVM.BrightenMode brightenMode = viewModel.CurrentBrightenMode;
        if (viewModel.CurrentBrightenMode != (brightenMode = NPVoxGUILayout.HotkeyToggleBar <NPVoxAnimationEditorVM.BrightenMode>(
                                                  new string[] { "Off", "Selected" },
                                                  new NPVoxAnimationEditorVM.BrightenMode[] {
            NPVoxAnimationEditorVM.BrightenMode.OFF,
            NPVoxAnimationEditorVM.BrightenMode.SELECTED,
            // NPVoxAnimationEditorVM.BrightenMode.CURRENT
        },
                                                  KeyCode.V,
                                                  brightenMode
                                                  )))
        {
            viewModel.SetCurrentBrightenMode(brightenMode);
        }


        GUILayout.EndHorizontal();
    }
    override public bool DrawInspector(NPipeEditFlags flags)
    {
        bool changed = base.DrawInspector(flags & ~NPipeEditFlags.INPUT);

        if (Input != null)
        {
            string newInputValue = NPVoxGUILayout.DrawSocketSelector("Socket 1", SocketName1, Input as NPVoxIModelFactory);
            if (newInputValue != SocketName1)
            {
                SocketName1 = newInputValue;
                changed     = true;
            }
            string newTargetValue = NPVoxGUILayout.DrawSocketSelector("Socket 2", SocketName2, Input as NPVoxIModelFactory);
            if (newTargetValue != SocketName2)
            {
                SocketName2 = newTargetValue;
                changed     = true;
            }
        }


        return(changed);
    }
Exemplo n.º 10
0
    private void DrawTransformationSelector()
    {
        NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel>[] transformers = viewModel.Transformers;
        if (transformers == null)
        {
            return;
        }
        GUIStyle foldoutStyle         = new GUIStyle(EditorStyles.foldout);
        GUIStyle foldoutSelectedStyle = new GUIStyle(foldoutStyle);
        GUIStyle labelStyle           = new GUIStyle(EditorStyles.label);
        GUIStyle labelSelectedStyle   = new GUIStyle(labelStyle);
        GUIStyle deleteStyle          = new GUIStyle(EditorStyles.miniButtonMid);

        deleteStyle.fixedWidth = 70;

        foldoutSelectedStyle.fontStyle = FontStyle.Bold;
        labelSelectedStyle.fontStyle   = FontStyle.Bold;

        for (int i = 0; i < transformers.Length; i++)
        {
            NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel> transformer = transformers[i];

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            bool isSelected        = i == viewModel.SelectedTransformationIndex;
            bool somethingSelected = viewModel.SelectedTransformationIndex != -1;
            bool isSelectedOrLast  = isSelected || (!somethingSelected && i == transformers.Length - 1);

            string name = transformer.GetInstanceName();
            if (name == null || name.Length < 1)
            {
                name = transformer.GetTypeName();
            }

            GUILayout.Label((i + 1) + (isSelectedOrLast ? "|A" : ""), isSelected ? labelSelectedStyle : labelStyle, GUILayout.Width(30));

            if (isSelected != EditorGUILayout.Foldout(isSelected, name, isSelected ? foldoutSelectedStyle : foldoutStyle))
            {
                if (isSelected)
                {
                    viewModel.SelectTransformation(-1);
                    unfocus();
                }
                else
                {
                    viewModel.SelectTransformation(i);
                }
            }

            GUILayout.Space(100);

            if (GUILayout.Button("Delete" + (isSelectedOrLast ? " (" + HOTKEY_DELETE_LAST_TRANSFOMRATION.ToString() + ")" : ""), deleteStyle))
            {
                viewModel.RemoveTransformationAt(i);
            }
            else if (GUILayout.Button("Copy", EditorStyles.miniButtonMid))
            {
                viewModel.CopyTransformation(i);
            }

            if (isSelected)
            {
                if (NPVoxGUILayout.HotkeyButton(new GUIContent("Up", "Move Up"), HOTKEY_MOVE_TRANSFORMATION_UP, false, false, false, EditorStyles.miniButtonMid))
                {
                    viewModel.MoveTransformation(i, -1);
                }

                if (NPVoxGUILayout.HotkeyButton(new GUIContent("Down", "Move Down"), HOTKEY_MOVE_TRANSFORMATION_DOWN, false, false, false, EditorStyles.miniButtonMid))
                {
                    viewModel.MoveTransformation(i, +1);
                }

                if (NPVoxGUILayout.HotkeyButton(new GUIContent("Duplicate", "Duplicate"), DUPLICATE_TRANSFORMATION, false, false, false, EditorStyles.miniButtonMid))
                {
                    viewModel.DuplicateTransformation(i);
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent("Up", "Move Up"), EditorStyles.miniButtonMid))
                {
                    viewModel.MoveTransformation(i, -1);
                }

                if (GUILayout.Button(new GUIContent("Down", "Move Down"), EditorStyles.miniButtonRight))
                {
                    viewModel.MoveTransformation(i, +1);
                }
            }

            GUILayout.EndHorizontal();

            if (isSelected && viewModel.SelectedTransformer != null)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.Space();
                    GUILayout.BeginVertical();
                    {
                        EditorGUILayout.Space();

                        if (viewModel.SelectedTransformer is NPVoxISceneEditable)
                        {
                            DrawTransformationToolbar();
                        }
                        {
                            if (viewModel.SelectedTransformer.DrawInspector(~NPipeEditFlags.TOOLS & ~NPipeEditFlags.INPUT & ~NPipeEditFlags.STORAGE_MODE))
                            {
                                GUI.changed = true;
                                viewModel.SelectedTransformerChanged();
                                viewModel.RegeneratePreview();
//                                GUI.changed = true; // TODO: is this still needed?
                            }
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.Space();
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }

        GUILayout.BeginHorizontal();
        if (NPVoxGUILayout.HotkeyButton("+ New T", HOTKEY_APPEND_TRANSFORMATION))
        {
            viewModel.AddTransformation();
        }
        if (viewModel.IsSkeletonBuilderAppendable() && GUILayout.Button("+ Skeleton"))
        {
            viewModel.AddSkeletonBuilder();
        }
        if (viewModel.IsSkeletonTransformerAppendable() && NPVoxGUILayout.HotkeyButton("+ SkeletonT", HOTKEY_APPEND_BONETRANSFORMATION))
        {
            viewModel.AddSkeletonTransformer();
        }
        if (GUILayout.Button("+ Mirror"))
        {
            viewModel.AddMirrorTransformators();
        }
//        if (GUILayout.Button("+ Combiner"))
//        {
//            viewModel.AddSocketCombiner();
//        }
//        if (GUILayout.Button("+ SocketT"))
//        {
//            viewModel.AddSocketTransformer();
//        }
        List <System.Type> allTypes  = new List <System.Type>(NPipeReflectionUtil.GetAllTypesWithAttribute(typeof(NPipeAppendableAttribute)));
        List <string>      allLabels = new List <string>();

        allLabels.Add("Other ...");
        foreach (System.Type factoryType in allTypes)
        {
            NPipeAppendableAttribute attr = (NPipeAppendableAttribute)factoryType.GetCustomAttributes(typeof(NPipeAppendableAttribute), true)[0];

            if (!attr.sourceType.IsAssignableFrom(typeof(NPVoxIModelFactory)))
            {
                continue;
            }
            allLabels.Add(attr.name);
        }
        int selection = EditorGUILayout.Popup(0, allLabels.ToArray());

        if (selection > 0)
        {
            viewModel.AddTransformer(allTypes[selection - 1]);
        }


        if (viewModel.HasTransformationToPaste() && GUILayout.Button("+ Paste"))
        {
            viewModel.Paste();
        }
        GUILayout.EndHorizontal();
    }