|
1 /* $Id$ */ |
|
2 |
|
3 /** @file transparency.h */ |
|
4 |
|
5 #ifndef TRANSPARENCY_H |
|
6 #define TRANSPARENCY_H |
|
7 |
|
8 /** |
|
9 * Transparency option bits: which position in _transparency_opt stands for which transparency. |
|
10 * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. |
|
11 * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. |
|
12 * If you add an option and have more then 8, change the typedef TransparencyOptionBits and |
|
13 * the save stuff (e.g. SLE_UINT8 to SLE_UINT16) in settings.cpp . |
|
14 */ |
|
15 enum TransparencyOption { |
|
16 TO_SIGNS = 0, ///< signs |
|
17 TO_TREES, ///< trees |
|
18 TO_HOUSES, ///< town buildings |
|
19 TO_INDUSTRIES, ///< industries |
|
20 TO_BUILDINGS, ///< player buildings - depots, stations, HQ, ... |
|
21 TO_BRIDGES, ///< bridges |
|
22 TO_STRUCTURES, ///< unmovable structures |
|
23 TO_LOADING, ///< loading indicators |
|
24 TO_END, |
|
25 }; |
|
26 |
|
27 typedef byte TransparencyOptionBits; ///< transparency option bits |
|
28 extern TransparencyOptionBits _transparency_opt; |
|
29 |
|
30 /** |
|
31 * Check if the transparency option bit is set |
|
32 * and if we aren't in the game menu (there's never transparency) |
|
33 * |
|
34 * @param to the structure which transparency option is ask for |
|
35 */ |
|
36 static inline bool IsTransparencySet(TransparencyOption to) |
|
37 { |
|
38 return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); |
|
39 } |
|
40 |
|
41 /** |
|
42 * Toggle the transparency option bit |
|
43 * |
|
44 * @param to the structure which transparency option is toggle |
|
45 */ |
|
46 static inline void ToggleTransparency(TransparencyOption to) |
|
47 { |
|
48 ToggleBit(_transparency_opt, to); |
|
49 } |
|
50 |
|
51 /** Toggle all transparency options (except signs) or restore the stored transparencies */ |
|
52 static inline void ResetRestoreAllTransparency() |
|
53 { |
|
54 /* backup of the original transparencies or if all transparencies false toggle them to true */ |
|
55 static TransparencyOptionBits trans_opt = ~0; |
|
56 |
|
57 if (_transparency_opt == 0) { |
|
58 /* no structure is transparent, so restore the old transparency if present otherwise set all true */ |
|
59 _transparency_opt = trans_opt; |
|
60 } else { |
|
61 /* any structure is transparent, so store current transparency settings and reset it */ |
|
62 trans_opt = _transparency_opt; |
|
63 _transparency_opt = 0; |
|
64 } |
|
65 |
|
66 MarkWholeScreenDirty(); |
|
67 } |
|
68 |
|
69 #endif /* TRANSPARENCY_H */ |