public Background(Renderer r, Map m) { _r = r; _hscroll = 0.0f; _vscroll = 0.0f; _width = m.Width; _height = m.Height; _blocks = m.Blocks; _tilemapNames = m.TilemapNames; _material = r.GetMaterial("default"); }
public override void BeginDraw(Renderer r) { GL.Disable (EnableCap.Blend); GL.Disable (EnableCap.Texture2D); if(_material == null) { _material = r.GetMaterial("line"); } GL.Color4(255,255,255,255); _material.Bind(); }
public Background(Renderer r, string tilemapName, int width, int height) { _r = r; _hscroll = 0.0f; _vscroll = 0.0f; _width = width; _height = height; _blocks = new List<MapBlock>(Enumerable.Repeat(MapBlock.Empty, width*height)); _tilemapNames = new List<string>(); _tilemapNames.Add(tilemapName); _material = r.GetMaterial("default"); }
public Material(Renderer r, string vsPath, string fsPath) { _program = GL.CreateProgram(); int vertexShader = CreateShader(r, ShaderType.VertexShader, vsPath); int fragmentShader = CreateShader(r, ShaderType.FragmentShader, fsPath); GL.AttachShader(_program, vertexShader); GL.AttachShader(_program, fragmentShader); GL.LinkProgram(_program); string info = GL.GetProgramInfoLog(_program); if(info.Length>0) Console.WriteLine(info); }
public HudToolbar(Game game, Renderer r, int basePriority) { _game = game; _basePriority = basePriority; _toolbarPanel = new Panel(_basePriority-2); _toolbarPanel.X = 0; _toolbarPanel.Y = r.Height-Height; _toolbarPanel.Width = r.Width; _toolbarPanel.Height = Height; _toolbarPanel.Color = PanelColor; _toolbarPanel.Corners = 0; _baseIcon = new Sprite(_game.Config.GetWidgetTemplate("baseicon"), Drawable.Flags.NoScroll|Drawable.Flags.Colorize, _basePriority+1); _baseIcon.Resize((int)ToolbarEntries.Count); _cashText = new TextLine(r,0,0,basePriority+1); _cashText.Font = TextLine.CashFont; _cashText.Color = Color4.LightGoldenrodYellow; Icons = new ToolbarEntry[(int)ToolbarEntries.Count]; Icons[(int)ToolbarEntries.None] = new ToolbarEntry(_game, null, _basePriority+2) { CursorFrame = 0, PulloutOptions = BuildablePulloutOptions.ShowCaption|BuildablePulloutOptions.ShowIconTab }; Icons[(int)ToolbarEntries.Wall] = new ToolbarEntry(_game, "wall", _basePriority+2) { CursorFrame = 2, PulloutOptions = BuildablePulloutOptions.ShowCaption|BuildablePulloutOptions.ShowPrice|BuildablePulloutOptions.ShowIconTab }; Icons[(int)ToolbarEntries.Machinegun] = new ToolbarEntry(_game, "machinegun", _basePriority+2) { CursorFrame = 1, PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab, }; Icons[(int)ToolbarEntries.Cannon] = new ToolbarEntry(_game, "cannon", _basePriority+2) { CursorFrame = 1, PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab, }; Icons[(int)ToolbarEntries.Flamethrower] = new ToolbarEntry(_game, "flamethrower", _basePriority+2) { CursorFrame = 1, PulloutOptions = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab, }; }
public unsafe override void Draw(Renderer r, Vertex* vertexData, ref int vertexCount) { Background layer = r.Backgrounds[0]; float x = X - layer.HScroll; float y = Y - layer.VScroll; float x2 = X2 - layer.HScroll; float y2 = Y2 - layer.VScroll; vertexData[vertexCount].Position.X = x; vertexData[vertexCount].Position.Y = y; vertexData[vertexCount].Color = new Color4( _a * Color.R, _a * Color.G, _a * Color.B, _a * Color.A); vertexCount++; vertexData[vertexCount].Position.X = x2; vertexData[vertexCount].Position.Y = y2; vertexData[vertexCount].Color = new Color4( _a2 * Color.R, _a2 * Color.G, _a2 * Color.B, _a2 * Color.A); vertexCount++; }
public override void BeginDraw(Renderer r) { _material = r.GetMaterial("circle"); GL.Enable(EnableCap.Blend); GL.Disable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); _material.Bind(); float cx = X - r.Backgrounds[0].HScroll; float cy = Y - r.Backgrounds[0].VScroll; Vector3 p = new Vector3(cx,cy,Radius); _material.Uniform3("circle", ref p); Vector2 le = new Vector2(_thickness/2.0f,-_thickness/2.0f-_aawidth); Vector2 he = new Vector2(_thickness/2.0f+_aawidth,-_thickness/2.0f); _material.Uniform2("lowedge", ref le); _material.Uniform2("highedge", ref he); _material.Color4("color", ref Color); }
public HudBuildablePullout(Game game, Renderer r, int basePriority) { _game = game; _basePriority = basePriority; _stayUpTimer = new Timer(TimerMode.CountDown, 60*3); _stayUpTimer.Elapsed += HandleStayUpTimerElapsed; _foldingTimer = new Timer(TimerMode.CountDown, 100); _foldingTimer.Ticked += HandleFoldingTimerTicked; _panel = new Panel(_basePriority-1); _panel.Width = 96; _panel.Corners = Corners.Top|Corners.BottomRight; _panel.Color = Color; _iconPanel = new Panel(_basePriority-1); _iconPanel.Y = r.Height-HudToolbar.Height; _iconPanel.Width = 56; _iconPanel.Height = HudToolbar.Height; _iconPanel.Corners = Corners.Bottom; _iconPanel.Color = Color; //_captionIcon = new Sprite(_captionIcons, Drawable.Flags.NoScroll, _basePriority+2); _icons = new Sprite(_game.Config.GetWidgetTemplate("bpinfoicons"), Drawable.Flags.NoScroll, _basePriority+2); _icons.Resize(4); _icons[0].Frame = 3; _icons[1].Frame = 0; _icons[2].Frame = 2; _icons[3].Frame = 1; _text[0] = new TextLine(r,0,0,_basePriority+2); _text[1] = new TextLine(r,0,0,_basePriority+2); _text[2] = new TextLine(r,0,0,_basePriority+2); _text[3] = new TextLine(r,0,0,_basePriority+2); _text[4] = new TextLine(r,0,0,_basePriority+2); }
public override void BeginDraw(Renderer r) { Tilemap tilemap; SpriteTemplate tmp = Font.Template; if(!r.Tilemaps.TryGetValue(tmp.TilemapName, out tilemap)) { r.Tilemaps[tmp.TilemapName] = tilemap = new Tilemap (tmp.TilemapName); } GL.BindTexture (TextureTarget.Texture2D, tilemap.Texture); //Flags type = _flags & Drawable.Flags.TypeMask; GL.Enable (EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); _material.Bind(); }
public unsafe override void Draw(Renderer r, Vertex* vertexData, ref int vertexCount) { if(_dirty) { _dirty = false; int xi = (int)X; int yi = (int)Y; int wi = (int)Width; int hi = (int)Height; int x0 = xi; int x1 = xi + 16; int x2 = xi + wi - 16; int x3 = xi + wi; int y0 = yi; int y1 = yi + 16; int y2 = yi + hi - 16; int y3 = yi + hi; SetQuad(1, x1, y0, x2, y1, 80, 325, 80, 325); SetQuad(3, x0, y1, x1, y2, 80, 325, 80, 325); SetQuad(4, x1, y1, x2, y2, 80, 325, 80, 325); SetQuad(5, x2, y1, x3, y2, 80, 325, 80, 325); SetQuad(7, x1, y2, x2, y3, 80, 325, 80, 325); if((_corners & Corners.TopLeft) != 0) SetQuad(0, x0, y0, x1, y1, 64, 320, 80, 336); else SetQuad(0, x0, y0, x1, y1, 80, 325, 80, 325); if((_corners & Corners.TopRight) != 0) SetQuad(2, x2, y0, x3, y1, 80, 320, 96, 336); else SetQuad(2, x2, y0, x3, y1, 80, 325, 80, 325); if((_corners & Corners.BottomLeft) != 0) SetQuad(6, x0, y2, x1, y3, 96, 320, 112, 336); else SetQuad(6, x0, y2, x1, y3, 80, 325, 80, 325); if((_corners & Corners.BottomRight) != 0) SetQuad(8, x2, y2, x3, y3, 112, 320, 128, 336); else SetQuad(8, x2, y2, x3, y3, 80, 325, 80, 325); } for(int i = 0; i < 9*4; ++i) vertexData[vertexCount++] = _verts[i]; }
public unsafe override void Draw(Renderer r, Vertex* vertexData, ref int vertexCount) { float cx = X - r.Backgrounds[0].HScroll; float cy = Y - r.Backgrounds[0].VScroll; float bbl = cx - Radius - _thickness/2.0f - _aawidth*2.0f; float bbr = cx + Radius + _thickness/2.0f + _aawidth*2.0f; float bbt = cy - Radius - _thickness/2.0f - _aawidth*2.0f; float bbb = cy + Radius + _thickness/2.0f + _aawidth*2.0f; int subdivs = 5; float suby = bbt; float xstep = (bbr-bbl)/subdivs; float ystep = (bbb-bbt)/subdivs; float halfdiagonal = (float)Math.Sqrt(xstep*xstep+ystep*ystep)*0.5f; Vertex* v = &vertexData[vertexCount]; for(int y = 0; y < subdivs; ++y) { float subx = bbl; for(int x = 0; x < subdivs; ++x) { Vector2 subcenter = new Vector2(subx + xstep/2.0f - cx, suby + ystep/2.0f - cy); float subdistance = subcenter.Length; if(Math.Abs(subdistance-Radius) < halfdiagonal) { float subl = subx; float subr = subx+xstep; float subt = suby; float subb = suby+ystep; v->Position.X = v->TexCoord.X = subl; v->Position.Y = v->TexCoord.Y = subt; v->Position.Z = 0.0f; v++; v->Position.X = v->TexCoord.X = subr; v->Position.Y = v->TexCoord.Y = subt; v->Position.Z = 0.0f; v++; v->Position.X = v->TexCoord.X = subr; v->Position.Y = v->TexCoord.Y = subb; v->Position.Z = 0.0f; v++; v->Position.X = v->TexCoord.X = subl; v->Position.Y = v->TexCoord.Y = subb; v->Position.Z = 0.0f; v++; vertexCount += 4; } subx += xstep; } suby += ystep; } }
private int CreateShader(Renderer r, ShaderType type, string srcPath) { int sh; if(!r.ShaderCache.TryGetValue(srcPath.GetHashCode(), out sh)) { using(StreamReader sr = File.OpenText(srcPath)) { sh = GL.CreateShader(type); GL.ShaderSource(sh, sr.ReadToEnd()); GL.CompileShader(sh); string log = GL.GetShaderInfoLog(sh); if(log != null) { string s = log.Trim('\n','\r',' ','\t'); if(s.Length > 0) Console.WriteLine(s); } int compileResult; GL.GetShader(sh, ShaderParameter.CompileStatus, out compileResult); if (compileResult != 1) { Console.WriteLine("Compile Error in " + srcPath); } } } return sh; }
public override void EndDraw(Renderer r, int vertexCount) { GL.DrawArrays(BeginMode.Quads, 0, vertexCount); // Material.Unbind(); }
public override void BeginDraw(Renderer r) { Tilemap tilemap = r.Tilemaps["units"]; if(_material == null) { _material = r.GetMaterial("default"); _psx = tilemap.PixelStepX; _psy = tilemap.PixelStepY; _material.SetTilemap("colortexture",tilemap); } GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, tilemap.Texture); _material.Bind(); }
public unsafe override void Draw(Renderer r, Vertex* vertexData, ref int vertexCount) { Tilemap tilemap = r.Tilemaps[Template.TilemapName]; foreach(Instance ins in _instances) { if((ins.Flags & SpriteFlags.Disable) != 0) continue; float x = ins.X; float y = ins.Y; float width = Template.Rectangle.Width; float height = Template.Rectangle.Height; // If the object should be included in scrolling... if ((_flags & Drawable.Flags.NoScroll) == 0) { // Apply offset so we're always positioned relative to the gameplay background. Background bg = r.Backgrounds[0]; x -= (float)Math.Floor(bg.HScroll); y -= (float)Math.Floor(bg.VScroll); } // Calculate texcoords, with possible animation. int tx = Template.Rectangle.X; int ty = Template.Rectangle.Y; int frameOffset = (Template.FrameOffset > 0 ? Template.FrameOffset : Template.Rectangle.Width); if(Template.VerticalAnimation) { ty += ins.Frame * frameOffset; } else { tx += ins.Frame * frameOffset; // If the animation would take us outside the right edge of the // texture, start on the next row. while (tx + width > tilemap.Width) { tx -= (tilemap.Width / frameOffset) * frameOffset; ty += Template.Rectangle.Height; } } float s0 = tx * tilemap.PixelStepX; float t0 = ty * tilemap.PixelStepY; float s1 = (tx + width) * tilemap.PixelStepX; float t1 = (ty + height) * tilemap.PixelStepY; // Flip the sprite horizontally? if ((ins.Flags & SpriteFlags.HFlip) != 0) { float stmp = s0; s0 = s1; s1 = stmp; } // Flip the sprite vertically? if ((ins.Flags & SpriteFlags.VFlip) != 0) { float ttmp = t0; t0 = t1; t1 = ttmp; } Matrix4 m = Matrix4.CreateTranslation(x,y,0.0f); Matrix4 scalem = Matrix4.Scale(ins.Scale); Matrix4 rotm = Matrix4.Rotate(Quaternion.FromAxisAngle(Vector3.UnitZ, ins.Angle * (2.0f * (float)Math.PI) / 4096.0f)); Matrix4.Mult(ref scalem, ref m, out m); Matrix4.Mult(ref rotm, ref m, out m); float ox = Template.Centered ? Template.Rectangle.Width/2 : Template.Offset.X; float oy = Template.Centered ? Template.Rectangle.Height/2 : Template.Offset.Y; Vector4 v00 = new Vector4(-ox, -oy, 0.0f, 1.0f); Vector4 v10 = new Vector4(width-ox, -oy, 0.0f, 1.0f); Vector4 v11 = new Vector4(width-ox, height-oy, 0.0f, 1.0f); Vector4 v01 = new Vector4(-ox, height-oy, 0.0f, 1.0f); Vector4.Transform(ref v00, ref m, out v00); Vector4.Transform(ref v10, ref m, out v10); Vector4.Transform(ref v11, ref m, out v11); Vector4.Transform(ref v01, ref m, out v01); float colorizeMode = (_flags & Drawable.Flags.Colorize) != 0 ? 1.0f : 0.0f; vertexData[vertexCount].Position.X = v00.X; vertexData[vertexCount].Position.Y = v00.Y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = ins.Color; vertexData[vertexCount].TexCoord.X = s0; vertexData[vertexCount].TexCoord.Y = t0; vertexData[vertexCount].TexCoord.Z = colorizeMode; vertexCount++; vertexData[vertexCount].Position.X = v10.X; vertexData[vertexCount].Position.Y = v10.Y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = ins.Color; vertexData[vertexCount].TexCoord.X = s1; vertexData[vertexCount].TexCoord.Y = t0; vertexData[vertexCount].TexCoord.Z = colorizeMode; vertexCount++; vertexData[vertexCount].Position.X = v11.X; vertexData[vertexCount].Position.Y = v11.Y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = ins.Color; vertexData[vertexCount].TexCoord.X = s1; vertexData[vertexCount].TexCoord.Y = t1; vertexData[vertexCount].TexCoord.Z = colorizeMode; vertexCount++; vertexData[vertexCount].Position.X = v01.X; vertexData[vertexCount].Position.Y = v01.Y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = ins.Color; vertexData[vertexCount].TexCoord.X = s0; vertexData[vertexCount].TexCoord.Y = t1; vertexData[vertexCount].TexCoord.Z = colorizeMode; vertexCount++; } }
public override void BeginDraw(Renderer r) { Tilemap tilemap; if(!r.Tilemaps.TryGetValue(Template.TilemapName, out tilemap)) { r.Tilemaps[Template.TilemapName] = tilemap = new Tilemap (Template.TilemapName); } GL.BindTexture (TextureTarget.Texture2D, tilemap.Texture); Flags type = _flags & Drawable.Flags.TypeMask; if(Drawable.Flags.TypeNoBlend == type) { GL.Disable (EnableCap.Blend); } else { GL.Enable (EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); } if(_material == null) { _material = r.GetMaterial("sprite"); } _material.Bind(); }
public void Render(Renderer r) { _stayUpTimer.Tick(); _foldingTimer.Tick(); const int minWidth = 96; const int leftMargin = 12; const int rightMargin = 12; const int topMargin = 12; const int bottomMargin = 8; const int leftTextMargin = 28; const int topTextMargin = 5; const int lineHeight = 24; int height = topMargin; if((Options & BuildablePulloutOptions.ShowCaption) != 0) height += lineHeight; if((Options & BuildablePulloutOptions.ShowPrice) != 0) height += lineHeight; if((Options & BuildablePulloutOptions.ShowDamage) != 0) height += lineHeight; if((Options & BuildablePulloutOptions.ShowReloadTime) != 0) height += lineHeight; if((Options & BuildablePulloutOptions.ShowRange) != 0) height += lineHeight; height += bottomMargin; int px = X; int py = Y - height; _panel.X = px; _panel.Y = py; _panel.Color = Color; _panel.Corners = Corners.Top | ((Options & BuildablePulloutOptions.ShowIconTab) != 0 ? Corners.BottomRight : Corners.Bottom); _panel.Height = height; r.AddDrawable(_panel); _iconPanel.X = px; _iconPanel.Y = py+height; _iconPanel.Color = Color; if((Options & BuildablePulloutOptions.ShowIconTab) != 0) r.AddDrawable(_iconPanel); var u = Upgrade; if(u != null) { r.AddDrawable(_icons); _text[0].Text = u.Price > 0 ? ""+u.Price : ""; _text[1].Text = u.Damage > 0 ? u.Damage+" hp" : ""; _text[2].Text = u.ReloadTime > 0 ? String.Format("{0:0.0}",((float)u.ReloadTime)/60.0f) + " s" : ""; _text[3].Text = u.Range > 0 ? ""+u.Range : ""; _text[4].Text = Caption ?? u.Caption; int y = 1; for(int i = 0; i < 4; ++i) { _icons[i].X = px+leftMargin; _icons[i].Y = py+topMargin+lineHeight*y; _text[i].X = px+leftMargin+leftTextMargin; _text[i].Y = py+topMargin+topTextMargin+lineHeight*y; if(((int)Options & (1<<i)) != 0) { r.AddDrawable(_text[i]); if(i<4) _icons[i].Flags &= ~SpriteFlags.Disable; y++; } else { if(i<4) _icons[i].Flags |= SpriteFlags.Disable; } } bool tooExpensive = !_game.CanAfford(u); _icons[0].Color = u.Price <= 0 ? Color4.Gray : (tooExpensive ? Color4.Gray : LineColor); _icons[1].Color = u.Damage <= 0 || tooExpensive ? Color4.Gray : LineColor; _icons[2].Color = u.ReloadTime <= 0 || tooExpensive ? Color4.Gray : LineColor; _icons[3].Color = u.Range <= 0 || tooExpensive ? Color4.Gray : LineColor; _text[0].Color = tooExpensive ? PulseColor(_TooExpensiveTextColor) : LineColor; _text[1].Color = tooExpensive ? Color4.Gray : LineColor; _text[2].Color = tooExpensive ? Color4.Gray : LineColor; _text[3].Color = tooExpensive ? Color4.Gray : LineColor; _text[4].Color = tooExpensive ? Color4.Gray : CaptionColor; _panel.Width = Math.Max(minWidth,_text[4].Width + leftMargin+rightMargin); //_panel.Corners = Corners.Top|Corners.BottomRight; } else { px--; _text[4].Text = "Select"; _panel.Corners = Corners.Top; _panel.Width = _iconPanel.Width; } if(CaptionIcon >= 0) { _captionIcon[0].X = px+leftMargin+4; _captionIcon[0].Y = py+topMargin-2; _captionIcon[0].Frame = (byte)CaptionIcon; _captionIcon[0].Color.A = 0.0f; r.AddDrawable(_captionIcon); _text[4].X = (int)_captionIcon[0].X+22; _text[4].Y = py+topMargin; // _text[4].Color = new Color4(246,233,185,255); _panel.Width += 28; } else { _text[4].X = px+leftMargin; _text[4].Y = py+topMargin; } r.AddDrawable(_text[4]); }
public override void EndDraw(Renderer r, int vertexCount) { GL.DrawArrays(BeginMode.Lines, 0, vertexCount); GL.Enable (EnableCap.Texture2D); }
public unsafe override void Draw(Renderer r, Vertex* vertexData, ref int vertexCount) { SpriteTemplate tmp = Font.Template; Tilemap tilemap = r.Tilemaps[tmp.TilemapName]; if(_text != null) for(int i = 0; i < _text.Length; ++i) { float x = X + _xs[i] - tmp.Offset.X; float y = Y - tmp.Offset.Y; float width = tmp.Rectangle.Width; float height = tmp.Rectangle.Height; // Calculate texcoords, with possible animation. int tx = tmp.Rectangle.X; int ty = tmp.Rectangle.Y; int frameOffset = Font.Template.FrameOffset; if(frameOffset == 0) frameOffset = Font.Template.Rectangle.Width; tx += _indices[i] * frameOffset; // If the animation would take us outside the right edge of the // texture, start on the next row. while (tx + width > tilemap.Width) { tx -= (tilemap.Width / frameOffset) * frameOffset; ty += Font.Template.Rectangle.Height; } float s0 = tx * tilemap.PixelStepX; float t0 = ty * tilemap.PixelStepY; float s1 = (tx + width) * tilemap.PixelStepX; float t1 = (ty + height) * tilemap.PixelStepY; vertexData[vertexCount].Position.X = x; vertexData[vertexCount].Position.Y = y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = Color; vertexData[vertexCount].TexCoord.X = s0; vertexData[vertexCount].TexCoord.Y = t0; vertexData[vertexCount].TexCoord.Z = 0.0f; vertexCount++; vertexData[vertexCount].Position.X = x + width; vertexData[vertexCount].Position.Y = y; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = Color; vertexData[vertexCount].TexCoord.X = s1; vertexData[vertexCount].TexCoord.Y = t0; vertexData[vertexCount].TexCoord.Z = 0.0f; vertexCount++; vertexData[vertexCount].Position.X = x+width; vertexData[vertexCount].Position.Y = y+height; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = Color; vertexData[vertexCount].TexCoord.X = s1; vertexData[vertexCount].TexCoord.Y = t1; vertexData[vertexCount].TexCoord.Z = 0.0f; vertexCount++; vertexData[vertexCount].Position.X = x; vertexData[vertexCount].Position.Y = y+height; vertexData[vertexCount].Position.Z = 0.0f; vertexData[vertexCount].Color = Color; vertexData[vertexCount].TexCoord.X = s0; vertexData[vertexCount].TexCoord.Y = t1; vertexData[vertexCount].TexCoord.Z = 0.0f; vertexCount++; } }
public TextLine(Renderer r, int x, int y, int priority) : base(0, priority) { if(CashFont == null) { CashFont = new TextFont(); CashFont.Template = new SpriteTemplate { TilemapName = "units", Rectangle = new Rectangle(240, 384, 16, 21), Centered = false }; byte i = 0; CashFont.Table = new Dictionary<char, byte[]>() { { '$', new byte[] { i++, 14 } }, { '0', new byte[] { i++, 13 } }, { '1', new byte[] { i++, 12 } }, { '2', new byte[] { i++, 12 } }, { '3', new byte[] { i++, 13 } }, { '4', new byte[] { i++, 13 } }, { '5', new byte[] { i++, 12 } }, { '6', new byte[] { i++, 13 } }, { '7', new byte[] { i++, 13 } }, { '8', new byte[] { i++, 12 } }, { '9', new byte[] { i++, 13 } } }; } if(NormalFont == null) { NormalFont = new TextFont(); NormalFont.Template = new SpriteTemplate { TilemapName = "units", Rectangle = new Rectangle(0, 464, 16, 16), Centered = false }; byte i = 0; NormalFont.Table = new Dictionary<char, byte[]>() { { 'a', new byte[] { i++, 5 } }, { 'b', new byte[] { i++, 6 } }, { 'c', new byte[] { i++, 5 } }, { 'd', new byte[] { i++, 6 } }, { 'e', new byte[] { i++, 6 } }, { 'f', new byte[] { i++, 5 } }, { 'g', new byte[] { i++, 6 } }, { 'h', new byte[] { i++, 6 } }, { 'i', new byte[] { i++, 2 } }, { 'j', new byte[] { i++, 3 } }, { 'k', new byte[] { i++, 6 } }, { 'l', new byte[] { i++, 2 } }, { 'm', new byte[] { i++, 11 } }, { 'n', new byte[] { i++, 6 } }, { 'o', new byte[] { i++, 6 } }, { 'p', new byte[] { i++, 6 } }, { 'q', new byte[] { i++, 6 } }, { 'r', new byte[] { i++, 4 } }, { 's', new byte[] { i++, 5 } }, { 't', new byte[] { i++, 5 } }, { 'u', new byte[] { i++, 6 } }, { 'v', new byte[] { i++, 7 } }, { 'w', new byte[] { i++, 10 } }, { 'x', new byte[] { i++, 7 } }, { 'y', new byte[] { i++, 7 } }, { 'z', new byte[] { i++, 5 } }, { 'A', new byte[] { i++, 9 } }, { 'B', new byte[] { i++, 7 } }, { 'C', new byte[] { i++, 7 } }, { 'D', new byte[] { i++, 8 } }, { 'E', new byte[] { i++, 5 } }, { 'F', new byte[] { i++, 6 } }, { 'G', new byte[] { i++, 8 } }, { 'H', new byte[] { i++, 8 } }, { 'I', new byte[] { i++, 5 } }, { 'J', new byte[] { i++, 5 } }, { 'K', new byte[] { i++, 7 } }, { 'L', new byte[] { i++, 6 } }, { 'M', new byte[] { i++, 10 } }, { 'N', new byte[] { i++, 8 } }, { 'O', new byte[] { i++, 9 } }, { 'P', new byte[] { i++, 6 } }, { 'Q', new byte[] { i++, 9 } }, { 'R', new byte[] { i++, 6 } }, { 'S', new byte[] { i++, 5 } }, { 'T', new byte[] { i++, 7 } }, { 'U', new byte[] { i++, 8 } }, { 'V', new byte[] { i++, 8 } }, { 'W', new byte[] { i++, 13 } }, { 'X', new byte[] { i++, 8 } }, { 'Y', new byte[] { i++, 7 } }, { 'Z', new byte[] { i++, 6 } }, { '0', new byte[] { i++, 6 } }, { '1', new byte[] { i++, 4 } }, { '2', new byte[] { i++, 7 } }, { '3', new byte[] { i++, 6 } }, { '4', new byte[] { i++, 7 } }, { '5', new byte[] { i++, 6 } }, { '6', new byte[] { i++, 6 } }, { '7', new byte[] { i++, 6 } }, { '8', new byte[] { i++, 6 } }, { '9', new byte[] { i++, 6 } }, { ',', new byte[] { i++, 2 } }, { '.', new byte[] { i++, 2 } }, { ':', new byte[] { i++, 2 } }, { '\"', new byte[] { i++, 5 } }, { '/', new byte[] { i++, 8 } }, { '_', new byte[] { i++, 6 } }, { '-', new byte[] { i++, 4 } }, { '!', new byte[] { i++, 2 } }, { '?', new byte[] { i++, 5 } }, { ';', new byte[] { i++, 2 } }, { '%', new byte[] { i++, 10 } }, { '$', new byte[] { i++, 6 } }, { '&', new byte[] { i++, 9 } }, { '#', new byte[] { i++, 0 } }, { '@', new byte[] { i++, 0 } }, { '(', new byte[] { i++, 0 } }, { ')', new byte[] { i++, 0 } }, { '[', new byte[] { i++, 0 } }, { ']', new byte[] { i++, 0 } }, { '{', new byte[] { i++, 0 } }, { '}', new byte[] { i++, 0 } }, { '=', new byte[] { i++, 0 } }, { '+', new byte[] { i++, 0 } }, { '\\', new byte[] { i++, 0 } }, { '\'', new byte[] { i++, 0 } }, { ' ', new byte[] { i++, 3 } }, }; } X = x; Y = y; Font = NormalFont; _material = r.GetMaterial("default"); }
private void RenderToolbar(Renderer r) { _toolbar.Render(r); _bpullout.X = _toolbar.SelectedIconIndex * HudToolbar.IconSpacing + HudToolbar.IconLeft - 28; _bpullout.Y = r.Height - HudToolbar.Height; _bpullout.Caption = null; if(_toolbar.SelectedIconIndex == 0) { if(_selectedObject != null) { var b = _selectedObject as Buildable; if(b != null) { if(_showSell) { _bpullout.Upgrade = b.CurrentUpgrade; _bpullout.Options = (BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab); _bpullout.CaptionIcon = 1; _bpullout.CaptionColor = SellColor; _bpullout.LineColor = Color4.White; _bpullout.Caption = "Sell"; } else if(_showUpgrade && (b.CurrentUpgradeIndex+1) < b.Upgrades.Count) { _bpullout.Upgrade = b.Upgrades[b.CurrentUpgradeIndex+1]; _bpullout.Options = BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab; _bpullout.CaptionIcon = 0; _bpullout.CaptionColor = UpgradeColor; _bpullout.LineColor = Color4.White; _bpullout.Caption = "Upgrade"; } else { _bpullout.Upgrade = b.CurrentUpgrade; _bpullout.Options = (BuildablePulloutOptions.ShowAllRows|BuildablePulloutOptions.ShowIconTab) & ~BuildablePulloutOptions.ShowPrice; _bpullout.CaptionIcon = -1; _bpullout.CaptionColor = Color4.LightGray; _bpullout.LineColor = Color4.LightGray; } } } else { _bpullout.Upgrade = null; _bpullout.Options = _toolbar.SelectedIcon.PulloutOptions; _bpullout.CaptionIcon = -1; _bpullout.CaptionColor = Color4.White; _bpullout.LineColor = Color4.White; } } else { _bpullout.Upgrade = _game.Config.GetBuildableUpgrade(_toolbar.SelectedBuildable.TypeId, 0); _bpullout.Options = _toolbar.SelectedIcon.PulloutOptions; _bpullout.CaptionIcon = -1; _bpullout.CaptionColor = Color4.White; _bpullout.LineColor = Color4.White; } _bpullout.Render(r); }
public void Render(Renderer r) { r.AddDrawable(_toolbarPanel); _cashText.Text = "$"+_game.Cash; _cashText.X = r.Width-_cashText.Width-16; _cashText.Y = r.Height-Height/2-11; r.AddDrawable(_cashText); for(int iconi = 0; iconi < Icons.Length; ++iconi) { var icon = Icons[iconi]; var b = icon.Buildable; var u = b != null ? _game.Config.GetBuildableUpgrade(b.TypeId,0) : null; bool isSelected = SelectedIconIndex == iconi; Color4 c = isSelected ? (iconi == 0 ? SelectedMarkerIconColor : SelectedBuildableIconColor) : Color4.Black; c = _game.CanAfford(b) ? c : TooExpensiveBuildableIconColor; _baseIcon[iconi].X = IconLeft + IconSpacing * iconi; _baseIcon[iconi].Y = _toolbarPanel.Y + Height/2; _baseIcon[iconi].Frame = (byte)icon.CursorFrame; _baseIcon[iconi].Color = c; if(icon.WeaponIcon != null) { icon.WeaponIcon[0].X = _baseIcon[iconi].X; icon.WeaponIcon[0].Y = _baseIcon[iconi].Y; icon.WeaponIcon[0].Color = c; r.AddDrawable(icon.WeaponIcon); } } r.AddDrawable(_baseIcon); }