author | richk |
Tue, 17 Jun 2008 13:41:57 +0000 | |
branch | NewGRF_ports |
changeset 10995 | 311b38c7f9a7 |
parent 10724 | 68a692eacf22 |
permissions | -rw-r--r-- |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
2 |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10184
diff
changeset
|
3 |
/** @file transparency.h Functions related to transparency. */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
4 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
5 |
#ifndef TRANSPARENCY_H |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
6 |
#define TRANSPARENCY_H |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
7 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
8 |
#include "gfx_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
9 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
10 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
11 |
* Transparency option bits: which position in _transparency_opt stands for which transparency. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
12 |
* If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
13 |
* If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
14 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
15 |
enum TransparencyOption { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
16 |
TO_SIGNS = 0, ///< signs |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
17 |
TO_TREES, ///< trees |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
18 |
TO_HOUSES, ///< town buildings |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
19 |
TO_INDUSTRIES, ///< industries |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
20 |
TO_BUILDINGS, ///< player buildings - depots, stations, HQ, ... |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
21 |
TO_BRIDGES, ///< bridges |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
22 |
TO_STRUCTURES, ///< unmovable structures |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
23 |
TO_CATENARY, ///< catenary |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
24 |
TO_LOADING, ///< loading indicators |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
25 |
TO_END, |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
26 |
}; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
27 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
28 |
typedef uint TransparencyOptionBits; ///< transparency option bits |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
29 |
extern TransparencyOptionBits _transparency_opt; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
30 |
extern TransparencyOptionBits _transparency_lock; |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
31 |
extern TransparencyOptionBits _invisibility_opt; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
32 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
33 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
34 |
* Check if the transparency option bit is set |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
35 |
* and if we aren't in the game menu (there's never transparency) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
36 |
* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
37 |
* @param to the structure which transparency option is ask for |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
38 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
39 |
static inline bool IsTransparencySet(TransparencyOption to) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
40 |
{ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
41 |
return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
42 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
43 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
44 |
/** |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
45 |
* Check if the invisibility option bit is set |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
46 |
* and if we aren't in the game menu (there's never transparency) |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
47 |
* |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
48 |
* @param to the structure which invisibility option is ask for |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
49 |
*/ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
50 |
static inline bool IsInvisibilitySet(TransparencyOption to) |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
51 |
{ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
52 |
return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
53 |
} |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
54 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
55 |
/** |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
56 |
* Toggle the transparency option bit |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
57 |
* |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
58 |
* @param to the transparency option to be toggled |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
59 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
60 |
static inline void ToggleTransparency(TransparencyOption to) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
61 |
{ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
62 |
ToggleBit(_transparency_opt, to); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
63 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
64 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
65 |
/** |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
66 |
* Toggle the invisibility option bit |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
67 |
* |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
68 |
* @param to the structure which invisibility option is toggle |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
69 |
*/ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
70 |
static inline void ToggleInvisibility(TransparencyOption to) |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
71 |
{ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
72 |
ToggleBit(_invisibility_opt, to); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
73 |
} |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
74 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
75 |
/** |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
76 |
* Toggles between invisible and solid state. |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
77 |
* If object is transparent, then it is made invisible. |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
78 |
* Used by the keyboard shortcuts. |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
79 |
* |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
80 |
* @param to the object type which invisibility option to toggle |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
81 |
*/ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
82 |
static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
83 |
{ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
84 |
if (IsInvisibilitySet(to)) { |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
85 |
ClrBit(_invisibility_opt, to); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
86 |
ClrBit(_transparency_opt, to); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
87 |
} else { |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
88 |
SetBit(_invisibility_opt, to); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
89 |
SetBit(_transparency_opt, to); |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
90 |
} |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
91 |
} |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
92 |
|
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
93 |
/** |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
94 |
* Toggle the transparency lock bit |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
95 |
* |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
96 |
* @param to the transparency option to be locked or unlocked |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
97 |
*/ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
98 |
static inline void ToggleTransparencyLock(TransparencyOption to) |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
99 |
{ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
100 |
ToggleBit(_transparency_lock, to); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
101 |
} |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
102 |
|
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
103 |
/** Set or clear all non-locked transparency options */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
104 |
static inline void ResetRestoreAllTransparency() |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
105 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
106 |
/* if none of the non-locked options are set */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
107 |
if ((_transparency_opt & ~_transparency_lock) == 0) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
108 |
/* set all non-locked options */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
109 |
_transparency_opt |= GB(~_transparency_lock, 0, TO_END); |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
110 |
} else { |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
111 |
/* clear all non-locked options */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
112 |
_transparency_opt &= _transparency_lock; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
113 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
114 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
115 |
MarkWholeScreenDirty(); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
116 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
117 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
diff
changeset
|
118 |
#endif /* TRANSPARENCY_H */ |