From 4e839aacf650f65cd8aeeece91fa038b3c68ffdb Mon Sep 17 00:00:00 2001 From: maedhros Date: Sun, 10 Feb 2008 14:49:44 +0000 Subject: (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin) --- src/transparency.h | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/transparency.h') diff --git a/src/transparency.h b/src/transparency.h index 344946769..8f4dbbeeb 100644 --- a/src/transparency.h +++ b/src/transparency.h @@ -28,6 +28,7 @@ enum TransparencyOption { typedef byte TransparencyOptionBits; ///< transparency option bits extern TransparencyOptionBits _transparency_opt; +extern TransparencyOptionBits _transparency_lock; /** * Check if the transparency option bit is set @@ -43,26 +44,33 @@ static inline bool IsTransparencySet(TransparencyOption to) /** * Toggle the transparency option bit * - * @param to the structure which transparency option is toggle + * @param to the transparency option to be toggled */ static inline void ToggleTransparency(TransparencyOption to) { ToggleBit(_transparency_opt, to); } -/** Toggle all transparency options (except signs) or restore the stored transparencies */ -static inline void ResetRestoreAllTransparency() +/** + * Toggle the transparency lock bit + * + * @param to the transparency option to be locked or unlocked + */ +static inline void ToggleTransparencyLock(TransparencyOption to) { - /* backup of the original transparencies or if all transparencies false toggle them to true */ - static TransparencyOptionBits trans_opt = ~0; + ToggleBit(_transparency_lock, to); +} - if (_transparency_opt == 0) { - /* no structure is transparent, so restore the old transparency if present otherwise set all true */ - _transparency_opt = trans_opt; +/** Set or clear all non-locked transparency options */ +static inline void ResetRestoreAllTransparency() +{ + /* if none of the non-locked options are set */ + if ((_transparency_opt & ~_transparency_lock) == 0) { + /* set all non-locked options */ + _transparency_opt |= ~_transparency_lock; } else { - /* any structure is transparent, so store current transparency settings and reset it */ - trans_opt = _transparency_opt; - _transparency_opt = 0; + /* clear all non-locked options */ + _transparency_opt &= _transparency_lock; } MarkWholeScreenDirty(); -- cgit v1.2.3-54-g00ecf