Show snow on depot tiles. (Looks weird my ass)
[openttd-joker.git] / src / zoom_func.h
blobc178065a0de1c9ccc1f24e4d8f67198b547c3c3f
1 /* $Id: zoom_func.h 26202 2014-01-02 11:05:42Z rubidium $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 <http://www.gnu.org/licenses/>.
8 */
10 /** @file zoom_func.h Functions related to zooming. */
12 #ifndef ZOOM_FUNC_H
13 #define ZOOM_FUNC_H
15 #include "zoom_type.h"
17 /**
18 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
19 * When shifting right, value is rounded up
20 * @param value value to shift
21 * @param zoom zoom level to shift to
22 * @return shifted value
24 static inline int ScaleByZoom(int value, ZoomLevel zoom)
26 assert(zoom >= 0);
27 return value << zoom;
30 /**
31 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
32 * When shifting right, value is rounded up
33 * @param value value to shift
34 * @param zoom zoom level to shift to
35 * @return shifted value
37 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
39 assert(zoom >= 0);
40 return (value + (1 << zoom) - 1) >> zoom;
43 /**
44 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
45 * @param value value to shift
46 * @param zoom zoom level to shift to
47 * @return shifted value
49 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
51 assert(zoom >= 0);
52 return value << zoom;
55 /**
56 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
57 * @param value value to shift
58 * @param zoom zoom level to shift to
59 * @return shifted value
61 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
63 assert(zoom >= 0);
64 return value >> zoom;
67 /**
68 * Short-hand to apply GUI zoom level.
69 * @param value Pixel amount at #ZOOM_LVL_BEGIN (full zoom in).
70 * @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
72 static inline int UnScaleGUI(int value)
74 return UnScaleByZoom(value, ZOOM_LVL_GUI);
77 /**
78 * Scale traditional pixel dimensions to GUI zoom level.
79 * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size).
80 * @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
82 static inline int ScaleGUITrad(int value)
84 return UnScaleGUI(value * ZOOM_LVL_BASE);
87 #endif /* ZOOM_FUNC_H */