diff options
author | peter1138 <peter1138@openttd.org> | 2014-10-12 20:43:25 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2014-10-12 20:43:25 +0000 |
commit | 1088ad48fceb19408f41f4f3caf0f9e525d977d9 (patch) | |
tree | 8cfd5f56b89acc4ab3a5c9be761b1015f121d79d | |
parent | 771dcf3b7b15f58e1d6fb2795e7df3c00ebf2809 (diff) | |
download | openttd-1088ad48fceb19408f41f4f3caf0f9e525d977d9.tar.xz |
(svn r27004) -Codechange: Make GUI size apply to (sprite-font) text as well.
-rw-r--r-- | src/fontcache.cpp | 7 | ||||
-rw-r--r-- | src/fontcache.h | 2 | ||||
-rw-r--r-- | src/gfx.cpp | 1 | ||||
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | src/settings_gui.cpp | 3 | ||||
-rw-r--r-- | src/spritecache.cpp | 18 | ||||
-rw-r--r-- | src/spriteloader/grf.cpp | 6 |
7 files changed, 30 insertions, 13 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 45a1b28dc..c8aca9852 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -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(GlyphID key) 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; diff --git a/src/fontcache.h b/src/fontcache.h index 804ad2c4b..8caf4f1bd 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -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. diff --git a/src/gfx.cpp b/src/gfx.cpp index cd14fdcfd..6db886dda 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1139,6 +1139,7 @@ void LoadStringWidthTable(bool monospace) } } + ClearFontCache(); ReInitAllWindows(); } diff --git a/src/settings.cpp b/src/settings.cpp index 58b2000d1..e2baed5ba 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1066,14 +1066,14 @@ static bool InvalidateVehTimetableWindow(int32 p1) 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; } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 03dc618b9..5bfcb04ce 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -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: diff --git a/src/spritecache.cpp b/src/spritecache.cpp index c41b8f51c..764616e8f 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -438,12 +438,20 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty 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); } diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index a45bd0fa8..b21e70b1d 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -230,7 +230,7 @@ uint8 LoadSpriteV1(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_po /* 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 *sprite, uint8 file_slot, size_t file_po 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. */ |