public void setText(MonoGameGameFontCache fontCache) { if (_caches.ContainsKey(fontCache.cacheId) && _caches[fontCache.cacheId] != null) { //TODO: Implement some way to clear old texture regions _gc.Add(_caches[fontCache.cacheId]); _caches.Remove(fontCache.cacheId); } Rectangle rect = determineRequiredArea(fontCache); if (!allocateTextureRegionXY(fontCache.cacheId, ref rect)) { clear(); setText(fontCache); return; } begin(); for (int i = 0; i < fontCache._previousDrawingOperations.Count; i++) { MonoGameGameFontCacheDrawingOperation operation = fontCache._previousDrawingOperations[i]; fontCache._gameFont.draw(_spriteBatch, operation.text, operation.targetWidth, operation.horizontalAlign, operation.wrap, new Vector2(rect.X + operation.x, rect.Y + operation.y), operation.color * operation.alpha); } end(); _caches[fontCache.cacheId] = new MonoGameTextureRegion(_texture, rect.X, rect.Y, rect.Width, rect.Height); }
public void setAllAlphas(float alpha) { GLOBAL_CACHE.clear(cacheId); for (int i = 0; i < _previousDrawingOperations.Count; i++) { MonoGameGameFontCacheDrawingOperation op = _previousDrawingOperations[i]; op.alpha = alpha; } updateCache(); }
public void setAllColors(Color color) { GLOBAL_CACHE.clear(cacheId); for (int i = 0; i < _previousDrawingOperations.Count; i++) { MonoGameGameFontCacheDrawingOperation op = _previousDrawingOperations[i]; op.color = ((MonoGameColor)color)._color; } updateCache(); }
public void addText(CharSequence str, float x, float y, float targetWidth, int horizontalAlign, bool wrap) { var operation = new MonoGameGameFontCacheDrawingOperation() { text = str.toString(), x = x, y = y, targetWidth = targetWidth, horizontalAlign = horizontalAlign, wrap = wrap, color = _setColor, alpha = 1 }; _previousDrawingOperations.AddLast(operation); addText(operation); }
public void addText(CharSequence str, float x, float y, float targetWidth, float targetHeight, int horizontalAlign, bool wrap) { Vector2 v2 = _gameFont._spriteFont.MeasureString(str.toString()); var operation = new MonoGameGameFontCacheDrawingOperation() { text = str.toString(), x = x, y = y, targetWidth = targetWidth, targetHeight = targetHeight, horizontalAlign = horizontalAlign, wrap = wrap, color = _setColor, alpha = 1 }; _previousDrawingOperations.Add(operation); updateCache(); }
private void addText(MonoGameGameFontCacheDrawingOperation operation) { _gameFont.draw(_spriteBatch, operation.text, operation.targetWidth, operation.horizontalAlign, operation.wrap, new Vector2(operation.x, operation.y), Vector2.One, operation.color * operation.alpha); }