mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
This commit is contained in:
parent
e075cf5500
commit
4e839aacf6
@ -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_DRIVE_THROUGH_ERROR_DIRECTION :{WHITE}...road facing in the wrong direction
|
||||||
|
|
||||||
STR_TRANSPARENCY_TOOLB :{WHITE}Transparency Options
|
STR_TRANSPARENCY_TOOLB :{WHITE}Transparency Options
|
||||||
STR_TRANSPARENT_SIGNS_DESC :{BLACK}Toggle transparency for station signs
|
STR_TRANSPARENT_SIGNS_DESC :{BLACK}Toggle transparency for station signs. CTRL+click to lock.
|
||||||
STR_TRANSPARENT_TREES_DESC :{BLACK}Toggle transparency for trees
|
STR_TRANSPARENT_TREES_DESC :{BLACK}Toggle transparency for trees. CTRL+click to lock.
|
||||||
STR_TRANSPARENT_HOUSES_DESC :{BLACK}Toggle transparency for houses
|
STR_TRANSPARENT_HOUSES_DESC :{BLACK}Toggle transparency for houses. CTRL+click to lock.
|
||||||
STR_TRANSPARENT_INDUSTRIES_DESC :{BLACK}Toggle transparency for industries
|
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
|
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
|
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, maybe in future for eyecandy
|
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
|
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_SMALL :{TINYFONT}{WHITE}{NUM}%{UPARROW}
|
||||||
STR_PERCENT_UP :{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("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("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_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()
|
SDTG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ enum TransparencyOption {
|
|||||||
|
|
||||||
typedef byte TransparencyOptionBits; ///< transparency option bits
|
typedef byte TransparencyOptionBits; ///< transparency option bits
|
||||||
extern TransparencyOptionBits _transparency_opt;
|
extern TransparencyOptionBits _transparency_opt;
|
||||||
|
extern TransparencyOptionBits _transparency_lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the transparency option bit is set
|
* Check if the transparency option bit is set
|
||||||
@ -43,26 +44,33 @@ static inline bool IsTransparencySet(TransparencyOption to)
|
|||||||
/**
|
/**
|
||||||
* Toggle the transparency option bit
|
* 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)
|
static inline void ToggleTransparency(TransparencyOption to)
|
||||||
{
|
{
|
||||||
ToggleBit(_transparency_opt, to);
|
ToggleBit(_transparency_opt, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggle all transparency options (except signs) or restore the stored transparencies */
|
/**
|
||||||
|
* Toggle the transparency lock bit
|
||||||
|
*
|
||||||
|
* @param to the transparency option to be locked or unlocked
|
||||||
|
*/
|
||||||
|
static inline void ToggleTransparencyLock(TransparencyOption to)
|
||||||
|
{
|
||||||
|
ToggleBit(_transparency_lock, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set or clear all non-locked transparency options */
|
||||||
static inline void ResetRestoreAllTransparency()
|
static inline void ResetRestoreAllTransparency()
|
||||||
{
|
{
|
||||||
/* backup of the original transparencies or if all transparencies false toggle them to true */
|
/* if none of the non-locked options are set */
|
||||||
static TransparencyOptionBits trans_opt = ~0;
|
if ((_transparency_opt & ~_transparency_lock) == 0) {
|
||||||
|
/* set all non-locked options */
|
||||||
if (_transparency_opt == 0) {
|
_transparency_opt |= ~_transparency_lock;
|
||||||
/* no structure is transparent, so restore the old transparency if present otherwise set all true */
|
|
||||||
_transparency_opt = trans_opt;
|
|
||||||
} else {
|
} else {
|
||||||
/* any structure is transparent, so store current transparency settings and reset it */
|
/* clear all non-locked options */
|
||||||
trans_opt = _transparency_opt;
|
_transparency_opt &= _transparency_lock;
|
||||||
_transparency_opt = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
@ -12,12 +12,10 @@
|
|||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
TransparencyOptionBits _transparency_opt;
|
TransparencyOptionBits _transparency_opt;
|
||||||
|
TransparencyOptionBits _transparency_lock;
|
||||||
|
|
||||||
enum TransparencyToolbarWidgets{
|
enum TransparencyToolbarWidgets{
|
||||||
/* Widgets not toggled when pressing the X key */
|
|
||||||
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
|
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
|
||||||
|
|
||||||
/* Widgets toggled when pressing the X key */
|
|
||||||
TTW_WIDGET_TREES, ///< Make trees transparent
|
TTW_WIDGET_TREES, ///< Make trees transparent
|
||||||
TTW_WIDGET_HOUSES, ///< Make houses transparent
|
TTW_WIDGET_HOUSES, ///< Make houses transparent
|
||||||
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
|
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
|
||||||
@ -39,15 +37,24 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
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;
|
break;
|
||||||
|
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
|
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
|
||||||
/* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */
|
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));
|
ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
|
||||||
SndPlayFx(SND_15_BEEP);
|
SndPlayFx(SND_15_BEEP);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user