diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index 73187d31f7..85ef96e11c 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -356,7 +356,21 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const dst_px->a = a; if (a != 0 && a != 255) flags |= BSF_TRANSLUCENT; *dst_n = src->m; - if (src->m != 0) { + if (z >= _settings_client.gui.disable_water_animation && src->m >= 245 && src->m <= 254) { + *dst_n = 0; + + /* Get brightest value */ + uint8 rgb_max = std::max({ src->r, src->g, src->b }); + + /* Black pixel (8bpp or old 32bpp image), so use default value */ + if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS; + + extern Colour _water_palette[10]; + Colour c = this->AdjustBrightness(_water_palette[src->m - 245], rgb_max); + dst_px->r = c.r; + dst_px->g = c.g; + dst_px->b = c.b; + } else if (src->m != 0) { flags &= ~BSF_NO_REMAP; if (src->m >= PALETTE_ANIM_START) flags &= ~BSF_NO_ANIM; diff --git a/src/blitter/32bpp_sse2.cpp b/src/blitter/32bpp_sse2.cpp index 5bb9a02519..d4303e0adf 100644 --- a/src/blitter/32bpp_sse2.cpp +++ b/src/blitter/32bpp_sse2.cpp @@ -74,7 +74,20 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca dst_rgba->a = src->a; if (src->a != 0 && src->a != 255) has_translucency = true; dst_mv->m = src->m; - if (src->m != 0) { + if (z >= _settings_client.gui.disable_water_animation && src->m >= 245 && src->m <= 254) { + /* Get brightest value */ + uint8 rgb_max = std::max({ src->r, src->g, src->b }); + + /* Black pixel (8bpp or old 32bpp image), so use default value */ + if (rgb_max == 0) rgb_max = Blitter_32bppBase::DEFAULT_BRIGHTNESS; + + extern Colour _water_palette[10]; + Colour c = AdjustBrightneSSE(_water_palette[src->m - 245], rgb_max); + dst_rgba->r = c.r; + dst_rgba->g = c.g; + dst_rgba->b = c.b; + dst_mv->v = Blitter_32bppBase::DEFAULT_BRIGHTNESS; + } else if (src->m != 0) { /* Do some accounting for flags. */ has_remap = true; if (src->m >= PALETTE_ANIM_START) has_anim = true; diff --git a/src/gfx.cpp b/src/gfx.cpp index 3c26803a4b..f2ace87078 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1289,8 +1289,16 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, void DoPaletteAnimations(); +Colour _water_palette[10]; + void GfxInitPalettes() { + MemCpyT(_water_palette, (_settings_game.game_creation.landscape == LT_TOYLAND) ? _extra_palette_values.dark_water_toyland : _extra_palette_values.dark_water, 5); + const Colour *s = (_settings_game.game_creation.landscape == LT_TOYLAND) ? _extra_palette_values.glitter_water_toyland : _extra_palette_values.glitter_water; + for (int i = 0; i < 5; i++) { + _water_palette[i + 5] = s[i * 3]; + } + std::lock_guard lock_state(_cur_palette_mutex); memcpy(&_cur_palette, &_palette, sizeof(_cur_palette)); DoPaletteAnimations(); diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 11b3d47288..3eb7227553 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -515,8 +515,8 @@ void GfxLoadSprites() VideoDriver::GetInstance()->ClearSystemSprites(); ClearFontCache(); GfxInitSpriteMem(); - LoadSpriteTables(); GfxInitPalettes(); + LoadSpriteTables(); GfxDetermineMainColours(); UpdateRouteStepSpriteSize(); diff --git a/src/lang/english.txt b/src/lang/english.txt index 122922fd09..887d99adb0 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1621,6 +1621,12 @@ STR_CONFIG_SETTING_DUAL_PANE_TRAIN_PURCHASE_WINDOW_HELPTEXT :When enabled, t STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL :Allow hiding waypoint viewport labels: {STRING2} STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL_HELPTEXT :When enabled, waypoints can have their viewport labels individually hidden.{}This is useful when waypoints are used decoratively or when minor waypoints do not require a label. +STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION :Disable water animation: {STRING2} +STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_HELPTEXT :When enabled, disables water animation when the zoom level is at or more zoomed out than the specified zoom level.{}This can be useful to avoid visual artefacts with animated water at high zoom levels with some basesets. +STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_8X :8x zoom and above +STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_16X :16x zoom and above +STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_32X :32x zoom and above + STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES :Enable signals on bridges/tunnels advanced modes: {STRING2} STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES_HELPTEXT :Enables use of advanced modes of signal simulation on bridges and tunnels. When disabled, bridges/tunnels which are not already in an advanced mode cannot be changed to an advanced mode, however other players may choose to enable this setting and use an advanced mode. diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 069a0d7120..15b3edc237 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1934,6 +1934,7 @@ static SettingsContainer &GetSettingsTree() interface->Add(new SettingEntry("gui.station_rating_tooltip_mode")); interface->Add(new SettingEntry("gui.dual_pane_train_purchase_window")); interface->Add(new SettingEntry("gui.allow_hiding_waypoint_labels")); + interface->Add(new SettingEntry("gui.disable_water_animation")); } SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS)); diff --git a/src/settings_type.h b/src/settings_type.h index 13cce7b135..b0f44b1496 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -246,6 +246,7 @@ struct GUISettings : public TimeSettings { uint8 demolish_confirm_mode; ///< Demolition confirmation mode bool dual_pane_train_purchase_window; ///< Dual pane train purchase window bool allow_hiding_waypoint_labels; ///< Allow hiding waypoint viewport labels + uint8 disable_water_animation; ///< Disable water animation depending on zoom level 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. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index e124642049..c26a0526ce 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -131,6 +131,14 @@ static const SettingDescEnumEntry _station_delivery_mode[] = { { 0, STR_NULL } }; +static const SettingDescEnumEntry _disable_water_animation[] = { +{ 255, STR_CONFIG_SETTING_OFF }, +{ 3, STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_8X }, +{ 4, STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_16X }, +{ 5, STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_32X }, +{ 0, STR_NULL } +}; + /* Some settings do not need to be synchronised when playing in multiplayer. * These include for example the GUI settings and will not be saved with the * savegame. @@ -5502,6 +5510,16 @@ str = STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL strhelp = STR_CONFIG_SETTING_ALLOW_HIDE_WAYPOINT_LABEL_HELPTEXT post_cb = [](auto) { MarkWholeScreenDirty(); InvalidateWindowClassesData(WC_WAYPOINT_VIEW, 0); } +[SDTC_ENUM] +var = gui.disable_water_animation +type = SLE_UINT8 +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC +def = 255 +enumlist = _disable_water_animation +str = STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION +strhelp = STR_CONFIG_SETTING_DISABLE_WATER_ANIMATION_HELPTEXT +post_cb = SpriteZoomMinChanged + ; For the dedicated build we'll enable dates in logs by default. [SDTC_BOOL] ifdef = DEDICATED