Example #1
0
        void DrawPanel()
        {
            Handles.BeginGUI();
            toolMode = (ToolModes)GUI.Toolbar(new Rect(10, 10, 200, 30), (int)toolMode, new[] { "Move", "Build", "Paint" });
            switch (toolMode)
            {
            case ToolModes.Building:
                GUI.Label(new Rect(10, 40, 200, 30), "Left-click to select tile.");
                GUI.Label(new Rect(10, 70, 200, 30), "Hold SHIFT for multiple selection.");
                break;

            case ToolModes.Painting:
                GUI.Window(0, new Rect(10, 70, 200, PAINTING_WINDOW_HEIGHT), PaintingWindow, "Tiles");
                break;

            default:
                break;
            }
            Handles.EndGUI();
        }
Example #2
0
    private void Start()
    {
        mode = ToolModes.defaultMode;

        multiTool   = FindObjectOfType <MultiTool>();
        wheel       = GameObject.FindWithTag("wheel");
        topLeft     = wheel.transform.Find("TopLeft").GetComponent <Image>();
        topRight    = wheel.transform.Find("TopRight").GetComponent <Image>();
        bottomLeft  = wheel.transform.Find("BottomLeft").GetComponent <Image>();
        bottomRight = wheel.transform.Find("BottomRight").GetComponent <Image>();

        currentImage  = null;
        selectedImage = null;

        blue     = new Color32(182, 205, 242, 190);
        darkBlue = new Color32(34, 90, 200, 190);
        white    = new Color32(255, 255, 255, 190);
        resetColors();

        wheel.SetActive(false);
    }
Example #3
0
    public void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Paint"))
        {
            toolMode = ToolModes.Painting;
        }
        if (GUILayout.Button("Ao"))
        {
            toolMode = ToolModes.AO;
        }
        EditorGUILayout.EndHorizontal();


        EditorGUIUtility.labelWidth = 100;
        EditorGUILayout.LabelField("Important :", "On mesh-reimport all changes are gone.", EditorStyles.miniLabel);
        EditorGUILayout.LabelField("Important :", "Press stop button to apply colors!!", EditorStyles.miniLabel);
        EditorGUILayout.Space();
        GUI.enabled = CheckSelection();

        toolModeGui[toolMode]();
        GUI.enabled = true;
    }
Example #4
0
 public void ExitDrawingTool()
 {
     _pen.SetActive(false);
     _eraser.SetActive(false);
     mode = DrawingTool.ToolModes.None;
 }
Example #5
0
 public void EnterEraserMode()
 {
     _eraser.SetActive(true);
     _pen.SetActive(false);
     mode = DrawingTool.ToolModes.Eraser;
 }
Example #6
0
 //mode setting methods...
 public void EnterPenMode()
 {
     _pen.SetActive(true);
     _eraser.SetActive(false);
     mode = DrawingTool.ToolModes.Pen;
 }
Example #7
0
 public void SetColor(Color c)
 {
     _toolController.lineColor = c;
     _pen.transform.Find("tip").GetComponent <Renderer>().material.color = c;
     mode = ToolModes.Pen;             //this is a dirty hack to get the OnModeChange to trigger on the color picker and turn off the color buttons
 }
