Mercurial > hg > openttd
annotate src/zoom.hpp @ 7272:dc7fb38ec443 draft
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 16 Jul 2007 23:55:22 +0000 |
parents | 735550a14c63 |
children | 63c86d0b97e7 |
rev | line source |
---|---|
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
2 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
3 /** @file zoom.hpp */ |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
4 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
5 #ifndef ZOOM_HPP |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
6 #define ZOOM_HPP |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
7 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
8 enum ZoomLevel { |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
9 /* Our possible zoom-levels */ |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
10 ZOOM_LVL_NORMAL = 0, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
11 ZOOM_LVL_OUT_2X, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
12 ZOOM_LVL_OUT_4X, |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
13 ZOOM_LVL_OUT_8X, |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
14 ZOOM_LVL_END, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
15 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
16 /* Here we define in which zoom viewports are */ |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
17 ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
18 ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
19 ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
20 ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
21 ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
22 ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
23 ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
24 ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
25 ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL, |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
26 |
6852
31184effcea5
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents:
6833
diff
changeset
|
27 ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, ///< All zoomlevels below or equal to this, will result in details on the screen, like road-work, ... |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
28 |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
29 ZOOM_LVL_MIN = ZOOM_LVL_NORMAL, |
6853
735550a14c63
(svn r10093) -Revert: removed 16x zoom-out as it is broken beyond repair
truelight <truelight@openttd.org>
parents:
6852
diff
changeset
|
30 ZOOM_LVL_MAX = ZOOM_LVL_OUT_8X, |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
31 }; |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
32 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
33 extern ZoomLevel _saved_scrollpos_zoom; |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
34 |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
35 static inline int ScaleByZoom(int value, ZoomLevel zoom) |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
36 { |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
37 if (zoom == ZOOM_LVL_NORMAL) return value; |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
38 int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; |
6833
dff2f8df67f4
(svn r10072) -Fix r10070: typo in zoom.hpp
truelight <truelight@openttd.org>
parents:
6831
diff
changeset
|
39 return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom; |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
40 } |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
41 |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
42 static inline int UnScaleByZoom(int value, ZoomLevel zoom) |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
43 { |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
44 if (zoom == ZOOM_LVL_NORMAL) return value; |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
45 int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; |
6831
bfec3bac46a7
(svn r10070) -Fix: fix the rounding problem of zoom-levels in zoom.hpp, so it is global for every call
truelight <truelight@openttd.org>
parents:
6704
diff
changeset
|
46 return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom; |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
47 } |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
48 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
49 #endif /* ZOOM_HPP */ |