OpenTTD Source 20250205-master-gfd85ab1e2c
transparency.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10#ifndef TRANSPARENCY_H
11#define TRANSPARENCY_H
12
13#include "gfx_func.h"
14#include "openttd.h"
15#include "core/bitmath_func.hpp"
16
35
40extern uint8_t _display_opt;
41extern uint8_t _facility_display_opt;
42
50{
51 return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
52}
53
61{
62 return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
63}
64
74
84
102
112
115{
116 /* if none of the non-locked options are set */
118 /* set all non-locked options */
120 } else {
121 /* clear all non-locked options */
123 }
124
126}
127
128#endif /* TRANSPARENCY_H */
Functions related to bit mathematics.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Functions related to the gfx engine.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1529
Some generic types.
void ResetRestoreAllTransparency()
Set or clear all non-locked transparency options.
TransparencyOptionBits _transparency_opt
The bits that should be transparent.
uint8_t _facility_display_opt
What station facilities to draw.
void ToggleTransparency(TransparencyOption to)
Toggle the transparency option bit.
bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
void ToggleInvisibility(TransparencyOption to)
Toggle the invisibility option bit.
TransparencyOptionBits _transparency_lock
Prevent these bits from flipping with X.
void ToggleInvisibilityWithTransparency(TransparencyOption to)
Toggles between invisible and solid state.
TransparencyOptionBits _invisibility_opt
The bits that should be invisible.
uint8_t _display_opt
What do we want to draw/do?
uint TransparencyOptionBits
transparency option bits
bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren't in the game menu (there's never transpar...
TransparencyOption
Transparency option bits: which position in _transparency_opt stands for which transparency.
@ TO_INVALID
Invalid transparency option.
@ TO_BRIDGES
bridges
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
@ TO_TEXT
loading and cost/income text
@ TO_CATENARY
catenary
@ TO_TREES
trees
@ TO_HOUSES
town buildings
@ TO_SIGNS
signs
@ TO_STRUCTURES
other objects such as transmitters and lighthouses
@ TO_INDUSTRIES
industries
void ToggleTransparencyLock(TransparencyOption to)
Toggle the transparency lock bit.