# transparency.h

Go to the documentation of this file.

    00001 /* $Id: transparency.h 17248 2009-08-21 20:21:05Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef TRANSPARENCY_H
    00013 #define TRANSPARENCY_H
    00014
    00015 #include "gfx_func.h"
    00016
    00022 enum TransparencyOption {
    00023   TO_SIGNS = 0,
    00024   TO_TREES,
    00025   TO_HOUSES,
    00026   TO_INDUSTRIES,
    00027   TO_BUILDINGS,
    00028   TO_BRIDGES,
    00029   TO_STRUCTURES,
    00030   TO_CATENARY,
    00031   TO_LOADING,
    00032   TO_END,
    00033 };
    00034
    00035 typedef uint TransparencyOptionBits;
    00036 extern TransparencyOptionBits _transparency_opt;
    00037 extern TransparencyOptionBits _transparency_lock;
    00038 extern TransparencyOptionBits _invisibility_opt;
    00039
    00046 static inline bool IsTransparencySet(TransparencyOption to)
    00047 {
    00048   return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
    00049 }
    00050
    00057 static inline bool IsInvisibilitySet(TransparencyOption to)
    00058 {
    00059   return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
    00060 }
    00061
    00067 static inline void ToggleTransparency(TransparencyOption to)
    00068 {
    00069   ToggleBit(_transparency_opt, to);
    00070 }
    00071
    00077 static inline void ToggleInvisibility(TransparencyOption to)
    00078 {
    00079   ToggleBit(_invisibility_opt, to);
    00080 }
    00081
    00089 static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
    00090 {
    00091   if (IsInvisibilitySet(to)) {
    00092     ClrBit(_invisibility_opt, to);
    00093     ClrBit(_transparency_opt, to);
    00094   } else {
    00095     SetBit(_invisibility_opt, to);
    00096     SetBit(_transparency_opt, to);
    00097   }
    00098 }
    00099
    00105 static inline void ToggleTransparencyLock(TransparencyOption to)
    00106 {
    00107   ToggleBit(_transparency_lock, to);
    00108 }
    00109
    00111 static inline void ResetRestoreAllTransparency()
    00112 {
    00113   /* if none of the non-locked options are set */
    00114   if ((_transparency_opt & ~_transparency_lock) == 0) {
    00115     /* set all non-locked options */
    00116     _transparency_opt |= GB(~_transparency_lock, 0, TO_END);
    00117   } else {
    00118     /* clear all non-locked options */
    00119     _transparency_opt &= _transparency_lock;
    00120   }
    00121
    00122   MarkWholeScreenDirty();
    00123 }
    00124
    00125 #endif /* TRANSPARENCY_H */