mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use ZOOM_LVL_MIN to refer to first zoom level.
Many uses of ZOOM_LVL_NORMAL actually just want the first zoom level slot, so use ZOOM_LVL_MIN to make this clearer.
This commit is contained in:
parent
7c322ebcf1
commit
3c94e81665
|
@ -306,9 +306,9 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_MIN;
|
||||
zoom_max = ZOOM_LVL_MIN;
|
||||
} else {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
|
@ -416,10 +416,10 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(SpriteData) + len);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
SpriteData *dst = (SpriteData *)dest_sprite->data;
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
|
|
|
@ -118,17 +118,17 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
|
|||
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
{
|
||||
Blitter_32bppSimple::Pixel *dst;
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_NORMAL].height * (size_t)sprite[ZOOM_LVL_NORMAL].width * sizeof(*dst));
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_MIN].height * (size_t)sprite[ZOOM_LVL_MIN].width * sizeof(*dst));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
dst = (Blitter_32bppSimple::Pixel *)dest_sprite->data;
|
||||
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite[ZOOM_LVL_NORMAL].data;
|
||||
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite[ZOOM_LVL_MIN].data;
|
||||
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_NORMAL].height * sprite[ZOOM_LVL_NORMAL].width; i++) {
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_MIN].height * sprite[ZOOM_LVL_MIN].width; i++) {
|
||||
if (src->m == 0) {
|
||||
dst[i].r = src->r;
|
||||
dst[i].g = src->g;
|
||||
|
|
|
@ -26,9 +26,9 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
* Second uint32_t of a line = the number of transparent pixels from the right.
|
||||
* Then all RGBA then all MV.
|
||||
*/
|
||||
ZoomLevel zoom_min = ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_NORMAL].type != SpriteType::Font) {
|
||||
ZoomLevel zoom_min = ZOOM_LVL_MIN;
|
||||
ZoomLevel zoom_max = ZOOM_LVL_MIN;
|
||||
if (sprite[ZOOM_LVL_MIN].type != SpriteType::Font) {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
if (zoom_max == zoom_min) zoom_max = ZOOM_LVL_MAX;
|
||||
|
@ -52,10 +52,10 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
}
|
||||
|
||||
Sprite *dst_sprite = (Sprite *) allocator(sizeof(Sprite) + sizeof(SpriteData) + all_sprites_size);
|
||||
dst_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dst_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dst_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dst_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dst_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dst_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dst_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dst_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
memcpy(dst_sprite->data, &sd, sizeof(SpriteData));
|
||||
|
||||
/* Copy colours and determine flags. */
|
||||
|
|
|
@ -128,9 +128,9 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_MIN;
|
||||
zoom_max = ZOOM_LVL_MIN;
|
||||
} else {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
|
@ -221,10 +221,10 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
/* Allocate the exact amount of memory we need */
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + size);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
memcpy(dest_sprite->data, temp_dst, size);
|
||||
|
||||
return dest_sprite;
|
||||
|
|
|
@ -64,16 +64,16 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
|||
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
{
|
||||
Sprite *dest_sprite;
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_NORMAL].height * (size_t)sprite[ZOOM_LVL_NORMAL].width);
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_MIN].height * (size_t)sprite[ZOOM_LVL_MIN].width);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
/* Copy over only the 'remap' channel, as that is what we care about in 8bpp */
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_NORMAL].height * sprite[ZOOM_LVL_NORMAL].width; i++) {
|
||||
dest_sprite->data[i] = sprite[ZOOM_LVL_NORMAL].data[i].m;
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_MIN].height * sprite[ZOOM_LVL_MIN].width; i++) {
|
||||
dest_sprite->data[i] = sprite[ZOOM_LVL_MIN].data[i].m;
|
||||
}
|
||||
|
||||
return dest_sprite;
|
||||
|
|
|
@ -20,10 +20,10 @@ Sprite *Blitter_Null::Encode(const SpriteLoader::SpriteCollection &sprite, Alloc
|
|||
Sprite *dest_sprite;
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
return dest_sprite;
|
||||
}
|
||||
|
|
|
@ -272,8 +272,8 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
|
|||
|
||||
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */
|
||||
SpriteLoader::SpriteCollection spritecollection;
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_NORMAL];
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, static_cast<size_t>(width) * height);
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_MIN];
|
||||
sprite.AllocateData(ZOOM_LVL_MIN, static_cast<size_t>(width) * height);
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
|
|
14
src/gfx.cpp
14
src/gfx.cpp
|
@ -53,7 +53,7 @@ static uint8_t _stringwidth_table[FS_END][224]; ///< Cache containing width of o
|
|||
DrawPixelInfo *_cur_dpi;
|
||||
|
||||
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE);
|
||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL);
|
||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_MIN);
|
||||
|
||||
static ReusableBuffer<uint8_t> _cursor_backup;
|
||||
|
||||
|
@ -99,7 +99,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
|||
/**
|
||||
* Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
|
||||
*
|
||||
* @pre dpi->zoom == ZOOM_LVL_NORMAL, right >= left, bottom >= top
|
||||
* @pre dpi->zoom == ZOOM_LVL_MIN, right >= left, bottom >= top
|
||||
* @param left Minimum X (inclusive)
|
||||
* @param top Minimum Y (inclusive)
|
||||
* @param right Maximum X (inclusive)
|
||||
|
@ -118,7 +118,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
|
|||
const int otop = top;
|
||||
const int oleft = left;
|
||||
|
||||
if (dpi->zoom != ZOOM_LVL_NORMAL) return;
|
||||
if (dpi->zoom != ZOOM_LVL_MIN) return;
|
||||
if (left > right || top > bottom) return;
|
||||
if (right < dpi->left || left >= dpi->left + dpi->width) return;
|
||||
if (bottom < dpi->top || top >= dpi->top + dpi->height) return;
|
||||
|
@ -198,7 +198,7 @@ static std::vector<LineSegment> MakePolygonSegments(const std::vector<Point> &sh
|
|||
* The odd-even winding rule is used, i.e. self-intersecting polygons will have holes in them.
|
||||
* Left and top edges are inclusive, right and bottom edges are exclusive.
|
||||
* @note For rectangles the GfxFillRect function will be faster.
|
||||
* @pre dpi->zoom == ZOOM_LVL_NORMAL
|
||||
* @pre dpi->zoom == ZOOM_LVL_MIN
|
||||
* @param shape List of points on the polygon.
|
||||
* @param colour An 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR).
|
||||
* @param mode
|
||||
|
@ -210,7 +210,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
|||
{
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
const DrawPixelInfo *dpi = _cur_dpi;
|
||||
if (dpi->zoom != ZOOM_LVL_NORMAL) return;
|
||||
if (dpi->zoom != ZOOM_LVL_MIN) return;
|
||||
|
||||
std::vector<LineSegment> segments = MakePolygonSegments(shape, Point{ dpi->left, dpi->top });
|
||||
|
||||
|
@ -1565,7 +1565,7 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int heigh
|
|||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
const DrawPixelInfo *o = _cur_dpi;
|
||||
|
||||
n->zoom = ZOOM_LVL_NORMAL;
|
||||
n->zoom = ZOOM_LVL_MIN;
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
|
@ -1789,7 +1789,7 @@ void UpdateGUIZoom()
|
|||
_gui_scale = Clamp(_gui_scale_cfg, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
|
||||
}
|
||||
|
||||
int8_t new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
|
||||
int8_t new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_NORMAL : ZOOM_LVL_OUT_2X;
|
||||
/* Font glyphs should not be clamped to min/max zoom. */
|
||||
_font_zoom = static_cast<ZoomLevel>(new_zoom);
|
||||
/* Ensure the gui_zoom is clamped between min/max. */
|
||||
|
|
|
@ -1078,7 +1078,7 @@ struct SpriteAlignerWindow : Window {
|
|||
}
|
||||
|
||||
SpriteAlignerWindow::zoom = Clamp(SpriteAlignerWindow::zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max);
|
||||
for (ZoomLevel z = ZOOM_LVL_NORMAL; z < ZOOM_LVL_END; z++) {
|
||||
for (ZoomLevel z = ZOOM_LVL_BEGIN; z < ZOOM_LVL_END; z++) {
|
||||
this->SetWidgetsDisabledState(z < _settings_client.gui.zoom_min || z > _settings_client.gui.zoom_max, WID_SA_ZOOM + z);
|
||||
this->SetWidgetsLoweredState(SpriteAlignerWindow::zoom == z, WID_SA_ZOOM + z);
|
||||
}
|
||||
|
|
|
@ -770,7 +770,7 @@ int openttd_main(int argc, char *argv[])
|
|||
InitializeSpriteSorter();
|
||||
|
||||
/* Initialize the zoom level of the screen to normal */
|
||||
_screen.zoom = ZOOM_LVL_NORMAL;
|
||||
_screen.zoom = ZOOM_LVL_MIN;
|
||||
|
||||
/* The video driver is now selected, now initialise GUI zoom */
|
||||
AdjustGUIZoom(false);
|
||||
|
|
|
@ -241,8 +241,8 @@ const Sprite *CoreTextFontCache::InternalGetGlyph(GlyphID key, bool use_aa)
|
|||
if (width > MAX_GLYPH_DIM || height > MAX_GLYPH_DIM) UserError("Font glyph is too large");
|
||||
|
||||
SpriteLoader::SpriteCollection spritecollection;
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_NORMAL];
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, width * height);
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_MIN];
|
||||
sprite.AllocateData(ZOOM_LVL_MIN, width * height);
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (use_aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
|
|
|
@ -229,8 +229,8 @@ void Win32FontCache::ClearFontCache()
|
|||
|
||||
/* GDI has rendered the glyph, now we allocate a sprite and copy the image into it. */
|
||||
SpriteLoader::SpriteCollection spritecollection;
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_NORMAL];
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, width * height);
|
||||
SpriteLoader::Sprite &sprite = spritecollection[ZOOM_LVL_MIN];
|
||||
sprite.AllocateData(ZOOM_LVL_MIN, width * height);
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
|
|
|
@ -243,11 +243,11 @@ static bool ResizeSpriteIn(SpriteLoader::SpriteCollection &sprite, ZoomLevel src
|
|||
static void ResizeSpriteOut(SpriteLoader::SpriteCollection &sprite, ZoomLevel zoom)
|
||||
{
|
||||
/* Algorithm based on 32bpp_Optimized::ResizeSprite() */
|
||||
sprite[zoom].width = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].width, zoom);
|
||||
sprite[zoom].height = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].height, zoom);
|
||||
sprite[zoom].x_offs = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].x_offs, zoom);
|
||||
sprite[zoom].y_offs = UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].y_offs, zoom);
|
||||
sprite[zoom].colours = sprite[ZOOM_LVL_NORMAL].colours;
|
||||
sprite[zoom].width = UnScaleByZoom(sprite[ZOOM_LVL_MIN].width, zoom);
|
||||
sprite[zoom].height = UnScaleByZoom(sprite[ZOOM_LVL_MIN].height, zoom);
|
||||
sprite[zoom].x_offs = UnScaleByZoom(sprite[ZOOM_LVL_MIN].x_offs, zoom);
|
||||
sprite[zoom].y_offs = UnScaleByZoom(sprite[ZOOM_LVL_MIN].y_offs, zoom);
|
||||
sprite[zoom].colours = sprite[ZOOM_LVL_MIN].colours;
|
||||
|
||||
sprite[zoom].AllocateData(zoom, static_cast<size_t>(sprite[zoom].height) * sprite[zoom].width);
|
||||
|
||||
|
@ -375,22 +375,24 @@ static bool ResizeSprites(SpriteLoader::SpriteCollection &sprite, uint8_t sprite
|
|||
{
|
||||
/* Create a fully zoomed image if it does not exist */
|
||||
ZoomLevel first_avail = static_cast<ZoomLevel>(FindFirstBit(sprite_avail));
|
||||
if (first_avail != ZOOM_LVL_NORMAL) {
|
||||
if (!ResizeSpriteIn(sprite, first_avail, ZOOM_LVL_NORMAL)) return false;
|
||||
SetBit(sprite_avail, ZOOM_LVL_NORMAL);
|
||||
if (first_avail != ZOOM_LVL_MIN) {
|
||||
if (!ResizeSpriteIn(sprite, first_avail, ZOOM_LVL_MIN)) return false;
|
||||
SetBit(sprite_avail, ZOOM_LVL_MIN);
|
||||
}
|
||||
|
||||
/* Pad sprites to make sizes match. */
|
||||
if (!PadSprites(sprite, sprite_avail, encoder)) return false;
|
||||
|
||||
/* Create other missing zoom levels */
|
||||
for (ZoomLevel zoom = ZOOM_LVL_OUT_2X; zoom != ZOOM_LVL_END; zoom++) {
|
||||
for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
|
||||
if (zoom == ZOOM_LVL_MIN) continue;
|
||||
|
||||
if (HasBit(sprite_avail, zoom)) {
|
||||
/* Check that size and offsets match the fully zoomed image. */
|
||||
assert(sprite[zoom].width == UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].width, zoom));
|
||||
assert(sprite[zoom].height == UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].height, zoom));
|
||||
assert(sprite[zoom].x_offs == UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].x_offs, zoom));
|
||||
assert(sprite[zoom].y_offs == UnScaleByZoom(sprite[ZOOM_LVL_NORMAL].y_offs, zoom));
|
||||
assert(sprite[zoom].width == UnScaleByZoom(sprite[ZOOM_LVL_MIN].width, zoom));
|
||||
assert(sprite[zoom].height == UnScaleByZoom(sprite[ZOOM_LVL_MIN].height, zoom));
|
||||
assert(sprite[zoom].x_offs == UnScaleByZoom(sprite[ZOOM_LVL_MIN].x_offs, zoom));
|
||||
assert(sprite[zoom].y_offs == UnScaleByZoom(sprite[ZOOM_LVL_MIN].y_offs, zoom));
|
||||
}
|
||||
|
||||
/* Zoom level is not available, or unusable, so create it */
|
||||
|
@ -465,7 +467,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
|
||||
SpriteLoader::SpriteCollection sprite;
|
||||
uint8_t sprite_avail = 0;
|
||||
sprite[ZOOM_LVL_NORMAL].type = sprite_type;
|
||||
sprite[ZOOM_LVL_MIN].type = sprite_type;
|
||||
|
||||
SpriteLoaderGrf sprite_loader(file.GetContainerVersion());
|
||||
if (sprite_type != SpriteType::MapGen && encoder->Is32BppSupported()) {
|
||||
|
@ -492,15 +494,15 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
* Ugly: yes. Other solution: no. Blame the original author or
|
||||
* something ;) The image should really have been a data-stream
|
||||
* (so type = 0xFF basically). */
|
||||
uint num = sprite[ZOOM_LVL_NORMAL].width * sprite[ZOOM_LVL_NORMAL].height;
|
||||
uint num = sprite[ZOOM_LVL_MIN].width * sprite[ZOOM_LVL_MIN].height;
|
||||
|
||||
Sprite *s = (Sprite *)allocator(sizeof(*s) + num);
|
||||
s->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
s->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
s->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
s->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
s->width = sprite[ZOOM_LVL_MIN].width;
|
||||
s->height = sprite[ZOOM_LVL_MIN].height;
|
||||
s->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
s->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
SpriteLoader::CommonPixel *src = sprite[ZOOM_LVL_NORMAL].data;
|
||||
SpriteLoader::CommonPixel *src = sprite[ZOOM_LVL_MIN].data;
|
||||
uint8_t *dest = s->data;
|
||||
while (num-- > 0) {
|
||||
*dest++ = src->m;
|
||||
|
@ -515,14 +517,14 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
return (void*)GetRawSprite(SPR_IMG_QUERY, SpriteType::Normal, allocator, encoder);
|
||||
}
|
||||
|
||||
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font && _font_zoom != ZOOM_LVL_NORMAL) {
|
||||
/* Make ZOOM_LVL_NORMAL be ZOOM_LVL_GUI */
|
||||
sprite[ZOOM_LVL_NORMAL].width = sprite[_font_zoom].width;
|
||||
sprite[ZOOM_LVL_NORMAL].height = sprite[_font_zoom].height;
|
||||
sprite[ZOOM_LVL_NORMAL].x_offs = sprite[_font_zoom].x_offs;
|
||||
sprite[ZOOM_LVL_NORMAL].y_offs = sprite[_font_zoom].y_offs;
|
||||
sprite[ZOOM_LVL_NORMAL].data = sprite[_font_zoom].data;
|
||||
sprite[ZOOM_LVL_NORMAL].colours = sprite[_font_zoom].colours;
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font && _font_zoom != ZOOM_LVL_MIN) {
|
||||
/* Make ZOOM_LVL_MIN be ZOOM_LVL_GUI */
|
||||
sprite[ZOOM_LVL_MIN].width = sprite[_font_zoom].width;
|
||||
sprite[ZOOM_LVL_MIN].height = sprite[_font_zoom].height;
|
||||
sprite[ZOOM_LVL_MIN].x_offs = sprite[_font_zoom].x_offs;
|
||||
sprite[ZOOM_LVL_MIN].y_offs = sprite[_font_zoom].y_offs;
|
||||
sprite[ZOOM_LVL_MIN].data = sprite[_font_zoom].data;
|
||||
sprite[ZOOM_LVL_MIN].colours = sprite[_font_zoom].colours;
|
||||
}
|
||||
|
||||
return encoder->Encode(sprite, allocator);
|
||||
|
|
|
@ -230,7 +230,7 @@ uint8_t LoadSpriteV1(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, s
|
|||
/* 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 != SpriteType::MapGen) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_lvl = (sprite_type != SpriteType::MapGen) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_MIN;
|
||||
|
||||
sprite[zoom_lvl].height = file.ReadByte();
|
||||
sprite[zoom_lvl].width = file.ReadWord();
|
||||
|
@ -299,7 +299,7 @@ uint8_t LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, s
|
|||
}
|
||||
|
||||
if (is_wanted_colour_depth && is_wanted_zoom_lvl) {
|
||||
ZoomLevel zoom_lvl = (sprite_type != SpriteType::MapGen) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_lvl = (sprite_type != SpriteType::MapGen) ? zoom_lvl_map[zoom] : ZOOM_LVL_MIN;
|
||||
|
||||
if (HasBit(loaded_sprites, zoom_lvl)) {
|
||||
/* We already have this zoom level, skip sprite. */
|
||||
|
|
|
@ -1270,17 +1270,17 @@ void OpenGLBackend::ReleaseAnimBuffer(const Rect &update_rect)
|
|||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite));
|
||||
|
||||
OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data;
|
||||
new (gl_sprite) OpenGLSprite(sprite[ZOOM_LVL_NORMAL].width, sprite[ZOOM_LVL_NORMAL].height, sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font ? 1 : ZOOM_LVL_END, sprite[ZOOM_LVL_NORMAL].colours);
|
||||
new (gl_sprite) OpenGLSprite(sprite[ZOOM_LVL_MIN].width, sprite[ZOOM_LVL_MIN].height, sprite[ZOOM_LVL_MIN].type == SpriteType::Font ? 1 : ZOOM_LVL_END, sprite[ZOOM_LVL_MIN].colours);
|
||||
|
||||
/* Upload texture data. */
|
||||
for (int i = 0; i < (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font ? 1 : ZOOM_LVL_END); i++) {
|
||||
for (int i = 0; i < (sprite[ZOOM_LVL_MIN].type == SpriteType::Font ? 1 : ZOOM_LVL_END); i++) {
|
||||
gl_sprite->Update(sprite[i].width, sprite[i].height, i, sprite[i].data);
|
||||
}
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
return dest_sprite;
|
||||
}
|
||||
|
|
|
@ -1772,7 +1772,7 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
|
|||
|
||||
DrawPixelInfo dp = _vd.dpi;
|
||||
ZoomLevel zoom = _vd.dpi.zoom;
|
||||
dp.zoom = ZOOM_LVL_NORMAL;
|
||||
dp.zoom = ZOOM_LVL_MIN;
|
||||
dp.width = UnScaleByZoom(dp.width, zoom);
|
||||
dp.height = UnScaleByZoom(dp.height, zoom);
|
||||
_cur_dpi = &dp;
|
||||
|
@ -2006,10 +2006,10 @@ static bool MarkViewportDirty(const Viewport *vp, int left, int top, int right,
|
|||
|
||||
/**
|
||||
* Mark all viewports that display an area as dirty (in need of repaint).
|
||||
* @param left Left edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_NORMAL)
|
||||
* @param top Top edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_NORMAL)
|
||||
* @param right Right edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_NORMAL)
|
||||
* @param bottom Bottom edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_NORMAL)
|
||||
* @param left Left edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_MIN)
|
||||
* @param top Top edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_MIN)
|
||||
* @param right Right edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_MIN)
|
||||
* @param bottom Bottom edge of area to repaint. (viewport coordinates, that is wrt. #ZOOM_LVL_MIN)
|
||||
* @return true if at least one viewport has a dirty block
|
||||
* @ingroup dirty
|
||||
*/
|
||||
|
|
|
@ -905,7 +905,7 @@ static void DrawOverlappedWindow(Window *w, int left, int top, int right, int bo
|
|||
dp->top = top - w->top;
|
||||
dp->pitch = _screen.pitch;
|
||||
dp->dst_ptr = BlitterFactory::GetCurrentBlitter()->MoveTo(_screen.dst_ptr, left, top);
|
||||
dp->zoom = ZOOM_LVL_NORMAL;
|
||||
dp->zoom = ZOOM_LVL_MIN;
|
||||
w->OnPaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "zoom_type.h"
|
||||
|
||||
/**
|
||||
* Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
|
||||
* Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN)
|
||||
* When shifting right, value is rounded up
|
||||
* @param value value to shift
|
||||
* @param zoom zoom level to shift to
|
||||
|
@ -25,7 +25,7 @@ inline int ScaleByZoom(int value, ZoomLevel zoom)
|
|||
}
|
||||
|
||||
/**
|
||||
* Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
|
||||
* Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN)
|
||||
* When shifting right, value is rounded up
|
||||
* @param value value to shift
|
||||
* @param zoom zoom level to shift to
|
||||
|
@ -48,7 +48,7 @@ inline int AdjustByZoom(int value, int zoom)
|
|||
}
|
||||
|
||||
/**
|
||||
* Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
|
||||
* Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN)
|
||||
* @param value value to shift
|
||||
* @param zoom zoom level to shift to
|
||||
* @return shifted value
|
||||
|
@ -59,7 +59,7 @@ inline int ScaleByZoomLower(int value, ZoomLevel zoom)
|
|||
}
|
||||
|
||||
/**
|
||||
* Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
|
||||
* Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN)
|
||||
* @param value value to shift
|
||||
* @param zoom zoom level to shift to
|
||||
* @return shifted value
|
||||
|
@ -71,7 +71,7 @@ inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
|
|||
|
||||
/**
|
||||
* Short-hand to apply GUI zoom level.
|
||||
* @param value Pixel amount at #ZOOM_LVL_BEGIN (full zoom in).
|
||||
* @param value Pixel amount at #ZOOM_LVL_MIN (full zoom in).
|
||||
* @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
|
||||
*/
|
||||
inline int UnScaleGUI(int value)
|
||||
|
|
Loading…
Reference in New Issue