OpenTTD
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 
25  TO_SIGNS = 0,
34  TO_END,
36 };
37 
38 typedef uint TransparencyOptionBits;
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 {
74 }
75 
81 static inline void ToggleInvisibility(TransparencyOption to)
82 {
84 }
85 
94 {
95  if (IsInvisibilitySet(to)) {
98  } else {
101  }
102 }
103 
110 {
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 */
124  }
125 
127 }
128 
129 #endif /* TRANSPARENCY_H */
company buildings - depots, stations, HQ, ...
Definition: transparency.h:29
signs
Definition: transparency.h:25
byte _display_opt
What do we want to draw/do?
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Functions related to bit mathematics.
TransparencyOptionBits _transparency_lock
Prevent these bits from flipping with X.
loading indicators
Definition: transparency.h:33
static void ResetRestoreAllTransparency()
Set or clear all non-locked transparency options.
Definition: transparency.h:115
town buildings
Definition: transparency.h:27
static void ToggleInvisibility(TransparencyOption to)
Toggle the invisibility option bit.
Definition: transparency.h:81
Functions related to the gfx engine.
Some generic types.
TransparencyOptionBits _transparency_opt
The bits that should be transparent.
static void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
Definition: transparency.h:71
static void ToggleTransparencyLock(TransparencyOption to)
Toggle the transparency lock bit.
Definition: transparency.h:109
catenary
Definition: transparency.h:32
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
uint TransparencyOptionBits
transparency option bits
Definition: transparency.h:38
TransparencyOptionBits _invisibility_opt
The bits that should be invisible.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Invalid transparency option.
Definition: transparency.h:35
other objects such as transmitters and lighthouses
Definition: transparency.h:31
trees
Definition: transparency.h:26
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren&#39;t in the game menu (there&#39;s never transpar...
Definition: transparency.h:61
bridges
Definition: transparency.h:30
industries
Definition: transparency.h:28
static void ToggleInvisibilityWithTransparency(TransparencyOption to)
Toggles between invisible and solid state.
Definition: transparency.h:93
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren&#39;t in the game menu (there&#39;s never transpar...
Definition: transparency.h:50
TransparencyOption
Transparency option bits: which position in _transparency_opt stands for which transparency.
Definition: transparency.h:24
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1461