Mercurial > hg > openttd
annotate src/zoom.hpp @ 6653:cbe12394f776 draft
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
-Codechange: unified the blitter function so we have 1 function for all zoom-levels
-Codechange: make most of the label functions work with zoom-level instead of magic numbers and big switches per zoom-level
-Codechange: MakeXXXDirty() functions didn't take into account zoom-level, but just used the biggest possible value
-Codechange: simplified blitter functions to avoid code duplication
author | truelight <truelight@openttd.org> |
---|---|
date | Sat, 19 May 2007 22:48:04 +0000 |
parents | f358a236fcf4 |
children | 245ee4529876 |
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, |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
14 ZOOM_LVL_OUT_16X, |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
15 ZOOM_LVL_END, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
16 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
17 /* Here we define in which zoom viewports are */ |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
18 ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
19 ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
20 ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
21 ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
22 ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
23 ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
24 ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
25 ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL, |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
26 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
|
27 |
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 ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, //! All zoomlevels below or equal to this, will result in details on the screen, like road-work, ... |
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 |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
30 ZOOM_LVL_MIN = ZOOM_LVL_NORMAL, |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
31 ZOOM_LVL_MAX = ZOOM_LVL_OUT_16X, |
6624
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 |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
34 extern ZoomLevel _saved_scrollpos_zoom; |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
35 |
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
|
36 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
|
37 { |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
38 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
|
39 int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; |
6628
f358a236fcf4
(svn r9848) -Fix r9846: how every many times you check something, of course you always switch them at the last moment... UnScaleByZoom was ScaleByZoom and visa versa... (tnx to yeti_ for noticing)
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
40 return (zoom > ZOOM_LVL_NORMAL) ? value << 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
|
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 |
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 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
|
44 { |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6628
diff
changeset
|
45 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
|
46 int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; |
6628
f358a236fcf4
(svn r9848) -Fix r9846: how every many times you check something, of course you always switch them at the last moment... UnScaleByZoom was ScaleByZoom and visa versa... (tnx to yeti_ for noticing)
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
47 return (zoom > ZOOM_LVL_NORMAL) ? value >> 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
|
48 } |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
49 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
diff
changeset
|
50 #endif /* ZOOM_HPP */ |