summaryrefslogtreecommitdiff
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
parente075cf550033b68dbfba0c60988943e23a252ccc (diff)
downloadopenttd-4e839aacf650f65cd8aeeece91fa038b3c68ffdb.tar.xz
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
-rw-r--r--src/lang/english.txt16
-rw-r--r--src/settings.cpp1
-rw-r--r--src/transparency.h30
-rw-r--r--src/transparency_gui.cpp21
4 files changed, 42 insertions, 26 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index f07f2cb1d..1000fbbc9 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3337,14 +3337,14 @@ STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD :{WHITE}...this
STR_DRIVE_THROUGH_ERROR_DIRECTION :{WHITE}...road facing in the wrong direction
STR_TRANSPARENCY_TOOLB :{WHITE}Transparency Options
-STR_TRANSPARENT_SIGNS_DESC :{BLACK}Toggle transparency for station signs
-STR_TRANSPARENT_TREES_DESC :{BLACK}Toggle transparency for trees
-STR_TRANSPARENT_HOUSES_DESC :{BLACK}Toggle transparency for houses
-STR_TRANSPARENT_INDUSTRIES_DESC :{BLACK}Toggle transparency for industries
-STR_TRANSPARENT_BUILDINGS_DESC :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary
-STR_TRANSPARENT_BRIDGES_DESC :{BLACK}Toggle transparency for bridges
-STR_TRANSPARENT_STRUCTURES_DESC :{BLACK}Toggle transparency for structures like lighthouses and antennas, maybe in future for eyecandy
-STR_TRANSPARENT_LOADING_DESC :{BLACK}Toggle transparency for loading indicators
+STR_TRANSPARENT_SIGNS_DESC :{BLACK}Toggle transparency for station signs. CTRL+click to lock.
+STR_TRANSPARENT_TREES_DESC :{BLACK}Toggle transparency for trees. CTRL+click to lock.
+STR_TRANSPARENT_HOUSES_DESC :{BLACK}Toggle transparency for houses. CTRL+click to lock.
+STR_TRANSPARENT_INDUSTRIES_DESC :{BLACK}Toggle transparency for industries. CTRL+click to lock.
+STR_TRANSPARENT_BUILDINGS_DESC :{BLACK}Toggle transparency for buildables like stations, depots, waypoints and catenary. CTRL+click to lock.
+STR_TRANSPARENT_BRIDGES_DESC :{BLACK}Toggle transparency for bridges. CTRL+click to lock.
+STR_TRANSPARENT_STRUCTURES_DESC :{BLACK}Toggle transparency for structures like lighthouses and antennas. CTRL+click to lock.
+STR_TRANSPARENT_LOADING_DESC :{BLACK}Toggle transparency for loading indicators. CTRL+click to lock.
STR_PERCENT_UP_SMALL :{TINYFONT}{WHITE}{NUM}%{UPARROW}
STR_PERCENT_UP :{WHITE}{NUM}%{UPARROW}
diff --git a/src/settings.cpp b/src/settings.cpp
index 5f18f3c5c..8e88c5e8c 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1283,6 +1283,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
SDTG_VAR("transparency_options", SLE_UINT8, S, 0, _transparency_opt, 0, 0,0xFF,0, STR_NULL, NULL),
+ SDTG_VAR("transparency_locks", SLE_UINT8, S, 0, _transparency_lock, 0, 0,0xFF,0, STR_NULL, NULL),
SDTG_END()
};
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();
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 33c21d078..b33003f9e 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -12,12 +12,10 @@
#include "table/strings.h"
TransparencyOptionBits _transparency_opt;
+TransparencyOptionBits _transparency_lock;
enum TransparencyToolbarWidgets{
- /* Widgets not toggled when pressing the X key */
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
-
- /* Widgets toggled when pressing the X key */
TTW_WIDGET_TREES, ///< Make trees transparent
TTW_WIDGET_HOUSES, ///< Make houses transparent
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
@@ -39,14 +37,23 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
}
DrawWindowWidgets(w);
+ for (uint i = TO_SIGNS; i < TO_END; i++) {
+ if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[TTW_WIDGET_SIGNS + i].left + 1, w->widget[TTW_WIDGET_SIGNS + i].top + 1);
+ }
break;
case WE_CLICK:
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
- /* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */
- ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
- SndPlayFx(SND_15_BEEP);
- MarkWholeScreenDirty();
+ if (_ctrl_pressed) {
+ /* toggle the bit of the transparencies lock variable */
+ ToggleTransparencyLock((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
+ SetWindowDirty(w);
+ } else {
+ /* toggle the bit of the transparencies variable and play a sound */
+ ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
+ SndPlayFx(SND_15_BEEP);
+ MarkWholeScreenDirty();
+ }
}
break;
}