Example #8
0
    protected virtual void OnSceneGUI()
    {
        var e             = Event.current;
        var invokeRepaint = false;
        var draggingBlock = false;
        var interacting   = (!e.control && !e.alt && e.button == 0);

        // overlay gui
        Handles.BeginGUI();
        {
            // mode toolbar
            toolMode = (ToolModes)GUI.Toolbar(new Rect(10, 10, 200, 30), (int)toolMode, new[] { "Move", "Build", "Paint" });
            if (toolMode == ToolModes.Painting)
            {
                selected = null;
            }

            // tileset
            if (toolMode == ToolModes.Painting)
            {
                GUI.Window(0, new Rect(10, 70, 200, 400), PaintingWindow, "Tiles");
            }
        }
        Handles.EndGUI();

        // cancel everything if in "move" mode
        if (toolMode == ToolModes.Transform)
        {
            if (Tools.current == Tool.None)
            {
                Tools.current = Tool.Move;
            }
            return;
        }

        // override default control
        Tools.current = Tool.None;
        HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

        // Selecting & Dragging Blocks
        if (toolMode == ToolModes.Building)
        {
            // drag block in / out
            if (selected != null)
            {
                Handles.color = Color.blue;
                EditorGUI.BeginChangeCheck();

                var start  = CenterOfSelection(selected) + selected.Face * 0.5f;
                var pulled = Handles.Slider(start, selected.Face);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(target, "EditMesh");

                    draggingBlock = true;
                    if (hover != null)
                    {
                        hover         = null;
                        invokeRepaint = true;
                    }

                    // get distance and direction
                    var distance = (pulled - start).magnitude;
                    var outwards = (int)Mathf.Sign(Vector3.Dot(pulled - start, selected.Face));

                    // create or destroy a block (depending on direction)
                    if (distance > 1f)
                    {
                        var newTiles = new List <Vector3Int>();
                        foreach (var tile in selected.Tiles)
                        {
                            var was  = tile;
                            var next = tile + selected.Face.Int() * outwards;

                            if (outwards > 0)
                            {
                                tiler.Create(next, was);
                            }
                            else
                            {
                                tiler.Destroy(was);
                            }
                            tiler.Rebuild();

                            newTiles.Add(next);
                        }

                        selected.Tiles = newTiles;
                        tiler.Rebuild();
                    }
                }
            }

            // select tiles
            if (!draggingBlock && interacting)
            {
                if (e.type == EventType.MouseDown && !e.shift)
                {
                    if (hover == null)
                    {
                        selected = null;
                    }
                    else
                    {
                        selected = new MultiSelection(hover);
                    }
                    invokeRepaint = true;
                }
                else if (e.type == EventType.MouseDrag && selected != null && hover != null && !selected.Tiles.Contains(hover.Tile))
                {
                    selected.Tiles.Add(hover.Tile);
                    invokeRepaint = true;
                }
            }
        }

        // active hover
        if ((e.type == EventType.MouseMove || e.type == EventType.MouseDrag) && interacting && !draggingBlock)
        {
            var next = GetSelectionAt(e.mousePosition);
            if ((hover == null && next != null) || (hover != null && next == null) || (hover != null && next != null && (hover.Tile != next.Tile || hover.Face != next.Face)))
            {
                invokeRepaint = true;
            }
            hover = next;
        }

        // painting
        if (toolMode == ToolModes.Painting && (e.type == EventType.MouseDown || e.type == EventType.MouseDrag) && interacting && hover != null)
        {
            var block = tiler.At(hover.Tile);
            if (block != null)
            {
                // paint single tile
                if (paintMode == PaintModes.Brush)
                {
                    if (SetBlockFace(block, hover.Face, brush))
                    {
                        tiler.Rebuild();
                    }
                }
                // paint bucket
                else if (paintMode == PaintModes.Fill)
                {
                    var face = GetBlockFace(block, hover.Face);
                    if (FillBlockFace(block, face))
                    {
                        tiler.Rebuild();
                    }
                }
            }
        }

        // right-click to rotate face
        if (toolMode == ToolModes.Painting && (e.type == EventType.MouseDown || e.type == EventType.MouseDrag) && e.button == 1 && !e.control && !e.alt && hover != null)
        {
            brush.Rotation = (brush.Rotation + 1) % 4;

            var cell = tiler.At(hover.Tile);
            if (cell != null && SetBlockFace(cell, hover.Face, brush))
            {
                tiler.Rebuild();
            }
        }

        // Drawing
        {
            // draw hovers / selected outlines
            if (hover != null)
            {
                DrawSelection(hover, Color.magenta);
            }
            if (selected != null)
            {
                DrawSelection(selected, Color.blue);
            }

            // force repaint
            if (invokeRepaint)
            {
                Repaint();
            }
        }

        // always keep the tiler selected for now
        // later should detect if something is being grabbed or hovered
        Selection.activeGameObject = tiler.transform.gameObject;
    }
