# transparency.h

Go to the documentation of this file.

    00001 /* $Id: transparency.h 14421 2008-09-30 20:39:50Z rubidium $ */
    00002
    00005 #ifndef TRANSPARENCY_H
    00006 #define TRANSPARENCY_H
    00007
    00008 #include "gfx_func.h"
    00009
    00015 enum TransparencyOption {
    00016   TO_SIGNS = 0,
    00017   TO_TREES,
    00018   TO_HOUSES,
    00019   TO_INDUSTRIES,
    00020   TO_BUILDINGS,
    00021   TO_BRIDGES,
    00022   TO_STRUCTURES,
    00023   TO_CATENARY,
    00024   TO_LOADING,
    00025   TO_END,
    00026 };
    00027
    00028 typedef uint TransparencyOptionBits;
    00029 extern TransparencyOptionBits _transparency_opt;
    00030 extern TransparencyOptionBits _transparency_lock;
    00031 extern TransparencyOptionBits _invisibility_opt;
    00032
    00039 static inline bool IsTransparencySet(TransparencyOption to)
    00040 {
    00041   return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
    00042 }
    00043
    00050 static inline bool IsInvisibilitySet(TransparencyOption to)
    00051 {
    00052   return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
    00053 }
    00054
    00060 static inline void ToggleTransparency(TransparencyOption to)
    00061 {
    00062   ToggleBit(_transparency_opt, to);
    00063 }
    00064
    00070 static inline void ToggleInvisibility(TransparencyOption to)
    00071 {
    00072   ToggleBit(_invisibility_opt, to);
    00073 }
    00074
    00082 static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
    00083 {
    00084   if (IsInvisibilitySet(to)) {
    00085     ClrBit(_invisibility_opt, to);
    00086     ClrBit(_transparency_opt, to);
    00087   } else {
    00088     SetBit(_invisibility_opt, to);
    00089     SetBit(_transparency_opt, to);
    00090   }
    00091 }
    00092
    00098 static inline void ToggleTransparencyLock(TransparencyOption to)
    00099 {
    00100   ToggleBit(_transparency_lock, to);
    00101 }
    00102
    00104 static inline void ResetRestoreAllTransparency()
    00105 {
    00106   /* if none of the non-locked options are set */
    00107   if ((_transparency_opt & ~_transparency_lock) == 0) {
    00108     /* set all non-locked options */
    00109     _transparency_opt |= GB(~_transparency_lock, 0, TO_END);
    00110   } else {
    00111     /* clear all non-locked options */
    00112     _transparency_opt &= _transparency_lock;
    00113   }
    00114
    00115   MarkWholeScreenDirty();
    00116 }
    00117
    00118 #endif /* TRANSPARENCY_H */