public override void Draw(SpriteBatch spriteBatch, double timePassed) { if (!IsOpened) return; WindowUtils.spriteBatch = spriteBatch; // Window Window window = new Window(bounds.Width / 2 - Width / 2, bounds.Height / 2 - Height / 2, Width, Height); window.Margin = 15; // Item slot int slotX = 0; int slotY = 0; for (int x = 0; x < 2; x++) { for (int y = 0; y < 4; y++) { // Gets the right color Color color = Color.White; if (selectedTile.X == x && selectedTile.Y == y) color = Color.Cyan; // when the slot is selected slotX = x * (itemSize + marginIn * 2 + Global.TileSize); slotY = y * (itemSize + marginIn); // Adds the slot window to the master window Window slot = new Window(slotX, slotY, itemSize, itemSize, slotTexture, color); window.AddChild(slot); // Checks if there's any item EquipmentType type = GetEquipType(x, y); Item item = null; foreach (KeyValuePair<int, Equipment> e in EquippedItems) { if (e.Value.EquipType == type) { if (type == EquipmentType.Accessory) { if (!(x == 0 && e.Key == Accessory1) && !(x == 1 && e.Key == Accessory2)) continue; } item = e.Value; break; } } // Draws item sprite or thumbnail if nothing is equipped if (item != null) { Texture2D texture = Global.GetTexture(item.TextureName); if (texture != null) { Rectangle rect = Utils.GetRectangleByGid(item.Gid, item.TextureTileSize, texture.Width); Window icon = new Window(item.TextureTileSize / 4, item.TextureTileSize / 4, item.TextureTileSize, item.TextureTileSize, texture, Color.White, rect); slot.AddChild(icon); } } else { //TODO: thumbnail } } } // Player image Window playerImage = new Window(itemSize + marginIn, Height / 2 - Global.TileSize / 2, Global.TileSize, Global.TileSize, Global.Player.Texture, Color.White, Utils.GetRectangleByGid(Global.Player.GetSprite(FacingDirection.Down), Global.TileSize, Global.Player.Texture.Width)); window.AddChild(playerImage); // Description frame Window description = new Window(playerImage.Bounds.X + Global.TileSize + itemSize + marginIn * 2, 0, Width - playerImage.Bounds.X - Global.TileSize - itemSize - marginIn * 2 - marginOut * 2, Height - marginOut * 2, slotTexture, Color.White); window.AddChild(description); // Item name if (selectedItem != -1) { Item i = EquippedItems[selectedItem]; int margin = 10; TextWindow nameWindow = new TextWindow(Global.DialogFont, i.Name, new Vector2(margin, margin), new Vector2(description.Bounds.Width - margin * 2, description.Bounds.Height - margin * 2), Color.DarkSlateBlue); description.AddChild(nameWindow); // Item description Vector2 measure = nameWindow.Font.MeasureString(nameWindow.Text); TextWindow descriptionText = new TextWindow(Global.DetailFont, i.Description, new Vector2(margin, measure.Y), new Vector2(description.Bounds.Width - margin * 3, description.Bounds.Height - margin * 3 - measure.Y)); description.AddChild(descriptionText); } // Draws the window WindowUtils.DrawWindow(window); }
public override void Draw(SpriteBatch spriteBatch, double timePassed) { if (!IsOpened) return; WindowUtils.spriteBatch = spriteBatch; // Window Window window = new Window(bounds.Center.X - Width / 2, bounds.Center.Y - Height / 2, Width, Height); window.Margin = 20; // Attributes SpriteFont font = Global.DetailFont; int fontHeight = font.LineSpacing / 2; int innerMargin = 5; Vector2 maxSize = new Vector2(115, 50); int biggerX = (int)font.MeasureString("Intelligence:").X / 2; window.AddChild(new TextWindow(font, "Level:", new Vector2(biggerX - font.MeasureString("Level:").X / 2, 0), maxSize, Color.Cyan)); window.AddChild(new TextWindow(font, "Vitality:", new Vector2(biggerX - font.MeasureString("Vitality:").X / 2, fontHeight + innerMargin), maxSize)); window.AddChild(new TextWindow(font, "Wisdom:", new Vector2(biggerX - font.MeasureString("Wisdom:").X / 2, (fontHeight + innerMargin) * 2), maxSize)); window.AddChild(new TextWindow(font, "Endurance:", new Vector2(biggerX - font.MeasureString("Endurance:").X / 2, (fontHeight + innerMargin) * 3), maxSize)); window.AddChild(new TextWindow(font, "Strenght:", new Vector2(biggerX - font.MeasureString("Strenght:").X / 2, (fontHeight + innerMargin) * 4), maxSize)); window.AddChild(new TextWindow(font, "Dexterity:", new Vector2(biggerX - font.MeasureString("Dexterity:").X / 2, (fontHeight + innerMargin) * 5), maxSize)); window.AddChild(new TextWindow(font, "Intelligence:", new Vector2(0, (fontHeight + innerMargin) * 6), maxSize)); window.AddChild(new TextWindow(font, "Faith:", new Vector2(biggerX - font.MeasureString("Faith:").X / 2, (fontHeight + innerMargin) * 7), maxSize)); window.AddChild(new TextWindow(font, "Luck:", new Vector2(biggerX - font.MeasureString("Luck:").X / 2, (fontHeight + innerMargin) * 8), maxSize)); window.AddChild(new TextWindow(font, "Points left:", new Vector2(biggerX - font.MeasureString("Points left:").X / 2, (fontHeight + innerMargin) * 9), maxSize, Color.Cyan)); window.AddChild(new TextWindow(font, "Experience:", new Vector2(biggerX - font.MeasureString("Experience:").X / 2, (fontHeight + innerMargin) * 10), maxSize, Color.Cyan)); // Values int x = biggerX + innerMargin; Dictionary<CharacterAttribute, int> atts = Attributes.PureBase; window.AddChild(new TextWindow(font, Attributes.PureBase[CharacterAttribute.Level].ToString(), new Vector2(x, 0), maxSize, Color.Cyan)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Vitality].ToString(), new Vector2(x, (fontHeight + innerMargin)), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Wisdom].ToString(), new Vector2(x, (fontHeight + innerMargin) * 2), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Endurance].ToString(), new Vector2(x, (fontHeight + innerMargin) * 3), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Strenght].ToString(), new Vector2(x, (fontHeight + innerMargin) * 4), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Dexterity].ToString(), new Vector2(x, (fontHeight + innerMargin) * 5), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Intelligence].ToString(), new Vector2(x, (fontHeight + innerMargin) * 6), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Faith].ToString(), new Vector2(x, (fontHeight + innerMargin) * 7), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, atts[CharacterAttribute.Luck].ToString(), new Vector2(x, (fontHeight + innerMargin) * 8), maxSize, Color.Yellow)); window.AddChild(new TextWindow(font, Attributes.PointsLeft.ToString(), new Vector2(x, (fontHeight + innerMargin) * 9), maxSize, Color.Cyan)); window.AddChild(new TextWindow(font, Attributes.PureBase[CharacterAttribute.Experience].ToString(), new Vector2(x, (fontHeight + innerMargin) * 10), maxSize, Color.Cyan)); // Buttons x += 100; int buttonSize = fontHeight * 2; innerMargin = 10; window.AddChild(new Window(x, (buttonSize + innerMargin), buttonSize, buttonSize, slotTexture, selectedAtt == 0 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 2, buttonSize, buttonSize, slotTexture, selectedAtt == 1 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 3, buttonSize, buttonSize, slotTexture, selectedAtt == 2 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 4, buttonSize, buttonSize, slotTexture, selectedAtt == 3 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 5, buttonSize, buttonSize, slotTexture, selectedAtt == 4 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 6, buttonSize, buttonSize, slotTexture, selectedAtt == 5 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 7, buttonSize, buttonSize, slotTexture, selectedAtt == 6 ? Color.Cyan : Color.White)); window.AddChild(new Window(x, (buttonSize + innerMargin) * 8, buttonSize, buttonSize, slotTexture, selectedAtt == 7 ? Color.Cyan : Color.White)); WindowUtils.DrawWindow(window); }
public void AddChild(Window w) { Children.Add(w); }