diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index 5b69601d4b..ea7979003c 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -21,14 +21,14 @@ namespace OpenRA.Graphics throw new InvalidOperationException("FT_New_Face failed"); FT.FT_Set_Pixel_Sizes(face, 0, (uint)size); - glyphs = new Cache(CreateGlyph); + glyphs = new Cache, GlyphInfo>(CreateGlyph); // setup a 1-channel SheetBuilder for our private use if (builder == null) builder = new SheetBuilder(r, TextureChannel.Alpha); // precache glyphs for U+0020 - U+007f for (var n = (char)0x20; n < (char)0x7f; n++) - if (glyphs[n] == null) + if (glyphs[Pair.New(n, Color.White)] == null) throw new InvalidOperationException(); } @@ -45,8 +45,8 @@ namespace OpenRA.Graphics p = location; continue; } - - var g = glyphs[s]; + + var g = glyphs[Pair.New(s, c)]; renderer.RgbaSpriteRenderer.DrawSprite(g.Sprite, new float2( (int)Math.Round(p.X + g.Offset.X, 0), @@ -60,15 +60,15 @@ namespace OpenRA.Graphics public int2 Measure(string text) { - return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[a].Advance)), text.Split('\n').Count()*size); + return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size); } - Cache glyphs; + Cache, GlyphInfo> glyphs; IntPtr face; - GlyphInfo CreateGlyph(char c) + GlyphInfo CreateGlyph(Pair c) { - var index = FT.FT_Get_Char_Index(face, (uint)c); + var index = FT.FT_Get_Char_Index(face, (uint)c.First); FT.FT_Load_Glyph(face, index, FT.FT_LOAD_RENDER); var _face = (FT_FaceRec)Marshal.PtrToStructure(face, typeof(FT_FaceRec)); @@ -92,7 +92,7 @@ namespace OpenRA.Graphics for (var i = 0; i < s.size.X; i++) if (p[i] != 0) s.sheet.Bitmap.SetPixel(i + s.bounds.Left, j + s.bounds.Top, - Color.FromArgb(p[i], 0xff, 0xff, 0xff)); + Color.FromArgb(p[i], c.Second.R, c.Second.G, c.Second.B)); p += _glyph.bitmap.pitch; } diff --git a/OpenRA.Game/Widgets/BuildPaletteWidget.cs b/OpenRA.Game/Widgets/BuildPaletteWidget.cs index 9d0073077d..7c0d12d77a 100644 --- a/OpenRA.Game/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Game/Widgets/BuildPaletteWidget.cs @@ -474,19 +474,20 @@ namespace OpenRA.Widgets if (!canBuildThis) longDescSize += 8; WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.viewport.Width - 300, pos.Y, 300, longDescSize + 50)); - - Game.chrome.renderer.BoldFont.DrawText(buildable.Description, p.ToInt2() + new int2(5, 5), Color.White); - - DrawRightAligned("${0}".F(buildable.Cost), pos + new int2(-5, 5), Color.White); - - if (buildable.Hotkey != null) - DrawRightAligned("{0}".F(buildable.Hotkey.ToUpper()), pos + new int2(-5, 35),Color.White); + + Game.chrome.renderer.BoldFont.DrawText( + buildable.Description + ((buildable.Hotkey != null)? " ({0})".F(buildable.Hotkey.ToUpper()) : ""), + p.ToInt2() + new int2(5, 5), Color.White); + + DrawRightAligned("${0}".F(buildable.Cost), pos + new int2(-5, 5), + (world.LocalPlayer.PlayerActor.traits.Get().DisplayCash >= buildable.Cost)? Color.White: Color.Red); var bi = info.Traits.GetOrDefault(); + var playerres = world.LocalPlayer.PlayerActor.traits.Get(); if (bi != null) - DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20), Color.White); - - + DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20), + ((playerres.PowerProvided - playerres.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red); + p += new int2(5, 20); if (!canBuildThis) {