# transparency.h

Go to the documentation of this file.

    00001 /* $Id: transparency.h 18802 2010-01-14 22:56:54Z frosch $ */
    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 #include "openttd.h"
    00017 #include "core/bitmath_func.hpp"
    00018
    00024 enum TransparencyOption {
    00025   TO_SIGNS = 0,
    00026   TO_TREES,
    00027   TO_HOUSES,
    00028   TO_INDUSTRIES,
    00029   TO_BUILDINGS,
    00030   TO_BRIDGES,
    00031   TO_STRUCTURES,
    00032   TO_CATENARY,
    00033   TO_LOADING,
    00034   TO_END,
    00035 };
    00036
    00037 typedef uint TransparencyOptionBits;
    00038 extern TransparencyOptionBits _transparency_opt;
    00039 extern TransparencyOptionBits _transparency_lock;
    00040 extern TransparencyOptionBits _invisibility_opt;
    00041
    00048 static inline bool IsTransparencySet(TransparencyOption to)
    00049 {
    00050   return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
    00051 }
    00052
    00059 static inline bool IsInvisibilitySet(TransparencyOption to)
    00060 {
    00061   return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
    00062 }
    00063
    00069 static inline void ToggleTransparency(TransparencyOption to)
    00070 {
    00071   ToggleBit(_transparency_opt, to);
    00072 }
    00073
    00079 static inline void ToggleInvisibility(TransparencyOption to)
    00080 {
    00081   ToggleBit(_invisibility_opt, to);
    00082 }
    00083
    00091 static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
    00092 {
    00093   if (IsInvisibilitySet(to)) {
    00094     ClrBit(_invisibility_opt, to);
    00095     ClrBit(_transparency_opt, to);
    00096   } else {
    00097     SetBit(_invisibility_opt, to);
    00098     SetBit(_transparency_opt, to);
    00099   }
    00100 }
    00101
    00107 static inline void ToggleTransparencyLock(TransparencyOption to)
    00108 {
    00109   ToggleBit(_transparency_lock, to);
    00110 }
    00111
    00113 static inline void ResetRestoreAllTransparency()
    00114 {
    00115   /* if none of the non-locked options are set */
    00116   if ((_transparency_opt & ~_transparency_lock) == 0) {
    00117     /* set all non-locked options */
    00118     _transparency_opt |= GB(~_transparency_lock, 0, TO_END);
    00119   } else {
    00120     /* clear all non-locked options */
    00121     _transparency_opt &= _transparency_lock;
    00122   }
    00123
    00124   MarkWholeScreenDirty();
    00125 }
    00126
    00127 #endif /* TRANSPARENCY_H */