OpenTTD Source 20260531-master-g0e951f3528
transparency.h File Reference

Functions related to transparency. More...

#include "gfx_func.h"
#include "openttd.h"
#include "core/bitmath_func.hpp"
#include "station_type.h"

Go to the source code of this file.

Typedefs

using TransparencyOptions = EnumBitSet<TransparencyOption, uint32_t>
 Bitset of TransparencyOption elements.

Enumerations

enum class  TransparencyOption : uint8_t {
  Signs = 0 , Trees = 1 , Houses = 2 , Industries = 3 ,
  Buildings = 4 , Bridges = 5 , Structures = 6 , Catenary = 7 ,
  Text = 8 , Invalid
}
 Transparency option bits: which position in _transparency_opt stands for which transparency. More...

Functions

bool IsTransparencySet (TransparencyOption to)
 Check if the transparency option bit is set and if we aren't in the game menu (there's never transparency).
bool IsInvisibilitySet (TransparencyOption to)
 Check if the invisibility option bit is set and if we aren't in the game menu (there's never transparency).
void ToggleTransparency (TransparencyOption to)
 Toggle the transparency option bit.
void ToggleInvisibility (TransparencyOption to)
 Toggle the invisibility option bit.
void ToggleInvisibilityWithTransparency (TransparencyOption to)
 Toggles between invisible and solid state.
void ToggleTransparencyLock (TransparencyOption to)
 Toggle the transparency lock bit.
void ResetRestoreAllTransparency ()
 Set or clear all non-locked transparency options.

Variables

TransparencyOptions _transparency_opt
 The bits that should be transparent.
TransparencyOptions _transparency_lock
 Prevent these bits from flipping with X.
TransparencyOptions _invisibility_opt
 The bits that should be invisible.
DisplayOptions _display_opt
 What do we want to draw/do?
StationFacilities _facility_display_opt
 What station facilities to draw.

Detailed Description

Functions related to transparency.

Definition in file transparency.h.

Typedef Documentation

◆ TransparencyOptions

Bitset of TransparencyOption elements.

Definition at line 37 of file transparency.h.

Enumeration Type Documentation

◆ TransparencyOption

enum class TransparencyOption : uint8_t
strong

Transparency option bits: which position in _transparency_opt stands for which transparency.

If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp.

Enumerator
Signs 

signs

Trees 

trees

Houses 

town buildings

Industries 

industries

Buildings 

company buildings - depots, stations, HQ, ...

Bridges 

bridges

Structures 

other objects such as transmitters and lighthouses

Catenary 

catenary

Text 

loading and cost/income text

Invalid 

Invalid transparency option.

Definition at line 23 of file transparency.h.

Function Documentation

◆ IsInvisibilitySet()

bool IsInvisibilitySet ( TransparencyOption to)
inline

Check if the invisibility option bit is set and if we aren't in the game menu (there's never transparency).

Parameters
tothe structure which invisibility option is ask for
Returns
true if invisibility is set for the option, and not in the main menu.

Definition at line 64 of file transparency.h.

References _invisibility_opt, IsTransparencySet(), and Menu.

Referenced by CheckClickOnViewportSign(), DoDrawVehicle(), DrawBridgeMiddle(), DrawBridgeRoadBits(), DrawCommonTileSeq(), DrawRoadBits(), DrawTile_Industry(), DrawTile_Object(), DrawTile_Rail(), DrawTile_Town(), DrawTile_Trees(), DrawWaterTileStruct(), HasRailCatenaryDrawn(), HasRoadCatenaryDrawn(), and ToggleInvisibilityWithTransparency().

◆ IsTransparencySet()

bool IsTransparencySet ( TransparencyOption to)
inline

Check if the transparency option bit is set and if we aren't in the game menu (there's never transparency).

Parameters
tothe structure which transparency option is ask for
Returns
true if transparency is set for the option, and not in the main menu.

Definition at line 52 of file transparency.h.

References _transparency_opt, and Menu.

Referenced by DoDrawVehicle(), DrawBridgeMiddle(), DrawBridgeRoadBits(), DrawCommonTileSeq(), DrawRailCatenary(), DrawRailCatenaryOnBridge(), DrawRailCatenaryOnTunnel(), DrawRailCatenaryRailway(), DrawRoadBits(), DrawRoadTypeCatenary(), DrawTile_Industry(), DrawTile_Object(), DrawTile_Town(), DrawTile_Trees(), DrawTile_TunnelBridge(), DrawWaterTileStruct(), IsInvisibilitySet(), TransparenciesWindow::OnClick(), TransparenciesWindow::OnInvalidateData(), ToolbarOptionsClick(), ViewportAddSignStrings(), and ViewportAddStationStrings().

◆ ResetRestoreAllTransparency()

void ResetRestoreAllTransparency ( )
inline

Set or clear all non-locked transparency options.

Definition at line 118 of file transparency.h.

References _transparency_lock, _transparency_opt, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), and MarkWholeScreenDirty().

Referenced by MainWindow::OnHotkey().

◆ ToggleInvisibility()

void ToggleInvisibility ( TransparencyOption to)
inline

Toggle the invisibility option bit.

Parameters
tothe structure which invisibility option is toggle

Definition at line 84 of file transparency.h.

References _invisibility_opt.

Referenced by TransparenciesWindow::OnClick().

◆ ToggleInvisibilityWithTransparency()

void ToggleInvisibilityWithTransparency ( TransparencyOption to)
inline

Toggles between invisible and solid state.

If object is transparent, then it is made invisible. Used by the keyboard shortcuts.

Parameters
tothe object type which invisibility option to toggle

Definition at line 96 of file transparency.h.

References _invisibility_opt, _transparency_opt, and IsInvisibilitySet().

Referenced by MainWindow::OnHotkey().

◆ ToggleTransparency()

void ToggleTransparency ( TransparencyOption to)
inline

Toggle the transparency option bit.

Parameters
tothe transparency option to be toggled

Definition at line 74 of file transparency.h.

References _transparency_opt.

Referenced by MenuClickSettings(), TransparenciesWindow::OnClick(), and MainWindow::OnHotkey().

◆ ToggleTransparencyLock()

void ToggleTransparencyLock ( TransparencyOption to)
inline

Toggle the transparency lock bit.

Parameters
tothe transparency option to be locked or unlocked

Definition at line 112 of file transparency.h.

References _transparency_lock.

Referenced by TransparenciesWindow::OnClick().

Variable Documentation

◆ _display_opt

◆ _facility_display_opt

StationFacilities _facility_display_opt
extern

What station facilities to draw.

Definition at line 27 of file transparency_gui.cpp.

Referenced by MenuClickSettings(), and ToolbarOptionsClick().

◆ _invisibility_opt

TransparencyOptions _invisibility_opt
extern

The bits that should be invisible.

Definition at line 25 of file transparency_gui.cpp.

Referenced by TransparenciesWindow::DrawWidget(), IsInvisibilitySet(), ToggleInvisibility(), and ToggleInvisibilityWithTransparency().

◆ _transparency_lock

TransparencyOptions _transparency_lock
extern

Prevent these bits from flipping with X.

Definition at line 24 of file transparency_gui.cpp.

Referenced by TransparenciesWindow::DrawWidget(), ResetRestoreAllTransparency(), and ToggleTransparencyLock().

◆ _transparency_opt

TransparencyOptions _transparency_opt
extern