public override void Project(GameTime gameTime, int x, int y, IRender render) { if (!DrawBorder) { return; } render.Begin(); render.DrawLine(new Vector2(x + borderPosition, y), new Vector2(x + borderPosition, y + Height), OuterBorderColor); render.DrawLine(new Vector2(x + borderPosition + BorderSize - 1, y), new Vector2(x + borderPosition + BorderSize - 1, y + Height), OuterBorderColor); render.DrawRect(new Rectangle(x + borderPosition, y, BorderSize - 2, Height), InnerBorderColor); render.End(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { ViewRect orig = render.GetViewRect(); render.Begin(); ISprite iconUpSignInUse = UpIsPressed ? IconUpSignPressed : IconUpSign; ISprite iconInsideInUse = UpIsPressed ? IconInsidePressed : IconInside; // /-------\ // | /|\ | // | / | \ | // | | | // \-------/ render.DrawSprite(IconTop, new Vector2(x, y), Color.White); render.DrawSprite(IconLeft, new Rectangle(x, y + IconTop.Height, IconLeft.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconRight, new Rectangle(x + IconTop.Width - IconRight.Width, y + IconTop.Height, IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconBottom, new Vector2(x, y + UpperFieldHeight - IconBottom.Height), Color.White); render.DrawSprite(iconInsideInUse, new Rectangle(x + IconLeft.Width, y + IconTop.Height, IconTop.Width - IconLeft.Width - IconRight.Width, UpperFieldHeight - IconTop.Height - IconBottom.Height), Color.White); render.DrawSprite(IconUpSign, new Vector2(x + IconLeft.Width + ((IconTop.Width - IconLeft.Width - IconRight.Width) / 2) - (IconUpSign.Width / 2), y + (UpperFieldHeight / 2) - (IconUpSign.Height / 2)), Color.White); //UPPER FIELD: //Top render.DrawSprite(TopBorder, new Rectangle(x + IconTop.Width, y, Width - IconTop.Width - TopRightCorner.Width, TopBorder.Height), Color.White); //TopRight render.DrawSprite(TopRightCorner, new Vector2(x + Width - TopRightCorner.Width, y), Color.White); //Right render.DrawSprite(RightBorder, new Rectangle(x + Width - RightBorder.Width, y + TopRightCorner.Height, RightBorder.Width, UpperFieldHeight - TopRightCorner.Height - UpperFieldBottomRightCorner.Height), Color.White); //BottomRight render.DrawSprite(UpperFieldBottomRightCorner, new Vector2(x + Width - UpperFieldBottomRightCorner.Width, y + UpperFieldHeight - UpperFieldBottomRightCorner.Height), Color.White); //Bottom render.DrawSprite(BottomBorder, new Rectangle(x + IconTop.Width, y + UpperFieldHeight - BottomBorder.Height, Width - IconTop.Width - TopRightCorner.Width, BottomBorder.Height), Color.White); //Inside render.DrawSprite(Inside, new Rectangle(x + IconTop.Width, y + TopBorder.Height, Width - IconTop.Width - RightBorder.Width, UpperFieldHeight - TopBorder.Height - BottomBorder.Height), Color.White); //LOWER FIELD: //Middle render.DrawSprite(MiddleBorder, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, MiddleBorder.Height), Color.White); //Right render.DrawSprite(RightBorder, new Rectangle(x + LowerFieldWidth - RightBorder.Width, y + UpperFieldHeight, RightBorder.Width, LowerFieldHeight - BottomRightCorner.Height), Color.White); //BottomRight render.DrawSprite(BottomRightCorner, new Vector2(x + LowerFieldWidth - BottomRightCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomRightCorner.Height), Color.White); //Bottom render.DrawSprite(BottomBorder, new Rectangle(x + BottomLeftCorner.Width, y + UpperFieldHeight + LowerFieldHeight - BottomBorder.Height, LowerFieldWidth - BottomLeftCorner.Width - BottomRightCorner.Width, BottomBorder.Height), Color.White); //BottomLeft render.DrawSprite(BottomLeftCorner, new Vector2(x, y + UpperFieldHeight + LowerFieldHeight - BottomLeftCorner.Height), Color.White); //Left render.DrawSprite(LeftBorder, new Rectangle(x, y + UpperFieldHeight, LeftBorder.Width, LowerFieldHeight - BottomLeftCorner.Height), Color.White); //Inside render.DrawSprite(Inside, new Rectangle(x + LeftBorder.Width, y + UpperFieldHeight + MiddleBorder.Height, LowerFieldWidth - LeftBorder.Width - RightBorder.Width, LowerFieldHeight - MiddleBorder.Height - BottomBorder.Height), Color.White); render.End(); render.SetViewRect(orig.AddGet(new ViewRect(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin, Width - IconTop.Width - RightBorder.Width - TextMargin * 2, UpperFieldHeight - TopBorder.Height - MiddleBorder.Height - TextMargin * 2))); render.Begin(); string textToDraw = Text; if (HasFocus) { textToDraw = Text.Insert(CursorPosition, "|"); } Font.DrawString(textToDraw, new Point(RealX + IconTop.Width + TextMargin, RealY + TopBorder.Height + TextMargin), FontColor, render); render.End(); render.SetViewRect(orig.AddGet(new ViewRect(selectorX, selectorY, selectorWidth, selectorHeight))); render.Begin(); int drawX = selectorX + textAreaOriginX; int drawY = selectorY + textAreaOriginY; //DrawSprite filedir Font.DrawString(CurrentDirectory.FullName, new Point(drawX, drawY), FontColor, render); drawY += TextMargin + Font.CharHeight; render.DrawLine(new Vector2(drawX, drawY), new Vector2(selectorX + selectorWidth, drawY), SeparatorColor); drawY += 1 + TextMargin; foreach (DirectoryInfo d in directoryList) { if (selectedDirectories.Contains(d)) { render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor); } render.DrawSprite(FolderSign, new Vector2(drawX, drawY), Color.White); Font.DrawString(d.Name, new Point(drawX + FolderSign.Width + TextMargin, drawY), FontColor, render); drawY += Font.CharHeight + Font.VerticalSpace; } foreach (FileInfo f in fileList) { if (selectedFiles.Contains(f)) { render.DrawRect(new Rectangle(selectorX, drawY, selectorWidth, Font.CharHeight + Font.VerticalSpace), SelectedColor); } Font.DrawString(f.Name, new Point(drawX, drawY), FontColor, render); drawY += Font.CharHeight + Font.VerticalSpace; } render.End(); }
void DrawMenu(GameTime gameTime, ViewRect viewRect) { if (IsClosed || !IsInitialized || !Activated || Hidden) { return; } viewRect.Add(MasterBoundaries); IRender render = GraphicsManager.GetRender(); int x = RealX; int y = RealY; int posX = x + menuItemMarginX; int posY = y + Height / 2 - Font.CharHeight / 2; int count = 0; foreach (var item in MenuItems) { int strinW = Font.MeasureString(item.Name).X; if (count == SelectedMenuItem && ItemIsOpen) { render.Begin(); Color color = count == SelectedMenuItem && item.Enabled ? FontHighlightColor : FontColor; render.DrawHorizontalLine(new Point(posX, y + menuItemMarginY), strinW, DropdownBorder); render.DrawVerticalLine(new Point(posX, y + menuItemMarginY), Height - menuItemMarginY + toolbarDropdownMargin, DropdownBorder); render.DrawVerticalLine(new Point(posX + strinW, y + menuItemMarginY), Height - menuItemMarginY + toolbarDropdownMargin, DropdownBorder); render.DrawRect(new Rectangle(posX + 1, y + menuItemMarginY + 1, strinW - 2, Height - menuItemMarginY + toolbarDropdownMargin - 2), DropdownBody); Font.DrawString(item.Name, new Point(posX + 1, posY), color, render); //DropdownMenu int top = y + Height + toolbarDropdownMargin - 1; render.DrawHorizontalLine(new Point(posX + strinW, top), dropdownMenuWidth - strinW, DropdownBorder); render.DrawHorizontalLine(new Point(posX, top + dropdownMenuHeight), dropdownMenuWidth, DropdownBorder); render.DrawVerticalLine(new Point(posX, top), dropdownMenuHeight, DropdownBorder); render.DrawVerticalLine(new Point(posX + dropdownMenuWidth - 1, top), dropdownMenuHeight, DropdownBorder); render.DrawRect(new Rectangle(posX + 1, top + 1, dropdownMenuWidth - 3, dropdownMenuHeight - 2), DropdownBody); int elemX = posX; int elemY = top + menuElemMarginY; var selectedItem = MenuItems[SelectedMenuItem]; int c = 0; foreach (var elem in selectedItem.Elements) { int elemH; if (elem.Name != null) { elemH = Font.MeasureString(elem.Name).Y + menuElemMarginY; } else { elemH = separatorHeight; } if (c == SelectedMenuElement && item.Enabled && elem.Enabled) { render.DrawRect(new Rectangle(elemX + 1, elemY - menuElemMarginY + 2, dropdownMenuWidth - 3, elemH - 2), ElementHighlightColor); } if (elem.IsSeparator) { render.DrawLine(new Vector2(elemX + separatorMargin, elemY + separatorHeight / 2), new Vector2(elemX + dropdownMenuWidth - separatorMargin, elemY + separatorHeight / 2), SeparatorColor); } else { Font.DrawString(elem.Name, new Point(elemX + menuElemMarginX, elemY), FontColor, render); } elemY += elemH; c += 1; } render.End(); } posX += strinW + menuItemMarginX; count += 1; } render.Reset(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { if (drawFpsList.Count == meanFloor) { drawFpsList.RemoveAt(0); } double add = 1 / gameTime.ElapsedGameTime.TotalSeconds; if (!double.IsInfinity(add)) { drawFpsList.Add(1 / gameTime.ElapsedGameTime.TotalSeconds); } DrawFps = 0; foreach (double fps in drawFpsList) { DrawFps += fps; } DrawFps /= drawFpsList.Count; render.Begin(); Color background = BackgroundColor; Color fontColor = FontColor; Color bumpColor = BumpColor; const float transparencyFactor = 0.3F; if (CheckIfUnderMouse()) { background.R = Convert.ToByte(BackgroundColor.R * transparencyFactor); background.G = Convert.ToByte(BackgroundColor.G * transparencyFactor); background.B = Convert.ToByte(BackgroundColor.B * transparencyFactor); background.A = Convert.ToByte(BackgroundColor.A * transparencyFactor); fontColor.R = Convert.ToByte(FontColor.R * transparencyFactor); fontColor.G = Convert.ToByte(FontColor.G * transparencyFactor); fontColor.B = Convert.ToByte(FontColor.B * transparencyFactor); fontColor.A = Convert.ToByte(FontColor.A * transparencyFactor); bumpColor.R = Convert.ToByte(bumpColor.R * transparencyFactor); bumpColor.G = Convert.ToByte(bumpColor.G * transparencyFactor); bumpColor.B = Convert.ToByte(bumpColor.B * transparencyFactor); bumpColor.A = Convert.ToByte(bumpColor.A * transparencyFactor); } render.DrawRect(new Rectangle(x, y, Width, Height), background); //Draw bump render.DrawLine(new Vector2(x + bumpX, Height), new Vector2(x + bumpX, 0), bumpColor); //Move bump if (bumpX + speed > Width || bumpX + speed < 0) { speed = -speed; } bumpX += speed; if (ShowUpdateFps) { Font.DrawString("DrawFps: " + UpdateFps.ToString(), new Point(x, y), fontColor, render); } if (ShowDrawFps) { Font.DrawString("UpdateFps: " + DrawFps.ToString(), new Point(x, y + Font.CharHeight + margin), fontColor, render); } render.End(); }
public override void Project(GameTime gameTime, int x, int y, IRender render) { render.Begin(); if (World == null) { Font.DrawString("No World", new Point(x + Width / 2, y + Height / 2), new Vector2(0, 0), Color.White, render); render.End(); return; } float originX = ViewCamera.LookX; float originY = ViewCamera.LookY; if (ShowRegions) { var gridColor = new Color(100, 100, 100, 100); int width = (int)Math.Round(World.Width * ViewCamera.Zoom); int height = (int)Math.Round(World.Height * ViewCamera.Zoom); int regionSize = (int)Math.Round(World.RegionSize * ViewCamera.Zoom); int stop = width + x; for (int gridX = x; gridX < stop; gridX += regionSize) { render.DrawLine(new Vector2(gridX - originX, y - originY), new Vector2(gridX - originX, y + height - originY), gridColor); } stop = height + y; for (int gridY = y; gridY < stop; gridY += regionSize) { render.DrawLine(new Vector2(x - originX, gridY - originY), new Vector2(x + width - originX, gridY - originY), gridColor); } } foreach (Entity entity in World.EntityList) { //Color color = entity.EntityColor; //switch (entity.EntityName) //{ // case "Creature": // sprite = Creature; // double energyQ = ((Creature)entity).Energy.Value / ((Creature)entity).Energy.Max; // color.R = (byte)Math.Round(color.R * energyQ, 0); // color.G = (byte)Math.Round(color.G * energyQ, 0); // color.B = (byte)Math.Round(color.B * energyQ, 0); // break; // case "Food": // sprite = Food; // break; //} Type eType = entity.GetType(); int radius = (int)Math.Round(entity.Radius * ViewCamera.Zoom); Rectangle destRect = new Rectangle((int)Math.Round(x - originX + entity.Position.X * ViewCamera.Zoom, 0), (int)Math.Round(y - originY + entity.Position.Y * ViewCamera.Zoom, 0), radius * 2, radius * 2); if (EntityPaintersDictionary.ContainsKey(eType)) { foreach (var painter in EntityPaintersDictionary[eType]) { painter.Draw(gameTime, entity, destRect.X, destRect.Y, ViewCamera.Zoom, render); } } //render.DrawSprite(sprite, destRect, new Vector2(radius, radius), Color.Red, (float)entity.Rotation); if (entity == SelectedEntity) { destRect.X -= destRect.Width / 2; destRect.Y -= destRect.Height / 2; render.DrawHorizontalLine(new Point(destRect.X, destRect.Y), destRect.Width, Color.White); render.DrawHorizontalLine(new Point(destRect.X, destRect.Bottom), destRect.Width, Color.White); render.DrawVerticalLine(new Point(destRect.X, destRect.Y), destRect.Height, Color.White); render.DrawVerticalLine(new Point(destRect.Right, destRect.Y), destRect.Height, Color.White); } //if (entity.EntityName == "Creature" && entity == infoDrawCreature) //{ // var creature = (Creature)entity; // double rotation = (creature.Rotation - creature.EyeSpan / 2); // double rotationStep = creature.EyeSpan / creature.EyeNeuronsAmount; // float length = infoDrawCreature.ViewDistance; // for (int i = 0; i < creature.EyeNeuronsAmount + 1; i++) // { // float posX = (float)destRect.X; // float posY = (float)destRect.Y; // float lineX = (float)Math.Cos(rotation) * length + posX; // float lineY = (float)Math.Sin(rotation) * length + posY; // render.DrawLine(new Vector2(posX, posY), new Vector2(lineX, lineY), Color.Red); // rotation += rotationStep; // } //} } int tX = 10 + x; int tY = 30 + y; foreach (string s in stringsToDraw) { Font.DrawString(s, new Point(tX, tY), Color.White, render); tY += Font.CharHeight + 2; } stringsToDraw.Clear(); render.End(); }