Ejemplo n.º 1
0
        void DisplayHelpBox()
        {
            string sHelp =
                "\n" +
                " - <b>Left Mouse Button:</b>\n" +
                "   * Select tile from tileset menu\n" +
                "   * Draw tile or copied group of tiles.\n" +
                "      If the tile is selected from tileset, not copied using right mouse button,\n" +
                "      and the tile is opaque, it will be drawn in the ground layer without overwriting\n" +
                "      any other tile in the other layers.\n" +
                "      Useful to change terrain type without erasing ground overlay tiles.\n" +
                "\n" +
                " - <b>Left Mouse Button + Shift Key:</b>\n" +
                "   * Force drawing opaque tiles in the ground overlay layer\n" +
                "\n" +
                " - <b>Right Mouse Button</b>\n" +
                "   * Copy tile under the cursor or press and drag to copy a group of tiles.\n" +
                "      It's workingboth, in the map and tileset\n" +
                "\n" +
                " - <b>Right Mouse Button + Shift:</b>\n" +
                "   * Copy only alpha tiles if any, otherwise copy opaque tile.\n" +
                "      Use this to copy, for example, a tree without copy the ground tiles under it.\n" +
                "\n" +
                " - <b>Shift + Z:</b> Undo last Brush Action\n" +
                "\n" +
                " - <b>Shift + Y:</b> Redo last Brush Action\n" +
                "\n";
            GUIContent helpContent = new GUIContent(sHelp);

            Handles.BeginGUI();
            Vector2 helpBoxSize = m_toolbarBoxStyle.CalcSize(helpContent);
            Rect    rHelpBox    = new Rect(2f, 50f, helpBoxSize.x + 5f, helpBoxSize.y);

            GUILayout.BeginArea(rHelpBox);
            HandlesEx.DrawRectWithOutline(new Rect(0, 0, rHelpBox.size.x, rHelpBox.size.y), s_toolbarBoxBgColor, s_toolbarBoxOutlineColor);
            GUILayout.Label(sHelp, m_toolbarBoxStyle);
            GUILayout.EndArea();
            Handles.EndGUI();
        }
Ejemplo n.º 2
0
        bool DoToolBar()
        {
            bool isMouseInsideToolbar = false;

            if (m_toolbarBoxStyle == null)
            {
                m_toolbarBoxStyle = new GUIStyle();
                m_toolbarBoxStyle.normal.textColor = Color.white;
                m_toolbarBoxStyle.richText         = true;
            }

            GUIContent brushCoords    = new GUIContent("<b> Brush Pos: " + MyAutoTileMap.BrushGizmo.BrushTilePos + "</b>");
            GUIContent selectedTileId = new GUIContent("<b> Selected Tile Id: " + m_tilesetComponent.SelectedTileIdx + "</b>");

            Rect rTools = new Rect(4f, 4f, Mathf.Max(m_toolbarBoxStyle.CalcSize(brushCoords).x, m_toolbarBoxStyle.CalcSize(selectedTileId).x) + 4f, 44f);

            Handles.BeginGUI();
            GUILayout.BeginArea(rTools);
            HandlesEx.DrawRectWithOutline(new Rect(0, 0, rTools.size.x, rTools.size.y), s_toolbarBoxBgColor, s_toolbarBoxOutlineColor);

            GUILayout.Space(2f);
            GUILayout.Label(brushCoords, m_toolbarBoxStyle);
            GUILayout.Label(selectedTileId, m_toolbarBoxStyle);
            GUILayout.Label("<b> F1 - Display Help</b>", m_toolbarBoxStyle);
            GUILayout.EndArea();

            if (s_tabType == eTabType.Paint && s_isEditModeOn)
            {
                // Display ToolBar
                Rect rToolBar = new Rect(rTools.xMax + 4f, rTools.y, System.Enum.GetValues(typeof(ToolIcons.eToolIcon)).Length * 32f, 32f);
                isMouseInsideToolbar = rToolBar.Contains(Event.current.mousePosition);
                GUILayout.BeginArea(rToolBar);
                HandlesEx.DrawRectWithOutline(new Rect(0, 0, rToolBar.size.x, rToolBar.size.y), s_toolbarBoxBgColor, s_toolbarBoxOutlineColor);
                GUILayout.BeginHorizontal();

                int  buttonPadding = 4;
                Rect rToolBtn      = new Rect(buttonPadding, buttonPadding, rToolBar.size.y - 2 * buttonPadding, rToolBar.size.y - 2 * buttonPadding);
                foreach (ToolIcons.eToolIcon toolIcon in System.Enum.GetValues(typeof(ToolIcons.eToolIcon)))
                {
                    _DoToolbarButton(rToolBtn, toolIcon);
                    rToolBtn.x = rToolBtn.xMax + 2 * buttonPadding;
                }
                GUI.color = Color.white;
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                //---
            }

            Handles.EndGUI();

            if (m_displayHelpBox)
            {
                DisplayHelpBox();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.F1)
            {
                m_displayHelpBox = !m_displayHelpBox;
            }

            return(isMouseInsideToolbar);
        }