Example #1
0
        /*public override void drawInLine(util.SpriteBatchWrapper sprites, int line) {
            base.drawInLine(sprites, line);
            if (this.active) {
                int y = sprites.getYForTextLine(line + 1);
                int x = 75;
                foreach (MenuItem item in this.items) {
                    sprites.drawTextAt(item.title, x, y, .8f,
                        item.isSelected() ? Color.Orange : Color.GhostWhite);
                    x += sprites.getWidthOfText(item.title, .8f);
                    x += 15;
                }
            }
        }*/
        /*public override int getLineSize() {
            int size = base.getLineSize();
            if (this.active) {
                size += 2;
            }
            return size;
        }*/
        public override void drawFromCenter(util.SpriteBatchWrapper sprites, int x, int y)
        {
            base.drawFromCenter(sprites, x, y);
            if (this.active) {
                int width = 0;
                foreach (MenuItem item in this.items) {
                    width += sprites.getWidthOfText(item.title, 1.0f, SubMenu.FONTNAME);
                    width += 15;
                }
                width -= 15;

                int submenuX = x - width / 2;
                int submenuY = y + this.texture.bounds.Height;

                int textHeight = sprites.getHeightOfText("FOO", 1.0f, SubMenu.FONTNAME);
                int backdropY = submenuY - 3;
                sprites.drawColorAt(Color.Black, .3f, width +10, textHeight + 6, submenuX - 5, backdropY);

                foreach (MenuItem item in this.items) {
                    sprites.drawTextAt(item.title, submenuX, submenuY, 1.0f,
                        item.isSelected() ? Color.Orange : Color.GhostWhite,
                        SubMenu.FONTNAME);
                    submenuX += sprites.getWidthOfText(item.title, 1.0f, SubMenu.FONTNAME);
                    submenuX += 15;
                }
            }
        }