Example #9
0
        private void SettingsGUIInit()
        {
            /* Read settings */
            enableTexturesToolStripMenuItem.Checked = Configuration.RenderTextures;
            renderCollisionToolStripMenuItem.Checked = Configuration.RenderCollision;

            whiteToolStripMenuItem.Checked = Configuration.RenderCollisionAsWhite;
            typebasedToolStripMenuItem.Checked = !whiteToolStripMenuItem.Checked;

            renderRoomActorsToolStripMenuItem.Checked = Configuration.RenderRoomActors;
            renderSpawnPointsToolStripMenuItem.Checked = Configuration.RenderSpawnPoints;
            renderTransitionsToolStripMenuItem.Checked = Configuration.RenderTransitions;

            renderPathWaypointsToolStripMenuItem.Checked = Configuration.RenderPathWaypoints;
            linkAllWaypointsInPathToolStripMenuItem.Checked = Configuration.LinkAllWPinPath;

            renderWaterboxesToolStripMenuItem.Checked = Configuration.RenderWaterboxes;

            showWaterboxesPerRoomToolStripMenuItem.Checked = Configuration.ShowWaterboxesPerRoom;

            enableVSyncToolStripMenuItem.Checked = customGLControl.VSync = Configuration.OGLVSync;
            enableAntiAliasingToolStripMenuItem.Checked = Configuration.EnableAntiAliasing;
            enableMipmapsToolStripMenuItem.Checked = Configuration.EnableMipmaps;

            currentToolMode = Configuration.LastToolMode;
            currentCombinerType = Configuration.CombinerType;

            /* Create tool mode menu */
            int i = 0;
            foreach (KeyValuePair<ToolModes, string[]> kvp in toolModeNametable)
            {
                Controls.ToolStripRadioButtonMenuItem tsmi = new Controls.ToolStripRadioButtonMenuItem(kvp.Value[0]) { Tag = kvp.Key, CheckOnClick = true, HelpText = kvp.Value[1] };
                if (currentToolMode == kvp.Key) tsmi.Checked = true;

                tsmi.Click += new EventHandler((s, ex) =>
                {
                    object tag = ((ToolStripMenuItem)s).Tag;
                    if (tag is ToolModes) currentToolMode = ((ToolModes)tag);
                });

                mouseModeToolStripMenuItem.DropDownItems.Add(tsmi);
                i++;
            }

            /* Create combiner type menu */
            i = 0;
            foreach (KeyValuePair<CombinerTypes, string[]> kvp in combinerTypeNametable)
            {
                Controls.ToolStripRadioButtonMenuItem tsmi = new Controls.ToolStripRadioButtonMenuItem(kvp.Value[0]) { Tag = kvp.Key, CheckOnClick = true, HelpText = kvp.Value[1] };
                if (currentCombinerType == kvp.Key) tsmi.Checked = true;

                tsmi.Click += new EventHandler((s, ex) =>
                {
                    object tag = ((ToolStripMenuItem)s).Tag;
                    if (tag is CombinerTypes) currentCombinerType = ((CombinerTypes)tag);
                });

                combinerTypeToolStripMenuItem.DropDownItems.Add(tsmi);
                i++;
            }

            /* Initialize help */
            InitializeMenuHelp();
        }
Example #10
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            wheel.SetActive(true);
        }
        else if (Input.GetKeyUp("tab"))
        {
            wheel.SetActive(false);
            if (currentImage == topLeft)
            {
                mode = ToolModes.buildingMode;
            }
            else if (currentImage == topRight)
            {
                mode = ToolModes.farmMode;
            }
            else if (currentImage == bottomLeft)
            {
                mode = ToolModes.combatMode;
                Tutorial.Instance.TriggerDialogue(8);
            }
            else if (currentImage == bottomRight)
            {
                mode = ToolModes.defaultMode;
            }
        }

        if (Input.GetKey(KeyCode.Tab))
        {
            Vector2 viewportPoint = Camera.main.ScreenToViewportPoint(Input.mousePosition);  //convert game object position to VievportPoint

            resetColors();
            if (viewportPoint.x > 0.5f && viewportPoint.y > 0.5f)
            {
                currentImage = topRight;
            }
            else if (viewportPoint.x < 0.5f && viewportPoint.y > 0.5f)
            {
                currentImage = topLeft;
            }
            else if (viewportPoint.x > 0.5f && viewportPoint.y < 0.5f)
            {
                currentImage = bottomRight;
            }
            else if (viewportPoint.x < 0.5f && viewportPoint.y < 0.5f)
            {
                currentImage = bottomLeft;
            }
            else
            {
                currentImage = null;
            }

            if (currentImage != null)
            {
                currentImage.color = blue;
            }
            if (selectedImage != null)
            {
                selectedImage.color = darkBlue;
            }
            if (Input.GetMouseButtonDown(0))
            {
                selectedImage = currentImage;
            }
        }
    }
Example #11
0
		void CycleToolMode(bool forward)
		{
			var length = System.Enum.GetValues(typeof(ToolModes)).Length;
			if(forward)
			{
				toolMode++;
				if((int)toolMode == length) toolMode = 0;
			}
			else
			{
				toolMode--;
				if((int)toolMode == -1) toolMode = (ToolModes) length-1;
			}
		}
Example #12
0
    public void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Paint")) toolMode = ToolModes.Painting;
        if (GUILayout.Button("Ao")) toolMode = ToolModes.AO;
        EditorGUILayout.EndHorizontal();

        EditorGUIUtility.labelWidth = 100;
        EditorGUILayout.LabelField("Important :", "On mesh-reimport all changes are gone.", EditorStyles.miniLabel);
        EditorGUILayout.LabelField("Important :", "Press stop button to apply colors!!", EditorStyles.miniLabel);
        EditorGUILayout.Space();
        GUI.enabled = CheckSelection();

        toolModeGui[toolMode]();
        GUI.enabled = true;
    }