summaryrefslogtreecommitdiff
path: root/src/transparency.h
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2008-02-10 14:49:44 +0000
committermaedhros <maedhros@openttd.org>2008-02-10 14:49:44 +0000
commit4e839aacf650f65cd8aeeece91fa038b3c68ffdb (patch)
tree9f2fca07965bf4aafc72cfaa9e2264d08d5c0ec1 /src/transparency.h
parente075cf550033b68dbfba0c60988943e23a252ccc (diff)
downloadopenttd-4e839aacf650f65cd8aeeece91fa038b3c68ffdb.tar.xz
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
Diffstat (limited to 'src/transparency.h')
-rw-r--r--src/transparency.h30
1 files changed, 19 insertions, 11 deletions
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();