From a1ef54fa607a562ceacd7f205b10b93d3e80bd68 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 29 Nov 2021 03:15:54 +0200 Subject: [PATCH] Fixed compilation, deleted 16bpp blitter --- src/ai/ai_gui.cpp | 2 +- src/blitter/16bpp_anim.cpp | 386 -------------------- src/blitter/16bpp_anim.hpp | 75 ---- src/blitter/16bpp_base.cpp | 156 -------- src/blitter/16bpp_base.hpp | 226 ------------ src/blitter/16bpp_simple.cpp | 173 --------- src/blitter/16bpp_simple.hpp | 36 -- src/blitter/CMakeLists.txt | 4 - src/build_confirmation_gui.cpp | 8 +- src/console_cmds.cpp | 2 +- src/music_gui.cpp | 4 +- src/openttd.cpp | 11 +- src/screenshot.cpp | 12 - src/settings_gui.cpp | 6 +- src/settings_table.cpp | 2 +- src/spritecache.cpp | 4 - src/table/settings/gui_settings.ini | 12 +- src/table/settings/old_gameopt_settings.ini | 3 +- src/toolbar_gui.cpp | 4 +- src/tutorial_gui.cpp | 2 +- src/widget.cpp | 8 +- src/window.cpp | 4 +- 22 files changed, 30 insertions(+), 1110 deletions(-) delete mode 100644 src/blitter/16bpp_anim.cpp delete mode 100644 src/blitter/16bpp_anim.hpp delete mode 100644 src/blitter/16bpp_base.cpp delete mode 100644 src/blitter/16bpp_base.hpp delete mode 100644 src/blitter/16bpp_simple.cpp delete mode 100644 src/blitter/16bpp_simple.hpp diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 8efaeafe31..2b2e49ed9d 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -778,7 +778,7 @@ struct AIConfigWindow : public Window { case WID_AIC_LIST: this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - this->line_height = GetMinButtonSize(NWST_BUTTON, this->line_height); + this->line_height = GetMinButtonSize(this->line_height); resize->height = this->line_height; size->height = 8 * this->line_height; break; diff --git a/src/blitter/16bpp_anim.cpp b/src/blitter/16bpp_anim.cpp deleted file mode 100644 index f5a51cfb60..0000000000 --- a/src/blitter/16bpp_anim.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 16bpp_anim.cpp Implementation of the optimized 16 bpp blitter with animation support, currently broken. */ - -#include "../stdafx.h" -#include "../video/video_driver.hpp" -#include "../zoom_func.h" -#include "16bpp_anim.hpp" - -#include "../table/sprites.h" - -/** Instantiation of the 16bpp with animation blitter factory. */ -static FBlitter_16bppAnim iFBlitter_16bppAnim; - -template -void Blitter_16bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) -{ - const Pixel *src, *src_line; - Colour16 *dst, *dst_line; - Anim *anim, *anim_line; - - /* Find where to start reading in the source sprite */ - src_line = (const Pixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (Colour16 *)bp->dst + bp->top * bp->pitch + bp->left; - anim_line = this->anim_buf + ((Colour16 *)bp->dst - (Colour16 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left; - - for (int y = 0; y < bp->height; y++) { - dst = dst_line; - dst_line += bp->pitch; - - src = src_line; - src_line += bp->sprite_width * ScaleByZoom(1, zoom); - - anim = anim_line; - anim_line += this->anim_buf_width; - - for (int x = 0; x < bp->width; x++) { - switch (mode) { - case BM_COLOUR_REMAP: - /* In case the m-channel is zero, do not remap this pixel in any way */ - anim->m = 0; - anim->v = 0; - if (src->m == 0) { - if (src->a != 0) *dst = ComposeColourPA(src->c, src->a, *dst); - } else { - uint8 r = bp->remap[src->m]; - if (r != 0) { - *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(r), src->v), src->a, *dst); - if (src->a == 15 && r >= PALETTE_ANIM_START) { - anim->m = r - PALETTE_ANIM_START + 1; - anim->v = src->v >> 1; - } - } - } - break; - - case BM_TRANSPARENT: - /* TODO -- We make an assumption here that the remap in fact is transparency, not some colour. - * This is never a problem with the code we produce, but newgrfs can make it fail... or at least: - * we produce a result the newgrf maker didn't expect ;) */ - - /* Make the current colour a bit more black, so it looks like this image is transparent */ - if (src->a != 0) *dst = MakeTransparent(*dst, 192); - anim->m = 0; - anim->v = 0; - break; - - default: - if (src->a == 15 && src->m >= PALETTE_ANIM_START) { - *dst = AdjustBrightness(LookupColourInPalette(src->m), src->v); - anim->m = src->m - PALETTE_ANIM_START + 1; - anim->v = src->v >> 1; - } else { - if (src->a != 0) { - if (src->m >= PALETTE_ANIM_START) { - *dst = ComposeColourPANoCheck(AdjustBrightness(LookupColourInPalette(src->m), src->v), src->a, *dst); - } else { - *dst = ComposeColourPA(src->c, src->a, *dst); - } - } - anim->m = 0; - anim->v = 0; - } - break; - } - dst++; - src += ScaleByZoom(1, zoom); - } - } -} - -void Blitter_16bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) -{ - if (_screen_disable_anim) { - /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */ - Blitter_16bppOptimized::Draw(bp, mode, zoom); - return; - } - - switch (mode) { - default: NOT_REACHED(); - case BM_NORMAL: Draw (bp, zoom); return; - case BM_COLOUR_REMAP: Draw(bp, zoom); return; - case BM_TRANSPARENT: Draw (bp, zoom); return; - } -} - -void Blitter_16bppAnim::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) -{ - if (_screen_disable_anim) { - /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColourMappingRect() */ - Blitter_16bppOptimized::DrawColourMappingRect(dst, width, height, pal); - return; - } - - Colour16 *udst = (Colour16 *)dst; - Anim *anim; - - anim = this->anim_buf + ((Colour16 *)dst - (Colour16 *)_screen.dst_ptr); - - if (pal == PALETTE_TO_TRANSPARENT) { - do { - for (int i = 0; i != width; i++) { - *udst = MakeTransparent(*udst, 154); - anim->m = 0; - anim->v = 0; - udst++; - anim++; - } - udst = udst - width + _screen.pitch; - anim = anim - width + this->anim_buf_width; - } while (--height); - return; - } - if (pal == PALETTE_NEWSPAPER) { - do { - for (int i = 0; i != width; i++) { - *udst = MakeGrey(*udst); - anim->m = 0; - anim->v = 0; - udst++; - anim++; - } - udst = udst - width + _screen.pitch; - anim = anim - width + this->anim_buf_width; - } while (--height); - return; - } - - DEBUG(misc, 0, "16bpp blitter doesn't know how to draw this colour table ('%d')", pal); -} - -void Blitter_16bppAnim::SetPixel(void *video, int x, int y, uint8 colour) -{ - *((Colour16 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour); - - /* Set the colour in the anim-buffer too, if we are rendering to the screen */ - if (_screen_disable_anim) return; - Anim *anim = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr) + x + y * this->anim_buf_width; - if (colour >= PALETTE_ANIM_START) { - anim->m = colour - PALETTE_ANIM_START + 1; - anim->v = DEFAULT_BRIGHTNESS >> 1; - } else { - anim->m = 0; - anim->v = 0; - } -} - -void Blitter_16bppAnim::DrawRect(void *video, int width, int height, uint8 colour) -{ - if (_screen_disable_anim) { - /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */ - Blitter_16bppOptimized::DrawRect(video, width, height, colour); - return; - } - - Colour16 colour16 = LookupColourInPalette(colour); - Anim *anim_line = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr); - - do { - Colour16 *dst = (Colour16 *)video; - Anim *anim = anim_line; - - for (int i = width; i > 0; i--) { - *dst = colour16; - /* Set the colour in the anim-buffer too */ - if (colour >= PALETTE_ANIM_START) { - anim->m = colour - PALETTE_ANIM_START + 1; - anim->v = DEFAULT_BRIGHTNESS >> 1; - } else { - anim->m = 0; - anim->v = 0; - } - dst++; - anim++; - } - video = (Colour16 *)video + _screen.pitch; - anim_line += this->anim_buf_width; - } while (--height); -} - -void Blitter_16bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height) -{ - assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - Colour16 *dst = (Colour16 *)video; - const uint8 *usrc = (const uint8 *)src; - Anim *anim_line = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr); - - for (; height > 0; height--) { - /* We need to keep those for palette animation. */ - Colour16 *dst_pal = dst; - Anim *anim_pal = anim_line; - - memcpy(dst, usrc, width * sizeof(Colour16)); - usrc += width * sizeof(Colour16); - dst += _screen.pitch; - /* Copy back the anim-buffer */ - memcpy(anim_line, usrc, width * sizeof(Anim)); - usrc += width * sizeof(Anim); - anim_line += this->anim_buf_width; - - /* Okay, it is *very* likely that the image we stored is using - * the wrong palette animated colours. There are two things we - * can do to fix this. The first is simply reviewing the whole - * screen after we copied the buffer, i.e. run PaletteAnimate, - * however that forces a full screen redraw which is expensive - * for just the cursor. This just copies the implementation of - * palette animation, much cheaper though slightly nastier. */ - for (int i = 0; i < width; i++) { - uint8 colour = anim_pal->m; - if (colour) { - /* Update this pixel */ - *dst_pal = AdjustBrightness(LookupColourInPalette(colour + PALETTE_ANIM_START - 1), anim_pal->v << 1); - } - dst_pal++; - anim_pal++; - } - } -} - -void Blitter_16bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height) -{ - assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint8 *udst = (uint8 *)dst; - const Colour16 *src = (const Colour16 *)video; - const Anim *anim_line = this->anim_buf + ((const Colour16 *)video - (Colour16 *)_screen.dst_ptr); - - for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(Colour16)); - src += _screen.pitch; - udst += width * sizeof(Colour16); - /* Copy the anim-buffer */ - memcpy(udst, anim_line, width * sizeof(Anim)); - udst += width * sizeof(Anim); - anim_line += this->anim_buf_width; - } -} - -void Blitter_16bppAnim::ScrollBuffer(void *video, int &left_ref, int &top_ref, int &width_ref, int &height_ref, int scroll_x, int scroll_y) -{ - assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - const Anim *src; - Anim *dst; - int left = left_ref, top = top_ref, width = width_ref, height = height_ref; - - /* We need to scroll the anim-buffer too */ - if (scroll_y > 0) { - /* Calculate pointers */ - dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width; - src = dst - scroll_y * this->anim_buf_width; - - /* Decrease height and increase top */ - top += scroll_y; - height -= scroll_y; - assert(height > 0); - - /* Adjust left & width */ - if (scroll_x >= 0) { - dst += scroll_x; - left += scroll_x; - width -= scroll_x; - } else { - src -= scroll_x; - width += scroll_x; - } - - for (int h = height; h > 0; h--) { - memcpy(dst, src, width * sizeof(Anim)); - src -= this->anim_buf_width; - dst -= this->anim_buf_width; - } - } else { - /* Calculate pointers */ - dst = this->anim_buf + left + top * this->anim_buf_width; - src = dst - scroll_y * this->anim_buf_width; - - /* Decrease height. (scroll_y is <=0). */ - height += scroll_y; - assert(height > 0); - - /* Adjust left & width */ - if (scroll_x >= 0) { - dst += scroll_x; - left += scroll_x; - width -= scroll_x; - } else { - src -= scroll_x; - width += scroll_x; - } - - /* the y-displacement may be 0 therefore we have to use memmove, - * because source and destination may overlap */ - for (int h = height; h > 0; h--) { - memmove(dst, src, width * sizeof(Anim)); - src += _screen.pitch; - dst += _screen.pitch; - } - } - - Blitter_16bppOptimized::ScrollBuffer(video, left_ref, top_ref, width_ref, height_ref, scroll_x, scroll_y); -} - -int Blitter_16bppAnim::BufferSize(int width, int height) -{ - return width * height * (sizeof(Anim) + sizeof(Colour16)); -} - -void Blitter_16bppAnim::PaletteAnimate(const Palette &palette) -{ - assert(!_screen_disable_anim); - - /* If first_dirty is 0, it is for 8bpp indication to send the new - * palette. However, only the animation colours might possibly change. - * Especially when going between toyland and non-toyland. */ - assert(palette.first_dirty == PALETTE_ANIM_START || palette.first_dirty == 0); - - for (int i = 0; i < 256; i++) { - this->palette[i] = To16(palette.palette[i]); - } - - const Anim *anim = this->anim_buf; - Colour16 *dst = (Colour16 *)_screen.dst_ptr; - - /* Let's walk the anim buffer and try to find the pixels */ - for (int y = this->anim_buf_height; y != 0 ; y--) { - for (int x = this->anim_buf_width; x != 0 ; x--) { - uint8 colour = anim->m; - if (colour) { - /* Update this pixel */ - *dst = AdjustBrightness(LookupColourInPalette(colour + PALETTE_ANIM_START - 1), anim->v << 1); - } - dst++; - anim++; - } - dst += _screen.pitch - this->anim_buf_width; - } - - /* Make sure the backend redraws the whole screen */ - VideoDriver::GetInstance()->MakeDirty(0, 0, _screen.width, _screen.height); -} - -Blitter::PaletteAnimation Blitter_16bppAnim::UsePaletteAnimation() -{ - return Blitter::PALETTE_ANIMATION_BLITTER; -} - -void Blitter_16bppAnim::PostResize() -{ - if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) { - /* The size of the screen changed; we can assume we can wipe all data from our buffer */ - free(this->anim_buf); - this->anim_buf = CallocT(_screen.width * _screen.height); - this->anim_buf_width = _screen.width; - this->anim_buf_height = _screen.height; - } -} diff --git a/src/blitter/16bpp_anim.hpp b/src/blitter/16bpp_anim.hpp deleted file mode 100644 index 80bf6e5df5..0000000000 --- a/src/blitter/16bpp_anim.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 16bpp_anim.hpp A 16 bpp blitter with animation support. */ - -#ifndef BLITTER_16BPP_ANIM_HPP -#define BLITTER_16BPP_ANIM_HPP - -#include "16bpp_simple.hpp" - -class Blitter_16bppOptimized: public Blitter_16bppSimple { - // TODO: implement that -}; - -/** The optimised 16 bpp blitter with palette animation. */ -class Blitter_16bppAnim : public Blitter_16bppOptimized { -protected: - // PALETTE_ANIM_SIZE is less than 32, so we'll use 5 bits for color index, and 3 bits for brightness, losing 1 bit compared to struct Pixel - struct Anim { - unsigned m : 5 __attribute__((packed)); ///< Color index channel, packed 5 bits, 0 = no animation, 1 = PALETTE_ANIM_START - unsigned v : 3 __attribute__((packed)); ///< Brightness-channel, packed 3 bits - }; - - Anim *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation - int anim_buf_width; ///< The width of the animation buffer. - int anim_buf_height; ///< The height of the animation buffer. - Colour16 palette[256]; ///< The current palette. - -public: - Blitter_16bppAnim() : - anim_buf(NULL), - anim_buf_width(0), - anim_buf_height(0) - {} - - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); - /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); - /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); - /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height); - /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height); - /* virtual */ void ScrollBuffer(void *video, int &left_ref, int &top_ref, int &width_ref, int &height_ref, int scroll_x, int scroll_y); - /* virtual */ int BufferSize(int width, int height); - /* virtual */ void PaletteAnimate(const Palette &palette); - /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); - /* virtual */ int GetBytesPerPixel() { return 3; } - - /* virtual */ const char *GetName() { return "16bpp-anim"; } - /* virtual */ void PostResize(); - - /** - * Look up the colour in the current palette. - */ - inline Colour16 LookupColourInPalette(uint8 index) - { - return this->palette[index]; - } - - template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); -}; - -/** Factory for the 16bpp blitter with animation. */ -class FBlitter_16bppAnim : public BlitterFactory { -public: - FBlitter_16bppAnim() : BlitterFactory("16bpp-anim-broken", "16bpp Animation Blitter, currently broken (palette animation)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_16bppAnim(); } -}; - -#endif /* BLITTER_16BPP_ANIM_HPP */ diff --git a/src/blitter/16bpp_base.cpp b/src/blitter/16bpp_base.cpp deleted file mode 100644 index df1ba3ccb0..0000000000 --- a/src/blitter/16bpp_base.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 16bpp_base.cpp Implementation of base for 16 bpp blitters. */ - -#include "../stdafx.h" -#include "16bpp_base.hpp" -#include "common.hpp" - -void *Blitter_16bppBase::MoveTo(void *video, int x, int y) -{ - return (uint16 *)video + x + y * _screen.pitch; -} - -void Blitter_16bppBase::SetPixel(void *video, int x, int y, uint8 colour) -{ - *((Colour16 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour); -} - -void Blitter_16bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) -{ - const Colour16 c = LookupColourInPalette(colour); - this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) { - *((Colour16 *)video + x + y * _screen.pitch) = c; - }); -} - -void Blitter_16bppBase::DrawRect(void *video, int width, int height, uint8 colour) -{ - Colour16 target = LookupColourInPalette(colour); - - do { - Colour16 *dst = (Colour16 *)video; - for (int i = width; i > 0; i--) { - *dst = target; - dst++; - } - video = (uint16 *)video + _screen.pitch; - } while (--height); -} - -void Blitter_16bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) -{ - uint16 *dst = (uint16 *)video; - const uint16 *usrc = (const uint16 *)src; - - for (; height > 0; height--) { - memcpy(dst, usrc, width * sizeof(uint16)); - usrc += width; - dst += _screen.pitch; - } -} - -void Blitter_16bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) -{ - uint16 *udst = (uint16 *)dst; - const uint16 *src = (const uint16 *)video; - - for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint16)); - src += _screen.pitch; - udst += width; - } -} - -void Blitter_16bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) -{ - uint16 *udst = (uint16 *)dst; - const uint16 *src = (const uint16 *)video; - - for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint16)); - src += _screen.pitch; - udst += dst_pitch; - } -} - -void Blitter_16bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) -{ - const Colour16 *src; - Colour16 *dst; - - if (scroll_y > 0) { - /* Calculate pointers */ - dst = (Colour16 *)video + left + (top + height - 1) * _screen.pitch; - src = dst - scroll_y * _screen.pitch; - - /* Decrease height and increase top */ - top += scroll_y; - height -= scroll_y; - assert(height > 0); - - /* Adjust left & width */ - if (scroll_x >= 0) { - dst += scroll_x; - left += scroll_x; - width -= scroll_x; - } else { - src -= scroll_x; - width += scroll_x; - } - - for (int h = height; h > 0; h--) { - memcpy(dst, src, width * sizeof(Colour16)); - src -= _screen.pitch; - dst -= _screen.pitch; - } - } else { - /* Calculate pointers */ - dst = (Colour16 *)video + left + top * _screen.pitch; - src = dst - scroll_y * _screen.pitch; - - /* Decrease height. (scroll_y is <=0). */ - height += scroll_y; - assert(height > 0); - - /* Adjust left & width */ - if (scroll_x >= 0) { - dst += scroll_x; - left += scroll_x; - width -= scroll_x; - } else { - src -= scroll_x; - width += scroll_x; - } - - /* the y-displacement may be 0 therefore we have to use memmove, - * because source and destination may overlap */ - for (int h = height; h > 0; h--) { - memmove(dst, src, width * sizeof(Colour16)); - src += _screen.pitch; - dst += _screen.pitch; - } - } -} - -int Blitter_16bppBase::BufferSize(int width, int height) -{ - return width * height * sizeof(Colour16); -} - -void Blitter_16bppBase::PaletteAnimate(const Palette &palette) -{ - /* By default, 16bpp doesn't have palette animation */ -} - -Blitter::PaletteAnimation Blitter_16bppBase::UsePaletteAnimation() -{ - return Blitter::PALETTE_ANIMATION_NONE; -} diff --git a/src/blitter/16bpp_base.hpp b/src/blitter/16bpp_base.hpp deleted file mode 100644 index 47e1aa843f..0000000000 --- a/src/blitter/16bpp_base.hpp +++ /dev/null @@ -1,226 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 16bpp_base.hpp Base for all 16 bits blitters. */ - -#ifndef BLITTER_16BPP_BASE_HPP -#define BLITTER_16BPP_BASE_HPP - -#include "base.hpp" -#include "../core/bitmath_func.hpp" -#include "../core/math_func.hpp" -#include "../gfx_func.h" - -/** Base for all 16bpp blitters. */ -class Blitter_16bppBase : public Blitter { -public: - - // TODO: GCC-specific attributes - struct Colour16 { - unsigned b : 5 __attribute__((packed)); ///< Blue-channel, packed 5 bits - unsigned g : 6 __attribute__((packed)); ///< Green-channel, packed 6 bits - unsigned r : 5 __attribute__((packed)); ///< Red-channel, packed 5 bits - Colour16(uint8 r = 0, uint8 g = 0, uint8 b = 0): - b(b), g(g), r(r) - { - } - }; - - struct Pixel { - Colour16 c; - unsigned a : 4 __attribute__((packed)); ///< Alpha-channel, packed 4 bits - unsigned v : 4 __attribute__((packed)); ///< Brightness-channel, packed 4 bits - unsigned m : 8 __attribute__((packed)); ///< Remap-channel, cannot pack it, because it's palette lookup index, so it must be in range 0-255 - }; - - /* virtual */ uint8 GetScreenDepth() { return 16; } - /* virtual */ void *MoveTo(void *video, int x, int y); - /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); - /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash); - /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); - /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height); - /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height); - /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch); - /* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y); - /* virtual */ int BufferSize(int width, int height); - /* virtual */ void PaletteAnimate(const Palette &palette); - /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); - /* virtual */ int GetBytesPerPixel() { return 2; } - - - /** - * Convert from rgb values to screen native 16bpp colour - */ - static inline Colour16 To16(uint8 r, uint8 g, uint8 b) - { - return Colour16(r >> 3, g >> 2, b >> 3); - } - - /** - * Convert from 32bpp colour to screen native 16bpp colour - */ - static inline Colour16 To16(Colour c) - { - return To16(c.r, c.g, c.b); - } - - /** - * Look up the colour in the current palette. - */ - static inline Colour LookupColourInPalette32(uint index) - { - return _cur_palette.palette[index]; - } - - /** - * Look up the colour in the current palette. - */ - static inline Colour16 LookupColourInPalette(uint index) - { - return To16(LookupColourInPalette32(index)); - } - - /** - * Compose a colour based on RGBA values and the current pixel value. - * @param r range is from 0 to 31. - * @param g range is from 0 to 63. - * @param b range is from 0 to 31. - * @param a range is from 0 to 15. - */ - static inline Colour16 ComposeColourRGBANoCheck(uint8 r, uint8 g, uint8 b, uint8 a, Colour16 current) - { - /* The 16 is wrong, it should be 15, but 16 is much faster... */ - return Colour16 ( ((int)(r - current.r) * a) / 16 + current.r, - ((int)(g - current.g) * a) / 16 + current.g, - ((int)(b - current.b) * a) / 16 + current.b ); - } - - /** - * Compose a colour based on RGBA values and the current pixel value. - * Handles fully transparent and solid pixels in a special (faster) way. - * @param r range is from 0 to 31. - * @param g range is from 0 to 63. - * @param b range is from 0 to 31. - * @param a range is from 0 to 15. - */ - static inline Colour16 ComposeColourRGBA(uint8 r, uint8 g, uint8 b, uint8 a, Colour16 current) - { - if (a == 0) return current; - if (a >= 15) return Colour16(r, g, b); - - return ComposeColourRGBANoCheck(r, g, b, a, current); - } - - /** - * Compose a colour based on Pixel value, alpha value, and the current pixel value. - * @param a range is from 0 to 16. - */ - static inline Colour16 ComposeColourPANoCheck(Colour16 colour, uint8 a, Colour16 current) - { - return ComposeColourRGBANoCheck(colour.r, colour.g, colour.b, a, current); - } - - /** - * Compose a colour based on Pixel value, alpha value, and the current pixel value. - * Handles fully transparent and solid pixels in a special (faster) way. - * @param a range is from 0 to 15. - */ - static inline Colour16 ComposeColourPA(Colour16 colour, uint8 a, Colour16 current) - { - if (a == 0) return current; - if (a >= 15) return colour; - - return ComposeColourPANoCheck(colour, a, current); - } - - /** - * Make a pixel looks like it is transparent. - * @param colour the colour already on the screen. - * @param nom the amount of transparency, nominator, makes colour lighter. - * @param denom denominator, makes colour darker. - * @return the new colour for the screen. - */ - static inline Colour16 MakeTransparent(Colour16 colour, uint nom, uint denom = 256) - { - uint r = colour.r; - uint g = colour.g; - uint b = colour.b; - - return Colour16( r * nom / denom, - g * nom / denom, - b * nom / denom ); - } - - /** - * Make a colour grey - based. - * @param colour the colour to make grey. - * @return the new colour, now grey. - */ - static inline Colour16 MakeGrey(Colour16 colour) - { - uint8 r = colour.r; - uint8 g = colour.g; - uint8 b = colour.b; - - /* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then - * divide by it to normalize the value to a byte again. See heightmap.cpp for - * information about the formula. */ - uint grey = (((r << 3) * 19595) + ((g << 2) * 38470) + ((b << 3) * 7471)) / 65536; - - return To16(grey, grey, grey); - } - - /** - * Make a colour dark grey, for specialized 32bpp remapping. - * @param r red component - * @param g green component - * @param b blue component - * @return the brightness value of the new colour, now dark grey. - */ - static inline uint8 MakeDark(Colour16 colour) - { - uint8 r = colour.r; - uint8 g = colour.g; - uint8 b = colour.b; - - /* Magic-numbers are ~66% of those used in MakeGrey() */ - return (((r << 3) * 13063) + ((g << 2) * 25647) + ((b << 3) * 4981)) / 65536; - } - - enum { DEFAULT_BRIGHTNESS = 8 }; - - /** - * @param brightness range is from 0 to 15. - */ - static inline Colour16 AdjustBrightness(Colour16 colour, uint8 brightness) - { - /* Shortcut for normal brightness */ - if (brightness == DEFAULT_BRIGHTNESS) return colour; - - uint16 ob = 0; - uint16 r = colour.r * brightness / DEFAULT_BRIGHTNESS; - uint16 g = colour.g * brightness / DEFAULT_BRIGHTNESS; - uint16 b = colour.b * brightness / DEFAULT_BRIGHTNESS; - - /* Sum overbright */ - if (r > 31) ob += r - 31; - if (g > 63) ob += g - 63; - if (b > 31) ob += b - 31; - - if (ob == 0) return Colour16(r, g, b); - - /* Reduce overbright strength */ - ob /= 2; - return Colour16( r >= 31 ? 31 : std::min(r + ob * (31 - r) / 32, 31), - g >= 63 ? 63 : std::min(g + ob * (63 - g) / 64, 63), - b >= 31 ? 31 : std::min(b + ob * (31 - b) / 32, 31) ); - } -}; - -#endif /* BLITTER_16BPP_BASE_HPP */ diff --git a/src/blitter/16bpp_simple.cpp b/src/blitter/16bpp_simple.cpp deleted file mode 100644 index bfde123661..0000000000 --- a/src/blitter/16bpp_simple.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 32bpp_simple.cpp Implementation of the simple 16 bpp blitter. */ - -#include "../stdafx.h" -#include "../zoom_func.h" -#include "16bpp_simple.hpp" - -#include "../table/sprites.h" - -/** Instantiation of the simple 16bpp blitter factory. */ -static FBlitter_16bppSimple iFBlitter_16bppSimple; - -template -void Blitter_16bppSimple::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) -{ - const Pixel *src, *src_line; - Colour16 *dst, *dst_line; - - /* Find where to start reading in the source sprite */ - src_line = (const Pixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (Colour16 *)bp->dst + bp->top * bp->pitch + bp->left; - - for (int y = 0; y < bp->height; y++) { - dst = dst_line; - dst_line += bp->pitch; - - src = src_line; - src_line += bp->sprite_width * ScaleByZoom(1, zoom); - - for (int x = 0; x < bp->width; x++) { - switch (mode) { - case BM_COLOUR_REMAP: - /* In case the m-channel is zero, do not remap this pixel in any way */ - if (src->m == 0) { - if (src->a != 0) *dst = ComposeColourPA(src->c, src->a, *dst); - } else { - if (bp->remap[src->m] != 0) *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst); - } - break; - - case BM_CRASH_REMAP: - if (src->m == 0) { - if (src->a != 0) { - uint8 g = MakeDark(src->c); - *dst = ComposeColourRGBA(g, g, g, src->a, *dst); - } - } else { - if (bp->remap[src->m] != 0) *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst); - } - break; - - case BM_TRANSPARENT: - /* TODO -- We make an assumption here that the remap in fact is transparency, not some colour. - * This is never a problem with the code we produce, but newgrfs can make it fail... or at least: - * we produce a result the newgrf maker didn't expect ;) */ - - /* Make the current colour a bit more black, so it looks like this image is transparent */ - if (src->a != 0) *dst = MakeTransparent(*dst, 192); - break; - - case BM_BLACK_REMAP: - if (src->a != 0) { - *dst = Colour16(0, 0, 0); - } - break; - - default: - if (src->a != 0) *dst = ComposeColourPA(src->c, src->a, *dst); - break; - } - dst++; - src += ScaleByZoom(1, zoom); - } - } -} - -void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) -{ - switch (mode) { - default: NOT_REACHED(); - case BM_NORMAL: Draw (bp, zoom); return; - case BM_COLOUR_REMAP: Draw(bp, zoom); return; - case BM_TRANSPARENT: Draw (bp, zoom); return; - case BM_CRASH_REMAP: Draw (bp, zoom); return; - case BM_BLACK_REMAP: Draw (bp, zoom); return; - } -} - -void Blitter_16bppSimple::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) -{ - Colour16 *udst = (Colour16 *)dst; - - if (pal == PALETTE_TO_TRANSPARENT) { - do { - for (int i = 0; i != width; i++) { - *udst = MakeTransparent(*udst, 154); - udst++; - } - udst = udst - width + _screen.pitch; - } while (--height); - return; - } - if (pal == PALETTE_NEWSPAPER) { - do { - for (int i = 0; i != width; i++) { - *udst = MakeGrey(*udst); - udst++; - } - udst = udst - width + _screen.pitch; - } while (--height); - return; - } - - DEBUG(misc, 0, "16bpp blitter doesn't know how to draw this colour table ('%d')", pal); -} - -Sprite *Blitter_16bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) -{ - Pixel *dst; - Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite->height * (size_t)sprite->width * sizeof(Pixel)); - - dest_sprite->height = sprite->height; - dest_sprite->width = sprite->width; - dest_sprite->x_offs = sprite->x_offs; - dest_sprite->y_offs = sprite->y_offs; - - dst = (Pixel *)dest_sprite->data; - SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite->data; - - for (int i = 0; i < sprite->height * sprite->width; i++) { - if (src->m == 0) { - dst[i].c = To16(src->r, src->g, src->b); - dst[i].a = src->a / 16; - dst[i].m = 0; - dst[i].v = 0; - } else { - /* Get brightest value */ - uint8 rgb_max = std::max(src->r, std::max(src->g, src->b)); -#if 0 - /* Pre-convert the mapping channel to a RGB value, - use 32bpp AdjustBrightness() variant for better colors, - because this function is not called each frame */ - if (rgb_max == 0) rgb_max = Blitter_32bppBase::DEFAULT_BRIGHTNESS; - dst[i].c = To16(Blitter_32bppBase::AdjustBrightness(LookupColourInPalette32(src->m), rgb_max)); - dst[i].v = rgb_max / 16; -#endif - rgb_max /= 16; - - /* Black pixel (8bpp or old 32bpp image), so use default value */ - if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS; - - /* Pre-convert the mapping channel to a RGB value, - use 32bpp AdjustBrightness() variant for better colors, - because this function is not called each frame */ - dst[i].c = AdjustBrightness(LookupColourInPalette(src->m), rgb_max); - dst[i].v = rgb_max; - - dst[i].a = src->a / 16; - dst[i].m = src->m; - } - src++; - } - - return dest_sprite; -} diff --git a/src/blitter/16bpp_simple.hpp b/src/blitter/16bpp_simple.hpp deleted file mode 100644 index 9feb934062..0000000000 --- a/src/blitter/16bpp_simple.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* $Id$ */ - -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file 16bpp_simple.hpp Simple 16 bpp blitter. */ - -#ifndef BLITTER_16BPP_SIMPLE_HPP -#define BLITTER_16BPP_SIMPLE_HPP - -#include "16bpp_base.hpp" -#include "factory.hpp" - -/** The most trivial 32 bpp blitter (without palette animation). */ -class Blitter_16bppSimple : public Blitter_16bppBase { -public: - /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); - /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator); - template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); - - /* virtual */ const char *GetName() { return "16bpp-simple"; } -}; - -/** Factory for the simple 16 bpp blitter. */ -class FBlitter_16bppSimple : public BlitterFactory { -public: - FBlitter_16bppSimple() : BlitterFactory("16bpp-simple", "16bpp Simple Blitter (no palette animation)") {} - /* virtual */ Blitter *CreateInstance() { return new Blitter_16bppSimple(); } -}; - -#endif /* BLITTER_16BPP_SIMPLE_HPP */ diff --git a/src/blitter/CMakeLists.txt b/src/blitter/CMakeLists.txt index 421aefe6cc..ddcc9a0082 100644 --- a/src/blitter/CMakeLists.txt +++ b/src/blitter/CMakeLists.txt @@ -13,10 +13,6 @@ add_files( 8bpp_optimized.hpp 8bpp_simple.cpp 8bpp_simple.hpp - 16bpp_base.cpp - 16bpp_base.hpp - 16bpp_simple.cpp - 16bpp_simple.hpp CONDITION NOT OPTION_DEDICATED ) diff --git a/src/build_confirmation_gui.cpp b/src/build_confirmation_gui.cpp index 9175244902..72bc2b19be 100644 --- a/src/build_confirmation_gui.cpp +++ b/src/build_confirmation_gui.cpp @@ -174,10 +174,10 @@ struct BuildConfirmationWindow : Window { ToolbarSelectLastTool(); } else { ResetObjectToPlace(); - DeleteWindowByClass(WC_BUILD_BRIDGE); + CloseWindowByClass(WC_BUILD_BRIDGE); //ClearErrorMessages(); Window *w = FindWindowById(WC_ERRMSG, 0); - if (w != NULL) delete w; + if (w != NULL) w->Close(); } break; } @@ -268,8 +268,8 @@ void HideBuildConfirmationWindow() if (!BuildConfirmationWindow::shown) return; - DeleteWindowById(WC_BUILD_CONFIRMATION, 0); - DeleteWindowById(WC_TOOLTIPS, 0); + CloseWindowById(WC_BUILD_CONFIRMATION, 0); + CloseWindowById(WC_TOOLTIPS, 0); } bool ConfirmationWindowShown() diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index eba9841cbb..e7d10ca9cf 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -418,7 +418,7 @@ DEF_CONSOLE_CMD(ConListFiles) DEF_CONSOLE_CMD(ConOpenCheats) { if (argc == 0) { - IConsoleHelp("Open the cheat window. Usage: 'open_cheats'"); + IConsolePrint(CC_HELP, "Open the cheat window. Usage: 'cheats'."); return true; } diff --git a/src/music_gui.cpp b/src/music_gui.cpp index fbed2e4404..0181480926 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -582,13 +582,13 @@ struct MusicTrackSelectionWindow : public Window { { switch (widget) { case WID_MTS_LIST_LEFT: { // add to playlist - int y = this->left_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_LEFT, WD_FRAMERECT_TOP, this->resize.step_height); + int y = this->left_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_LEFT); _music.PlaylistAdd(y); break; } case WID_MTS_LIST_RIGHT: { // remove from playlist - int y = this->right_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_RIGHT, WD_FRAMERECT_TOP, this->resize.step_height); + int y = this->right_sb->GetScrolledRowFromWidget(pt.y, this, WID_MTS_LIST_RIGHT); _music.PlaylistRemove(y); break; } diff --git a/src/openttd.cpp b/src/openttd.cpp index d2a2d0f559..1037adbd77 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -703,7 +703,6 @@ int openttd_main(int argc, char *argv[]) #ifndef WIN32 // Configure local font path on Android, it uses older Fontconfig version that does not require config file setenv("FONTCONFIG_FONTS", "fonts", 1); - DEBUG(misc, 1, "Set FONTCONFIG_FONTS to %s", getenv("FONTCONFIG_FONTS")); #endif #ifdef __EMSCRIPTEN__ // Fontconfig config file is required on Emscripten, and the path to fonts directory is named differently @@ -816,15 +815,7 @@ int openttd_main(int argc, char *argv[]) /* ScanNewGRFFiles now has control over the scanner. */ RequestNewGRFScan(scanner.release()); - try { - VideoDriver::GetInstance()->MainLoop(); - } catch (const std::exception & e) { - DEBUG(misc, 0, "Main thread got exception: %s", e.what()); - throw; - } catch (...) { - DEBUG(misc, 0, "Main thread got unknown exception"); - throw; - } + VideoDriver::GetInstance()->MainLoop(); WaitTillSaved(); diff --git a/src/screenshot.cpp b/src/screenshot.cpp index f46d3e36d7..ce6bf7666b 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -25,7 +25,6 @@ #include "window_func.h" #include "tile_map.h" #include "landscape.h" -#include "blitter/16bpp_base.hpp" #include "video/video_driver.hpp" #include "table/strings.h" @@ -384,17 +383,6 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user /* render the pixels into the buffer */ callb(userdata, buff, y, w, n); y += n; - if (pixelformat == 16) { - // Convert to 24bpp - Blitter_16bppBase::Colour16 *inp = (Blitter_16bppBase::Colour16 *)buff; - uint8 *outp = (uint8 *)buff; - for (i = 1; i <= w * n; i++) { - outp[(w * n - i) * 3 ] = inp[w * n - i].r << 3; - outp[(w * n - i) * 3 + 1] = inp[w * n - i].g << 2; - outp[(w * n - i) * 3 + 2] = inp[w * n - i].b << 3; - //outp[(w * n - i) * 3] = 0xff; - } - } /* write them to png */ for (i = 0; i != n; i++) { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 43f2e98492..9b8aa273a4 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2851,11 +2851,11 @@ void ReconstructUserInterface() InitFreeType(true); CheckForMissingGlyphs(); - DeleteAllNonVitalWindows(); + CloseAllNonVitalWindows(); switch (_game_mode) { case GM_MENU: - DeleteWindowById(WC_SELECT_GAME, 0); + CloseWindowById(WC_SELECT_GAME, 0); extern void ShowSelectGameWindow(); ShowSelectGameWindow(); break; @@ -2870,7 +2870,7 @@ void ReconstructUserInterface() break; } - ReInitAllWindows(); + ReInitAllWindows(false); if (_settings_client.gui.windows_titlebars) { // Hack to prevent second click on the same button via button-up event ShowGameOptions(); diff --git a/src/settings_table.cpp b/src/settings_table.cpp index 47f18da92b..069f48b7d4 100644 --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -267,7 +267,7 @@ static void VerticalToolbarChanged(int32 p1) if (FindWindowByClass(WC_MAIN_TOOLBAR)) { HideVitalWindows(); ShowVitalWindows(); - ReInitAllWindows(); + ReInitAllWindows(false); } } diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 25e24b44f8..6d5ce0189c 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -473,10 +473,6 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty /* Try for 32bpp sprites first. */ sprite_avail = sprite_loader.LoadSprite(sprite, file, file_pos, sprite_type, true); } - if (sprite_type != ST_MAPGEN && BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 16) { - /* 32bpp sprites for 16bpp videomode. */ - sprite_avail = sprite_loader.LoadSprite(sprite, file, file_pos, sprite_type, true); - } if (sprite_avail == 0) { sprite_avail = sprite_loader.LoadSprite(sprite, file, file_pos, sprite_type, false); } diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 375bfe3719..38c3c65aa9 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -225,7 +225,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.vertical_toolbar -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_VERTICAL_TOOLBAR strhelp = STR_CONFIG_SETTING_VERTICAL_TOOLBAR_HELPTEXT @@ -234,7 +234,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.compact_vertical_toolbar -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_COMPACT_VERTICAL_TOOLBAR strhelp = STR_CONFIG_SETTING_COMPACT_VERTICAL_TOOLBAR_HELPTEXT @@ -242,7 +242,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.build_confirmation -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_BUILD_CONFIRMATION strhelp = STR_CONFIG_SETTING_BUILD_CONFIRMATION_HELPTEXT @@ -250,7 +250,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.windows_titlebars -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = false str = STR_CONFIG_SETTING_WINDOWS_TITLEBARS strhelp = STR_CONFIG_SETTING_WINDOWS_TITLEBARS_HELPTEXT @@ -258,7 +258,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.draw_mouse_cursor -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_MOUSE_CURSOR strhelp = STR_CONFIG_SETTING_MOUSE_CURSOR_HELPTEXT @@ -266,7 +266,7 @@ cat = SC_BASIC [SDTC_BOOL] var = gui.windows_decorations -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = true str = STR_CONFIG_SETTING_WINDOWS_DECORATIONS strhelp = STR_CONFIG_SETTING_WINDOWS_DECORATIONS_HELPTEXT diff --git a/src/table/settings/old_gameopt_settings.ini b/src/table/settings/old_gameopt_settings.ini index 42dd2c65d7..547bde5ac2 100644 --- a/src/table/settings/old_gameopt_settings.ini +++ b/src/table/settings/old_gameopt_settings.ini @@ -16,6 +16,7 @@ [pre-amble] static constexpr std::initializer_list _town_names{"english", "french", "german", "american", "latin", "silly", "swedish", "dutch", "finnish", "polish", "slovak", "norwegian", "hungarian", "austrian", "romanian", "czech", "swiss", "danish", "turkish", "italian", "catalan"}; static constexpr std::initializer_list _climates{"temperate", "arctic", "tropic", "toyland"}; +static constexpr std::initializer_list _save_to_network{"disabled", "enabled", "ask"}; static const SettingVariant _old_gameopt_settings_table[] = { /* In version 4 a new difficulty setting has been added to the difficulty settings, @@ -154,7 +155,7 @@ cat = SC_BASIC [SDTC_OMANY] var = gui.save_to_network type = SLE_UINT8 -flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = 2 max = 2 full = _save_to_network diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 2d5b15cd68..790b58c181 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -242,7 +242,7 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0) list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false)); } - list.emplace_back(new DropDownListStringItem(STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, CTMN_SPEAK_ALL, false)); + list.emplace_back(new DropDownListStringItem(STR_NETWORK_CHAT_ALL_CAPTION, CTMN_SPEAK_ALL, false)); break; case WID_TN_STORY: @@ -1234,7 +1234,7 @@ static CallBackFunction ToolbarShiftClick(Window *w) static CallBackFunction ToolbarDeleteClick(Window *w) { - DeleteNonVitalWindows(); + CloseNonVitalWindows(); _ctrl_pressed = false; w->SetWidgetLoweredState(WID_TN_CTRL, _ctrl_pressed); w->SetWidgetDirty(WID_TN_CTRL); diff --git a/src/tutorial_gui.cpp b/src/tutorial_gui.cpp index bf746e606f..3f6aa7e4b4 100644 --- a/src/tutorial_gui.cpp +++ b/src/tutorial_gui.cpp @@ -179,7 +179,7 @@ struct TutorialWindow : public Window { void ShowTutorialWindow() { - DeleteWindowByClass(WC_GAME_OPTIONS); + CloseWindowByClass(WC_GAME_OPTIONS); new TutorialWindow(); } diff --git a/src/widget.cpp b/src/widget.cpp index 56bf0763e5..d9c48c3707 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -2980,23 +2980,23 @@ void NWidgetLeaf::Draw(const Window *w) case WWT_SHADEBOX: assert(this->widget_data == 0); - DrawImageButtons(r, WWT_SHADEBOX, this->colour, w->IsShaded(), w->IsShaded() ? SPR_WINDOW_SHADE : SPR_WINDOW_UNSHADE); + DrawImageButtons(r, WWT_SHADEBOX, this->colour, w->IsShaded(), w->IsShaded() ? SPR_WINDOW_SHADE : SPR_WINDOW_UNSHADE, SA_CENTER); break; case WWT_DEBUGBOX: - DrawImageButtons(r, WWT_DEBUGBOX, this->colour, clicked, SPR_WINDOW_DEBUG); + DrawImageButtons(r, WWT_DEBUGBOX, this->colour, clicked, SPR_WINDOW_DEBUG, SA_CENTER); break; case WWT_STICKYBOX: { assert(this->widget_data == 0); bool clicked = !!(w->flags & WF_STICKY); - DrawImageButtons(r, WWT_STICKYBOX, this->colour, clicked, clicked ? SPR_PIN_DOWN : SPR_PIN_UP); + DrawImageButtons(r, WWT_STICKYBOX, this->colour, clicked, clicked ? SPR_PIN_DOWN : SPR_PIN_UP, SA_CENTER); break; } case WWT_DEFSIZEBOX: assert(this->widget_data == 0); - DrawImageButtons(r, WWT_DEFSIZEBOX, this->colour, clicked, SPR_WINDOW_DEFSIZE); + DrawImageButtons(r, WWT_DEFSIZEBOX, this->colour, clicked, SPR_WINDOW_DEFSIZE, SA_CENTER); break; case WWT_RESIZEBOX: diff --git a/src/window.cpp b/src/window.cpp index da5070095a..27b4c44207 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2343,7 +2343,7 @@ static EventState HandleWindowDragging() if (!_left_button_down) { w->flags &= ~WF_DRAGGING; if (GetWindowDraggedOffScreen(w)) { - delete w; + w->Close(); } break; } @@ -3853,7 +3853,7 @@ static void MoveAllWindowsOffScreen(bool moveOffScreen) Window *w; bool updateScreen = false; - FOR_ALL_WINDOWS_FROM_BACK(w) { + for (Window *w : Window::Iterate()) { switch (w->window_class) { case WC_MAIN_WINDOW: case WC_BUILD_CONFIRMATION: