Exemplo n.º 1
0
    public void drawSelectedBlock()
    {
        int blockSelectKey = getBlockSelectButton();

        if (blockSelectKey > 0 && blockSelectMenu.selectedBlockStacks[blockSelectKey - 1] != null)
        {
            selectedBlockStack = (BlockStack)blockSelectMenu.selectedBlockStacks[blockSelectKey - 1];
        }

        if (selectedBlockStack != null)
        {
            GuiFunctions.drawSlotTexture(selectedBlockStack.blockTexture, selectedBlockPosition.x,
                                         selectedBlockPosition.y, selectedBlockScale);
        }
    }
Exemplo n.º 2
0
    public MenuActions draw()
    {
        MenuActions menuAction = MenuActions.none;

        GUI.DrawTexture(backgroundRect, background, ScaleMode.ScaleAndCrop, false, 0);

        GUILayout.BeginArea(backgroundRect);
        GUILayout.BeginVertical();
        GUILayout.Label("Assign blocks to keys 1-9", normalStyle);

        float     slotScale   = slotWidth / 16;
        ArrayList blockStacks = getBlockStacksForSlots();

        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(ResourceLookup.getSideButtonTexture(0), slotGuiOptions))
            {
                scrollLeft();
            }

            if (blockStacks.Count == slotPositions)
            {
                GUILayout.FlexibleSpace();
            }

            BlockStack blockStack;
            for (int i = 0; i < blockStacks.Count; i++)
            {
                GUILayout.Box("", slotGuiOptions);
                if (blockStacks[i] == null)
                {
                    break;
                }
                blockStack = (BlockStack)blockStacks[i];
                Rect rect = GUILayoutUtility.GetLastRect();
                GuiFunctions.drawSlotTexture(blockStack.blockTexture, rect.xMin, rect.yMin, slotScale);

                if (Input.GetMouseButtonDown(0) && GuiFunctions.isMouseInGuiRect(rect))
                {
                    mouseDownBlockStack = blockStack;
                }
            }


            GUILayout.FlexibleSpace();

            if (GUILayout.Button(ResourceLookup.getSideButtonTexture(1), slotGuiOptions))
            {
                scrollRight();
            }
            GUILayout.EndHorizontal();
        }

        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            for (int i = 0; i < slotPositions; i++)
            {
                GUILayout.Box((i + 1).ToString(), slotGuiOptions);
                Rect rect = GUILayoutUtility.GetLastRect();
                if (selectedBlockStacks[i] != null)
                {
                    BlockStack blockStack = (BlockStack)selectedBlockStacks[i];
                    GuiFunctions.drawSlotTexture(blockStack.blockTexture, rect.xMin, rect.yMin, slotScale);
                }
                if (Input.GetMouseButtonUp(0) && mouseDownBlockStack != null && GuiFunctions.isMouseInGuiRect(rect))
                {
                    selectedBlockStacks[i] = mouseDownBlockStack;
                    mouseDownBlockStack    = null;
                }
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.EndArea();

        if (mouseDownBlockStack != null)
        {
            GuiFunctions.drawSlotTexture(mouseDownBlockStack.blockTexture, Input.mousePosition.x - slotWidth / 2, Screen.height - Input.mousePosition.y - slotHeight / 2, slotScale);
            if (!Input.GetMouseButton(0) && Event.current.type == EventType.repaint)
            {
                mouseDownBlockStack = null;
            }
        }

        return(menuAction);
    }