Changeset - r21852:0988eb0acc74
[Not reviewed]
master
0 7 0
peter1138 - 10 years ago 2014-10-12 20:43:25
peter1138@openttd.org
(svn r27004) -Codechange: Make GUI size apply to (sprite-font) text as well.
7 files changed with 30 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/fontcache.cpp
Show inline comments
 
@@ -18,6 +18,7 @@
 
#include "strings_func.h"
 
#include "zoom_type.h"
 
#include "gfx_layout.h"
 
#include "zoom_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/control_codes.h"
 
@@ -80,6 +81,7 @@ public:
 
	virtual void ClearFontCache();
 
	virtual const Sprite *GetGlyph(GlyphID key);
 
	virtual uint GetGlyphWidth(GlyphID key);
 
	virtual int GetHeight() const;
 
	virtual bool GetDrawGlyphShadow();
 
	virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
 
	virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return NULL; }
 
@@ -184,6 +186,11 @@ uint SpriteFontCache::GetGlyphWidth(Glyp
 
	return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + (this->fs != FS_NORMAL) : 0;
 
}
 

	
 
int SpriteFontCache::GetHeight() const
 
{
 
	return UnScaleByZoom(4 * this->height, ZOOM_LVL_GUI);
 
}
 

	
 
bool SpriteFontCache::GetDrawGlyphShadow()
 
{
 
	return false;
src/fontcache.h
Show inline comments
 
@@ -44,7 +44,7 @@ public:
 
	 * Get the height of the font.
 
	 * @return The height of the font.
 
	 */
 
	inline int GetHeight() const { return this->height; }
 
	virtual int GetHeight() const { return this->height; }
 

	
 
	/**
 
	 * Get the ascender value of the font.
src/gfx.cpp
Show inline comments
 
@@ -1139,6 +1139,7 @@ void LoadStringWidthTable(bool monospace
 
		}
 
	}
 

	
 
	ClearFontCache();
 
	ReInitAllWindows();
 
}
 

	
src/settings.cpp
Show inline comments
 
@@ -1066,14 +1066,14 @@ static bool InvalidateVehTimetableWindow
 
static bool ZoomMinMaxChanged(int32 p1)
 
{
 
	extern void ConstrainAllViewportsZoom();
 
	ConstrainAllViewportsZoom();
 
	GfxClearSpriteCache();
 
	if (_settings_client.gui.zoom_min > _gui_zoom) {
 
		/* Restrict GUI zoom if it is no longer available. */
 
		_gui_zoom = _settings_client.gui.zoom_min;
 
		UpdateCursorSize();
 
		ReInitAllWindows();
 
		LoadStringWidthTable();
 
	}
 
	ConstrainAllViewportsZoom();
 
	GfxClearSpriteCache();
 
	return true;
 
}
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -528,9 +528,10 @@ struct GameOptionsWindow : Window {
 
				break;
 

	
 
			case WID_GO_GUI_ZOOM_DROPDOWN:
 
				GfxClearSpriteCache();
 
				_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
 
				UpdateCursorSize();
 
				ReInitAllWindows();
 
				LoadStringWidthTable();
 
				break;
 

	
 
			case WID_GO_BASE_GRF_DROPDOWN:
src/spritecache.cpp
Show inline comments
 
@@ -438,12 +438,20 @@ static void *ReadSprite(const SpriteCach
 
		return s;
 
	}
 

	
 
	if (sprite_type == ST_NORMAL) {
 
		if (!ResizeSprites(sprite, sprite_avail, file_slot, sc->id)) {
 
			if (id == SPR_IMG_QUERY) usererror("Okay... something went horribly wrong. I couldn't resize the fallback sprite. What should I do?");
 
			return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
 
		}
 
	if (!ResizeSprites(sprite, sprite_avail, file_slot, sc->id)) {
 
		if (id == SPR_IMG_QUERY) usererror("Okay... something went horribly wrong. I couldn't resize the fallback sprite. What should I do?");
 
		return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
 
	}
 

	
 
	if (sprite->type == ST_FONT && ZOOM_LVL_GUI != ZOOM_LVL_NORMAL) {
 
		/* Make ZOOM_LVL_GUI be ZOOM_LVL_NORMAL */
 
		sprite[ZOOM_LVL_NORMAL] = sprite[ZOOM_LVL_GUI];
 
		sprite->width  = sprite[ZOOM_LVL_NORMAL].width;
 
		sprite->height = sprite[ZOOM_LVL_NORMAL].height;
 
		sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
 
		sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
 
	}
 

	
 
	return BlitterFactory::GetCurrentBlitter()->Encode(sprite, allocator);
 
}
 

	
src/spriteloader/grf.cpp
Show inline comments
 
@@ -230,7 +230,7 @@ uint8 LoadSpriteV1(SpriteLoader::Sprite 
 
	/* Type 0xFF indicates either a colourmap or some other non-sprite info; we do not handle them here */
 
	if (type == 0xFF) return 0;
 

	
 
	ZoomLevel zoom_lvl = (sprite_type == ST_NORMAL) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_NORMAL;
 
	ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_NORMAL;
 

	
 
	sprite[zoom_lvl].height = FioReadByte();
 
	sprite[zoom_lvl].width  = FioReadWord();
 
@@ -275,8 +275,8 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite 
 
		byte colour = type & SCC_MASK;
 
		byte zoom = FioReadByte();
 

	
 
		if (colour != 0 && (load_32bpp ? colour != SCC_PAL : colour == SCC_PAL) && (sprite_type == ST_NORMAL ? zoom < lengthof(zoom_lvl_map) : zoom == 0)) {
 
			ZoomLevel zoom_lvl = (sprite_type == ST_NORMAL) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
 
		if (colour != 0 && (load_32bpp ? colour != SCC_PAL : colour == SCC_PAL) && (sprite_type != ST_MAPGEN ? zoom < lengthof(zoom_lvl_map) : zoom == 0)) {
 
			ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
 

	
 
			if (HasBit(loaded_sprites, zoom_lvl)) {
 
				/* We already have this zoom level, skip sprite. */
0 comments (0 inline, 0 general)