public override void Render(DXGui gui) { bool sel = gui.sel == nro_item ? true : false; Color clr = Color.FromArgb(Math.Min(gui.alpha, c_fondo.A), c_fondo); switch (borde) { case frameBorder.sin_borde: // dibujo solo interior gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 1, clr, true); break; case frameBorder.redondeado: // Interior gui.RoundRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 30, 6, clr, true); // Contorno gui.RoundRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 30, 6, Color.FromArgb(gui.alpha, DXGui.c_frame_border)); break; case frameBorder.solapa: { float r = 40; TGCVector2[] pt = new TGCVector2[10]; pt[0].X = rc.X; pt[0].Y = rc.Y + rc.Height; pt[1].X = rc.X; pt[1].Y = rc.Y; pt[2].X = rc.X + rc.Width - r; pt[2].Y = rc.Y; pt[3].X = rc.X + rc.Width; pt[3].Y = rc.Y + r; pt[4].X = rc.X + rc.Width; pt[4].Y = rc.Y + rc.Height; pt[5].X = rc.X; pt[5].Y = rc.Y + rc.Height; pt[6] = pt[0]; gui.DrawSolidPoly(pt, 7, clr, false); gui.DrawPoly(pt, 5, 6, DXGui.c_frame_border); } break; case frameBorder.rectangular: default: // interior gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 1, Color.FromArgb(gui.alpha, c_fondo), true); // contorno gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 6, Color.FromArgb(gui.alpha, DXGui.c_frame_border)); break; } // Texto del frame Rectangle rc2 = new Rectangle(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height); rc2.Y += 30; rc2.X += 30; Color color = sel ? c_selected : c_font; gui.font.DrawText(gui.sprite, text, rc2, DrawTextFormat.NoClip | DrawTextFormat.Top, Color.FromArgb(gui.alpha, color)); }
public override void Render(DXGui gui) { bool sel = gui.sel == nro_item ? true : false; float rx = rc.Width / 2; float ry = rc.Height / 2; float x0 = rc.Left + rx; float y0 = rc.Top + ry; if (sel || marcado) { rx += 12; ry += 12; x0 -= 6; y0 -= 6; } TGCVector2[] Q = new TGCVector2[7]; for (int i = 0; i < 6; ++i) { Q[i].X = (float)(x0 + rx * Math.Cos(2 * Math.PI / 6 * i)); Q[i].Y = (float)(y0 + ry * Math.Sin(2 * Math.PI / 6 * i)); } Q[6] = Q[0]; gui.DrawSolidPoly(Q, 7, c_fondo, false); if (sel) { // boton seleccionado: lleno el interior gui.DrawPoly(Q, 7, 4, DXGui.c_buttom_selected); } else if (marcado) { gui.DrawPoly(Q, 7, 3, Color.FromArgb(240, 245, 245)); } else { gui.DrawPoly(Q, 7, 1, Color.FromArgb(120, 120, 64)); } }
// custom draw del menu item public override void Render(DXGui gui) { bool sel = gui.sel == nro_item ? true : false; float rx = rc.Height / 2; float ry = rc.Height / 2; float x0 = rc.Left + rx; float y0 = rc.Top + ry; if (sel) { rx += 12; ry += 12; x0 -= 6; y0 -= 6; } Vector2[] p = new Vector2[20]; p[0].X = rc.Left + 50; p[0].Y = rc.Bottom - 15; p[1].X = rc.Left + 50; p[1].Y = rc.Top + 15; p[2].X = rc.Right; p[2].Y = rc.Top + 15; p[3].X = rc.Right; p[3].Y = rc.Bottom - 15; p[4].X = rc.Left + 50; p[4].Y = rc.Bottom - 15; p[5] = p[0]; if (sel) { gui.DrawGradientPoly(p, 6, Color.White, Color.FromArgb(35, 56, 68)); } else { gui.DrawSolidPoly(p, 6, Color.FromArgb(42, 71, 90), false); gui.DrawPoly(p, 6, 1, Color.FromArgb(50, 75, 240)); } Vector2[] Q = new Vector2[7]; for (int i = 0; i < 6; ++i) { Q[i].X = (float)(x0 + rx * Math.Cos(2 * Math.PI / 6 * i)); Q[i].Y = (float)(y0 + ry * Math.Sin(2 * Math.PI / 6 * i)); } Q[6] = Q[0]; gui.DrawSolidPoly(Q, 7, c_fondo, false); if (sel) { // boton seleccionado: lleno el interior gui.DrawPoly(Q, 7, 4, DXGui.c_buttom_selected); } else { gui.DrawPoly(Q, 7, 2, Color.FromArgb(61, 96, 100)); } if (textura != null) { gui.sprite.Draw(textura, Rectangle.Empty, Vector3.Empty, new Vector3(x0 - image_width / 2, y0 - image_height / 2, 0), Color.FromArgb(gui.alpha, 255, 255, 255)); } // Texto del boton Rectangle rc2 = new Rectangle(rc.Left + 90, rc.Top + 3, rc.Width, rc.Height - 3); font.DrawText(gui.sprite, text, rc2, DrawTextFormat.VerticalCenter | DrawTextFormat.Left, sel ? Color.Black : Color.WhiteSmoke); }
public override void Render(DXGui gui) { bool sel = gui.sel == nro_item ? true : false; float M_PI = (float)Math.PI; TGCVector2[] pt = new TGCVector2[255]; float da = M_PI / 8; float alfa; float x0 = rc.Left; float x1 = rc.Right; float y0 = rc.Top; float y1 = rc.Bottom; float r = 10; int t = 0; float x = x0; float y = y0; for (alfa = 0; alfa < M_PI / 2; alfa += da) { pt[t].X = (float)(x - r * Math.Cos(alfa)); pt[t].Y = (float)(y - r * Math.Sin(alfa)); ++t; } pt[t].X = x; pt[t].Y = y - r; ++t; pt[t].X = (x1 + x0) / 2; pt[t].Y = y - r; ++t; pt[t].X = (x1 + x0) / 2 + 50; pt[t].Y = y + 20 - r; ++t; x = x1; y = y0 + 20; for (alfa = M_PI / 2; alfa < M_PI; alfa += da) { pt[t].X = (float)(x - r * Math.Cos(alfa)); pt[t].Y = (float)(y - r * Math.Sin(alfa)); ++t; } pt[t].X = x + r; pt[t].Y = y; ++t; x = x1; y = y1; for (alfa = 0; alfa < M_PI / 2; alfa += da) { pt[t].X = (float)(x + r * Math.Cos(alfa)); pt[t].Y = (float)(y + r * Math.Sin(alfa)); ++t; } pt[t].X = x; pt[t].Y = y + r; ++t; pt[t].X = x0 + 150; pt[t].Y = y + r; ++t; pt[t].X = x0 + 100; pt[t].Y = y - 20 + r; ++t; x = x0; y = y - 20; for (alfa = M_PI / 2; alfa < M_PI; alfa += da) { pt[t].X = (float)(x + r * Math.Cos(alfa)); pt[t].Y = (float)(y + r * Math.Sin(alfa)); ++t; } pt[t++] = pt[0]; // interior gui.DrawSolidPoly(pt, t, c_fondo); // contorno gui.DrawPoly(pt, t, 6, DXGui.c_frame_border); // Texto del frame Rectangle rc2 = new Rectangle(rc.Top, rc.Left, rc.Width, rc.Height); rc2.Y += 25; rc2.X += 30; Color color = sel ? c_selected : c_font; gui.font.DrawText(gui.sprite, text, rc2, DrawTextFormat.NoClip | DrawTextFormat.Top, color); }
public void renderHUD() { Device d3dDevice = D3DDevice.Instance.Device; d3dDevice.RenderState.ZBufferEnable = false; int W = D3DDevice.Instance.Width; int H = D3DDevice.Instance.Height; // Elapsed time int an = (int)(time * 10) % 360; float hasta = an / 180.0f * (float)Math.PI; gui.DrawArc(new TGCVector2(40, H - 100), 25, 0, hasta, 8, Color.Yellow); gui.TextOut(20, H - 140, "Elapsed Time:" + Math.Round(time), Color.LightSteelBlue); // dibujo los enemigos TGCVector3 pos_personaje = Camera.Position; TGCVector3 dir_view = Camera.LookAt - pos_personaje; TGCVector2 dir_v = new TGCVector2(dir_view.X, dir_view.Z); dir_v.Normalize(); TGCVector2 dir_w = new TGCVector2(dir_v.Y, -dir_v.X); int dx = 1000; int dy = 1000; int dW = 200; int dH = 200; float ex = dW / (float)dx; float ey = dH / (float)dy; int ox = 10 + dW / 2; int oy = 10 + dH / 2; for (int t = 0; t < cant_enemigos; ++t) { TGCVector3 pos = enemigos[t].Position - pos_personaje; TGCVector2 p = new TGCVector2(pos.X, pos.Z); float x = TGCVector2.Dot(dir_w, p); float y = TGCVector2.Dot(dir_v, p); int xm = (int)(ox + x * ex); int ym = (int)(oy + y * ey); if (Math.Abs(xm - ox) < dW / 2 - 10 && Math.Abs(ym - oy) < dH / 2 - 10) { gui.DrawRect(xm - 2, ym - 2, xm + 2, ym + 2, 1, Color.WhiteSmoke); } } TGCVector2[] P = new TGCVector2[20]; P[0] = new TGCVector2(ox - 5, oy + 5); P[1] = new TGCVector2(ox + 5, oy + 5); P[2] = new TGCVector2(ox, oy - 10); P[3] = P[0]; gui.DrawSolidPoly(P, 4, Color.Tomato, false); gui.DrawCircle(new TGCVector2(ox, oy), 14, 3, Color.Yellow); foreach (TgcBoundingAxisAlignBox room in rooms) { TGCVector2[] Q = new TGCVector2[4]; TGCVector2[] Qp = new TGCVector2[5]; float xm = 0; float ym = 0; Q[0] = new TGCVector2(room.PMin.X - pos_personaje.X, room.PMin.Z - pos_personaje.Z); Q[1] = new TGCVector2(room.PMin.X - pos_personaje.X, room.PMax.Z - pos_personaje.Z); Q[2] = new TGCVector2(room.PMax.X - pos_personaje.X, room.PMax.Z - pos_personaje.Z); Q[3] = new TGCVector2(room.PMax.X - pos_personaje.X, room.PMin.Z - pos_personaje.Z); for (int t = 0; t < 4; ++t) { float x = TGCVector2.Dot(dir_w, Q[t]); float y = TGCVector2.Dot(dir_v, Q[t]); Qp[t] = new TGCVector2(ox + x * ex, oy + y * ey); xm += x * ex; ym += y * ey; } Qp[4] = Qp[0]; xm /= 4; ym /= 4; if (Math.Abs(xm) < dW / 2 - 10 && Math.Abs(ym) < dH / 2 - 10) { gui.DrawPoly(Qp, 5, 1, Color.Tomato); } } // posicion X,Z float kx = pos_personaje.X * ex; P[0] = new TGCVector2(10, H - 10); P[1] = new TGCVector2(15, H - 30); P[2] = new TGCVector2(5 + kx, H - 30); P[3] = new TGCVector2(25 + kx, H - 10); P[4] = P[0]; gui.DrawSolidPoly(P, 5, Color.Tomato); gui.DrawPoly(P, 5, 2, Color.HotPink); float kz = pos_personaje.Z * ey; P[0] = new TGCVector2(10, H - 40); P[1] = new TGCVector2(15, H - 60); P[2] = new TGCVector2(5 + kz, H - 60); P[3] = new TGCVector2(25 + kz, H - 40); P[4] = P[0]; gui.DrawSolidPoly(P, 5, Color.Green); gui.DrawPoly(P, 5, 2, Color.YellowGreen); d3dDevice.RenderState.ZBufferEnable = true; gui.Render(); }