mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Set ZoomLevel's base type to byte instead of using ZoomLevelByte
This commit is contained in:
parent
aa220b2375
commit
96a4787710
|
@ -58,8 +58,8 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
|
|||
|
||||
static ReusableBuffer<uint8> _cursor_backup;
|
||||
|
||||
ZoomLevelByte _gui_zoom; ///< GUI Zoom level
|
||||
ZoomLevelByte _font_zoom; ///< Font Zoom level
|
||||
ZoomLevel _gui_zoom; ///< GUI Zoom level
|
||||
ZoomLevel _font_zoom; ///< Font Zoom level
|
||||
|
||||
/**
|
||||
* The rect for repaint.
|
||||
|
|
|
@ -2834,7 +2834,7 @@ bool AfterLoadGame()
|
|||
|
||||
if (IsSavegameVersionBefore(SLV_165)) {
|
||||
/* Adjust zoom level to account for new levels */
|
||||
_saved_scrollpos_zoom = _saved_scrollpos_zoom + ZOOM_LVL_SHIFT;
|
||||
_saved_scrollpos_zoom = static_cast<ZoomLevel>(_saved_scrollpos_zoom + ZOOM_LVL_SHIFT);
|
||||
_saved_scrollpos_x *= ZOOM_LVL_BASE;
|
||||
_saved_scrollpos_y *= ZOOM_LVL_BASE;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ extern byte _trees_tick_ctr;
|
|||
/* Keep track of current game position */
|
||||
int _saved_scrollpos_x;
|
||||
int _saved_scrollpos_y;
|
||||
ZoomLevelByte _saved_scrollpos_zoom;
|
||||
ZoomLevel _saved_scrollpos_zoom;
|
||||
|
||||
void SaveViewportBeforeSaveGame()
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ void CopyTempEngineData();
|
|||
|
||||
extern int32 _saved_scrollpos_x;
|
||||
extern int32 _saved_scrollpos_y;
|
||||
extern ZoomLevelByte _saved_scrollpos_zoom;
|
||||
extern ZoomLevel _saved_scrollpos_zoom;
|
||||
|
||||
extern SavegameType _savegame_type;
|
||||
extern uint32 _ttdp_version;
|
||||
|
|
|
@ -107,8 +107,8 @@ struct GUISettings {
|
|||
uint8 statusbar_pos; ///< position of statusbar, 0=left, 1=center, 2=right
|
||||
uint8 window_snap_radius; ///< windows snap at each other if closer than this
|
||||
uint8 window_soft_limit; ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
|
||||
ZoomLevelByte zoom_min; ///< minimum zoom out level
|
||||
ZoomLevelByte zoom_max; ///< maximum zoom out level
|
||||
ZoomLevel zoom_min; ///< minimum zoom out level
|
||||
ZoomLevel zoom_max; ///< maximum zoom out level
|
||||
bool disable_unsuitable_building; ///< disable infrastructure building when no suitable vehicles are available
|
||||
byte autosave; ///< how often should we do autosaves?
|
||||
bool threaded_saves; ///< should we do threaded saves?
|
||||
|
|
|
@ -1692,7 +1692,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
|
|||
*/
|
||||
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
|
||||
{
|
||||
if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE) {
|
||||
if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > (int)(180000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE)) {
|
||||
if ((bottom - top) > (right - left)) {
|
||||
int t = (top + bottom) >> 1;
|
||||
ViewportDrawChk(vp, left, top, right, t);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
static inline int ScaleByZoom(int value, ZoomLevel zoom)
|
||||
{
|
||||
assert(zoom >= 0);
|
||||
return value << zoom;
|
||||
}
|
||||
|
||||
|
@ -36,7 +35,6 @@ static inline int ScaleByZoom(int value, ZoomLevel zoom)
|
|||
*/
|
||||
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
|
||||
{
|
||||
assert(zoom >= 0);
|
||||
return (value + (1 << zoom) - 1) >> zoom;
|
||||
}
|
||||
|
||||
|
@ -48,7 +46,6 @@ static inline int UnScaleByZoom(int value, ZoomLevel zoom)
|
|||
*/
|
||||
static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
|
||||
{
|
||||
assert(zoom >= 0);
|
||||
return value << zoom;
|
||||
}
|
||||
|
||||
|
@ -60,7 +57,6 @@ static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
|
|||
*/
|
||||
static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
|
||||
{
|
||||
assert(zoom >= 0);
|
||||
return value >> zoom;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
#include "core/enum_type.hpp"
|
||||
|
||||
static int const ZOOM_LVL_SHIFT = 2;
|
||||
static int const ZOOM_LVL_BASE = 1 << ZOOM_LVL_SHIFT;
|
||||
static uint const ZOOM_LVL_SHIFT = 2;
|
||||
static uint const ZOOM_LVL_BASE = 1 << ZOOM_LVL_SHIFT;
|
||||
|
||||
/** All zoom levels we know. */
|
||||
enum ZoomLevel {
|
||||
enum ZoomLevel : byte {
|
||||
/* Our possible zoom-levels */
|
||||
ZOOM_LVL_BEGIN = 0, ///< Begin for iteration.
|
||||
ZOOM_LVL_NORMAL = 0, ///< The normal zoom level.
|
||||
|
@ -46,14 +46,12 @@ enum ZoomLevel {
|
|||
|
||||
ZOOM_LVL_MIN = ZOOM_LVL_NORMAL, ///< Minimum zoom level.
|
||||
ZOOM_LVL_MAX = ZOOM_LVL_OUT_32X, ///< Maximum zoom level.
|
||||
|
||||
};
|
||||
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
|
||||
|
||||
/** Type for storing the zoom level in a byte. */
|
||||
typedef SimpleTinyEnumT<ZoomLevel, byte> ZoomLevelByte;
|
||||
|
||||
extern ZoomLevelByte _gui_zoom;
|
||||
extern ZoomLevelByte _font_zoom;
|
||||
extern ZoomLevel _gui_zoom;
|
||||
extern ZoomLevel _font_zoom;
|
||||
#define ZOOM_LVL_GUI (_gui_zoom)
|
||||
#define ZOOM_LVL_FONT (_font_zoom)
|
||||
|
||||
|
|
Loading…
Reference in New Issue