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