Add setting to show restricted electric signals using the default sprites.

This is to improve visual distinctiveness of restricted signals when
using signal GRFs.
This defaults to off.
This commit is contained in:
Jonathan G Rennison 2015-12-09 01:01:37 +00:00
parent 8edf5e0a34
commit a93714a720
8 changed files with 43 additions and 3 deletions

View File

@ -177,6 +177,11 @@ static void LoadSpriteTables()
/* Tracerestrict sprites. */
LoadGrfFile("tracerestrict.grf", SPR_TRACERESTRICT_BASE, i++);
/* Fill duplicate original signal graphics sprite block */
for (uint i = 0; i < DUP_ORIGINAL_SIGNALS_SPRITE_COUNT; i++) {
DupSprite(SPR_ORIGINAL_SIGNALS_BASE + i, SPR_DUP_ORIGINAL_SIGNALS_BASE + i);
}
/*
* The second basic file always starts at the given location and does
* contain a different amount of sprites depending on the "type"; DOS

View File

@ -1287,6 +1287,8 @@ STR_CONFIG_SETTING_POPULATION_IN_LABEL :Show town popul
STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Display the population of towns in their label on the map
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS :Thickness of lines in graphs: {STRING2}
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Width of the line in the graphs. A thin line is more precisely readable, a thicker line is easier to see and colours are easier to distinguish
STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF :Show restricted electric signals using default graphics: {STRING2}
STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF_HELPTEXT :Show electric signals with routing restriction programs using the default signal graphics with a blue signal post, instead of using any NewGRF signal graphics. This is to make it easier to visually distinguish restricted signals.
STR_CONFIG_SETTING_LANDSCAPE :Landscape: {STRING2}
STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Landscapes define basic gameplay scenarios with different cargos and town growth requirements. NewGRF and Game Scripts allow finer control though

View File

@ -5671,11 +5671,19 @@ static void GraphicsNew(ByteReader *buf)
/* Load <num> sprites starting from <replace>, then skip <skip_num> sprites. */
grfmsg(2, "GraphicsNew: Replacing sprites %d to %d of %s (type 0x%02X) at SpriteID 0x%04X", offset, offset + num - 1, action5_type->name, type, replace);
for (; num > 0; num--) {
for (uint16 n = num; n > 0; n--) {
_cur.nfo_line++;
LoadNextSprite(replace == 0 ? _cur.spriteid++ : replace++, _cur.file_index, _cur.nfo_line, _cur.grf_container_ver);
}
if (type == 0x04 && (_cur.grffile->is_ottdfile || _cur.grfconfig->ident.grfid == BSWAP32(0xFF4F4701))) {
/* Signal graphics action 5: Fill duplicate signal sprite block if this is a baseset GRF or OpenGFX */
const SpriteID end = offset + num;
for (SpriteID i = offset; i < end; i++) {
DupSprite(SPR_SIGNALS_BASE + i, SPR_DUP_SIGNALS_BASE + i);
}
}
if (type == 0x0D) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_5;
_cur.skip_sprites = skip_num;

View File

@ -1862,6 +1862,8 @@ static void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track trac
SignalType type = GetSignalType(tile, track);
SignalVariant variant = GetSignalVariant(tile, track);
bool show_restricted = (variant == SIG_ELECTRIC) && IsRestrictedSignal(tile) && (GetExistingTraceRestrictProgram(tile, track) != NULL);
SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
bool is_custom_sprite = (sprite != 0);
if (sprite != 0) {
@ -1877,7 +1879,14 @@ static void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track trac
extern uint _opengfx_grf_file_index;
if (!is_custom_sprite) is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index);
if (!is_custom_sprite && variant == SIG_ELECTRIC && IsRestrictedSignal(tile) && GetExistingTraceRestrictProgram(tile, track) != NULL) {
if (is_custom_sprite && show_restricted && _settings_client.gui.show_restricted_signal_default) {
/* Use duplicate sprite block, instead of GRF-specified signals */
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_DUP_ORIGINAL_SIGNALS_BASE : SPR_DUP_SIGNALS_BASE - 16;
sprite += type * 16 + variant * 64 + image * 2 + condition + (type > SIGTYPE_LAST_NOPBS ? 64 : 0);
is_custom_sprite = false;
}
if (!is_custom_sprite && show_restricted) {
if (type == SIGTYPE_PBS || type == SIGTYPE_PBS_ONEWAY) {
static const SubSprite lower_part = { -50, -10, 50, 50 };
static const SubSprite upper_part = { -50, -50, 50, -11 };

View File

@ -1478,6 +1478,7 @@ static SettingsContainer &GetSettingsTree()
graphics->Add(new SettingEntry("gui.zoom_max"));
graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
graphics->Add(new SettingEntry("gui.graph_line_thickness"));
graphics->Add(new SettingEntry("gui.show_restricted_signal_default"));
}
SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));

View File

@ -135,6 +135,7 @@ struct GUISettings {
uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan
byte missing_strings_threshold; ///< the number of missing strings before showing the warning
uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis
bool show_restricted_signal_default; ///< Show restricted electric signals using the default sprite
uint8 osk_activation; ///< Mouse gesture to trigger the OSK.
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.

View File

@ -3133,6 +3133,14 @@ strhelp = STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT
strval = STR_JUST_COMMA
proc = RedrawScreen
[SDTC_BOOL]
var = gui.show_restricted_signal_default
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = false
str = STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF
strhelp = STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF_HELPTEXT
proc = RedrawScreen
; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL]
ifdef = DEDICATED

View File

@ -300,8 +300,14 @@ static const uint16 PALETTE_SPRITE_COUNT = 1;
static const SpriteID SPR_TRACERESTRICT_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT;
static const uint16 TRACERESTRICT_SPRITE_COUNT = 2;
/* Duplicated signal sprites */
static const SpriteID SPR_DUP_ORIGINAL_SIGNALS_BASE = SPR_TRACERESTRICT_BASE + TRACERESTRICT_SPRITE_COUNT;
static const uint16 DUP_ORIGINAL_SIGNALS_SPRITE_COUNT = 16;
static const SpriteID SPR_DUP_SIGNALS_BASE = SPR_DUP_ORIGINAL_SIGNALS_BASE + DUP_ORIGINAL_SIGNALS_SPRITE_COUNT;
static const uint16 DUP_SIGNALS_SPRITE_COUNT = PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT;
/* From where can we start putting NewGRFs? */
static const SpriteID SPR_NEWGRFS_BASE = SPR_TRACERESTRICT_BASE + TRACERESTRICT_SPRITE_COUNT;
static const SpriteID SPR_NEWGRFS_BASE = SPR_DUP_SIGNALS_BASE + DUP_SIGNALS_SPRITE_COUNT;
/* Manager face sprites */
static const SpriteID SPR_GRADIENT = 874; // background gradient behind manager face