Example #1
0
        protected override void OnRebuild()
        {
            m_geometry.Clear();
            if (m_paletteOpen)
            {
                m_geometry.Add2DQuad(
                    new Vector2(0.0f, 0.0f),
                    new Vector2(Screen.Width, Screen.Height),
                    new Quad(0.5f, 0.5f, 0.5f, 0.5f)
                    );

                int numColumns = (int)((Screen.Width - 85.0f) / 80.0f);
                int numRows    = 5;
                if (numColumns > 0)
                {
                    int numPerPage = numColumns * numRows;
                    int start      = m_palettePage * numPerPage;

                    int paletteSelect = m_tileList.GetTileIndex(SelectedTile);
                    if (paletteSelect >= 0)
                    {
                        int x = (paletteSelect - start) % numColumns;
                        int y = (paletteSelect - start) / numColumns;
                        if (y >= 0 && y < numRows)
                        {
                            m_geometry.Add2DQuad(
                                new Vector2(85.0f + x * 80.0f, y * 80.0f),
                                new Vector2(85.0f + x * 80.0f + 80.0f, y * 80.0f + 80.0f),
                                new Quad(0.0f, 0.5f, 0.5f * (80.0f / 128.0f), 0.5f * (80.0f / 128.0f))
                                );
                        }
                    }
                    if (m_paletteHover >= 0 && m_paletteHover != paletteSelect)
                    {
                        int x = (m_paletteHover - start) % numColumns;
                        int y = (m_paletteHover - start) / numColumns;
                        if (y >= 0 && y < numRows)
                        {
                            m_geometry.Add2DQuad(
                                new Vector2(85.0f + x * 80.0f, y * 80.0f),
                                new Vector2(85.0f + x * 80.0f + 80.0f, y * 80.0f + 80.0f),
                                new Quad(0.5f, 0.0f, 0.5f * (80.0f / 128.0f), 0.5f * (80.0f / 128.0f))
                                );
                        }
                    }
                }
            }
            for (int i = 0; i < SIDEBAR_ROWS; ++i)
            {
                if (i == m_selection)
                {
                    m_geometry.Add2DQuad(
                        new Vector2(0.0f, i * 80.0f),
                        new Vector2(96.0f, i * 80.0f + 128.0f),
                        new Quad(0.0f, 0.5f, 0.375f, 0.5f)
                        );
                }
                else if (i == m_hover)
                {
                    m_geometry.Add2DQuad(
                        new Vector2(0.0f, i * 80.0f),
                        new Vector2(96.0f, i * 80.0f + 128.0f),
                        new Quad(0.5f, 0.0f, 0.375f, 0.5f)
                        );
                }
                else
                {
                    m_geometry.Add2DQuad(
                        new Vector2(0.0f, i * 80.0f),
                        new Vector2(96.0f, i * 80.0f + 128.0f),
                        new Quad(0.0f, 0.0f, 0.375f, 0.5f)
                        );
                }
            }
            m_geometry.Rebuild();
        }