protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode normal = style.GetNodeByName("Crosshair").GetNodeByName("Normal"); this.m_position.X -= normal.Rectangle.Width / 2; this.m_position.Y -= normal.Rectangle.Height / 2; this.m_size = normal.Rectangle.Size; float tWidth=style.ImageInfo.Width; float tHeight=style.ImageInfo.Height; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; //topLeft=new CustomVertex.TransformedColoredTextured(m_position.X,m_position.Y+normal.Rectangle.Height,0,1,normal.Color.ToArgb(), ImageNode i = normal; RectangleF rect = normal.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y , 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); normalQuad = new Quad(topleft, topright, bottomleft, bottomright); }
public static CustomVertex.TransformedColoredTextured[] Create() { CustomVertex.TransformedColoredTextured[] texturedArray = new CustomVertex.TransformedColoredTextured[4]; texturedArray[0].Rhw = 1f; texturedArray[1].Rhw = 1f; texturedArray[2].Rhw = 1f; texturedArray[3].Rhw = 1f; return texturedArray; }
public static CustomVertex.TransformedColoredTextured[] Create() { CustomVertex.TransformedColoredTextured[] texturedArray = new CustomVertex.TransformedColoredTextured[4]; texturedArray[0].Rhw = 1f; texturedArray[1].Rhw = 1f; texturedArray[2].Rhw = 1f; texturedArray[3].Rhw = 1f; return(texturedArray); }
/// <summary>Initializes DirectX graphics</summary> /// <returns>true on success, false on failure</returns> public bool InitializeGraphics() { PresentParameters tPresentParas = new PresentParameters(); tPresentParas.SwapEffect = SwapEffect.Discard; tPresentParas.Windowed = true; try { _Device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, tPresentParas); //create main fui class _FNUIMain = new FNUIMain(); _FNUIMain.CreateUI(""); float tFramerate = 0; int tFrames = 0; _FNUIMain.LoadFlashHeader(_Path, ref _Width, ref _Height, ref tFramerate, ref tFrames); this.ClientSize = new Size(_Width, _Height); _Vertices = new CustomVertex.TransformedColoredTextured[4]; _Vertices[0] = new CustomVertex.TransformedColoredTextured(0, 0, 0, 1.0f, Color.White.ToArgb(), 0.0f, 0.0f); _Vertices[1] = new CustomVertex.TransformedColoredTextured(_Width - 1, 0, 0, 1.0f, Color.White.ToArgb(), 1.0f, 0.0f); _Vertices[2] = new CustomVertex.TransformedColoredTextured(_Width - 1, _Height - 1, 0, 1.0f, Color.White.ToArgb(), 1.0f, 1.0f); _Vertices[3] = new CustomVertex.TransformedColoredTextured(0, _Height - 1, 0, 1.0f, Color.White.ToArgb(), 0.0f, 1.0f); _Texture1 = new Texture(_Device, _Width, _Height, 1, 0, Format.A8R8G8B8, Pool.Managed); _Texture2 = new Texture(_Device, _Width, _Height, 1, 0, Format.A8R8G8B8, Pool.Managed); //create a new flash player instance _FNUIFlashPlayer = _FNUIMain.CreateFlashPlayer(); //set the callback delegates and the event notifier _FNUIFlashPlayer.SetDelegates(ResizeTexture, LockRectangle, UnlockRectangle, AddDirtyRectangle); _FNUIFlashPlayer.SetEventNotifier(EventNotifier); //create the flash control at resolution 512x512 and with tex1 and tex2 as textures, //eg. doublebuffering, for singlebuffering, just provide 1 texture _FNUIFlashPlayer.CreateFlashControl(0, _Width, _Height, (IntPtr)0, (IntPtr)1, false); //load a movie _FNUIFlashPlayer.LoadMovie(_Path); return(true); } catch (DirectXException) { return(false); } }
protected void RotatePointInPlace(ref CustomVertex.TransformedColoredTextured pt, PointF rotation) { //PointF local = new PointF(pt.X - rotation.X, pt.Y - rotation.Y); float localX = pt.X - rotation.X; float localY = pt.Y - rotation.Y; double cos = Math.Cos(RotationAngle); double sin = Math.Sin(RotationAngle); pt.X = (float)(cos * localX + sin * localY); pt.Y = (float)(-sin * localX + cos * localY); pt.X += rotation.X; pt.Y += rotation.Y; }
/// <summary>Initializes DirectX graphics</summary> /// <returns>true on success, false on failure</returns> public bool InitializeGraphics() { PresentParameters pp = new PresentParameters(); pp.SwapEffect = SwapEffect.Discard; //pp.IsWindowed = true; pp.Windowed = true; try { m_device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, pp); verts = new CustomVertex.TransformedColoredTextured[4]; verts[0] = new CustomVertex.TransformedColoredTextured( 0, 0, 0, 1.0f, Color.White.ToArgb(), 0.0f, 0.0f); verts[1] = new CustomVertex.TransformedColoredTextured( 511, 0, 0, 1.0f, Color.White.ToArgb(), 1.0f, 0.0f); verts[2] = new CustomVertex.TransformedColoredTextured( 511, 511, 0, 1.0f, Color.White.ToArgb(), 1.0f, 1.0f); verts[3] = new CustomVertex.TransformedColoredTextured( 0, 511, 0, 1.0f, Color.White.ToArgb(), 0.0f, 1.0f); tex1 = new Texture(m_device, 512, 512, 1, 0, Format.A8R8G8B8, Pool.Managed); tex2 = new Texture(m_device, 512, 512, 1, 0, Format.A8R8G8B8, Pool.Managed); //create main fui class fmain = new FNUIMain(); fmain.CreateUI(""); //create a new flash player instance fplayer = fmain.CreateFlashPlayer(); //set the callback delegates and the event notifier fplayer.SetDelegates(ResizeTexture, GetTextureSurfacePointer, ReleaseTextureSurfacePointer, DirtyRect); fplayer.SetEventNotifier(EventNotifier); //create the flash control at resolution 512x512 and with tex1 and tex2 as textures, //eg. doublebuffering, for singlebuffering, just provide 1 texture fplayer.CreateFlashControl(0, 512, 512, (IntPtr)0, (IntPtr)1, true); //load a movie to test fplayer.LoadMovie(Application.StartupPath + "\\SiemensContent\\index.swf"); return(true); } catch (DirectXException) { return(false); } }
/// <summary> /// Set the data for the water's vertex buffer /// </summary> private void BackGroundCreated(object sender, EventArgs e) { VertexBuffer vb = (VertexBuffer)sender; CustomVertex.TransformedColoredTextured[] v = new CustomVertex.TransformedColoredTextured[4]; for (int i = 0; i < 4; i++) { v[i].SetPosition(new Vector4(0.0f, 0.0f, 0.9f, 1.0f)); v[i].Color = unchecked ((int)0xffffffff); } v[0].Y = (float)device.PresentationParameters.BackBufferHeight; v[2].Y = (float)device.PresentationParameters.BackBufferHeight; v[2].X = (float)device.PresentationParameters.BackBufferWidth; v[3].X = (float)device.PresentationParameters.BackBufferWidth; v[0].Tu = 0.0f; v[0].Tv = 1.0f; v[1].Tu = 0.0f; v[1].Tv = 0.0f; v[2].Tu = 1.0f; v[2].Tv = 1.0f; v[3].Tu = 1.0f; v[3].Tv = 0.0f; vb.SetData(v, 0, 0); }
public void DrawTexture(Texture tex, Vector3 pos, Vector2 size, int color) { CustomVertex.TransformedColoredTextured[] vb = new CustomVertex.TransformedColoredTextured[4]; pos.X -= 0.5f; pos.Y -= 0.5f; for (int i = 0; i < 4; i++) { vb[i].Color = color; vb[i].Rhw = 1f; vb[i].Z = pos.Z; } vb[0].X = pos.X; vb[0].Y = pos.Y; vb[0].Tu = 0; vb[0].Tv = 0; vb[1].X = pos.X + size.X; vb[1].Y = pos.Y; vb[1].Tu = 1; vb[1].Tv = 0; vb[2].X = pos.X; vb[2].Y = pos.Y + size.Y; vb[2].Tu = 0; vb[2].Tv = 1; vb[3].X = pos.X + size.X; vb[3].Y = pos.Y + size.Y; vb[3].Tu = 1; vb[3].Tv = 1; base.device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; base.device.SetTexture(0, tex); base.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vb); }
public static unsafe void DrawUnsafe() { if ((Engine.m_Device != null) && Validate()) { Stats.Reset(); Engine.m_Device.Clear(3, Color.Black, 1f, 0); Queue toUpdateQueue = m_ToUpdateQueue; if (toUpdateQueue == null) { toUpdateQueue = m_ToUpdateQueue = new Queue(); } else if (toUpdateQueue.Count > 0) { toUpdateQueue.Clear(); } Mobile mobile = null; Engine.m_Device.BeginScene(); try { int num = 0; int num2 = 0; int num3 = 0; bool preserveHue = false; bool flag2 = false; m_xWorld = m_yWorld = m_zWorld = 0; Mobile player = World.Player; if (player != null) { preserveHue = player.Ghost; flag2 = player.Flags[MobileFlag.Warmode]; m_xWorld = num = player.X; m_yWorld = num2 = player.Y; m_zWorld = num3 = player.Z; } m_Dead = preserveHue; m_xScroll = 0; m_yScroll = 0; ArrayList textToDrawList = m_TextToDrawList; if (textToDrawList == null) { textToDrawList = m_TextToDrawList = new ArrayList(); } else if (textToDrawList.Count > 0) { textToDrawList.Clear(); } m_TextToDraw = textToDrawList; Queue miniHealthQueue = m_MiniHealthQueue; if (miniHealthQueue == null) { miniHealthQueue = m_MiniHealthQueue = new Queue(); } else if (miniHealthQueue.Count > 0) { miniHealthQueue.Clear(); } eOffsetX = 0; eOffsetY = 0; if (Engine.m_Ingame) { if (GDesktopBorder.Instance != null) { GDesktopBorder.Instance.DoRender(); } SetViewport(Engine.GameX, Engine.GameY, Engine.GameWidth, Engine.GameHeight); if (m_VertexPool == null) { m_VertexPool = new CustomVertex.TransformedColoredTextured[cellWidth][][]; for (int m = 0; m < cellWidth; m++) { m_VertexPool[m] = new CustomVertex.TransformedColoredTextured[cellHeight][]; for (int n = 0; n < cellHeight; n++) { m_VertexPool[m][n] = VertexConstructor.Create(); } } } Map.Lock(); MapPackage package = Map.GetMap((num >> 3) - (blockWidth >> 1), (num2 >> 3) - (blockHeight >> 1), blockWidth, blockHeight); int num6 = ((num >> 3) - (blockWidth >> 1)) << 3; int num7 = ((num2 >> 3) - (blockHeight >> 1)) << 3; ArrayList[,] cells = package.cells; LandTile[,] landTiles = package.landTiles; byte[,] buffer = package.flags; int[,] colorMap = package.colorMap; int num8 = num & 7; int num9 = num2 & 7; int num10 = ((blockWidth / 2) * 8) + num8; int num11 = ((blockHeight / 2) * 8) + num9; int num12 = 0; int num13 = 0; num12 = Engine.GameWidth >> 1; num12 -= 0x16; num12 += (4 - num8) * 0x16; num12 -= (4 - num9) * 0x16; num13 += (4 - num8) * 0x16; num13 += (4 - num9) * 0x16; num13 += num3 << 2; num13 += ((((Engine.GameHeight >> 1) - ((num10 + num11) * 0x16)) - ((4 - num9) * 0x16)) - ((4 - num8) * 0x16)) - 0x16; num12--; num13--; num12 += Engine.GameX; num13 += Engine.GameY; Mobile mobile3 = World.Player; bool flag3 = false; m_xScroll = m_yScroll = 0; if ((player != null) && (player.Walking.Count > 0)) { WalkAnimation animation = (WalkAnimation) player.Walking.Peek(); int xOffset = 0; int yOffset = 0; int fOffset = 0; if (!animation.Snapshot(ref xOffset, ref yOffset, ref fOffset)) { if (!animation.Advance) { xOffset = animation.xOffset; yOffset = animation.yOffset; } else { xOffset = 0; yOffset = 0; } } num12 -= xOffset; num13 -= yOffset; m_xScroll = xOffset; m_yScroll = yOffset; } if (Engine.m_Quake) { Random random = new Random(); num12 += -2 + random.Next(5); num13 += -2 + random.Next(5); } bool flag4 = (((!m_Invalidate && !Engine.m_Quake) && ((m_CharX == num) && (m_CharY == num2))) && (((m_CharZ == num3) && (m_WasDead == preserveHue)) && (m_xBaseLast == num12))) && (m_yBaseLast == num13); m_xBaseLast = num12; m_yBaseLast = num13; m_Invalidate = false; m_WasDead = preserveHue; m_CharX = num; m_CharY = num2; m_CharZ = num3; int z = 0x7fffffff; int num18 = 0x7fffffff; ArrayList list2 = new ArrayList(); int count = cells[num10 + 1, num11 + 1].Count; for (int i = 0; i < count; i++) { ICell cell = (ICell) cells[num10 + 1, num11 + 1][i]; Type cellType = cell.CellType; if ((cellType == tStaticItem) || (cellType == tDynamicItem)) { ITile tile = (ITile) cell; if ((Map.m_ItemFlags[tile.ID & 0x3fff][TileFlag.Roof] && (tile.Z >= (num3 + 15))) && (tile.Z < z)) { z = tile.Z; } } } count = cells[num10, num11].Count; for (int j = 0; j < count; j++) { ICell cell2 = (ICell) cells[num10, num11][j]; Type type2 = cell2.CellType; if (((type2 == tStaticItem) || (type2 == tDynamicItem)) || (type2 == tLandTile)) { ITile tile2 = (ITile) cell2; if (!Map.GetTileFlags(tile2.ID)[TileFlag.Roof]) { int num22 = (type2 == tLandTile) ? tile2.SortZ : tile2.Z; if (num22 >= (num3 + 15)) { if (type2 == tLandTile) { if (num22 < z) { z = num22; } if ((num3 + 0x10) < num18) { num18 = num3 + 0x10; } } else if (num22 < z) { z = num22; } } } } } m_CullLand = num18 < 0x7fffffff; IHue hue = preserveHue ? Hues.Grayscale : Hues.Default; m_hGray = hue; Queue transDrawQueue = m_TransDrawQueue; if (transDrawQueue == null) { transDrawQueue = m_TransDrawQueue = new Queue(); } else if (transDrawQueue.Count > 0) { transDrawQueue.Clear(); } bool multiPreview = Engine.m_MultiPreview; int num23 = 0; int num24 = 0; int num25 = 0; int num26 = 0; int num27 = 0; int num28 = 0; int num29 = 0; int num30 = 0; int num31 = 0; int num32 = 0; int num33 = 0; int num34 = 0; int num35 = 0; IHue lightRed = null; if (multiPreview) { if (Gumps.IsWorldAt(Engine.m_xMouse, Engine.m_yMouse, true)) { short tileX = 0; short tileY = 0; ICell cell3 = FindTileFromXY(Engine.m_xMouse, Engine.m_yMouse, ref tileX, ref tileY, false); if (cell3 == null) { multiPreview = false; } else if ((cell3.CellType == tLandTile) || (cell3.CellType == tStaticItem)) { num23 = tileX - num6; num24 = tileY - num7; num25 = cell3.Z + ((cell3.CellType == tStaticItem) ? cell3.Height : 0); num27 = Engine.m_MultiList.Count; num23 -= Engine.m_xMultiOffset; num24 -= Engine.m_yMultiOffset; num25 -= Engine.m_zMultiOffset; num28 = num23 + Engine.m_MultiMinX; num29 = num24 + Engine.m_MultiMinY; num30 = num23 + Engine.m_MultiMaxX; num31 = num24 + Engine.m_MultiMaxY; } else { multiPreview = false; } } else { multiPreview = false; } } else if (((Control.ModifierKeys & (Keys.Control | Keys.Shift)) == (Keys.Control | Keys.Shift)) && (((Gumps.LastOver is GSpellIcon) && (((GSpellIcon) Gumps.LastOver).m_SpellID == 0x39)) || ((Gumps.LastOver is GContainerItem) && ((((GContainerItem) Gumps.LastOver).Item.ID & 0x3fff) == 0x1f65)))) { int num38 = 1 + ((int) (Engine.Skills[SkillName.Magery].Value / 15f)); if (m_LightRed == null) { m_LightRed = new Hues.HTemperedHue(Engine.C32216(0xff0000), 80); } lightRed = m_LightRed; num32 = (player.X - num6) - num38; num33 = (player.Y - num7) - num38; num34 = (player.X - num6) + num38; num35 = (player.Y - num7) + num38; } else if (Engine.TargetHandler is ServerTargetHandler) { ServerTargetHandler targetHandler = (ServerTargetHandler) Engine.TargetHandler; IHue lightBlue = null; int num39 = -1; bool flag6 = false; if ((targetHandler.Action == TargetAction.MeteorSwarm) || (targetHandler.Action == TargetAction.ChainLightning)) { if (m_LightRed == null) { m_LightRed = new Hues.HTemperedHue(Engine.C32216(0xff0000), 80); } lightBlue = m_LightRed; num39 = 2; } else if (targetHandler.Action == TargetAction.MassCurse) { if (m_LightRed == null) { m_LightRed = new Hues.HTemperedHue(Engine.C32216(0xff0000), 80); } lightBlue = m_LightRed; num39 = 3; } else if (targetHandler.Action == TargetAction.Reveal) { if (m_LightBlue == null) { m_LightBlue = new Hues.HTemperedHue(Engine.C32216(0x99ccff), 80); } lightBlue = m_LightBlue; num39 = 1 + ((int) (Engine.Skills[SkillName.Magery].Value / 20f)); } else if (targetHandler.Action == TargetAction.DetectHidden) { if (m_LightBlue == null) { m_LightBlue = new Hues.HTemperedHue(Engine.C32216(0x99ccff), 80); } lightBlue = m_LightBlue; num39 = (int) (Engine.Skills[SkillName.DetectingHidden].Value / 10f); } else if (targetHandler.Action == TargetAction.ArchProtection) { if (m_LightBlue == null) { m_LightBlue = new Hues.HTemperedHue(Engine.C32216(0x99ccff), 80); } lightBlue = m_LightBlue; num39 = Engine.Features.AOS ? 2 : 3; } else if (targetHandler.Action == TargetAction.ArchCure) { if (m_LightBlue == null) { m_LightBlue = new Hues.HTemperedHue(Engine.C32216(0x99ccff), 80); } lightBlue = m_LightBlue; num39 = 3; } else if (targetHandler.Action == TargetAction.WallOfStone) { if (m_LightRed == null) { m_LightRed = new Hues.HTemperedHue(Engine.C32216(0xff0000), 80); } lightBlue = m_LightRed; num39 = 1; flag6 = true; } else if (((targetHandler.Action == TargetAction.EnergyField) || (targetHandler.Action == TargetAction.FireField)) || ((targetHandler.Action == TargetAction.ParalyzeField) || (targetHandler.Action == TargetAction.PoisonField))) { if (m_LightRed == null) { m_LightRed = new Hues.HTemperedHue(Engine.C32216(0xff0000), 80); } lightBlue = m_LightRed; num39 = 2; flag6 = true; } if ((lightBlue != null) && Gumps.IsWorldAt(Engine.m_xMouse, Engine.m_yMouse, true)) { short num40 = 0; short num41 = 0; ICell cell4 = FindTileFromXY(Engine.m_xMouse, Engine.m_yMouse, ref num40, ref num41, false); if ((cell4 != null) && (((cell4.CellType == tLandTile) || (cell4.CellType == tStaticItem)) || ((cell4.CellType == tMobileCell) || (cell4.CellType == tDynamicItem)))) { lightRed = lightBlue; if (num39 >= 0) { if (flag6) { bool flag7; int num42 = player.X - num40; int num43 = player.Y - num41; int num44 = num42 - num43; int num45 = num42 + num43; if ((num44 >= 0) && (num45 >= 0)) { flag7 = false; } else if (num44 >= 0) { flag7 = true; } else if (num45 >= 0) { flag7 = true; } else { flag7 = false; } if (flag7) { num32 = (num40 - num6) - num39; num34 = (num40 - num6) + num39; num33 = num41 - num7; num35 = num41 - num7; } else { num32 = num40 - num6; num34 = num40 - num6; num33 = (num41 - num7) - num39; num35 = (num41 - num7) + num39; } } else { num32 = (num40 - num6) - num39; num33 = (num41 - num7) - num39; num34 = (num40 - num6) + num39; num35 = (num41 - num7) + num39; } } } } } int id = 0; int num47 = 0; IHue hue4 = null; bool flag8 = false; bool flag9 = false; DynamicItem item = null; StaticItem item2 = null; Item owner = null; bool xDouble = false; ArrayList equip = null; int num48 = (cellWidth < cellHeight) ? (cellWidth - 1) : (cellHeight - 1); if (num18 < 0x7fffffff) { colorMap = package.frameColors; int[,] realColors = package.realColors; for (int num49 = -1; num49 < (cellHeight - 1); num49++) { for (int num50 = -1; num50 < (cellWidth - 1); num50++) { colorMap[num50 + 1, num49 + 1] = realColors[num50 + 1, num49 + 1]; if ((num50 >= 0) && (num49 >= 0)) { LandTile tile3 = landTiles[num50, num49]; if (tile3.m_FoldLeftRight) { bool flag11 = ((landTiles[num50, num49].Z <= num18) && (landTiles[num50, num49 + 1].Z <= num18)) && (landTiles[num50 + 1, num49 + 1].Z <= num18); bool flag12 = ((landTiles[num50, num49].Z <= num18) && (landTiles[num50 + 1, num49].Z <= num18)) && (landTiles[num50 + 1, num49 + 1].Z <= num18); if (!flag11 && !flag12) { colorMap[num50, num49] = 0; colorMap[num50 + 1, num49] = 0; colorMap[num50 + 1, num49 + 1] = 0; colorMap[num50, num49 + 1] = 0; } else if (!flag11) { colorMap[num50, num49] = 0; colorMap[num50 + 1, num49 + 1] = 0; colorMap[num50, num49 + 1] = 0; } else if (!flag12) { colorMap[num50, num49] = 0; colorMap[num50 + 1, num49 + 1] = 0; colorMap[num50 + 1, num49] = 0; } } else { bool flag13 = ((landTiles[num50, num49].Z <= num18) && (landTiles[num50, num49 + 1].Z <= num18)) && (landTiles[num50 + 1, num49].Z <= num18); bool flag14 = ((landTiles[num50 + 1, num49].Z <= num18) && (landTiles[num50, num49 + 1].Z <= num18)) && (landTiles[num50 + 1, num49 + 1].Z <= num18); if (!flag13 && !flag14) { colorMap[num50, num49] = 0; colorMap[num50 + 1, num49] = 0; colorMap[num50 + 1, num49 + 1] = 0; colorMap[num50, num49 + 1] = 0; } else if (!flag13) { colorMap[num50, num49] = 0; colorMap[num50 + 1, num49] = 0; colorMap[num50, num49 + 1] = 0; } else if (!flag14) { colorMap[num50 + 1, num49 + 1] = 0; colorMap[num50 + 1, num49] = 0; colorMap[num50, num49 + 1] = 0; } } } } } } for (int k = 0; k < ((num48 * 2) - 1); k++) { int y = k; int num53 = 0; if (y >= num48) { num53 = (k - num48) + 1; y = num48 - 1; } int x = num53; while ((x < num48) && (y >= 0)) { int bx = ((x - y) * 0x16) + num12; int by = ((x + y) * 0x16) + num13; int num57 = cells[x, y].Count; for (int num58 = 0; num58 < num57; num58++) { TileFlags flags; Texture texture; float num69; bool flag17; int num71; int num72; ICell cell5 = (ICell) cells[x, y][num58]; Type type3 = cell5.CellType; if ((type3 != tStaticItem) && (type3 != tDynamicItem)) { goto Label_177B; } flag8 = type3 == tStaticItem; flag9 = !flag8; IItem item3 = (IItem) cell5; if (flag8) { item2 = (StaticItem) item3; id = item2.m_ID; switch (id) { case 0x4001: case 0x5796: case 0x61a4: case 0x6198: case 0x61bc: case 0x6199: { continue; } } num47 = item2.m_Z; flags = Map.m_ItemFlags[id & 0x3fff]; if ((z < 0x7fffffff) && ((num47 >= z) || flags[TileFlag.Roof])) { continue; } hue4 = item2.m_Hue; xDouble = false; } else { item = (DynamicItem) item3; id = item.m_ID; switch (id) { case 0x4001: case 0x5796: case 0x61a4: case 0x6198: case 0x61bc: case 0x6199: { continue; } } num47 = item.m_Z; flags = Map.m_ItemFlags[id & 0x3fff]; if ((z < 0x7fffffff) && ((num47 >= z) || flags[TileFlag.Roof])) { continue; } hue4 = item.m_Hue; owner = item.m_Item; id = Map.GetDispID(id, (ushort) owner.Amount, ref xDouble); } bool flag15 = false; if ((((lightRed != null) && (x >= num32)) && ((y >= num33) && (x <= num34))) && (y <= num35)) { hue4 = lightRed; flag15 = true; } if ((flag4 && flag8) && !flag15) { StaticItem item5 = item2; if (item5.m_bInit) { if (item5.m_bDraw) { if (item5.m_bAlpha) { if (!m_AlphaEnable) { m_AlphaEnable = true; } m_fAlpha = ((float) item5.m_vAlpha) / 255f; m_Alpha = item5.m_vAlpha << 0x18; } else if (m_AlphaEnable) { m_AlphaEnable = false; } if (!m_AlphaTestEnable) { m_AlphaTestEnable = true; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } m_Texture = item5.m_sDraw; fixed (CustomVertex.TransformedColoredTextured* texturedRef = item5.m_vPool) { PushQuad(texturedRef); } } continue; } } if ((!flag8 && (owner != null)) && (owner.ID == 0x2006)) { IHue hue5; int amount = owner.Amount; CorpseTableEntry entry = (CorpseTableEntry) CorpseTable.m_Entries[amount]; if ((entry != null) && (BodyConverter.GetFileSet(amount) == 1)) { amount = entry.m_OldID; hue4 = Hues.Load(entry.m_NewHue ^ 0x8000); } int animDirection = Engine.GetAnimDirection(owner.Direction); int actionID = Engine.m_Animations.ConvertAction(amount, owner.Serial, owner.X, owner.Y, animDirection, GenericAction.Die, null); int num63 = Engine.m_Animations.GetFrameCount(amount, actionID, animDirection); int xCenter = bx + 0x17; int yCenter = (by - (num47 << 2)) + 20; if (preserveHue) { hue5 = hue; } else { hue5 = hue4; } int textureX = 0; int textureY = 0; if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } if (!m_AlphaTestEnable) { m_AlphaTestEnable = true; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } Frame frame = Engine.m_Animations.GetFrame(owner, amount, actionID, animDirection, num63 - 1, xCenter, yCenter, hue5, ref textureX, ref textureY, preserveHue); owner.DrawGame(frame.Image, textureX, textureY); owner.MessageX = (textureX + frame.Image.xMin) + ((frame.Image.xMax - frame.Image.xMin) / 2); owner.MessageY = textureY; owner.BottomY = textureY + frame.Image.yMax; owner.MessageFrame = m_ActFrames; for (int num68 = 0; num68 < owner.CorpseEquip.Count; num68++) { EquipEntry entry2 = (EquipEntry) owner.CorpseEquip[num68]; if (owner.Items.Contains(entry2.m_Item)) { if (!preserveHue) { hue5 = Hues.Load(entry2.m_Item.Hue); } frame = Engine.m_Animations.GetFrame(entry2.m_Item, entry2.m_Animation, actionID, animDirection, num63 - 1, xCenter, yCenter, hue5, ref textureX, ref textureY, preserveHue); entry2.m_Item.DrawGame(frame.Image, textureX, textureY); } } } else { IHue grayscale; texture = null; num69 = 1f; flag17 = false; int itemID = id & 0x3fff; bool flag18 = false; if (preserveHue) { grayscale = hue; } else if (flag8) { grayscale = hue4; } else if ((owner != null) && owner.Flags[ItemFlag.Hidden]) { grayscale = Hues.Grayscale; flag17 = true; num69 = 0.5f; } else if ((owner != null) && ((owner.Hue & 0x4000) != 0)) { grayscale = Hues.Load(0xbb8); flag17 = true; num69 = 1f; flag18 = true; } else { grayscale = hue4; } AnimData anim = Map.GetAnim(itemID); if ((anim.frameCount == 0) || !flags[TileFlag.Animation]) { texture = item3.GetItem(grayscale, (short) id); } else { texture = item3.GetItem(grayscale, (short) (id + anim[(m_Frames / (anim.frameInterval + 1)) % anim.frameCount])); } if ((texture != null) && !texture.IsEmpty()) { num71 = (bx + 0x16) - (texture.Width >> 1); num72 = ((by - (num47 << 2)) + 0x2b) - texture.Height; if (flag3 && flags[TileFlag.Foliage]) { Rectangle rectangle = new Rectangle(num71 + texture.xMin, num72 + texture.yMin, texture.xMax, texture.yMax); if (rectangle.IntersectsWith(m_FoliageCheck)) { flag17 = true; num69 *= 0.4f; } } else if (flags[TileFlag.Translucent]) { flag17 = true; num69 *= 0.9f; } if (m_AlphaEnable != flag17) { SetAlphaEnablePrecalc(flag17); } if (flag17) { SetAlpha(num69); } if (!m_AlphaTestEnable) { m_AlphaTestEnable = true; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } if (!flag9) { goto Label_170C; } if (owner != null) { if (flag18) { SetBlendType(DrawBlendType.BlackTransparency); } owner.DrawGame(texture, num71, num72); if (xDouble) { owner.DrawGame(texture, num71 + 5, num72 + 5); } if (flag18) { SetBlendType(DrawBlendType.Normal); } goto Label_16A2; } texture.DrawGame(num71, num72); if (xDouble) { texture.DrawGame(num71 + 5, num72 + 5); } } } continue; Label_16A2: if (m_Transparency) { transDrawQueue.Enqueue(TransparentDraw.PoolInstance(texture, num71, num72, flag17, num69, xDouble)); } owner.MessageX = (num71 + texture.xMin) + ((texture.xMax - texture.xMin) / 2); owner.MessageY = num72; owner.BottomY = num72 + texture.yMax; owner.MessageFrame = m_ActFrames; continue; Label_170C: if (flags[TileFlag.Animation]) { texture.DrawGame(num71, num72, item2.m_vPool); } else { item2.m_bDraw = texture.DrawGame(num71, num72, item2.m_vPool); item2.m_vAlpha = (byte) (m_Alpha >> 0x18); item2.m_bInit = !flag15; item2.m_bAlpha = flag17; item2.m_sDraw = texture; } continue; Label_177B: if (type3 == tLandTile) { LandTile lt = (LandTile) cell5; num47 = lt.m_Z; int iD = lt.m_ID; if (iD != 2) { int num74 = bx; int num75 = by; int num76 = package.CellX + x; int num77 = package.CellY + y; bool flag19 = false; if ((((lightRed != null) && (x >= num32)) && ((y >= num33) && (x <= num34))) && (y <= num35)) { flag19 = true; } if ((flag4 && lt.m_bInit) && !flag19) { if (lt.m_bDraw) { AlphaTestEnable = !lt.m_bFilter; if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } SetTexture(lt.m_sDraw); if (m_FilterEnable != lt.m_bFilter) { SetFilterEnablePrecalc(!m_FilterEnable); } DrawQuadPrecalc(lt.m_vDraw); if (m_DrawGrid) { Grid(lt, landTiles, x, y, bx, by); } if (((num76 == m_xServerStart) || (num76 == m_xServerEnd)) && ((num77 >= m_yServerStart) && (num77 < m_yServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } else if ((x > 0) && (lt.m_Guarded != landTiles[x - 1, y].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } if (((num77 == m_yServerStart) || (num77 == m_yServerEnd)) && ((num76 >= m_xServerStart) && (num76 < m_xServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } else if ((y > 0) && (lt.m_Guarded != landTiles[x, y - 1].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } } } else { CustomVertex.TransformedColoredTextured[] texturedArray; IHue hue7 = flag19 ? lightRed : hue; int textureID = Map.GetTexture(iD); if ((((buffer[x, y] & 1) == 0) || (textureID == 0)) || (textureID >= 0x1000)) { Texture land = hue7.GetLand(iD); if ((land != null) && !land.IsEmpty()) { if ((num18 < 0x7fffffff) && (num47 >= num18)) { lt.m_bDraw = false; lt.m_bInit = true; } else { AlphaTestEnable = true; if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } texturedArray = m_VertexPool[x][y]; lt.m_bDraw = land.DrawGame(num74, num75 - (num47 << 2), texturedArray); lt.m_vDraw = texturedArray; lt.m_bInit = !flag19; lt.m_sDraw = land; lt.m_bFilter = false; if (m_DrawGrid) { Grid(lt, landTiles, x, y, bx, by); } if (((num76 == m_xServerStart) || (num76 == m_xServerEnd)) && ((num77 >= m_yServerStart) && (num77 < m_yServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } else if ((x > 0) && (lt.m_Guarded != landTiles[x - 1, y].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } if (((num77 == m_yServerStart) || (num77 == m_yServerEnd)) && ((num76 >= m_xServerStart) && (num76 < m_xServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } else if ((y > 0) && (lt.m_Guarded != landTiles[x, y - 1].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } } } } else { Texture texture3 = hue7.GetTexture(textureID); if ((texture3 == null) || texture3.IsEmpty()) { texture3 = hue7.GetTexture(1); if ((texture3 == null) || texture3.IsEmpty()) { continue; } } if ((num74 >= (Engine.GameX + Engine.GameWidth)) || ((num74 + 0x2c) <= Engine.GameX)) { lt.m_vDraw = null; lt.m_bDraw = false; lt.m_bInit = true; lt.m_sDraw = null; lt.m_bFilter = false; } else { texturedArray = m_VertexPool[x][y]; fixed (CustomVertex.TransformedColoredTextured* texturedRef2 = texturedArray) { if (lt.m_FoldLeftRight) { texturedRef2[1].X = num74 + 0x16; texturedRef2[1].Y = num75 - (num47 << 2); texturedRef2->Y = (num75 + 0x16) - (landTiles[x + 1, y].m_Z << 2); texturedRef2->X = num74 + 0x2c; texturedRef2[2].Y = (num75 + 0x2c) - (landTiles[x + 1, y + 1].m_Z << 2); texturedRef2[2].X = num74 + 0x16; texturedRef2[3].Y = (num75 + 0x16) - (landTiles[x, y + 1].m_Z << 2); texturedRef2[3].X = num74; if ((((texturedRef2->Y < Engine.GameY) || (texturedRef2->Y >= (Engine.GameY + Engine.GameHeight))) && ((texturedRef2[1].Y < Engine.GameY) || (texturedRef2[1].Y >= (Engine.GameY + Engine.GameHeight)))) && (((texturedRef2[2].Y < Engine.GameY) || (texturedRef2[2].Y >= (Engine.GameY + Engine.GameHeight))) && ((texturedRef2[3].Y < Engine.GameY) || (texturedRef2[3].Y >= (Engine.GameY + Engine.GameHeight))))) { lt.m_vDraw = texturedArray; lt.m_bDraw = false; lt.m_bInit = true; lt.m_sDraw = null; lt.m_bFilter = false; continue; } texturedRef2[2].Color = colorMap[x + 1, y + 1]; texturedRef2->Color = colorMap[x + 1, y]; texturedRef2[3].Color = colorMap[x, y + 1]; texturedRef2[1].Color = colorMap[x, y]; if (texture3.Width == 0x2c) { texturedRef2[1].Tu = 0.5f * texture3.MaxTU; texturedRef2[1].Tv = 0f; texturedRef2->Tu = 1f * texture3.MaxTU; texturedRef2->Tv = 0.5f * texture3.MaxTV; texturedRef2[2].Tu = 0.5f * texture3.MaxTU; texturedRef2[2].Tv = 1f * texture3.MaxTV; texturedRef2[3].Tu = 0f; texturedRef2[3].Tv = 0.5f * texture3.MaxTV; texturedRef2->Color = ((texturedRef2->Color & 0xff) * 0xff) / 210; texturedRef2[1].Color = ((texturedRef2[1].Color & 0xff) * 0xff) / 210; texturedRef2[2].Color = ((texturedRef2[2].Color & 0xff) * 0xff) / 210; texturedRef2[3].Color = ((texturedRef2[3].Color & 0xff) * 0xff) / 210; if (texturedRef2->Color < 0) { texturedRef2->Color = 0; } else if (texturedRef2->Color > 0xff) { texturedRef2->Color = 0xffffff; } else { IntPtr ptr1 = texturedRef2; ptr1.Color *= 0x10101; } if (texturedRef2[1].Color < 0) { texturedRef2[1].Color = 0; } else if (texturedRef2[1].Color > 0xff) { texturedRef2[1].Color = 0xffffff; } else { IntPtr ptr2 = texturedRef2 + 1; ptr2.Color *= 0x10101; } if (texturedRef2[2].Color < 0) { texturedRef2[2].Color = 0; } else if (texturedRef2[2].Color > 0xff) { texturedRef2[2].Color = 0xffffff; } else { IntPtr ptr3 = texturedRef2 + 2; ptr3.Color *= 0x10101; } if (texturedRef2[3].Color < 0) { texturedRef2[3].Color = 0; } else if (texturedRef2[3].Color > 0xff) { texturedRef2[3].Color = 0xffffff; } else { IntPtr ptr4 = texturedRef2 + 3; ptr4.Color *= 0x10101; } } else { texturedRef2->Tv = 0f; texturedRef2[1].Tv = 0f; texturedRef2[1].Tu = 0f; texturedRef2[3].Tu = 0f; texturedRef2->Tu = 1f; texturedRef2[2].Tu = 1f; texturedRef2[2].Tv = 1f; texturedRef2[3].Tv = 1f; } if (num18 < 0x7fffffff) { bool flag20 = ((landTiles[x, y].Z <= num18) && (landTiles[x, y + 1].Z <= num18)) && (landTiles[x + 1, y + 1].Z <= num18); bool flag21 = ((landTiles[x, y].Z <= num18) && (landTiles[x + 1, y].Z <= num18)) && (landTiles[x + 1, y + 1].Z <= num18); if (!flag20 && !flag21) { lt.m_vDraw = texturedArray; lt.m_bDraw = false; lt.m_bInit = true; lt.m_sDraw = null; lt.m_bFilter = false; continue; } if (!flag20) { texturedRef2[1].Color = texturedRef2[2].Color = 0; texturedRef2[3] = texturedRef2[1]; } else if (!flag21) { texturedRef2[1].Color = texturedRef2[2].Color = 0; texturedRef2 = texturedRef2[1]; } } } else { texturedRef2[3].X = num74 + 0x16; texturedRef2[3].Y = num75 - (num47 << 2); texturedRef2[1].Y = (num75 + 0x16) - (landTiles[x + 1, y].m_Z << 2); texturedRef2[1].X = num74 + 0x2c; texturedRef2->Y = (num75 + 0x2c) - (landTiles[x + 1, y + 1].m_Z << 2); texturedRef2->X = num74 + 0x16; texturedRef2[2].Y = (num75 + 0x16) - (landTiles[x, y + 1].m_Z << 2); texturedRef2[2].X = num74; if ((((texturedRef2->Y < Engine.GameY) || (texturedRef2->Y >= (Engine.GameY + Engine.GameHeight))) && ((texturedRef2[1].Y < Engine.GameY) || (texturedRef2[1].Y >= (Engine.GameY + Engine.GameHeight)))) && (((texturedRef2[2].Y < Engine.GameY) || (texturedRef2[2].Y >= (Engine.GameY + Engine.GameHeight))) && ((texturedRef2[3].Y < Engine.GameY) || (texturedRef2[3].Y >= (Engine.GameY + Engine.GameHeight))))) { lt.m_vDraw = texturedArray; lt.m_bDraw = false; lt.m_bInit = true; lt.m_sDraw = null; lt.m_bFilter = false; continue; } texturedRef2->Color = colorMap[x + 1, y + 1]; texturedRef2[1].Color = colorMap[x + 1, y]; texturedRef2[2].Color = colorMap[x, y + 1]; texturedRef2[3].Color = colorMap[x, y]; if (texture3.Width == 0x2c) { texturedRef2[3].Tu = 0.5f * texture3.MaxTU; texturedRef2[3].Tv = 0f; texturedRef2[1].Tu = 1f * texture3.MaxTU; texturedRef2[1].Tv = 0.5f * texture3.MaxTV; texturedRef2->Tu = 0.5f * texture3.MaxTU; texturedRef2->Tv = 1f * texture3.MaxTV; texturedRef2[2].Tu = 0f; texturedRef2[2].Tv = 0.5f * texture3.MaxTV; texturedRef2->Color = ((texturedRef2->Color & 0xff) * 0xff) / 210; texturedRef2[1].Color = ((texturedRef2[1].Color & 0xff) * 0xff) / 210; texturedRef2[2].Color = ((texturedRef2[2].Color & 0xff) * 0xff) / 210; texturedRef2[3].Color = ((texturedRef2[3].Color & 0xff) * 0xff) / 210; if (texturedRef2->Color < 0) { texturedRef2->Color = 0; } else if (texturedRef2->Color > 0xff) { texturedRef2->Color = 0xffffff; } else { IntPtr ptr5 = texturedRef2; ptr5.Color *= 0x10101; } if (texturedRef2[1].Color < 0) { texturedRef2[1].Color = 0; } else if (texturedRef2[1].Color > 0xff) { texturedRef2[1].Color = 0xffffff; } else { IntPtr ptr6 = texturedRef2 + 1; ptr6.Color *= 0x10101; } if (texturedRef2[2].Color < 0) { texturedRef2[2].Color = 0; } else if (texturedRef2[2].Color > 0xff) { texturedRef2[2].Color = 0xffffff; } else { IntPtr ptr7 = texturedRef2 + 2; ptr7.Color *= 0x10101; } if (texturedRef2[3].Color < 0) { texturedRef2[3].Color = 0; } else if (texturedRef2[3].Color > 0xff) { texturedRef2[3].Color = 0xffffff; } else { IntPtr ptr8 = texturedRef2 + 3; ptr8.Color *= 0x10101; } } else { texturedRef2[1].Tv = 0f; texturedRef2[2].Tu = 0f; texturedRef2[3].Tu = 0f; texturedRef2[3].Tv = 0f; texturedRef2->Tv = 1f; texturedRef2->Tu = 1f; texturedRef2[1].Tu = 1f; texturedRef2[2].Tv = 1f; } if (num18 < 0x7fffffff) { bool flag22 = ((landTiles[x, y].Z <= num18) && (landTiles[x, y + 1].Z <= num18)) && (landTiles[x + 1, y].Z <= num18); bool flag23 = ((landTiles[x + 1, y].Z <= num18) && (landTiles[x, y + 1].Z <= num18)) && (landTiles[x + 1, y + 1].Z <= num18); if (!flag22 && !flag23) { lt.m_vDraw = texturedArray; lt.m_bDraw = false; lt.m_bInit = true; lt.m_sDraw = null; lt.m_bFilter = false; continue; } if (!flag22) { texturedRef2[3] = texturedRef2[1]; } else if (!flag23) { texturedRef2 = texturedRef2[1]; } } } IntPtr ptr9 = texturedRef2; ptr9.X -= 0.5f; IntPtr ptr10 = texturedRef2; ptr10.Y -= 0.5f; IntPtr ptr11 = texturedRef2 + 1; ptr11.X -= 0.5f; IntPtr ptr12 = texturedRef2 + 1; ptr12.Y -= 0.5f; IntPtr ptr13 = texturedRef2 + 2; ptr13.X -= 0.5f; IntPtr ptr14 = texturedRef2 + 2; ptr14.Y -= 0.5f; IntPtr ptr15 = texturedRef2 + 3; ptr15.X -= 0.5f; IntPtr ptr16 = texturedRef2 + 3; ptr16.Y -= 0.5f; if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } if (!m_FilterEnable) { SetFilterEnablePrecalc(true); } AlphaTestEnable = false; SetTexture(texture3); DrawQuadPrecalc(texturedRef2); } lt.m_vDraw = texturedArray; lt.m_bDraw = true; lt.m_bInit = !flag19; lt.m_bFilter = true; lt.m_sDraw = texture3; if (m_DrawGrid) { Grid(lt, landTiles, x, y, bx, by); } if (((num76 == m_xServerStart) || (num76 == m_xServerEnd)) && ((num77 >= m_yServerStart) && (num77 < m_yServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } else if ((x > 0) && (lt.m_Guarded != landTiles[x - 1, y].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 0, 1); } if (((num77 == m_yServerStart) || (num77 == m_yServerEnd)) && ((num76 >= m_xServerStart) && (num76 < m_xServerEnd))) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } else if ((y > 0) && (lt.m_Guarded != landTiles[x, y - 1].m_Guarded)) { DrawMapLine(landTiles, num74, num75, x, y, 1, 0); } } } } } } else if (((type3 == tMobileCell) || (type3 == tCorpseCell)) && ((z >= 0x7fffffff) || (cell5.Z < z))) { IAnimatedCell cell6 = (IAnimatedCell) cell5; int body = 0; int direction = 0; int num81 = 0; int action = 0; int num83 = 0; bool flag24 = type3 == tMobileCell; Mobile mobile4 = flag24 ? ((MobileCell) cell5).m_Mobile : null; int frames = 0; int num85 = 0; int num86 = 0; if (flag24 && (mobile4 != null)) { equip = mobile4.Equip; if (mobile4.Player) { flag3 = true; } if (mobile4.Walking.Count > 0) { WalkAnimation animation2 = (WalkAnimation) mobile4.Walking.Peek(); if (!animation2.Snapshot(ref num85, ref num86, ref frames)) { if (!animation2.Advance) { num85 = animation2.xOffset; num86 = animation2.yOffset; } else { num85 = 0; num86 = 0; } frames = animation2.Frames; mobile4.SetLocation((short) animation2.NewX, (short) animation2.NewY, (short) animation2.NewZ); ((WalkAnimation) mobile4.Walking.Dequeue()).Dispose(); if (mobile4.Player) { if (Engine.amMoving) { Engine.DoWalk(Engine.movingDir, true); } eOffsetX += num85; eOffsetY += num86; } if (mobile4.Walking.Count == 0) { Engine.EquipSort(mobile4, animation2.NewDir); mobile4.Direction = (byte) animation2.NewDir; mobile4.IsMoving = false; mobile4.MovedTiles = 0; mobile4.HorseFootsteps = 0; } else { ((WalkAnimation) mobile4.Walking.Peek()).Start(); } toUpdateQueue.Enqueue(mobile4); } } } cell6.GetPackage(ref body, ref action, ref direction, ref num83, ref num81); int num87 = num83; int num88 = Engine.m_Animations.GetFrameCount(body, action, direction); if (num88 != 0) { IHue notoriety; Frame frame2; num87 = num87 % num88; int num89 = bx + 0x16; int num90 = (by - (cell6.Z << 2)) + 0x16; num89++; num90 -= 2; num89 += num85; num90 += num86; if (frames != 0) { num87 += frames; num87 = num87 % num88; num83 += frames; num83 = num83 % num88; } if (flag24 && (mobile4 != null)) { if ((mobile4.Human && mobile4.IsMoving) && (mobile4.LastFrame != num83)) { int num143; if ((equip.Count > 0) && (((EquipEntry) equip[0]).m_Layer == Layer.Mount)) { if ((direction & 0x80) == 0x80) { if ((mobile4.HorseFootsteps != mobile4.MovedTiles) && ((mobile4.MovedTiles & 1) == 1)) { mobile4.Sounds = (num143 = mobile4.Sounds) + 1; int soundID = 0x129 + (num143 & 1); Engine.Sounds.PlaySound(soundID, mobile4.X, mobile4.Y, mobile4.Z, 0.8f); mobile4.HorseFootsteps = mobile4.MovedTiles; } } else if ((mobile4.HorseFootsteps != mobile4.MovedTiles) && ((mobile4.MovedTiles & 1) == 1)) { mobile4.Sounds = (num143 = mobile4.Sounds) + 1; int num92 = 0x12b + (num143 & 1); Engine.Sounds.PlaySound(num92, mobile4.X, mobile4.Y, mobile4.Z, 0.8f); mobile4.HorseFootsteps = mobile4.MovedTiles; } } else { switch (num83) { case 1: case 6: { mobile4.Sounds = (num143 = mobile4.Sounds) + 1; int num93 = 0x12b + (num143 & 1); Engine.Sounds.PlaySound(num93, mobile4.X, mobile4.Y, mobile4.Z, 0.65f); break; } } } } mobile4.LastFrame = num83; } bool ghost = false; bool flag26 = false; IHue hue9 = null; bool enable = false; bool flag28 = false; float alpha = 1f; if (preserveHue) { notoriety = hue; flag26 = true; hue9 = notoriety; if (flag24 && (mobile4 != null)) { ghost = mobile4.Ghost; } } else if ((((lightRed != null) && (x >= num32)) && ((y >= num33) && (x <= num34))) && (y <= num35)) { notoriety = lightRed; flag26 = true; hue9 = notoriety; flag28 = false; } else if (flag24) { if (mobile4 != null) { ghost = mobile4.Ghost; if ((mobile4.Flags.Value & -223) != 0) { notoriety = Hues.Load(0x8485); flag26 = true; hue9 = notoriety; flag28 = false; } else if (mobile4.Flags[MobileFlag.Hidden]) { notoriety = Hues.Grayscale; flag26 = true; hue9 = notoriety; } else if (((Engine.m_Highlight == mobile4) || (m_AlwaysHighlight == mobile4.Serial)) && !mobile4.Player) { notoriety = Hues.GetNotoriety(mobile4.Notoriety); flag26 = true; hue9 = notoriety; flag28 = true; } else if (mobile4.Ignored) { notoriety = Hues.Load(0x8035); flag26 = true; hue9 = notoriety; flag28 = true; } else if (mobile4.Bonded) { notoriety = Hues.Grayscale; flag26 = true; hue9 = notoriety; flag28 = true; } else if ((mobile4.Hue & 0x4000) != 0) { notoriety = Hues.Load(0x8bb8); } else { notoriety = Hues.Load(num81); } } else { notoriety = Hues.Load(num81); } } else { notoriety = Hues.Load(num81); } int num95 = 0; int num96 = 0; try { frame2 = Engine.m_Animations.GetFrame(mobile4, body, action, direction, num87, num89, num90, notoriety, ref num95, ref num96, flag26); } catch { frame2 = Engine.m_Animations.GetFrame(mobile4, body, action, direction, num87, num89, num90, notoriety, ref num95, ref num96, flag26); } bool flag29 = false; bool alphaEnable = false; bool flag31 = false; float fAlpha = 1f; int num98 = -1; int num99 = -1; Texture t = null; if ((frame2.Image != null) && !frame2.Image.IsEmpty()) { if (flag24 && (mobile4 != null)) { mobile4.MessageFrame = m_ActFrames; mobile4.ScreenX = mobile4.MessageX = num89; mobile4.ScreenY = num90; mobile4.MessageY = num96; if (mobile4.Player) { m_FoliageCheck = new Rectangle(num95, num96, frame2.Image.Width, frame2.Image.Height); } } if (((flag2 && flag24) && ((mobile4 != null) && !mobile4.Player)) && (((mobile4.Notoriety >= Notoriety.Innocent) && (mobile4.Notoriety <= Notoriety.Vendor)) && World.CharData.Halos)) { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } SetAlpha(1f); ColorAlphaEnable = true; Engine.m_Halo.DrawGame(num89 - (Engine.m_Halo.Width >> 1), num90 - (Engine.m_Halo.Height >> 1), Engine.C16232(Hues.GetNotorietyData(mobile4.Notoriety).colors[0x2f]), m_vHaloPool); ColorAlphaEnable = false; } bool flag32 = false; if (flag24 && (mobile4 != null)) { if ((mobile4.Flags[MobileFlag.Hidden] || (body == 970)) || (mobile4.Bonded || mobile4.Ghost)) { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(0.5f); enable = true; alpha = 0.5f; } else if ((mobile4.Hue & 0x4000) != 0) { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(1f); alpha = 1f; flag32 = true; } else if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } } else if (body == 970) { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(0.5f); enable = true; alpha = 0.5f; } else if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } flag29 = type3 == tMobileCell; if (flag29) { if (((mobile4 != null) && mobile4.HumanOrGhost) && ((equip.Count > 0) && (((EquipEntry) equip[0]).m_Layer == Layer.Mount))) { alphaEnable = m_AlphaEnable; fAlpha = m_fAlpha; flag31 = flag32; t = frame2.Image; num98 = num95; num99 = num96; } else { flag29 = false; } } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } AlphaTestEnable = true; if (!ghost && !flag29) { if ((((num96 >= ((Engine.GameY + Engine.GameHeight) + 30)) || ((num96 + frame2.Image.Height) <= (Engine.GameY - 30))) || (num95 >= ((Engine.GameX + Engine.GameWidth) + 30))) || ((num95 + frame2.Image.Width) <= (Engine.GameX - 30))) { continue; } if (flag32) { SetBlendType(DrawBlendType.BlackTransparency); } if (flag24 && (mobile4 != null)) { mobile4.DrawGame(frame2.Image, num95, num96); } else { frame2.Image.DrawGame(num95, num96); } if (flag32) { SetBlendType(DrawBlendType.Normal); } } } if (type3 == tCorpseCell) { Item item6 = World.FindItem(((CorpseCell) cell5).Serial); if ((item6 != null) && (Engine.m_Animations.GetBodyType(body) == BodyType.Human)) { int num100 = item6.Equip.Count; for (int num101 = 0; num101 < num100; num101++) { EquipEntry entry3 = (EquipEntry) item6.Equip[num101]; int bodyID = entry3.m_Animation; if (!flag26) { notoriety = Hues.GetItemHue(item6.ID, entry3.m_Item.Hue); } int num103 = num83; int num104 = Engine.m_Animations.GetFrameCount(bodyID, action, direction); if (num104 == 0) { num103 = 0; } else { num103 = num103 % num104; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } if (m_AlphaEnable != enable) { SetAlphaEnablePrecalc(enable); } if (enable) { SetAlpha(alpha); } frame2 = Engine.m_Animations.GetFrame(null, bodyID, action, direction, num103, num89, num90, notoriety, ref num95, ref num96, flag26); if ((frame2.Image != null) && !frame2.Image.IsEmpty()) { AlphaTestEnable = true; frame2.Image.DrawGame(num95, num96); } } } } else if ((type3 == tMobileCell) && (mobile4 != null)) { int num105 = 0; int num106 = ((by - (cell5.Z << 2)) + 0x12) - (num105 = Engine.m_Animations.GetHeight(body, action, direction)); int num107 = bx + 0x16; num107 += num85; num106 += num86; if (((m_MiniHealth && mobile4.OpenedStatus) && ((mobile4.StatusBar == null) && !mobile4.Ghost)) && (mobile4.HPMax > 0)) { miniHealthQueue.Enqueue(MiniHealthEntry.PoolInstance(num107, (num106 + 4) + num105, mobile4)); } if (mobile4.HumanOrGhost) { int num108 = equip.Count; bool flag33 = false; bool flag34 = false; for (int num109 = 0; num109 < num108; num109++) { EquipEntry entry4 = (EquipEntry) equip[num109]; if (!ghost || (entry4.m_Layer == Layer.OuterTorso)) { int num110 = entry4.m_Animation; int num111 = action; int num112 = num83; if (ghost) { num110 = 970; } if (entry4.m_Layer == Layer.Mount) { flag33 = true; if (mobile4.IsMoving) { num111 = ((direction & 0x80) == 0) ? 0 : 1; } else if (mobile4.Animation == null) { num111 = 2; } else if (num111 == 0x17) { num111 = 0; } else if (num111 == 0x18) { num111 = 1; } else { if ((num111 < 0x19) || (num111 > 0x1d)) { goto Label_3A65; } num111 = 2; } } else if (flag33) { if (mobile4.IsMoving) { num111 = 0x17 + ((direction & 0x80) >> 7); } else if (mobile4.Animation == null) { num111 = 0x19; } } bool flag35 = enable; float num113 = alpha; int num114 = entry4.m_Item.Hue; if (entry4.m_Layer == Layer.Mount) { int num115 = num110; Engine.m_Animations.Translate(ref num115, ref num114); } bool flag36 = false; if ((!flag26 || ((entry4.m_Layer == Layer.Mount) && flag28)) && ((num114 & 0x4000) != 0)) { flag35 = true; num113 = 1f; flag36 = true; notoriety = Hues.Load(0x8bb8); flag34 = true; } else if (!flag26 || ((entry4.m_Layer == Layer.Mount) && flag28)) { notoriety = Hues.GetItemHue(entry4.m_Item.ID, entry4.m_Item.Hue); flag34 = false; } else if (flag26) { notoriety = hue9; flag34 = true; } else { flag34 = false; } int num116 = Engine.m_Animations.GetFrameCount(num110, num111, direction); if (num116 == 0) { num112 = 0; } else { num112 = num112 % num116; } frame2 = Engine.m_Animations.GetFrame(entry4.m_Item, num110, num111, direction, num112, num89, num90, notoriety, ref num95, ref num96, flag34); if ((frame2.Image != null) && !frame2.Image.IsEmpty()) { if (!ghost) { if (m_AlphaEnable != flag35) { SetAlphaEnablePrecalc(flag35); } SetAlpha(num113); } else { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(0.5f); } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } AlphaTestEnable = true; if (flag36) { SetBlendType(DrawBlendType.BlackTransparency); } entry4.DrawGame(frame2.Image, num95, num96); if (flag36) { SetBlendType(DrawBlendType.Normal); } } } Label_3A65: if ((entry4.m_Layer == Layer.Mount) && flag29) { if (m_AlphaEnable != alphaEnable) { SetAlphaEnablePrecalc(alphaEnable); } if (alphaEnable) { SetAlpha(fAlpha); } if (flag31) { SetBlendType(DrawBlendType.BlackTransparency); } if (flag24 && (mobile4 != null)) { mobile4.DrawGame(t, num98, num99); } else { t.DrawGame(num98, num99); } if (flag31) { SetBlendType(DrawBlendType.Normal); } } } } if (flag24 && (mobile4 != null)) { if ((mobile4 == Engine.m_LastHarmTarget) && (player.Warmode || ((Engine.TargetHandler is ServerTargetHandler) && ((((ServerTargetHandler) Engine.TargetHandler).Flags & ServerTargetFlags.Harmful) != ServerTargetFlags.None)))) { DrawColoredIcon(num89, num90, 0xff2200, false, true); } else if ((mobile4 == Engine.m_LastBenTarget) && (player.Warmode || ((Engine.TargetHandler is ServerTargetHandler) && ((((ServerTargetHandler) Engine.TargetHandler).Flags & ServerTargetFlags.Beneficial) != ServerTargetFlags.None)))) { DrawColoredIcon(num89, num90, 0xffff, false, true); } else if ((mobile4 == Engine.m_LastTarget) && (player.Warmode || ((Engine.TargetHandler is ServerTargetHandler) && ((((ServerTargetHandler) Engine.TargetHandler).Flags & (ServerTargetFlags.Beneficial | ServerTargetFlags.Harmful)) == ServerTargetFlags.None)))) { DrawColoredIcon(num89, num90, 0xcccccc, false, true); } } if ((flag24 && (mobile4 != null)) && World.CharData.Halos) { int color = -1; bool formation = false; if (mobile4.m_IsFriend) { color = 0xff22; } else if (!mobile4.Player && player.Warmode) { bool flag38 = false; if (mobile4.Notoriety == Notoriety.Innocent) { int num118 = mobile4.X - package.CellX; int num119 = mobile4.Y - package.CellY; if ((((num118 >= 0) && (num118 < cellWidth)) && ((num119 >= 0) && (num119 < cellHeight))) && package.landTiles[num118, num119].m_Guarded) { flag38 = true; } } if (!flag38 && mobile4.Human) { if (((mobile == null) || (mobile4.Serial < mobile.Serial)) && player.InSquareRange(mobile4, 12)) { mobile = mobile4; } color = 0xff2200; formation = mobile4 == m_LastEnemy; } } if (color != -1) { DrawColoredIcon(num89, num96 - 10, color, formation, false); } } } } } } if (((multiPreview && (x >= num28)) && ((x <= num30) && (y >= num29))) && (y <= num31)) { int num120 = bx + 0x16; int num121 = by + 0x2b; if (m_vMultiPool == null) { m_vMultiPool = VertexConstructor.Create(); } for (int num122 = 0; num122 < num27; num122++) { MultiItem item7 = (MultiItem) Engine.m_MultiList[num122]; if (((item7.X == (x - num23)) && (item7.Y == (y - num24))) && (item7.Z == 0)) { num26 = num122 + 1; int num123 = item7.ItemID & 0x3fff; AnimData data2 = Map.GetAnim(num123); Texture texture5 = null; if ((data2.frameCount == 0) || !Map.m_ItemFlags[num123][TileFlag.Animation]) { texture5 = hue.GetItem(item7.ItemID); } else { texture5 = hue.GetItem(item7.ItemID + data2[(m_Frames / (data2.frameInterval + 1)) % data2.frameCount]); } if ((texture5 != null) && !texture5.IsEmpty()) { if (m_AlphaEnable) { m_AlphaEnable = false; } if (!m_AlphaTestEnable) { m_AlphaTestEnable = true; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } texture5.DrawGame(num120 - (texture5.Width >> 1), (num121 - ((num25 + item7.Z) << 2)) - texture5.Height, m_vMultiPool); } } else if (((item7.X + num23) > x) || (((item7.X + num23) == x) && ((item7.Y + num24) >= y))) { break; } } } for (int num124 = 0; num124 < list2.Count; num124++) { DrawQueueEntry entry5 = (DrawQueueEntry) list2[num124]; if ((entry5.m_TileX == x) && (entry5.m_TileY == y)) { list2.RemoveAt(num124); num124--; entry5.m_Texture.Flip = entry5.m_Flip; Clipper clipper = new Clipper(Engine.GameX, by - 0x2e, Engine.GameWidth, (Engine.GameHeight - by) + 0x2e); if (m_AlphaEnable != entry5.m_bAlpha) { SetAlphaEnablePrecalc(entry5.m_bAlpha); } if (entry5.m_bAlpha) { SetAlpha(entry5.m_fAlpha); } if (!m_AlphaTestEnable) { m_AlphaTestEnable = true; } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } entry5.m_Texture.DrawClipped(entry5.m_DrawX, entry5.m_DrawY, clipper); } } x++; y--; } } if (m_FilterEnable) { SetFilterEnablePrecalc(false); } if (m_Transparency) { if (m_vTransDrawPool == null) { m_vTransDrawPool = VertexConstructor.Create(); } while (transDrawQueue.Count > 0) { TransparentDraw draw = (TransparentDraw) transDrawQueue.Dequeue(); if (m_AlphaEnable != draw.m_bAlpha) { SetAlphaEnablePrecalc(draw.m_bAlpha); } if (draw.m_bAlpha) { SetAlpha(draw.m_fAlpha); } AlphaTestEnable = true; draw.m_Texture.DrawGame(draw.m_X, draw.m_Y, m_vTransDrawPool); if (draw.m_Double) { draw.m_Texture.DrawGame(draw.m_X + 5, draw.m_Y + 5, m_vTransDrawPool); } draw.Dispose(); } } SetTexture(null); if (miniHealthQueue.Count > 0) { while (miniHealthQueue.Count > 0) { int num127; int num128; MiniHealthEntry entry6 = (MiniHealthEntry) miniHealthQueue.Dequeue(); Mobile mobile5 = entry6.m_Mobile; if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } AlphaTestEnable = false; TransparentRect(0, entry6.m_X - 0x10, entry6.m_Y + 8, 0x20, 7); double num125 = ((double) mobile5.HPCur) / ((double) mobile5.HPMax); if (num125 == double.NaN) { num125 = 0.0; } else if (num125 < 0.0) { num125 = 0.0; } else if (num125 > 1.0) { num125 = 1.0; } int width = (int) ((30.0 * num125) + 0.5); if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(0.6f); MobileFlags flags2 = mobile5.Flags; if (flags2[MobileFlag.Poisoned]) { num127 = 0xff00; num128 = 0x8000; } else if (flags2[MobileFlag.YellowHits]) { num127 = 0xffc000; num128 = 0x806000; } else { num127 = 0x20c0ff; num128 = 0x106080; } GradientRect(num127, num128, entry6.m_X - 15, entry6.m_Y + 9, width, 5); GradientRect(0xc80000, 0x640000, (entry6.m_X - 15) + width, entry6.m_Y + 9, 30 - width, 5); AlphaTestEnable = true; entry6.Dispose(); } } if (Engine.m_Ingame) { if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } AlphaTestEnable = true; Engine.Effects.Draw(); if ((eOffsetX != 0) || (eOffsetY != 0)) { Engine.Effects.Offset(eOffsetX, eOffsetY); } } Map.Unlock(); SetViewport(0, 0, Engine.ScreenWidth, Engine.ScreenHeight); } if (!Engine.m_Loading) { if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } AlphaTestEnable = true; MessageManager.BeginRender(); if (Engine.m_Ingame && (m_TextSurface != null)) { SetTexture(null); AlphaTestEnable = false; if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } SetAlpha(0.5f); if (((player != null) && player.OpenedStatus) && (player.StatusBar == null)) { SolidRect(0, Engine.GameX + 2, (Engine.GameY + Engine.GameHeight) - 0x15, Engine.GameWidth - 0x2e, 0x13); SetAlphaEnablePrecalc(false); int num129 = (Engine.GameX + Engine.GameWidth) - 0x2c; int num130 = (Engine.GameY + Engine.GameHeight) - 0x15; SolidRect(0, num129, num130, 0x2a, 0x13); num129++; num130++; if (player.Ghost) { GradientRect(0xc0c0c0, 0x606060, num129, num130, 40, 5); num130 += 6; GradientRect(0xc0c0c0, 0x606060, num129, num130, 40, 5); num130 += 6; GradientRect(0xc0c0c0, 0x606060, num129, num130, 40, 5); } else { int num132; int num133; int num131 = (int) ((((double) player.HPCur) / ((double) player.HPMax)) * 40.0); if (num131 > 40) { num131 = 40; } else if (num131 < 0) { num131 = 0; } MobileFlags flags3 = player.Flags; if (flags3[MobileFlag.Poisoned]) { num132 = 0xff00; num133 = 0x8000; } else if (flags3[MobileFlag.YellowHits]) { num132 = 0xffc000; num133 = 0x806000; } else { num132 = 0x20c0ff; num133 = 0x106080; } GradientRect(num132, num133, num129, num130, num131, 5); GradientRect(0xff0000, 0x800000, num129 + num131, num130, 40 - num131, 5); num130 += 6; num131 = (int) ((((double) player.ManaCur) / ((double) player.ManaMax)) * 40.0); if (num131 > 40) { num131 = 40; } else if (num131 < 0) { num131 = 0; } GradientRect(0x20c0ff, 0x106080, num129, num130, 40, 5); GradientRect(0xff0000, 0x800000, num129 + num131, num130, 40 - num131, 5); num130 += 6; num131 = (int) ((((double) player.StamCur) / ((double) player.StamMax)) * 40.0); if (num131 > 40) { num131 = 40; } else if (num131 < 0) { num131 = 0; } GradientRect(0x20c0ff, 0x106080, num129, num130, 40, 5); GradientRect(0xff0000, 0x800000, num129 + num131, num130, 40 - num131, 5); } } else { SolidRect(0, Engine.GameX + 2, (Engine.GameY + Engine.GameHeight) - 0x15, Engine.GameWidth - 4, 0x13); } if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } AlphaTestEnable = true; m_vTextCache.Draw(m_TextSurface, Engine.GameX + 2, ((Engine.GameY + Engine.GameHeight) - 2) - m_TextSurface.Height); } Gumps.Draw(); } if (Engine.m_Ingame) { int num134 = (Engine.GameY + Engine.GameHeight) - ((m_TextSurface == null) ? 2 : (m_TextSurface.Height + 4)); ArrayList rectsList = m_RectsList; if (rectsList == null) { rectsList = m_RectsList = new ArrayList(); } else if (rectsList.Count > 0) { rectsList.Clear(); } World.DrawAllMessages(); textToDrawList.Sort(); int num135 = textToDrawList.Count; for (int num136 = 0; num136 < num135; num136++) { TextMessage message = (TextMessage) textToDrawList[num136]; int num137 = message.X + Engine.GameX; int num138 = message.Y + Engine.GameY; if (num137 < (Engine.GameX + 2)) { num137 = Engine.GameX + 2; } else if ((num137 + message.Image.Width) >= ((Engine.GameX + Engine.GameWidth) - 2)) { num137 = ((Engine.GameX + Engine.GameWidth) - message.Image.Width) - 2; } if (num138 < (Engine.GameY + 2)) { num138 = Engine.GameY + 2; } else if ((num138 + message.Image.Height) >= ((Engine.GameY + Engine.GameHeight) - 2)) { num138 = ((Engine.GameY + Engine.GameHeight) - message.Image.Height) - 2; } rectsList.Add(new Rectangle(num137, num138, message.Image.Width, message.Image.Height)); } for (int num139 = 0; num139 < num135; num139++) { TextMessage message2 = (TextMessage) textToDrawList[num139]; Rectangle rect = (Rectangle) rectsList[num139]; float num140 = 1f; int num141 = rectsList.Count; for (int num142 = num139 + 1; num142 < num141; num142++) { Rectangle rectangle3 = (Rectangle) rectsList[num142]; if (rectangle3.IntersectsWith(rect)) { num140 += ((TextMessage) textToDrawList[num142]).Alpha; } } if ((num140 == 1f) && !message2.Disposing) { if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } } else { if (!m_AlphaEnable) { SetAlphaEnablePrecalc(true); } if (message2.Disposing) { SetAlpha((1f / num140) * message2.Alpha); } else { SetAlpha(1f / num140); } } AlphaTestEnable = true; message2.Draw(rect.X, rect.Y); } if ((eOffsetX != 0) || (eOffsetY != 0)) { World.Offset(eOffsetX, eOffsetY); } } if (!Engine.m_Loading) { if (m_AlphaEnable) { SetAlphaEnablePrecalc(false); } AlphaTestEnable = true; Cursor.Draw(); } PushAll(); } catch (Exception exception) { Debug.Trace("Draw Exception:"); Debug.Error(exception); } finally { Engine.m_Device.EndScene(); } Engine.m_Device.Present(); m_Count = 0; m_LastEnemy = mobile; if (m_ScreenShot != null) { Save(m_ScreenShot); } m_ActFrames++; while (toUpdateQueue.Count > 0) { Mobile mobile6 = (Mobile) toUpdateQueue.Dequeue(); mobile6.MovedTiles++; mobile6.Update(); } Map.Unlock(); } }
/// <summary> /// Draws scaled 2D text. Note that x and y are in viewport coordinates /// (ranging from -1 to +1). fXScale and fYScale are the size fraction /// relative to the entire viewport. For example, a fXScale of 0.25 is /// 1/8th of the screen width. This allows you to output text at a fixed /// fraction of the viewport, even if the screen or window size changes. /// </summary> public void DrawTextScaled(float x, float y, float z, float fXScale, float fYScale, System.Drawing.Color color, string text, RenderFlags flags) { if (device == null) { throw new System.ArgumentNullException(); } // Set up renderstate savedStateBlock.Capture(); drawTextStateBlock.Apply(); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.PixelShader = null; device.SetStreamSource(0, vertexBuffer, 0); // Set filter states if ((flags & RenderFlags.Filtered) != 0) { samplerState0.MinFilter = TextureFilter.Linear; samplerState0.MagFilter = TextureFilter.Linear; } Viewport vp = device.Viewport; float xpos = (x + 1.0f) * vp.Width / 2; float ypos = (y + 1.0f) * vp.Height / 2; float sz = z; float rhw = 1.0f; float fLineHeight = (textureCoords[0, 3] - textureCoords[0, 1]) * textureHeight; // Adjust for character spacing xpos -= spacingPerChar * (fXScale * vp.Height) / fLineHeight; float fStartX = xpos; // Fill vertex buffer int numTriangles = 0; int realColor = color.ToArgb(); int iv = 0; foreach (char c in text) { if (c == '\n') { xpos = fStartX; ypos += fYScale * vp.Height; } if ((c - 32) < 0 || (c - 32) >= 128 - 32) { continue; } float tx1 = textureCoords[c - 32, 0]; float ty1 = textureCoords[c - 32, 1]; float tx2 = textureCoords[c - 32, 2]; float ty2 = textureCoords[c - 32, 3]; float w = (tx2 - tx1) * textureWidth; float h = (ty2 - ty1) * textureHeight; w *= (fXScale * vp.Height) / fLineHeight; h *= (fYScale * vp.Height) / fLineHeight; if (c != ' ') { fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + h - 0.5f, sz, rhw), realColor, tx1, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + 0 - 0.5f, sz, rhw), realColor, tx1, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + h - 0.5f, sz, rhw), realColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + 0 - 0.5f, sz, rhw), realColor, tx2, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + h - 0.5f, sz, rhw), realColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + 0 - 0.5f, sz, rhw), realColor, tx1, ty1); numTriangles += 2; if (numTriangles * 3 > (MaxNumfontVertices - 6)) { // Unlock, render, and relock the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); device.DrawPrimitives(PrimitiveType.TriangleList, 0, numTriangles); numTriangles = 0; iv = 0; } } xpos += w - (2 * spacingPerChar) * (fXScale * vp.Height) / fLineHeight; } // Unlock and render the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); if (numTriangles > 0) { device.DrawPrimitives(PrimitiveType.TriangleList, 0, numTriangles); } // Restore the modified renderstates savedStateBlock.Apply(); }
/// <summary> /// Draw some text on the screen /// </summary> public void DrawText(float xpos, float ypos, Color color, string text, RenderFlags flags) { if (text == null) { return; } // Setup renderstate savedStateBlock.Capture(); drawTextStateBlock.Apply(); device.SetTexture(0, fontTexture); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.PixelShader = null; device.SetStreamSource(0, vertexBuffer, 0); // Set filter states if ((flags & RenderFlags.Filtered) != 0) { samplerState0.MinFilter = TextureFilter.Linear; samplerState0.MagFilter = TextureFilter.Linear; } // Adjust for character spacing xpos -= spacingPerChar; float fStartX = xpos; // Fill vertex buffer int iv = 0; int dwNumTriangles = 0; foreach (char c in text) { if (c == '\n') { xpos = fStartX; ypos += (textureCoords[0, 3] - textureCoords[0, 1]) * textureHeight; } if ((c - 32) < 0 || (c - 32) >= 128 - 32) { continue; } float tx1 = textureCoords[c - 32, 0]; float ty1 = textureCoords[c - 32, 1]; float tx2 = textureCoords[c - 32, 2]; float ty2 = textureCoords[c - 32, 3]; float w = (tx2 - tx1) * textureWidth / textureScale; float h = (ty2 - ty1) * textureHeight / textureScale; int intColor = color.ToArgb(); if (c != ' ') { fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + h - 0.5f, 0.9f, 1.0f), intColor, tx1, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + 0 - 0.5f, 0.9f, 1.0f), intColor, tx1, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + h - 0.5f, 0.9f, 1.0f), intColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + 0 - 0.5f, 0.9f, 1.0f), intColor, tx2, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + w - 0.5f, ypos + h - 0.5f, 0.9f, 1.0f), intColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos + 0 - 0.5f, ypos + 0 - 0.5f, 0.9f, 1.0f), intColor, tx1, ty1); dwNumTriangles += 2; if (dwNumTriangles * 3 > (MaxNumfontVertices - 6)) { // Set the data for the vertexbuffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); dwNumTriangles = 0; iv = 0; } } xpos += w - (2 * spacingPerChar); } // Set the data for the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); if (dwNumTriangles > 0) { device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); } // Restore the modified renderstates savedStateBlock.Apply(); }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode normal, over, down, disabled, mark; normal = style.GetNodeByName("RadioButton").GetNodeByName("Normal"); over = style.GetNodeByName("RadioButton").GetNodeByName("Over"); down = style.GetNodeByName("RadioButton").GetNodeByName("Down"); disabled = style.GetNodeByName("RadioButton").GetNodeByName("Disabled"); mark = style.GetNodeByName("RadioButton").GetNodeByName("RadioMark"); float tWidth = (float)style.ImageInfo.Width; float tHeight = (float)style.ImageInfo.Height; //Positioning Quads ImageNode i; RectangleF rect; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; //normal i = normal; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //over i = over; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //down i = down; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //disabled i = disabled; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //mark i = mark; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_checkMarkQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); foreach (Quad q in m_normalBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_overBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_downBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_disabledBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_checkMarkQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } }
protected void TranslatePointInPlace(ref CustomVertex.TransformedColoredTextured pt, PointF origin) { pt.X -= origin.X; pt.Y -= origin.Y; }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode outline = style.GetNodeByName("Speedometer").GetNodeByName("Outline"); ImageNode bar = style.GetNodeByName("Speedometer").GetNodeByName("Bar"); ImageNode marker = style.GetNodeByName("Speedometer").GetNodeByName("Marker"); this.m_position.X -= outline.Rectangle.Width / 2; this.m_position.Y -= outline.Rectangle.Height / 2; this.m_size = outline.Rectangle.Size; float tWidth = style.ImageInfo.Width; float tHeight = style.ImageInfo.Height; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; //topLeft=new CustomVertex.TransformedColoredTextured(m_position.X,m_position.Y+normal.Rectangle.Height,0,1,normal.Color.ToArgb(), ImageNode i = outline; RectangleF rect = outline.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); outlineQuad = new Quad(topleft, topright, bottomleft, bottomright); i = bar; rect = bar.Rectangle; barQuadWidth = rect.Width; float deltax = (outline.Rectangle.Width - bar.Rectangle.Width) / 2; float deltay = (outline.Rectangle.Height - bar.Rectangle.Height) / 2; barQuadStart = m_position.X + deltax; barQuadUWidth = (rect.Width) / tWidth; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + deltax, m_position.Y + deltay, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width + deltax, m_position.Y + deltay, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + deltax, m_position.Y + rect.Height + deltay, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width + deltax, m_position.Y + rect.Height + deltay, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); barQuad = new AdjustableQuad(topleft, topright, bottomleft, bottomright); i = marker; rect = marker.Rectangle; deltax = (outline.Rectangle.Width - bar.Rectangle.Width) / 2 - marker.Rectangle.Width / 2; deltay = -marker.Rectangle.Height; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + deltax, m_position.Y + deltay, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width + deltax, m_position.Y + deltay, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + deltax, m_position.Y + rect.Height + deltay, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width + deltax, m_position.Y + rect.Height + deltay, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); markerQuad = new Quad(topleft, topright, bottomleft, bottomright); }
public List<Quad> GetProcessedQuads(StringBlock b) { List<Quad> quads = new List<Quad>(); if (b.Text == null) return quads; //empty list string text = b.Text; float max_y = Math.Min(b.TextRect.Bottom, b.ViewportRect.Bottom); float x = b.TextRect.X; float y = b.TextRect.Y; float maxWidth = b.TextRect.Width; Align alignment = b.Alignment; float lineWidth = 0f; float sizeScale = b.Size / (float)m_charSet.LineHeight; char lastChar = new char(); int lineNumber = 1; int wordNumber = 1; //int numWords = 0; int quadsInWord = 0; int quadsInLine = 0; //float wordWidth = 0f; bool firstCharOfLine = true; float z = 0f; float rhw = 1f; for (int i = 0; i < text.Length; i++) { //if (text[i] < 0 || text[i] > 255) // continue; BitmapCharacter c = (BitmapCharacter)m_charSet.Characters[text[i]]; if (c == null) continue; float xOffset = c.XOffset * sizeScale; float yOffset = c.YOffset * sizeScale; float xAdvance = c.XAdvance * sizeScale; float width = c.Width * sizeScale; float height = c.Height * sizeScale; // Check vertical bounds if (y > max_y) { break; } //if( //check other bounds // Newline if (text[i] == '\n' || text[i] == '\r' || (lineWidth >= maxWidth)) { if (alignment == Align.Left) { // Start at left x = b.TextRect.X; } if (alignment == Align.Center) { // Start in center x = b.TextRect.X + (maxWidth / 2f); } else if (alignment == Align.Right) { // Start at right x = b.TextRect.Right; } y += m_charSet.LineHeight * sizeScale; // Check vertical bounds float offset = 0f; if ((lineWidth + xAdvance >= maxWidth) && (wordNumber != 1)) { // Next character extends past text box width // We have to move the last word down one line lineWidth = 0f; i -= quadsInWord; for (int j = quads.Count - quadsInWord; j < quads.Count; j++, i++) { if (alignment == Align.Left) { // Move current word to the left side of the text box //quads[j].LineNumber++; //quads[j].WordNumber = 1; quads[j].X = x + ((BitmapCharacter)m_charSet.Characters[text[i]]).XOffset * sizeScale; quads[j].Y = y + ((BitmapCharacter)m_charSet.Characters[text[i]]).YOffset * sizeScale; x += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; lineWidth += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; if (b.Kerning && j != quads.Count - 1) { m_nextChar = text[i + 1]; Kerning kern = ((BitmapCharacter)m_charSet.Characters[text[i]]).KerningList.Find(FindKerningNode); if (kern != null) { x += kern.Amount * sizeScale; lineWidth += kern.Amount * sizeScale; } } } else if (alignment == Align.Center) { // First move word down to next line //quads[j].LineNumber++; //quads[j].WordNumber = 1; quads[j].X = x + ((BitmapCharacter)m_charSet.Characters[text[i]]).XOffset * sizeScale; quads[j].Y = y + ((BitmapCharacter)m_charSet.Characters[text[i]]).YOffset * sizeScale; x += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; lineWidth += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; offset += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale / 2f; float kerning = 0f; if (b.Kerning && j != quads.Count - 1) { m_nextChar = text[i + 1]; Kerning kern = ((BitmapCharacter)m_charSet.Characters[text[i]]).KerningList.Find(FindKerningNode); if (kern != null) { kerning = kern.Amount * sizeScale; x += kerning; lineWidth += kerning; offset += kerning / 2f; } } } else if (alignment == Align.Right) { // Move character down to next line //quads[j].LineNumber++; //quads[j].WordNumber = 1; quads[j].X = x + ((BitmapCharacter)m_charSet.Characters[text[i]]).XOffset * sizeScale; quads[j].Y = y + ((BitmapCharacter)m_charSet.Characters[text[i]]).YOffset * sizeScale; lineWidth += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; x += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; offset += ((BitmapCharacter)m_charSet.Characters[text[i]]).XAdvance * sizeScale; float kerning = 0f; if (b.Kerning && j != quads.Count - 1) { m_nextChar = text[i + 1]; Kerning kern = ((BitmapCharacter)m_charSet.Characters[text[i]]).KerningList.Find(FindKerningNode); if (kern != null) { kerning = kern.Amount * sizeScale; x += kerning; lineWidth += kerning; offset += kerning; } } } //newLineLastChar = quads[j].Character; } // Make post-newline justifications if (alignment == Align.Center || alignment == Align.Right) { // Justify the new line for (int k = quads.Count - quadsInWord; k < quads.Count; k++) { quads[k].X -= offset; } x -= offset; // Rejustify the line it was moved from for (int k = quads.Count - quadsInLine; k < quads.Count - quadsInWord; k++) { quads[k].X += offset; } } quadsInLine = quadsInWord; } else { // New line without any "carry-down" word firstCharOfLine = true; lineWidth = 0f; quadsInLine = 0; quadsInWord = 0; } wordNumber = 1; lineNumber++; } // End new line check // Don't print these if (text[i] == '\n' || text[i] == '\r' || text[i] == '\t') { continue; } // Set starting cursor for alignment if (firstCharOfLine) { if (alignment == Align.Left) { // Start at left x = b.TextRect.Left; } if (alignment == Align.Center) { // Start in center x = b.TextRect.Left + (maxWidth / 2f); } else if (alignment == Align.Right) { // Start at right x = b.TextRect.Right; } } // Adjust for kerning float kernAmount = 0f; if (b.Kerning && !firstCharOfLine) { m_nextChar = (char)text[i]; Kerning kern = ((BitmapCharacter)m_charSet.Characters[lastChar]).KerningList.Find(FindKerningNode); if (kern != null) { kernAmount = kern.Amount * sizeScale; x += kernAmount; lineWidth += kernAmount; //wordWidth += kernAmount; } } // Create the vertices CustomVertex.TransformedColoredTextured topLeft = new CustomVertex.TransformedColoredTextured( x + xOffset, y + yOffset, z, rhw, b.Color.ToArgb(), (float)c.X / (float)m_charSet.Width, (float)c.Y / (float)m_charSet.Height); CustomVertex.TransformedColoredTextured topRight = new CustomVertex.TransformedColoredTextured( topLeft.X + width, topLeft.Y, z, rhw, b.Color.ToArgb(), (float)(c.X + c.Width) / (float)m_charSet.Width, topLeft.Tv); CustomVertex.TransformedColoredTextured bottomRight = new CustomVertex.TransformedColoredTextured( topRight.X, topLeft.Y + height, z, rhw, b.Color.ToArgb(), topRight.Tu, (float)(c.Y + c.Height) / (float)m_charSet.Height); CustomVertex.TransformedColoredTextured bottomLeft = new CustomVertex.TransformedColoredTextured( topLeft.X, bottomRight.Y, z, rhw, b.Color.ToArgb(), topLeft.Tu, bottomRight.Tv); // Create the quad Quad q = new Quad(topLeft, topRight, bottomLeft, bottomRight); quads.Add(q); quadsInLine++; quadsInWord++; if (text[i] == ' ') { wordNumber++; //wordWidth = 0f; //numWords++; quadsInWord = 0; } x += xAdvance; lineWidth += xAdvance; lastChar = text[i]; //wordWidth += xAdvance; // Rejustify text if (alignment == Align.Center) { // We have to recenter all Quads since we addded a // new character float offset = xAdvance / 2f; if (b.Kerning && !firstCharOfLine) { offset += kernAmount / 2f; } for (int j = quads.Count - quadsInLine; j < quads.Count; j++) { quads[j].X -= offset; } x -= offset; } else if (alignment == Align.Right) { // We have to rejustify all Quads since we addded a // new character float offset = xAdvance; if (b.Kerning && !firstCharOfLine) { offset += kernAmount; } for (int j = quads.Count - quadsInLine; j < quads.Count; j++) { quads[j].X -= offset; } x -= offset; } firstCharOfLine = false; } for (int j = 0; j < quads.Count; j++) { if (!ClampToViewport(quads[j], b.ViewportRect)) { quads.RemoveAt(j); j--; } } return quads; }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode bottomB, leftB, rightB, topB, trC, tlC, brC, blC, windowBg, cursor; bottomB = style.GetNodeByName("EditBox").GetNodeByName("NormalBottomBorder"); topB = style.GetNodeByName("EditBox").GetNodeByName("NormalTopBorder"); leftB = style.GetNodeByName("EditBox").GetNodeByName("NormalLeftBorder"); rightB = style.GetNodeByName("EditBox").GetNodeByName("NormalRightBorder"); trC = style.GetNodeByName("EditBox").GetNodeByName("NormalTopRightCorner"); tlC = style.GetNodeByName("EditBox").GetNodeByName("NormalTopLeftCorner"); brC = style.GetNodeByName("EditBox").GetNodeByName("NormalBottomRightCorner"); blC = style.GetNodeByName("EditBox").GetNodeByName("NormalBottomLeftCorner"); windowBg = style.GetNodeByName("EditBox").GetNodeByName("NormalBackground"); cursor = style.GetNodeByName("EditBox").GetNodeByName("NormalCursor"); float left, right, top, bottom; left = leftB.Rectangle.Width; right = rightB.Rectangle.Width; top = topB.Rectangle.Height; bottom = bottomB.Rectangle.Height; m_textRect = new RectangleF(); m_textRect.X = m_position.X + left; m_textRect.Y = m_position.Y + top; m_textRect.Width = m_size.Width - left - right; m_textRect.Height = m_size.Height - top - bottom; float line_width = GM.FontManager.GetFont(FontName, m_fontSize).GetStringWidth(m_text, m_fontSize, true); m_cursorPos = new PointF(m_textRect.X + line_width, m_textRect.Y); m_cursorOffset = m_text.Length; //m_cursorOffset = 0; float cursorH, cursorW; cursorW = cursor.Rectangle.Width; cursorH = m_fontSize; float tWidth = (float)style.ImageInfo.Width; float tHeight = (float)style.ImageInfo.Height; //Positioning Quads ImageNode i; RectangleF rect; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; #region Normal Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Normal Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Normal Background & Cursor //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //Cursor i = cursor; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_cursorPos.X, m_cursorPos.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_cursorPos.X + cursorW, m_cursorPos.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_cursorPos.X, m_cursorPos.Y + cursorH, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_cursorPos.X + cursorW, m_cursorPos.Y + cursorH, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_cursorQuad.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion bottomB = style.GetNodeByName("Button").GetNodeByName("DisabledBottomBorder"); topB = style.GetNodeByName("Button").GetNodeByName("DisabledTopBorder"); leftB = style.GetNodeByName("Button").GetNodeByName("DisabledLeftBorder"); rightB = style.GetNodeByName("Button").GetNodeByName("DisabledRightBorder"); trC = style.GetNodeByName("Button").GetNodeByName("DisabledTopRightCorner"); tlC = style.GetNodeByName("Button").GetNodeByName("DisabledTopLeftCorner"); brC = style.GetNodeByName("Button").GetNodeByName("DisabledBottomRightCorner"); blC = style.GetNodeByName("Button").GetNodeByName("DisabledBottomLeftCorner"); windowBg = style.GetNodeByName("Button").GetNodeByName("DisabledBackground"); #region Disabled Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Disabled Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Disabled Background //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledBoxQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion foreach (Quad q in m_normalBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_disabledBoxQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } m_cursorQuad[0].X += m_positionDelta.X; m_cursorQuad[0].Y += m_positionDelta.Y; }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode bottomB, leftB, rightB, topB, trC, tlC, brC, blC, windowBg; bottomB = style.GetNodeByName("Button").GetNodeByName("NormalBottomBorder"); topB = style.GetNodeByName("Button").GetNodeByName("NormalTopBorder"); leftB = style.GetNodeByName("Button").GetNodeByName("NormalLeftBorder"); rightB = style.GetNodeByName("Button").GetNodeByName("NormalRightBorder"); trC = style.GetNodeByName("Button").GetNodeByName("NormalTopRightCorner"); tlC = style.GetNodeByName("Button").GetNodeByName("NormalTopLeftCorner"); brC = style.GetNodeByName("Button").GetNodeByName("NormalBottomRightCorner"); blC = style.GetNodeByName("Button").GetNodeByName("NormalBottomLeftCorner"); windowBg = style.GetNodeByName("Button").GetNodeByName("NormalBackground"); float left, right, top, bottom; left = leftB.Rectangle.Width; right = rightB.Rectangle.Width; top = topB.Rectangle.Height; bottom = bottomB.Rectangle.Height; m_textRect = new RectangleF(); m_textRect.X = m_position.X + left; m_textRect.Y = m_position.Y + top; m_textRect.Width = m_size.Width - left - right; m_textRect.Height = m_size.Height - top - bottom; float tWidth = (float)style.ImageInfo.Width; float tHeight = (float)style.ImageInfo.Height; //Positioning Quads ImageNode i; RectangleF rect; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; #region Normal Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Normal Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Normal Background //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion bottomB = style.GetNodeByName("Button").GetNodeByName("OverBottomBorder"); topB = style.GetNodeByName("Button").GetNodeByName("OverTopBorder"); leftB = style.GetNodeByName("Button").GetNodeByName("OverLeftBorder"); rightB = style.GetNodeByName("Button").GetNodeByName("OverRightBorder"); trC = style.GetNodeByName("Button").GetNodeByName("OverTopRightCorner"); tlC = style.GetNodeByName("Button").GetNodeByName("OverTopLeftCorner"); brC = style.GetNodeByName("Button").GetNodeByName("OverBottomRightCorner"); blC = style.GetNodeByName("Button").GetNodeByName("OverBottomLeftCorner"); windowBg = style.GetNodeByName("Button").GetNodeByName("OverBackground"); #region Over Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Over Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Over Background //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion bottomB = style.GetNodeByName("Button").GetNodeByName("DownBottomBorder"); topB = style.GetNodeByName("Button").GetNodeByName("DownTopBorder"); leftB = style.GetNodeByName("Button").GetNodeByName("DownLeftBorder"); rightB = style.GetNodeByName("Button").GetNodeByName("DownRightBorder"); trC = style.GetNodeByName("Button").GetNodeByName("DownTopRightCorner"); tlC = style.GetNodeByName("Button").GetNodeByName("DownTopLeftCorner"); brC = style.GetNodeByName("Button").GetNodeByName("DownBottomRightCorner"); blC = style.GetNodeByName("Button").GetNodeByName("DownBottomLeftCorner"); windowBg = style.GetNodeByName("Button").GetNodeByName("DownBackground"); #region Down Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Down Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Down Background //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion bottomB = style.GetNodeByName("Button").GetNodeByName("DisabledBottomBorder"); topB = style.GetNodeByName("Button").GetNodeByName("DisabledTopBorder"); leftB = style.GetNodeByName("Button").GetNodeByName("DisabledLeftBorder"); rightB = style.GetNodeByName("Button").GetNodeByName("DisabledRightBorder"); trC = style.GetNodeByName("Button").GetNodeByName("DisabledTopRightCorner"); tlC = style.GetNodeByName("Button").GetNodeByName("DisabledTopLeftCorner"); brC = style.GetNodeByName("Button").GetNodeByName("DisabledBottomRightCorner"); blC = style.GetNodeByName("Button").GetNodeByName("DisabledBottomLeftCorner"); windowBg = style.GetNodeByName("Button").GetNodeByName("DisabledBackground"); #region Disabled Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_textRect.Width + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width + right, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Disabled Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_textRect.Width, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_textRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Disabled Background //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_textRect.Left, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_textRect.Right, m_textRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledButtonQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion foreach (Quad q in m_normalButtonQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_overButtonQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_downButtonQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_disabledButtonQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } }
public void Draw(int X, int Y, int Width, int Height, float tltu, float tltv, float trtu, float trtv, float brtu, float brtv, float bltu, float bltv) { if (this.m_Surface != null) { CustomVertex.TransformedColoredTextured[] v = new CustomVertex.TransformedColoredTextured[4]; float num = -0.5f + X; float num2 = -0.5f + Y; float num3 = Width; float num4 = Height; v[3].X = num; v[3].Y = num2; v[1].X = num + num3; v[1].Y = num2; v[0].X = num + num3; v[0].Y = num2 + num4; v[2].X = num; v[2].Y = num2 + num4; v[0].Color = v[1].Color = v[2].Color = v[3].Color = Renderer.GetQuadColor(0xffffff); v[0].Rhw = v[1].Rhw = v[2].Rhw = v[3].Rhw = 1f; v[3].Tu = tltu; v[3].Tv = tltv; v[1].Tu = trtu; v[1].Tv = trtv; v[0].Tu = brtu; v[0].Tv = brtv; v[2].Tu = bltu; v[2].Tv = bltv; Renderer.SetTexture(this); Renderer.DrawQuadPrecalc(v); } }
/// <summary> /// Draw some text on the screen /// </summary> public void DrawText(float xpos, float ypos, Color color, string text, RenderFlags flags) { if (text == null) return; // Setup renderstate savedStateBlock.Capture(); drawTextStateBlock.Apply(); device.SetTexture(0, fontTexture); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.PixelShader = null; device.SetStreamSource(0, vertexBuffer, 0); // Set filter states if ((flags & RenderFlags.Filtered) != 0) { samplerState0.MinFilter = TextureFilter.Linear; samplerState0.MagFilter = TextureFilter.Linear; } // Adjust for character spacing xpos -= spacingPerChar; float fStartX = xpos; // Fill vertex buffer int iv = 0; int dwNumTriangles = 0; foreach (char c in text) { if (c == '\n') { xpos = fStartX; ypos += (textureCoords[0,3]-textureCoords[0,1])*textureHeight; } if ((c-32) < 0 || (c-32) >= 128-32) continue; float tx1 = textureCoords[c-32,0]; float ty1 = textureCoords[c-32,1]; float tx2 = textureCoords[c-32,2]; float ty2 = textureCoords[c-32,3]; float w = (tx2-tx1) * textureWidth / textureScale; float h = (ty2-ty1) * textureHeight / textureScale; int intColor = color.ToArgb(); if (c != ' ') { fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx1, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx1, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx2, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,0.9f,1.0f), intColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,0.9f,1.0f), intColor, tx1, ty1); dwNumTriangles += 2; if (dwNumTriangles*3 > (MaxNumfontVertices-6)) { // Set the data for the vertexbuffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); dwNumTriangles = 0; iv = 0; } } xpos += w - (2 * spacingPerChar); } // Set the data for the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); if (dwNumTriangles > 0) device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); // Restore the modified renderstates savedStateBlock.Apply(); }
public static unsafe void DrawLine(CustomVertex.TransformedColoredTextured v1, CustomVertex.TransformedColoredTextured v2, int color) { CustomVertex.TransformedColoredTextured[] texturedArray = new CustomVertex.TransformedColoredTextured[] { v1, v2 }; texturedArray[0].Color = texturedArray[1].Color = GetQuadColor(color); fixed (CustomVertex.TransformedColoredTextured* texturedRef = texturedArray) { PushLineStrip(texturedRef, 2); } }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode map = style.GetNodeByName("Map").GetNodeByName("Map"); ImageNode ass = style.GetNodeByName("Map").GetNodeByName("Assassin"); ImageNode kni = style.GetNodeByName("Map").GetNodeByName("Knight"); this.m_size = new SizeF(map.Rectangle.Size.Width * 2, map.Rectangle.Size.Height * 2); this.m_position.X -= m_size.Width / 2; this.m_position.Y -= m_size.Height / 2; float tWidth = style.ImageInfo.Width; float tHeight = style.ImageInfo.Height; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; //topLeft=new CustomVertex.TransformedColoredTextured(m_position.X,m_position.Y+normal.Rectangle.Height,0,1,normal.Color.ToArgb(), ImageNode i = map; RectangleF rect = map.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + m_size.Width, m_position.Y + m_size.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); mapQuad = new Quad(topleft, topright, bottomleft, bottomright); i = ass; rect = ass.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); assassinQuad = new Quad(topleft, topright, bottomleft, bottomright); i = kni; rect = kni.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + rect.Width, m_position.Y + rect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); knightQuad = new Quad(topleft, topright, bottomleft, bottomright); }
//RestoreDeviceObjects //----------------------------------------------------------------------------- // Name: DrawText // Desc: Draw some text on the screen //----------------------------------------------------------------------------- public void DrawText(float sx, float sy, Color color, string strText, RenderFlags flags) { if (strText == null) { return; } // Setup renderstate savedStateBlock.Capture(); drawTextStateBlock.Apply(); device.SetTexture(0, fontTexture); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.PixelShader = null; device.SetStreamSource(0, vertexBuffer, 0); // Set filter states if ((flags & RenderFlags.Filtered) != 0) { samplerState0.MinFilter = TextureFilter.Linear; samplerState0.MagFilter = TextureFilter.Linear; } float fStartX = sx; // Fill vertex buffer int iv = 0; int dwNumTriangles = 0; foreach (char c in strText) { if (c == '\n') { sx = fStartX; sy += (textureCoords[0, 3] - textureCoords[0, 1]) * textureHeight; } if ((((int)c) - 32) < 0 || (((int)c) - 32) >= (128 - 32)) { continue; } float tx1 = textureCoords[((int)c) - 32, 0]; float ty1 = textureCoords[((int)c) - 32, 1]; float tx2 = textureCoords[((int)c) - 32, 2]; float ty2 = textureCoords[((int)c) - 32, 3]; float w = (tx2 - tx1) * textureWidth / textureScale; float h = (ty2 - ty1) * textureHeight / textureScale; int intColor = color.ToArgb(); if (c != ' ') { fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + 0 - 0.5f, sy + h - 0.5f, 0.9f, 1f), intColor, tx1, ty2); iv += 1; fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1f), intColor, tx1, ty1); iv += 1; fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1f), intColor, tx2, ty2); iv += 1; fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + w - 0.5f, sy + 0 - 0.5f, 0.9f, 1f), intColor, tx2, ty1); iv += 1; fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + w - 0.5f, sy + h - 0.5f, 0.9f, 1f), intColor, tx2, ty2); iv += 1; fontVertices[iv] = new CustomVertex.TransformedColoredTextured(new Vector4(sx + 0 - 0.5f, sy + 0 - 0.5f, 0.9f, 1f), intColor, tx1, ty1); iv += 1; dwNumTriangles += 2; if (dwNumTriangles * 3 > MaxNumfontVertices - 6) { // Set the data for the vertexbuffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); dwNumTriangles = 0; iv = 0; } } sx += w; } // Set the data for the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); if (dwNumTriangles > 0) { device.DrawPrimitives(PrimitiveType.TriangleList, 0, dwNumTriangles); } // Restore the modified renderstates savedStateBlock.Apply(); }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode bottomB, leftB, rightB, topB, trC, tlC, brC, blC, windowBg, titleBg; bottomB = style.GetNodeByName("Window").GetNodeByName("BottomBorder"); topB = style.GetNodeByName("Window").GetNodeByName("TopBorder"); leftB = style.GetNodeByName("Window").GetNodeByName("LeftBorder"); rightB = style.GetNodeByName("Window").GetNodeByName("RightBorder"); trC = style.GetNodeByName("Window").GetNodeByName("TopRightCorner"); tlC = style.GetNodeByName("Window").GetNodeByName("TopLeftCorner"); brC = style.GetNodeByName("Window").GetNodeByName("BottomRightCorner"); blC = style.GetNodeByName("Window").GetNodeByName("BottomLeftCorner"); windowBg = style.GetNodeByName("Window").GetNodeByName("Background"); titleBg = style.GetNodeByName("Window").GetNodeByName("TitleBackground"); float left, right, top, bottom, title; left = leftB.Rectangle.Width; right = rightB.Rectangle.Width; top = topB.Rectangle.Height; bottom = bottomB.Rectangle.Height; title = DefaultValues.TitleTextSize; m_usableRect = new RectangleF(); m_usableRect.X = m_position.X + left; m_usableRect.Y = m_position.Y + top + title; m_usableRect.Width = m_size.Width - left - right; m_usableRect.Height = m_size.Height - top - title - bottom; m_titleRect = new RectangleF(); m_titleRect.X = m_position.X + left; m_titleRect.Y = m_position.Y + top; m_titleRect.Width = m_size.Width - left - right; m_titleRect.Height = title; float tWidth = (float)style.ImageInfo.Width; float tHeight = (float)style.ImageInfo.Height; //Positioning Quads ImageNode i; RectangleF rect; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; #region Borders //leftBorder i = leftB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topBorder i = topB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //rightBorder i = rightB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_usableRect.Width + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width + right, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + m_usableRect.Width + left, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width + right, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomBorder i = bottomB; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Corners //topLeftCorner i = tlC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //topRightCorner i = trC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_usableRect.Width, m_position.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_usableRect.Width, m_position.Y + top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomRightCorner i = brC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_usableRect.Width, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X + left + m_usableRect.Width, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + right + left + m_usableRect.Width, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //bottomLeftCorner i = blC; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_position.X, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_position.X + left, m_position.Y + bottom + top + m_usableRect.Height + m_titleRect.Height, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion #region Backgrounds //WindowBackground i = windowBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_usableRect.Left, m_usableRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_usableRect.Right, m_usableRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_usableRect.Left, m_usableRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_usableRect.Right, m_usableRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //TitleBackground i = titleBg; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_titleRect.Left, m_titleRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_titleRect.Right, m_titleRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_titleRect.Left, m_titleRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_titleRect.Right, m_titleRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_windowQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion }
/// <summary> /// Draws scaled 2D text. Note that x and y are in viewport coordinates /// (ranging from -1 to +1). fXScale and fYScale are the size fraction /// relative to the entire viewport. For example, a fXScale of 0.25 is /// 1/8th of the screen width. This allows you to output text at a fixed /// fraction of the viewport, even if the screen or window size changes. /// </summary> public void DrawTextScaled(float x, float y, float z, float fXScale, float fYScale, System.Drawing.Color color, string text, RenderFlags flags) { if (device == null) throw new System.ArgumentNullException(); // Set up renderstate savedStateBlock.Capture(); drawTextStateBlock.Apply(); device.VertexFormat = CustomVertex.TransformedColoredTextured.Format; device.PixelShader = null; device.SetStreamSource(0, vertexBuffer, 0); // Set filter states if ((flags & RenderFlags.Filtered) != 0) { samplerState0.MinFilter = TextureFilter.Linear; samplerState0.MagFilter = TextureFilter.Linear; } Viewport vp = device.Viewport; float xpos = (x+1.0f)*vp.Width/2; float ypos = (y+1.0f)*vp.Height/2; float sz = z; float rhw = 1.0f; float fLineHeight = (textureCoords[0,3] - textureCoords[0,1]) * textureHeight; // Adjust for character spacing xpos -= spacingPerChar * (fXScale*vp.Height)/fLineHeight; float fStartX = xpos; // Fill vertex buffer int numTriangles = 0; int realColor = color.ToArgb(); int iv = 0; foreach (char c in text) { if (c == '\n') { xpos = fStartX; ypos += fYScale*vp.Height; } if ((c-32) < 0 || (c-32) >= 128-32) continue; float tx1 = textureCoords[c-32,0]; float ty1 = textureCoords[c-32,1]; float tx2 = textureCoords[c-32,2]; float ty2 = textureCoords[c-32,3]; float w = (tx2-tx1)*textureWidth; float h = (ty2-ty1)*textureHeight; w *= (fXScale*vp.Height)/fLineHeight; h *= (fYScale*vp.Height)/fLineHeight; if (c != ' ') { fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx1, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx1, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx2, ty1); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+w-0.5f,ypos+h-0.5f,sz,rhw), realColor, tx2, ty2); fontVertices[iv++] = new CustomVertex.TransformedColoredTextured(new Vector4(xpos+0-0.5f,ypos+0-0.5f,sz,rhw), realColor, tx1, ty1); numTriangles += 2; if (numTriangles*3 > (MaxNumfontVertices-6)) { // Unlock, render, and relock the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); device.DrawPrimitives(PrimitiveType.TriangleList , 0, numTriangles); numTriangles = 0; iv = 0; } } xpos += w - (2 * spacingPerChar) * (fXScale*vp.Height)/fLineHeight; } // Unlock and render the vertex buffer vertexBuffer.SetData(fontVertices, 0, LockFlags.Discard); if (numTriangles > 0) device.DrawPrimitives(PrimitiveType.TriangleList , 0, numTriangles); // Restore the modified renderstates savedStateBlock.Apply(); }
protected override void ProcessStyle(GUIStyle style) { base.ProcessStyle(style); ImageNode left, middle, right, marker; left = style.GetNodeByName("Slider").GetNodeByName("NormalLeftCap"); middle = style.GetNodeByName("Slider").GetNodeByName("NormalMiddle"); right = style.GetNodeByName("Slider").GetNodeByName("NormalRightCap"); marker = style.GetNodeByName("Slider").GetNodeByName("NormalMarker"); float tWidth = (float)style.ImageInfo.Width; float tHeight = (float)style.ImageInfo.Height; //Positioning Quads ImageNode i; RectangleF rect; CustomVertex.TransformedColoredTextured topleft, topright, bottomleft, bottomright; #region Normal //left i = left; rect = i.Rectangle; m_leftRect = new RectangleF(m_position.X, m_position.Y + m_size.Height / 2 - rect.Height / 2, rect.Width, rect.Height); topleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //right i = right; rect = i.Rectangle; m_rightRect = new RectangleF(m_position.X + m_size.Width - rect.Width, m_position.Y + m_size.Height / 2 - rect.Height / 2, rect.Width, rect.Height); topleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //middle i = middle; rect = i.Rectangle; m_sliderRect = new RectangleF(m_position.X + m_leftRect.Width, m_position.Y + m_size.Height / 2 - rect.Height / 2, m_size.Width - m_leftRect.Width - m_rightRect.Width, rect.Height); topleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Left, m_sliderRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Left, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //marker i = marker; rect = i.Rectangle; m_markerRect = new RectangleF(m_sliderRect.X + m_sliderPosition * m_sliderRect.Width, m_position.Y + m_size.Height / 2 - rect.Height / 2, rect.Width, rect.Height); m_sliderMarkerRect = new RectangleF(m_position.X + m_leftRect.Width, m_position.Y + m_size.Height / 2 - rect.Height / 2, m_size.Width - m_leftRect.Width - m_rightRect.Width - m_markerRect.Width, rect.Height); topleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Left, m_markerRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Left, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_normalMarkerQuad.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion left = style.GetNodeByName("Slider").GetNodeByName("OverLeftCap"); middle = style.GetNodeByName("Slider").GetNodeByName("OverMiddle"); right = style.GetNodeByName("Slider").GetNodeByName("OverRightCap"); marker = style.GetNodeByName("Slider").GetNodeByName("OverMarker"); #region Over //left i = left; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //right i = right; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //middle i = middle; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Left, m_sliderRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Left, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //marker i = marker; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Left, m_markerRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Left, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_overMarkerQuad.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion left = style.GetNodeByName("Slider").GetNodeByName("DownLeftCap"); middle = style.GetNodeByName("Slider").GetNodeByName("DownMiddle"); right = style.GetNodeByName("Slider").GetNodeByName("DownRightCap"); marker = style.GetNodeByName("Slider").GetNodeByName("DownMarker"); #region Down //left i = left; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //right i = right; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Left, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //middle i = middle; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.X, m_sliderRect.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Width, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //marker i = marker; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_markerRect.X, m_markerRect.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Width, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_downMarkerQuad.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion left = style.GetNodeByName("Slider").GetNodeByName("DisabledLeftCap"); middle = style.GetNodeByName("Slider").GetNodeByName("DisabledMiddle"); right = style.GetNodeByName("Slider").GetNodeByName("DisabledRightCap"); marker = style.GetNodeByName("Slider").GetNodeByName("DisabledMarker"); #region Disabled //left i = left; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Top, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_leftRect.Left, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_leftRect.Right, m_leftRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //right i = right; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_rightRect.X, m_rightRect.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_rightRect.Width, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_rightRect.Right, m_rightRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //middle i = middle; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.X, m_sliderRect.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_sliderRect.Width, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_sliderRect.Right, m_sliderRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledSliderQuads.Add(new Quad(topleft, topright, bottomleft, bottomright)); //marker i = marker; rect = i.Rectangle; topleft = new CustomVertex.TransformedColoredTextured(m_markerRect.X, m_markerRect.Y, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Top / tHeight); topright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Y, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Top / tHeight); bottomleft = new CustomVertex.TransformedColoredTextured(m_markerRect.Width, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Left / tWidth, rect.Bottom / tHeight); bottomright = new CustomVertex.TransformedColoredTextured(m_markerRect.Right, m_markerRect.Bottom, 0, 1, i.Color.ToArgb(), rect.Right / tWidth, rect.Bottom / tHeight); m_disabledMarkerQuad.Add(new Quad(topleft, topright, bottomleft, bottomright)); #endregion foreach (Quad q in m_normalSliderQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_overSliderQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_downSliderQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_disabledSliderQuads) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_normalMarkerQuad) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_overMarkerQuad) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_downMarkerQuad) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } foreach (Quad q in m_disabledMarkerQuad) { q.X += m_positionDelta.X; q.Y += m_positionDelta.Y; } }