belugas@7849: /* $Id$ */ belugas@7849: rubidium@9111: /** @file transparency.h Functions related to transparency. */ belugas@7849: belugas@7849: #ifndef TRANSPARENCY_H belugas@7849: #define TRANSPARENCY_H belugas@7849: rubidium@8123: #include "gfx_func.h" rubidium@8123: belugas@7849: /** belugas@7849: * Transparency option bits: which position in _transparency_opt stands for which transparency. belugas@7849: * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. belugas@7849: * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. belugas@7849: */ belugas@7849: enum TransparencyOption { belugas@7849: TO_SIGNS = 0, ///< signs belugas@7849: TO_TREES, ///< trees belugas@7849: TO_HOUSES, ///< town buildings belugas@7849: TO_INDUSTRIES, ///< industries rubidium@10207: TO_BUILDINGS, ///< company buildings - depots, stations, HQ, ... belugas@7849: TO_BRIDGES, ///< bridges belugas@7849: TO_STRUCTURES, ///< unmovable structures smatz@8528: TO_CATENARY, ///< catenary belugas@7849: TO_LOADING, ///< loading indicators belugas@7849: TO_END, belugas@7849: }; belugas@7849: smatz@8528: typedef uint TransparencyOptionBits; ///< transparency option bits belugas@7849: extern TransparencyOptionBits _transparency_opt; maedhros@8527: extern TransparencyOptionBits _transparency_lock; smatz@8806: extern TransparencyOptionBits _invisibility_opt; belugas@7849: belugas@7849: /** belugas@7849: * Check if the transparency option bit is set belugas@7849: * and if we aren't in the game menu (there's never transparency) belugas@7849: * belugas@7849: * @param to the structure which transparency option is ask for belugas@7849: */ belugas@7849: static inline bool IsTransparencySet(TransparencyOption to) belugas@7849: { skidd13@7928: return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); belugas@7849: } belugas@7849: belugas@7849: /** smatz@8806: * Check if the invisibility option bit is set smatz@8806: * and if we aren't in the game menu (there's never transparency) smatz@8806: * smatz@8806: * @param to the structure which invisibility option is ask for smatz@8806: */ smatz@8806: static inline bool IsInvisibilitySet(TransparencyOption to) smatz@8806: { smatz@8806: return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); smatz@8806: } smatz@8806: smatz@8806: /** belugas@7849: * Toggle the transparency option bit belugas@7849: * maedhros@8527: * @param to the transparency option to be toggled belugas@7849: */ belugas@7849: static inline void ToggleTransparency(TransparencyOption to) belugas@7849: { skidd13@7932: ToggleBit(_transparency_opt, to); belugas@7849: } belugas@7849: maedhros@8527: /** smatz@8806: * Toggle the invisibility option bit smatz@8806: * smatz@8806: * @param to the structure which invisibility option is toggle smatz@8806: */ smatz@8806: static inline void ToggleInvisibility(TransparencyOption to) smatz@8806: { smatz@8806: ToggleBit(_invisibility_opt, to); smatz@8806: } smatz@8806: smatz@8806: /** smatz@8806: * Toggles between invisible and solid state. smatz@8806: * If object is transparent, then it is made invisible. smatz@8806: * Used by the keyboard shortcuts. smatz@8806: * smatz@8806: * @param to the object type which invisibility option to toggle smatz@8806: */ smatz@8806: static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) smatz@8806: { smatz@8806: if (IsInvisibilitySet(to)) { smatz@8806: ClrBit(_invisibility_opt, to); smatz@8806: ClrBit(_transparency_opt, to); smatz@8806: } else { smatz@8806: SetBit(_invisibility_opt, to); smatz@8806: SetBit(_transparency_opt, to); smatz@8806: } smatz@8806: } smatz@8806: smatz@8806: /** maedhros@8527: * Toggle the transparency lock bit maedhros@8527: * maedhros@8527: * @param to the transparency option to be locked or unlocked maedhros@8527: */ maedhros@8527: static inline void ToggleTransparencyLock(TransparencyOption to) maedhros@8527: { maedhros@8527: ToggleBit(_transparency_lock, to); maedhros@8527: } maedhros@8527: maedhros@8527: /** Set or clear all non-locked transparency options */ belugas@7849: static inline void ResetRestoreAllTransparency() belugas@7849: { maedhros@8527: /* if none of the non-locked options are set */ maedhros@8527: if ((_transparency_opt & ~_transparency_lock) == 0) { maedhros@8527: /* set all non-locked options */ peter1138@8658: _transparency_opt |= GB(~_transparency_lock, 0, TO_END); belugas@7849: } else { maedhros@8527: /* clear all non-locked options */ maedhros@8527: _transparency_opt &= _transparency_lock; belugas@7849: } belugas@7849: belugas@7849: MarkWholeScreenDirty(); belugas@7849: } belugas@7849: belugas@7849: #endif /* TRANSPARENCY_H */