OpenTTD Source 20260531-master-g0e951f3528
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
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#include "station_type.h"
17
23enum class TransparencyOption : uint8_t {
24 Signs = 0,
25 Trees = 1,
26 Houses = 2,
29 Bridges = 5,
32 Text = 8,
34};
35
38
43extern StationFacilities _facility_display_opt;
44
53{
54 return _transparency_opt.Test(to) && _game_mode != GameMode::Menu;
55}
56
65{
66 return IsTransparencySet(to) && _invisibility_opt.Test(to) && _game_mode != GameMode::Menu;
67}
68
75{
76 _transparency_opt.Flip(to);
77}
78
85{
86 _invisibility_opt.Flip(to);
87}
88
97{
98 if (IsInvisibilitySet(to)) {
99 _invisibility_opt.Reset(to);
100 _transparency_opt.Reset(to);
101 } else {
102 _invisibility_opt.Set(to);
103 _transparency_opt.Set(to);
104 }
105}
106
113{
114 _transparency_lock.Flip(to);
115}
116
119{
121 unlocked.Flip();
122
123 /* if none of the non-locked options are set */
124 if (!_transparency_opt.Any(unlocked)) {
125 /* set all non-locked options */
126 _transparency_opt.Set(unlocked);
127 } else {
128 /* clear all non-locked options */
129 _transparency_opt.Reset(unlocked);
130 }
131
133}
134
135#endif /* TRANSPARENCY_H */
Functions related to bit mathematics.
constexpr Timpl & Flip()
Flip all bits.
Enum-as-bit-set wrapper.
Functions related to the gfx engine.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1553
Some generic types.
@ Menu
In the main menu.
Definition openttd.h:19
EnumBitSet< DisplayOption, uint8_t > DisplayOptions
Bitset of DisplayOption elements.
Definition openttd.h:56
Types related to stations.
void ResetRestoreAllTransparency()
Set or clear all non-locked transparency options.
StationFacilities _facility_display_opt
What station facilities to draw.
TransparencyOptions _invisibility_opt
The bits that should be invisible.
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.
EnumBitSet< TransparencyOption, uint32_t > TransparencyOptions
Bitset of TransparencyOption elements.
TransparencyOptions _transparency_opt
The bits that should be transparent.
TransparencyOptions _transparency_lock
Prevent these bits from flipping with X.
void ToggleInvisibilityWithTransparency(TransparencyOption to)
Toggles between invisible and solid state.
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...
DisplayOptions _display_opt
What do we want to draw/do?
TransparencyOption
Transparency option bits: which position in _transparency_opt stands for which transparency.
@ Structures
other objects such as transmitters and lighthouses
@ Invalid
Invalid transparency option.
@ Houses
town buildings
@ Text
loading and cost/income text
@ Buildings
company buildings - depots, stations, HQ, ...
@ Industries
industries
void ToggleTransparencyLock(TransparencyOption to)
Toggle the transparency lock bit.