diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index a154d1260d..36110654aa 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1171,7 +1171,7 @@ static void CrashAirplane(Aircraft *v) AddVehicleNewsItem(newsitem, NT_ACCIDENT, v->index, st != NULL ? st->index : INVALID_STATION); ModifyStationRatingAround(v->tile, v->owner, -160, 30); - SndPlayVehicleFx(SND_12_EXPLOSION, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); } /** diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 7b55c09d9f..8d97add910 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -43,7 +43,7 @@ void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 { if (result.Failed()) return; - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } @@ -450,7 +450,7 @@ public: this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); this->SetDirty(); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->UpdateSelectSize(); break; diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 88473b71c8..e5480dc371 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -59,7 +59,7 @@ typedef GUIList GUIBridgeList; ///< List of bridges, used in #B void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2) { if (result.Failed()) return; - SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, end_tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, end_tile); TransportType transport_type = Extract(p2); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index e5c62ea2f2..0abd8c6fbf 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -725,9 +725,9 @@ void CompaniesYearlyLoop() ShowCompanyFinances(_local_company); c = Company::Get(_local_company); if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) { - SndPlayFx(SND_01_BAD_YEAR); + if (_settings_client.sound.new_year) SndPlayFx(SND_01_BAD_YEAR); } else { - SndPlayFx(SND_00_GOOD_YEAR); + if (_settings_client.sound.new_year) SndPlayFx(SND_00_GOOD_YEAR); } } } diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 916a9b4c9c..12224eb137 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -253,7 +253,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) if (++v->age == 1) { CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE); - SndPlayVehicleFx(SND_12_EXPLOSION, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); v->image_override = SPR_BLIMP_CRASHING; } else if (v->age == 70) { v->image_override = SPR_BLIMP_CRASHED; @@ -361,7 +361,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v) /* Destroy? */ if (v->age > 50) { CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE); - SndPlayVehicleFx(SND_12_EXPLOSION, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); delete v; return false; } @@ -431,7 +431,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo SetDParam(0, i->town->index); AddIndustryNewsItem(news_message, NT_ACCIDENT, i->index); // delete the news, when the industry closes - SndPlayTileFx(SND_12_EXPLOSION, i->location.tile); + if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile); } } else if (v->current_order.GetDestination() == 0) { int x = v->x_pos + ((leave_at_top ? -15 : 15) * TILE_SIZE); @@ -596,7 +596,7 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v) v->current_order.SetDestination(1); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); - SndPlayVehicleFx(SND_12_EXPLOSION, u); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, u); delete u; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index e7b864618e..4779feb72e 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -40,13 +40,13 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p { if (result.Failed()) return; - SndPlayTileFx(SND_02_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (result.Succeeded()) SndPlayTileFx(SND_02_SPLAT, tile); + if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile); } @@ -436,7 +436,7 @@ public: this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } @@ -514,7 +514,7 @@ public: this->RaiseWidget(_ship_depot_direction + WID_BDD_X); _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y); this->LowerWidget(_ship_depot_direction + WID_BDD_X); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); UpdateDocksDirection(); this->SetDirty(); break; diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index 033d0bd2f4..861b728a6c 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -498,7 +498,7 @@ static bool BubbleTick(EffectVehicle *v) if (b->y == 4 && b->x == 1) { if (v->z_pos > 180 || Chance16I(1, 96, Random())) { v->spritenum = 5; - SndPlayVehicleFx(SND_2F_POP, v); + if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_2F_POP, v); } anim_state = 0; } @@ -507,7 +507,7 @@ static bool BubbleTick(EffectVehicle *v) TileIndex tile; anim_state++; - SndPlayVehicleFx(SND_31_EXTRACT, v); + if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_31_EXTRACT, v); tile = TileVirtXY(v->x_pos, v->y_pos); if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 1666a48034..85647bdb73 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -263,7 +263,7 @@ static void StartGeneratingLandscape(GenenerateLandscapeWindowMode mode) MakeNewgameSettingsLive(); ResetGRFConfig(true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); switch (mode) { case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break; case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index ab10c7de86..1ca511f01f 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -540,9 +540,11 @@ static void AnimateTile_Industry(TileIndex tile) if ((_tick_counter & 1) == 0) { byte m = GetAnimationFrame(tile) + 1; - switch (m & 7) { - case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break; - case 6: SndPlayTileFx(SND_29_RIP, tile); break; + if (_settings_client.sound.ambient) { + switch (m & 7) { + case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break; + case 6: SndPlayTileFx(SND_29_RIP, tile); break; + } } if (m >= 96) { @@ -559,7 +561,7 @@ static void AnimateTile_Industry(TileIndex tile) if ((_tick_counter & 3) == 0) { byte m = GetAnimationFrame(tile); - if (_industry_anim_offs_toffee[m] == 0xFF) { + if (_industry_anim_offs_toffee[m] == 0xFF && _settings_client.sound.ambient) { SndPlayTileFx(SND_30_CARTOON_SOUND, tile); } @@ -606,9 +608,9 @@ static void AnimateTile_Industry(TileIndex tile) byte m = GetAnimationFrame(tile) + 1; switch (m) { - case 1: SndPlayTileFx(SND_2C_MACHINERY, tile); break; - case 23: SndPlayTileFx(SND_2B_COMEDY_HIT, tile); break; - case 28: SndPlayTileFx(SND_2A_EXTRACT_AND_POP, tile); break; + case 1: if (_settings_client.sound.ambient) SndPlayTileFx(SND_2C_MACHINERY, tile); break; + case 23: if (_settings_client.sound.ambient) SndPlayTileFx(SND_2B_COMEDY_HIT, tile); break; + case 28: if (_settings_client.sound.ambient) SndPlayTileFx(SND_2A_EXTRACT_AND_POP, tile); break; default: if (m >= 50) { int n = GetIndustryAnimationLoop(tile) + 1; @@ -671,7 +673,7 @@ static void AnimateTile_Industry(TileIndex tile) byte m = GetAnimationFrame(tile); if (!(m & 0x40)) { SetAnimationFrame(tile, m | 0x40); - SndPlayTileFx(SND_0B_MINING_MACHINERY, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_0B_MINING_MACHINERY, tile); } if (state & 7) return; } else { @@ -772,7 +774,7 @@ static void TileLoopIndustry_BubbleGenerator(TileIndex tile) { 49, 59, 60, 65 }, }; - SndPlayTileFx(SND_2E_EXTRACT_AND_POP, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_2E_EXTRACT_AND_POP, tile); int dir = Random() & 3; @@ -860,7 +862,7 @@ static void TileLoop_Industry(TileIndex tile) case GFX_POWERPLANT_SPARKS: if (Chance16(1, 3)) { - SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile); AddAnimatedTile(tile); } break; @@ -1061,7 +1063,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *user_data) _industry_sound_ctr = 1; _industry_sound_tile = tile; - SndPlayTileFx(SND_38_CHAINSAW, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_38_CHAINSAW, tile); DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); @@ -1098,7 +1100,7 @@ static void ProduceIndustryGoods(Industry *i) if ((i->counter & 0x3F) == 0) { uint32 r; uint num; - if (Chance16R(1, 14, r) && (num = indsp->number_of_sounds) != 0) { + if (Chance16R(1, 14, r) && (num = indsp->number_of_sounds) != 0 && _settings_client.sound.ambient) { SndPlayTileFx( (SoundFx)(indsp->random_sounds[((r >> 16) * num) >> 16]), i->location.tile); @@ -1157,10 +1159,10 @@ void OnTick_Industry() _industry_sound_ctr++; if (_industry_sound_ctr == 75) { - SndPlayTileFx(SND_37_BALLOON_SQUEAK, _industry_sound_tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_37_BALLOON_SQUEAK, _industry_sound_tile); } else if (_industry_sound_ctr == 160) { _industry_sound_ctr = 0; - SndPlayTileFx(SND_36_CARTOON_CRASH, _industry_sound_tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_36_CARTOON_CRASH, _industry_sound_tile); } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 308d99250a..2d9c3771f1 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2557,7 +2557,7 @@ struct IndustryCargoesWindow : public Window { case WID_IC_NOTIFY: this->ToggleWidgetLoweredState(WID_IC_NOTIFY); this->SetWidgetDirty(WID_IC_NOTIFY); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); if (this->IsWidgetLowered(WID_IC_NOTIFY)) { if (FindWindowByClass(WC_SMALLMAP) == NULL) ShowSmallMap(); diff --git a/src/lang/english.txt b/src/lang/english.txt index 6068126593..7c4d0f3149 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1351,6 +1351,20 @@ STR_CONFIG_SETTING_EXPENSES_LAYOUT_HELPTEXT :Define the layo STR_CONFIG_SETTING_SOUND_TICKER :News ticker: {STRING2} STR_CONFIG_SETTING_SOUND_TICKER_HELPTEXT :Play sound for summarised news messages +STR_CONFIG_SETTING_SOUND_NEWS :Newspaper: {STRING2} +STR_CONFIG_SETTING_SOUND_NEWS_HELPTEXT :Play sound upon display of newspapers +STR_CONFIG_SETTING_SOUND_NEW_YEAR :End of year: {STRING2} +STR_CONFIG_SETTING_SOUND_NEW_YEAR_HELPTEXT :Play sound effect at the end of a year summarising the company's performance during the year compared to the previous year +STR_CONFIG_SETTING_SOUND_CONFIRM :Construction: {STRING2} +STR_CONFIG_SETTING_SOUND_CONFIRM_HELPTEXT :Play sound effect on successful constructions or other actions +STR_CONFIG_SETTING_SOUND_CLICK :Button clicks: {STRING2} +STR_CONFIG_SETTING_SOUND_CLICK_HELPTEXT :Beep when clicking buttons +STR_CONFIG_SETTING_SOUND_DISASTER :Disasters/accidents: {STRING2} +STR_CONFIG_SETTING_SOUND_DISASTER_HELPTEXT :Play sound effects of accidents and disasters +STR_CONFIG_SETTING_SOUND_VEHICLE :Vehicles: {STRING2} +STR_CONFIG_SETTING_SOUND_VEHICLE_HELPTEXT :Play sound effects of vehicles +STR_CONFIG_SETTING_SOUND_AMBIENT :Ambient: {STRING2} +STR_CONFIG_SETTING_SOUND_AMBIENT_HELPTEXT :Play ambient sound effects of landscape, industries and towns STR_CONFIG_SETTING_DISABLE_UNSUITABLE_BUILDING :Disable infrastructure building when no suitable vehicles are available: {STRING2} STR_CONFIG_SETTING_DISABLE_UNSUITABLE_BUILDING_HELPTEXT :When enabled, infrastructure is only available if there are also vehicles available, preventing waste of time and money on unusable infrastructure diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 444725ca29..593a896b70 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -101,7 +101,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl { if (w->IsWidgetDisabled(widget)) return false; - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); w->SetDirty(); if (w->IsWidgetLowered(widget)) { @@ -117,7 +117,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl void CcPlaySound10(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (result.Succeeded()) SndPlayTileFx(SND_12_EXPLOSION, tile); + if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); } #ifdef ENABLE_NETWORK diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h index 2eced32247..7b94031fbd 100644 --- a/src/newgrf_animation_base.h +++ b/src/newgrf_animation_base.h @@ -85,7 +85,7 @@ struct AnimationBase { /* If the lower 7 bits of the upper byte of the callback * result are not empty, it is a sound effect. */ - if (GB(callback, 8, 7) != 0) PlayTileSound(spec->grf_prop.grffile, GB(callback, 8, 7), tile); + if (GB(callback, 8, 7) != 0 && _settings_client.sound.ambient) PlayTileSound(spec->grf_prop.grffile, GB(callback, 8, 7), tile); } } @@ -134,6 +134,6 @@ struct AnimationBase { /* If the lower 7 bits of the upper byte of the callback * result are not empty, it is a sound effect. */ - if (GB(callback, 8, 7) != 0) PlayTileSound(spec->grf_prop.grffile, GB(callback, 8, 7), tile); + if (GB(callback, 8, 7) != 0 && _settings_client.sound.ambient) PlayTileSound(spec->grf_prop.grffile, GB(callback, 8, 7), tile); } }; diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index fe9100bba5..75e25c3d40 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -254,7 +254,7 @@ void AmbientSoundEffectCallback(TileIndex tile) /* Only run every 1/200-th time. */ uint32 r; // Save for later - if (!Chance16R(1, 200, r)) return; + if (!Chance16R(1, 200, r) || !_settings_client.sound.ambient) return; /* Prepare resolver object. */ GenericResolverObject object(false, CBID_SOUNDS_AMBIENT_EFFECT); diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp index b82853ac6a..fc345ded8b 100644 --- a/src/newgrf_sound.cpp +++ b/src/newgrf_sound.cpp @@ -18,6 +18,7 @@ #include "sound_func.h" #include "fileio_func.h" #include "debug.h" +#include "settings_type.h" static SmallVector _sounds; @@ -167,6 +168,8 @@ bool LoadNewGRFSound(SoundEntry *sound) */ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event) { + if (!_settings_client.sound.vehicle) return true; + const GRFFile *file = v->GetGRF(); uint16 callback; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 2490fbfd81..e8fafaa4e6 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -531,7 +531,7 @@ private: static void ShowNewspaper(const NewsItem *ni) { SoundFx sound = _news_type_data[ni->type].sound; - if (sound != 0) SndPlayFx(sound); + if (sound != 0 && _settings_client.sound.news_full) SndPlayFx(sound); new NewsWindow(GetNewsWindowLayout(ni->flags), ni); } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 90fe364e2f..7ddfd05108 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -842,7 +842,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3 CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile); if (ret.Failed()) return ret; - if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile); + if ((flags & DC_EXEC) && _settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile); bool had_success = false; CommandCost last_error = CMD_ERROR; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 73d1a2684b..bbbc695fe7 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -85,7 +85,7 @@ static bool IsStationAvailable(const StationSpec *statspec) void CcPlaySound1E(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (result.Succeeded()) SndPlayTileFx(SND_20_SPLAT_2, tile); + if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile); } static void GenericPlaceRail(TileIndex tile, int cmd) @@ -132,7 +132,7 @@ void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 DiagDirection dir = (DiagDirection)p2; - SndPlayTileFx(SND_20_SPLAT_2, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); tile += TileOffsByDiagDir(dir); @@ -170,7 +170,7 @@ void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { if (result.Failed()) return; - SndPlayTileFx(SND_20_SPLAT_2, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile); /* Only close the station builder window if the default station and non persistent building is chosen. */ if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } @@ -271,7 +271,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w) void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { if (result.Succeeded()) { - SndPlayTileFx(SND_20_SPLAT_2, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } else { SetRedErrorSquare(_build_tunnel_endtile); @@ -321,7 +321,7 @@ static void BuildRailClick_Remove(Window *w) { if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return; ToggleRailButton_Remove(w); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); /* handle station builder */ if (w->IsWidgetLowered(WID_RAT_BUILD_STATION)) { @@ -1162,7 +1162,7 @@ public: this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); _railstation.orientation = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X); this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1196,7 +1196,7 @@ public: this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1231,7 +1231,7 @@ public: this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1265,7 +1265,7 @@ public: this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop); this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1277,7 +1277,7 @@ public: this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; @@ -1299,7 +1299,7 @@ public: matrix->SetCount(_railstation.station_count); matrix->SetClicked(_railstation.station_type); } - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1322,7 +1322,7 @@ public: this->CheckSelectedSize(statspec); this->GetWidget(WID_BRAS_MATRIX)->SetClicked(_railstation.station_type); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1653,7 +1653,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { this->RaiseWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); _build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE); this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } @@ -1759,7 +1759,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { _cur_waypoint_type = type; this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index ad7579a196..9f070b7af5 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1517,7 +1517,7 @@ static void TileLoop_Road(TileIndex tile) if (GetFoundationSlope(tile) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile).Succeeded() && Chance16(1, 40)) { StartRoadWorks(tile); - SndPlayTileFx(SND_21_JACKHAMMER, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_21_JACKHAMMER, tile); CreateEffectVehicleAbove( TileX(tile) * TILE_SIZE + 7, TileY(tile) * TILE_SIZE + 7, diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 3b23e9c01d..74b31499b7 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -63,7 +63,7 @@ static DiagDirection _road_station_picker_orientation; void CcPlaySound1D(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { - if (result.Succeeded()) SndPlayTileFx(SND_1F_SPLAT, tile); + if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); } /** @@ -93,7 +93,7 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w) void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2) { if (result.Succeeded()) { - SndPlayTileFx(SND_20_SPLAT_2, start_tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_SPLAT_2, start_tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile)); @@ -174,7 +174,7 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 if (result.Failed()) return; DiagDirection dir = (DiagDirection)GB(p1, 0, 2); - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); ConnectRoadToStructure(tile, dir); } @@ -198,7 +198,7 @@ void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) if (result.Failed()) return; DiagDirection dir = (DiagDirection)GB(p2, 6, 2); - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); TileArea roadstop_area(tile, GB(p1, 0, 8), GB(p1, 8, 8)); TILE_AREA_LOOP(cur_tile, roadstop_area) { @@ -464,7 +464,7 @@ struct BuildRoadToolbarWindow : Window { DeleteWindowById(WC_SELECT_STATION, 0); ToggleRoadButton_Remove(this); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; default: NOT_REACHED(); @@ -869,7 +869,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE); _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE); this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; @@ -998,7 +998,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { this->RaiseWidget(_road_station_picker_orientation + WID_BROS_STATION_NE); _road_station_picker_orientation = (DiagDirection)(widget - WID_BROS_STATION_NE); this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); DeleteWindowById(WC_SELECT_STATION, 0); break; @@ -1008,7 +1008,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); _settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF); this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index fcc3b30ff8..646cb07722 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -548,7 +548,7 @@ static void RoadVehCrash(RoadVehicle *v) ); ModifyStationRatingAround(v->tile, v->owner, -160, 22); - SndPlayVehicleFx(SND_12_EXPLOSION, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); } static bool RoadVehCheckTrainCrash(RoadVehicle *v) diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 7289a581b6..9726b2fff0 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1459,7 +1459,14 @@ static SettingEntry _settings_ui_interaction[] = { static SettingsPage _settings_ui_interaction_page = {_settings_ui_interaction, lengthof(_settings_ui_interaction)}; static SettingEntry _settings_ui_sound[] = { + SettingEntry("sound.click_beep"), + SettingEntry("sound.confirm"), SettingEntry("sound.news_ticker"), + SettingEntry("sound.news_full"), + SettingEntry("sound.new_year"), + SettingEntry("sound.disaster"), + SettingEntry("sound.vehicle"), + SettingEntry("sound.ambient"), }; /** Sound effects sub-page */ static SettingsPage _settings_ui_sound_page = {_settings_ui_sound, lengthof(_settings_ui_sound)}; diff --git a/src/settings_type.h b/src/settings_type.h index 6a20b700df..72cad4c093 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -165,6 +165,13 @@ struct GUISettings { /** Settings related to sound effects. */ struct SoundSettings { bool news_ticker; ///< Play a ticker sound when a news item is published. + bool news_full; ///< Play sound effects associated to certain news types. + bool new_year; ///< Play sound on new year, summarising the performance during the last year. + bool confirm; ///< Play sound effect on succesful constructions or other actions. + bool click_beep; ///< Beep on a random selection of buttons. + bool disaster; ///< Play disaster and accident sounds. + bool vehicle; ///< Play vehicle sound effects. + bool ambient; ///< Play ambient, industry and town sounds. }; /** Settings related to music. */ diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 2bd4422958..528d7bf6a1 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1343,7 +1343,7 @@ public: const NWidgetBase *wid = this->GetWidget(WID_SM_MAP); Point pt = {wid->current_x / 2, wid->current_y / 2}; this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; } @@ -1354,13 +1354,13 @@ public: case WID_SM_VEGETATION: // Show vegetation case WID_SM_OWNERS: // Show land owners this->SwitchMapType((SmallMapType)(widget - WID_SM_CONTOUR)); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_SM_CENTERMAP: // Center the smallmap again this->SmallMapCenterOnCurrentPos(); this->HandleButtonClick(WID_SM_CENTERMAP); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_SM_TOGGLETOWNNAME: // Toggle town names @@ -1368,7 +1368,7 @@ public: this->SetWidgetLoweredState(WID_SM_TOGGLETOWNNAME, this->show_towns); this->SetDirty(); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_SM_LEGEND: // Legend diff --git a/src/table/settings.ini b/src/table/settings.ini index 42be320cc1..d1c1a1eb4a 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -2920,6 +2920,55 @@ def = true str = STR_CONFIG_SETTING_SOUND_TICKER strhelp = STR_CONFIG_SETTING_SOUND_TICKER_HELPTEXT +[SDTC_BOOL] +var = sound.news_full +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_NEWS +strhelp = STR_CONFIG_SETTING_SOUND_NEWS_HELPTEXT + +[SDTC_BOOL] +var = sound.new_year +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_NEW_YEAR +strhelp = STR_CONFIG_SETTING_SOUND_NEW_YEAR_HELPTEXT + +[SDTC_BOOL] +var = sound.confirm +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_CONFIRM +strhelp = STR_CONFIG_SETTING_SOUND_CONFIRM_HELPTEXT + +[SDTC_BOOL] +var = sound.click_beep +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_CLICK +strhelp = STR_CONFIG_SETTING_SOUND_CLICK_HELPTEXT + +[SDTC_BOOL] +var = sound.disaster +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_DISASTER +strhelp = STR_CONFIG_SETTING_SOUND_DISASTER_HELPTEXT + +[SDTC_BOOL] +var = sound.vehicle +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_VEHICLE +strhelp = STR_CONFIG_SETTING_SOUND_VEHICLE_HELPTEXT + +[SDTC_BOOL] +var = sound.ambient +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_SOUND_AMBIENT +strhelp = STR_CONFIG_SETTING_SOUND_AMBIENT_HELPTEXT + [SDTC_VAR] var = music.playlist type = SLE_UINT8 diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 15b6bf8cc1..d3c28ef9e0 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -39,7 +39,7 @@ void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) { if (result.Succeeded()) { - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); } else { extern TileIndex _terraform_err_tile; SetRedErrorSquare(_terraform_err_tile); @@ -87,7 +87,7 @@ static void GenerateRockyArea(TileIndex end, TileIndex start) success = true; } - if (success) SndPlayTileFx(SND_1F_SPLAT, end); + if (success && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, end); } /** @@ -411,7 +411,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode) if (ta.w == 0 || ta.h == 0) return; - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); uint h; if (mode != 0) { @@ -630,7 +630,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { if (!IsInsideMM(size, 1, 8 + 1)) return; _terraform_size = size; - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index ad3b8fff5a..7cb18de3d7 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -167,7 +167,7 @@ static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count list->push_back(new DropDownListStringItem(string + i, i, false)); } ShowDropDownList(w, list, 0, widget, 140, true, true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } /** Enum for the Company Toolbar's network related buttons */ @@ -201,7 +201,7 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0) } ShowDropDownList(w, list, _local_company == COMPANY_SPECTATOR ? CTMN_CLIENT_LIST : (int)_local_company, widget, 240, true, true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } @@ -224,7 +224,9 @@ static CallBackFunction ToolbarPauseClick(Window *w) { if (_networking && !_network_server) return CBF_NONE; // only server can pause the game - if (DoCommandP(0, PM_PAUSED_NORMAL, _pause_mode == PM_UNPAUSED, CMD_PAUSE)) SndPlayFx(SND_15_BEEP); + if (DoCommandP(0, PM_PAUSED_NORMAL, _pause_mode == PM_UNPAUSED, CMD_PAUSE)) { + if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); + } return CBF_NONE; } @@ -237,7 +239,7 @@ static CallBackFunction ToolbarPauseClick(Window *w) static CallBackFunction ToolbarFastForwardClick(Window *w) { _fast_forward ^= true; - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -290,7 +292,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w) list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS))); ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -753,7 +755,7 @@ static CallBackFunction ToolbarZoomInClick(Window *w) { if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; } @@ -764,7 +766,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) { if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) { w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; } @@ -774,7 +776,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) static CallBackFunction ToolbarBuildRailClick(Window *w) { ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true, true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -811,7 +813,7 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w) break; } ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1059,7 +1061,7 @@ static CallBackFunction ToolbarSwitchClick(Window *w) w->ReInit(); w->SetWidgetLoweredState(WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1107,7 +1109,7 @@ static CallBackFunction ToolbarScenDateForward(Window *w) static CallBackFunction ToolbarScenGenLand(Window *w) { w->HandleButtonClick(WID_TE_LAND_GENERATE); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowEditorTerraformToolbar(); return CBF_NONE; @@ -1117,7 +1119,7 @@ static CallBackFunction ToolbarScenGenLand(Window *w) static CallBackFunction ToolbarScenGenTown(Window *w) { w->HandleButtonClick(WID_TE_TOWN_GENERATE); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowFoundTownWindow(); return CBF_NONE; } @@ -1125,7 +1127,7 @@ static CallBackFunction ToolbarScenGenTown(Window *w) static CallBackFunction ToolbarScenGenIndustry(Window *w) { w->HandleButtonClick(WID_TE_INDUSTRY); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildIndustryWindow(); return CBF_NONE; } @@ -1133,7 +1135,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w) static CallBackFunction ToolbarScenBuildRoad(Window *w) { w->HandleButtonClick(WID_TE_ROADS); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildRoadScenToolbar(); return CBF_NONE; } @@ -1141,7 +1143,7 @@ static CallBackFunction ToolbarScenBuildRoad(Window *w) static CallBackFunction ToolbarScenBuildDocks(Window *w) { w->HandleButtonClick(WID_TE_WATER); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildDocksScenToolbar(); return CBF_NONE; } @@ -1149,7 +1151,7 @@ static CallBackFunction ToolbarScenBuildDocks(Window *w) static CallBackFunction ToolbarScenPlantTrees(Window *w) { w->HandleButtonClick(WID_TE_TREES); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildTreesToolbar(); return CBF_NONE; } @@ -1157,7 +1159,7 @@ static CallBackFunction ToolbarScenPlantTrees(Window *w) static CallBackFunction ToolbarScenPlaceSign(Window *w) { w->HandleButtonClick(WID_TE_SIGNS); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return SelectSignTool(); } @@ -1920,7 +1922,7 @@ struct ScenarioEditorToolbarWindow : Window { if (widget == WID_TE_SMALL_MAP) widget = WID_TN_SMALL_MAP; CallBackFunction cbf = _menu_clicked_procs[widget](index); if (cbf != CBF_NONE) this->last_started_action = cbf; - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } virtual EventState OnKeyPress(uint16 key, uint16 keycode) diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 490bca5ed9..9b09025f5a 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -902,7 +902,7 @@ void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 { if (result.Failed()) return; - SndPlayTileFx(SND_1F_SPLAT, tile); + if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 3e72a37a61..2e1b431250 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1660,7 +1660,7 @@ void UpdateLevelCrossing(TileIndex tile, bool sound) if (new_state != IsCrossingBarred(tile)) { if (new_state && sound) { - SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); } SetCrossingBarred(tile, new_state); MarkTileDirtyByTile(tile); @@ -1677,7 +1677,7 @@ static inline void MaybeBarCrossingWithSound(TileIndex tile) { if (!IsCrossingBarred(tile)) { BarCrossing(tile); - SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); + if (_settings_client.sound.ambient) SndPlayTileFx(SND_0E_LEVEL_CROSSING, tile); MarkTileDirtyByTile(tile); } } @@ -3034,7 +3034,7 @@ static bool CheckTrainCollision(Train *v) AddVehicleNewsItem(STR_NEWS_TRAIN_CRASH, NT_ACCIDENT, v->index); ModifyStationRatingAround(v->tile, v->owner, -160, 30); - SndPlayVehicleFx(SND_13_BIG_CRASH, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_BIG_CRASH, v); return true; } @@ -3277,7 +3277,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) /* If we are approaching a crossing that is reserved, play the sound now. */ TileIndex crossing = TrainApproachingCrossingTile(v); - if (crossing != INVALID_TILE && HasCrossingReservation(crossing)) SndPlayTileFx(SND_0E_LEVEL_CROSSING, crossing); + if (crossing != INVALID_TILE && HasCrossingReservation(crossing) && _settings_client.sound.new_year) SndPlayTileFx(SND_0E_LEVEL_CROSSING, crossing); /* Always try to extend the reservation when entering a tile. */ CheckNextTrainTile(v); diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 82e26e8e25..f47bbc5913 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -13,6 +13,7 @@ #include "window_gui.h" #include "transparency.h" #include "sound_func.h" +#include "settings_type.h" #include "widgets/transparency_widget.h" @@ -76,7 +77,7 @@ public: } else { /* toggle the bit of the transparencies variable and play a sound */ ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); MarkWholeScreenDirty(); } } else if (widget == WID_TT_BUTTONS) { @@ -90,7 +91,7 @@ public: if (i == WID_TT_LOADING || i == WID_TT_END) return; ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); /* Redraw whole screen only if transparency is set */ if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 527cc165a5..c30609e782 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -592,7 +592,7 @@ static void TileLoopTreesDesert(TileIndex tile) }; uint32 r = Random(); - if (Chance16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile); + if (Chance16I(1, 200, r) && _settings_client.sound.ambient) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile); break; } @@ -621,7 +621,7 @@ static void TileLoopTreesAlps(TileIndex tile) } else { if (GetTreeDensity(tile) == 3) { uint32 r = Random(); - if (Chance16I(1, 200, r)) { + if (Chance16I(1, 200, r) && _settings_client.sound.ambient) { SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile); } } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 1991559c2b..3a69da1245 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -134,7 +134,7 @@ public: break; case WID_BT_MANY_RANDOM: // place trees randomly over the landscape - SndPlayFx(SND_15_BEEP); + if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); PlaceTreesRandomly(); MarkWholeScreenDirty(); break; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 42afbabcdb..580ffa4d55 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -915,7 +915,7 @@ static void FloodVehicle(Vehicle *v) SetDParam(0, pass); AddVehicleNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NT_ACCIDENT, v->index); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); - SndPlayVehicleFx(SND_12_EXPLOSION, v); + if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); } /**