(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)

pull/155/head
maedhros 17 years ago
parent 0fc6754832
commit 56a5c2d7c2

@ -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}

@ -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()
};

@ -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();

@ -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;
}

Loading…
Cancel
Save