OpenTTD: src/transparency.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

transparency.h
Go to the documentation of this file.
1 /* $Id: transparency.h 22506 2011-05-28 09:46:37Z frosch $ */
2
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 */
9
12 #ifndef TRANSPARENCY_H
13 #define TRANSPARENCY_H
14
15 #include "gfx_func.h"
16 #include "openttd.h"
17 #include "core/bitmath_func.hpp"
18
24 enum TransparencyOption {
25 TO_SIGNS = 0,
26 TO_TREES,
27 TO_HOUSES,
28 TO_INDUSTRIES,
29 TO_BUILDINGS,
30 TO_BRIDGES,
31 TO_STRUCTURES,
32 TO_CATENARY,
33 TO_LOADING,
34 TO_END,
35 TO_INVALID,
36 };
37
38 typedef uint TransparencyOptionBits;
39 extern TransparencyOptionBits _transparency_opt;
40 extern TransparencyOptionBits _transparency_lock;
41 extern TransparencyOptionBits _invisibility_opt;
42 extern byte _display_opt;
43
50 static inline bool IsTransparencySet(TransparencyOption to)
51 {
52 return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
53 }
54
61 static inline bool IsInvisibilitySet(TransparencyOption to)
62 {
63 return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
64 }
65
71 static inline void ToggleTransparency(TransparencyOption to)
72 {
73 ToggleBit(_transparency_opt, to);
74 }
75
81 static inline void ToggleInvisibility(TransparencyOption to)
82 {
83 ToggleBit(_invisibility_opt, to);
84 }
85
93 static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
94 {
95 if (IsInvisibilitySet(to)) {
96 ClrBit(_invisibility_opt, to);
97 ClrBit(_transparency_opt, to);
98 } else {
99 SetBit(_invisibility_opt, to);
100 SetBit(_transparency_opt, to);
101 }
102 }
103
109 static inline void ToggleTransparencyLock(TransparencyOption to)
110 {
111 ToggleBit(_transparency_lock, to);
112 }
113
115 static inline void ResetRestoreAllTransparency()
116 {
117 /* if none of the non-locked options are set */
118 if ((_transparency_opt & ~_transparency_lock) == 0) {
119 /* set all non-locked options */
120 _transparency_opt |= GB(~_transparency_lock, 0, TO_END);
121 } else {
122 /* clear all non-locked options */
123 _transparency_opt &= _transparency_lock;
124 }
125
126 MarkWholeScreenDirty();
127 }
128
129 #endif /* TRANSPARENCY_H */