mirror of https://github.com/OpenTTD/OpenTTD
(svn r27004) -Codechange: Make GUI size apply to (sprite-font) text as well.
parent
771dcf3b7b
commit
1088ad48fc
|
@ -18,6 +18,7 @@
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "zoom_type.h"
|
#include "zoom_type.h"
|
||||||
#include "gfx_layout.h"
|
#include "gfx_layout.h"
|
||||||
|
#include "zoom_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/control_codes.h"
|
#include "table/control_codes.h"
|
||||||
|
@ -80,6 +81,7 @@ public:
|
||||||
virtual void ClearFontCache();
|
virtual void ClearFontCache();
|
||||||
virtual const Sprite *GetGlyph(GlyphID key);
|
virtual const Sprite *GetGlyph(GlyphID key);
|
||||||
virtual uint GetGlyphWidth(GlyphID key);
|
virtual uint GetGlyphWidth(GlyphID key);
|
||||||
|
virtual int GetHeight() const;
|
||||||
virtual bool GetDrawGlyphShadow();
|
virtual bool GetDrawGlyphShadow();
|
||||||
virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
|
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; }
|
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;
|
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()
|
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
* Get the height of the font.
|
* Get the height of the font.
|
||||||
* @return 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.
|
* Get the ascender value of the font.
|
||||||
|
|
|
@ -1139,6 +1139,7 @@ void LoadStringWidthTable(bool monospace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClearFontCache();
|
||||||
ReInitAllWindows();
|
ReInitAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1066,14 +1066,14 @@ static bool InvalidateVehTimetableWindow(int32 p1)
|
||||||
static bool ZoomMinMaxChanged(int32 p1)
|
static bool ZoomMinMaxChanged(int32 p1)
|
||||||
{
|
{
|
||||||
extern void ConstrainAllViewportsZoom();
|
extern void ConstrainAllViewportsZoom();
|
||||||
|
ConstrainAllViewportsZoom();
|
||||||
|
GfxClearSpriteCache();
|
||||||
if (_settings_client.gui.zoom_min > _gui_zoom) {
|
if (_settings_client.gui.zoom_min > _gui_zoom) {
|
||||||
/* Restrict GUI zoom if it is no longer available. */
|
/* Restrict GUI zoom if it is no longer available. */
|
||||||
_gui_zoom = _settings_client.gui.zoom_min;
|
_gui_zoom = _settings_client.gui.zoom_min;
|
||||||
UpdateCursorSize();
|
UpdateCursorSize();
|
||||||
ReInitAllWindows();
|
LoadStringWidthTable();
|
||||||
}
|
}
|
||||||
ConstrainAllViewportsZoom();
|
|
||||||
GfxClearSpriteCache();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -528,9 +528,10 @@ struct GameOptionsWindow : Window {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GO_GUI_ZOOM_DROPDOWN:
|
case WID_GO_GUI_ZOOM_DROPDOWN:
|
||||||
|
GfxClearSpriteCache();
|
||||||
_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
|
_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
|
||||||
UpdateCursorSize();
|
UpdateCursorSize();
|
||||||
ReInitAllWindows();
|
LoadStringWidthTable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GO_BASE_GRF_DROPDOWN:
|
case WID_GO_BASE_GRF_DROPDOWN:
|
||||||
|
|
|
@ -438,12 +438,20 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprite_type == ST_NORMAL) {
|
|
||||||
if (!ResizeSprites(sprite, sprite_avail, file_slot, sc->id)) {
|
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?");
|
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);
|
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);
|
return BlitterFactory::GetCurrentBlitter()->Encode(sprite, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 */
|
/* Type 0xFF indicates either a colourmap or some other non-sprite info; we do not handle them here */
|
||||||
if (type == 0xFF) return 0;
|
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].height = FioReadByte();
|
||||||
sprite[zoom_lvl].width = FioReadWord();
|
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 colour = type & SCC_MASK;
|
||||||
byte zoom = FioReadByte();
|
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)) {
|
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_NORMAL) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
|
ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
|
||||||
|
|
||||||
if (HasBit(loaded_sprites, zoom_lvl)) {
|
if (HasBit(loaded_sprites, zoom_lvl)) {
|
||||||
/* We already have this zoom level, skip sprite. */
|
/* We already have this zoom level, skip sprite. */
|
||||||
|
|
Loading…
Reference in New Issue