public MonoInventory(int x, int y, int width, int height, SpriteFont font, Color fontColor, Texture2D texture) { _font = font; _fontColor = fontColor; LeftTopX = x; LeftTopY = y; Width = width; Height = height; var textSize = _font.MeasureString(">"); var bottomY = height - (int)textSize.Y; _topButton = new MonoItem(new MonoItemInfo(null, null, "<", () => this.MovePrev()), _font, _fontColor, x, 0); _bottomButton = new MonoItem(new MonoItemInfo(null, null, ">", () => this.MoveNext()), _font, _fontColor, x, bottomY); _monoList = new MonoInventoryList(x, _topButton.Height, width, bottomY - _topButton.Height, _font, _fontColor, texture); }
public MonoKnowledges(GraphicsDevice graphicsDevice, SpriteFont font) { _font = font; var graphicsDevice1 = graphicsDevice; var texture = new Texture2D(graphicsDevice1, 1, 1, false, SurfaceFormat.Color); Color[] c = new Color[1]; c[0] = Color.White; texture.SetData <Color>(c); var textHeight = (int)font.MeasureString(_pointsToForget.ToString()).Y; _topButton = new MonoItem(new MonoItemInfo(texture, null, "<", this.MovePrev), _font, Color.Black, MonoDrawer.SCREEN_WIDTH - (int)font.MeasureString("<".ToString()).X - 10 - 40, MonoDrawer.SCREEN_HEIGHT - 40); _bottomButton = new MonoItem(new MonoItemInfo(texture, null, ">", this.MoveNext), _font, Color.Black, MonoDrawer.SCREEN_WIDTH - 40, MonoDrawer.SCREEN_HEIGHT - 40); _okButton = new MonoItem(new MonoItemInfo(texture, null, "Ok", DoRewrite), font, Color.Black, MonoDrawer.SCREEN_WIDTH - 40, MonoDrawer.SCREEN_HEIGHT - 40 - _topButton.Height - 10); _changableKnowledgesList = new MonoKnowledgeList(graphicsDevice1, 0, textHeight, MonoDrawer.SCREEN_WIDTH, MonoDrawer.SCREEN_HEIGHT - textHeight, font, texture); }
public void Show(List <MonoItemInfo> monoItemInfos, int parentX, int parentY) { SignalMenuIsShown(); // if (IsShown) // Clear(); var x = 0; var y = 0; var width = 0; var height = 0; var monoItems = monoItemInfos.Select(info => { var monoItem = new MonoItem(info, _font, _fontColor, x, y); height = height + OffsetItems + monoItem.Height; y = height; width = Math.Max(width, monoItem.Width); return(monoItem); }).ToList(); childControls.AddRange(monoItems); Height = height; Width = width; LeftTopX = parentX + Offset + Width >= _screenWidth ? parentX - Offset - Width : parentX + Offset; var minY = Math.Max(0, parentY - Height / 2); LeftTopY = minY + Height >= _screenHeight ? _screenHeight - Height - Offset : minY; childControls.ForEach(ctrl => { ctrl.LeftTopX = LeftTopX; ctrl.LeftTopY = LeftTopY + ctrl.LeftTopY; }); IsShown = true; }