src/transparency.h
changeset 8806 4fe163e0b52a
parent 8658 e6fd51e0e9b0
child 9111 48ce04029fe4
equal deleted inserted replaced
8805:f5ca1c3d16af 8806:4fe163e0b52a
    26 };
    26 };
    27 
    27 
    28 typedef uint TransparencyOptionBits; ///< transparency option bits
    28 typedef uint TransparencyOptionBits; ///< transparency option bits
    29 extern TransparencyOptionBits _transparency_opt;
    29 extern TransparencyOptionBits _transparency_opt;
    30 extern TransparencyOptionBits _transparency_lock;
    30 extern TransparencyOptionBits _transparency_lock;
       
    31 extern TransparencyOptionBits _invisibility_opt;
    31 
    32 
    32 /**
    33 /**
    33  * Check if the transparency option bit is set
    34  * Check if the transparency option bit is set
    34  * and if we aren't in the game menu (there's never transparency)
    35  * and if we aren't in the game menu (there's never transparency)
    35  *
    36  *
    39 {
    40 {
    40 	return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
    41 	return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
    41 }
    42 }
    42 
    43 
    43 /**
    44 /**
       
    45  * Check if the invisibility option bit is set
       
    46  * and if we aren't in the game menu (there's never transparency)
       
    47  *
       
    48  * @param to the structure which invisibility option is ask for
       
    49  */
       
    50 static inline bool IsInvisibilitySet(TransparencyOption to)
       
    51 {
       
    52 	return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
       
    53 }
       
    54 
       
    55 /**
    44  * Toggle the transparency option bit
    56  * Toggle the transparency option bit
    45  *
    57  *
    46  * @param to the transparency option to be toggled
    58  * @param to the transparency option to be toggled
    47  */
    59  */
    48 static inline void ToggleTransparency(TransparencyOption to)
    60 static inline void ToggleTransparency(TransparencyOption to)
    49 {
    61 {
    50 	ToggleBit(_transparency_opt, to);
    62 	ToggleBit(_transparency_opt, to);
       
    63 }
       
    64 
       
    65 /**
       
    66  * Toggle the invisibility option bit
       
    67  *
       
    68  * @param to the structure which invisibility option is toggle
       
    69  */
       
    70 static inline void ToggleInvisibility(TransparencyOption to)
       
    71 {
       
    72 	ToggleBit(_invisibility_opt, to);
       
    73 }
       
    74 
       
    75 /**
       
    76  * Toggles between invisible and solid state.
       
    77  * If object is transparent, then it is made invisible.
       
    78  * Used by the keyboard shortcuts.
       
    79  *
       
    80  * @param to the object type which invisibility option to toggle
       
    81  */
       
    82 static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
       
    83 {
       
    84 	if (IsInvisibilitySet(to)) {
       
    85 		ClrBit(_invisibility_opt, to);
       
    86 		ClrBit(_transparency_opt, to);
       
    87 	} else {
       
    88 		SetBit(_invisibility_opt, to);
       
    89 		SetBit(_transparency_opt, to);
       
    90 	}
    51 }
    91 }
    52 
    92 
    53 /**
    93 /**
    54  * Toggle the transparency lock bit
    94  * Toggle the transparency lock bit
    55  *
    95  *