OpenTTD Source 20261112-master-gbcbec5e63f
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 "station_type.h"
16
22enum class TransparencyOption : uint8_t {
23 Signs = 0,
24 Trees = 1,
25 Houses = 2,
28 Bridges = 5,
31 Text = 8,
33};
34
37
43
52{
53 return _transparency_opt.Test(to) && _game_mode != GameMode::Menu;
54}
55
64{
65 return IsTransparencySet(to) && _invisibility_opt.Test(to) && _game_mode != GameMode::Menu;
66}
67
74{
75 _transparency_opt.Flip(to);
76}
77
84{
85 _invisibility_opt.Flip(to);
86}
87
96{
97 if (IsInvisibilitySet(to)) {
98 _invisibility_opt.Reset(to);
99 _transparency_opt.Reset(to);
100 } else {
101 _invisibility_opt.Set(to);
102 _transparency_opt.Set(to);
103 }
104}
105
112{
113 _transparency_lock.Flip(to);
114}
115
118{
120 unlocked.Flip();
121
122 /* if none of the non-locked options are set */
123 if (!_transparency_opt.Any(unlocked)) {
124 /* set all non-locked options */
125 _transparency_opt.Set(unlocked);
126 } else {
127 /* clear all non-locked options */
128 _transparency_opt.Reset(unlocked);
129 }
130
132}
133
134#endif /* TRANSPARENCY_H */
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:1548
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
@ Invalid
broken savegame (used internally)
Definition saveload.h:438
Types related to stations.
EnumBitSet< StationFacility, uint8_t > StationFacilities
Bitset of StationFacility elements.
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
@ 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.