From 1f1233e0db03db28cf0d89e475c7e9bb5479f70c Mon Sep 17 00:00:00 2001 From: andy5995 Date: Wed, 21 Feb 2018 08:38:19 -0600 Subject: [PATCH] menu_masterserver.cpp:add function to play different sound This adds a function to play a different sound when a server becomes available. The sound hasn't changed, but now the separate function has been added, the sound can be changed very easily. The ticket to create the new sound is at https://github.com/ZetaGlest/zetaglest-data/issues/44 Can be customized by adding the variable to $HOME/.zetaglest/glestuser.ini closes #63 --- mk/linux/glest.ini | 1 + mk/macos/glest.ini | 1 + mk/windows/glest.ini | 1 + source/glest_game/global/core_data.cpp | 26 ++++++++++++++++ source/glest_game/global/core_data.h | 2 ++ .../menu/menu_state_connected_game.h | 28 ++++++++++++----- .../menu/menu_state_custom_game.cpp | 1 + .../glest_game/menu/menu_state_custom_game.h | 28 ++++++++++++----- .../menu/menu_state_masterserver.cpp | 30 +++++++++++++------ .../glest_game/menu/menu_state_masterserver.h | 28 ++++++++++++----- 10 files changed, 113 insertions(+), 33 deletions(-) diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index b3e745941..ebe86d0f0 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -98,3 +98,4 @@ Windowed=false ; sfx PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav +PlaySoundNewServer=../../../zetaglest-data/data/core/menu/sound/attention.wav diff --git a/mk/macos/glest.ini b/mk/macos/glest.ini index 6ba0e6cbe..7ea7e5e77 100644 --- a/mk/macos/glest.ini +++ b/mk/macos/glest.ini @@ -96,3 +96,4 @@ Windowed=true ; sfx PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav +PlaySoundNewServer=../../../zetaglest-data/data/core/menu/sound/attention.wav diff --git a/mk/windows/glest.ini b/mk/windows/glest.ini index 9329ab7f6..f97857603 100644 --- a/mk/windows/glest.ini +++ b/mk/windows/glest.ini @@ -98,3 +98,4 @@ Windowed=false ; sfx PlaySoundAttention=..\..\..\zetaglest-data\data\core\menu\sound\attention.wav PlaySoundHighlight=..\..\..\zetaglest-data\data\core\menu\sound\highlight.wav +PlaySoundNewServer=..\..\..\zetaglest-data\data\core\menu\sound\attention.wav diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index 6a050f8a8..9e21538b6 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -746,6 +746,32 @@ namespace Glest return &attentionSound; } + + StaticSound *CoreData::getNewServerSound () + { + int loadAttemptLookupKey = tsyst_COUNT + 6; + if (itemLoadAttempted.find (loadAttemptLookupKey) == + itemLoadAttempted.end ()) + { + + itemLoadAttempted[loadAttemptLookupKey] = true; + + try + { + static Config & config = Config::getInstance (); + newServerSound.load (config.getString ("PlaySoundNewServer", "")); + } + catch (const megaglest_runtime_error & ex) + { + message (ex.what (), + GlobalStaticFlags::getIsNonGraphicalModeEnabled (), + tempDataLocation); + } + } + + return &newServerSound; + } + StaticSound *CoreData::getHighlightSound () { int loadAttemptLookupKey = tsyst_COUNT + 7; diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index 987c70f47..d96ce880b 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -67,6 +67,7 @@ namespace Glest StaticSound clickSoundB; StaticSound clickSoundC; StaticSound attentionSound; + StaticSound newServerSound; StaticSound highlightSound; StaticSound markerSound; SoundContainer waterSounds; @@ -212,6 +213,7 @@ namespace Glest StaticSound *getClickSoundB (); StaticSound *getClickSoundC (); StaticSound *getAttentionSound (); + StaticSound *getNewServerSound (); StaticSound *getHighlightSound (); StaticSound *getMarkerSound (); StaticSound *getWaterSound (); diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index cc297e994..6de8b4d26 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -1,13 +1,25 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// menu_state_connected_game.cpp: game setup menu as it appears to +// to the host // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published -// by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version -// ============================================================== +// This file is part of ZetaGlest +// +// Copyright (C) 2018 The ZetaGlest team +// +// ZetaGlest is a fork of MegaGlest +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see #ifndef _GLEST_GAME_MENUSTATECONNECTEDGAME_H_ # define _GLEST_GAME_MENUSTATECONNECTEDGAME_H_ diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 3fd7008e3..981ce9744 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -20,6 +20,7 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see + #include "menu_state_custom_game.h" #include "renderer.h" diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index 3f44c64ed..b43e69af5 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -1,13 +1,25 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// menu_state_custom_game.h: game setup menu as it appears to +// to the host // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published -// by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version -// ============================================================== +// This file is part of ZetaGlest +// +// Copyright (C) 2018 The ZetaGlest team +// +// ZetaGlest is a fork of MegaGlest +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see #ifndef _GLEST_GAME_MENUSTATECUSTOMGAME_H_ # define _GLEST_GAME_MENUSTATECUSTOMGAME_H_ diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index d88d81dd2..fc4583c5f 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -1,13 +1,25 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) // -// Copyright (C) 2010- by Titus Tscharntke +// menu_state_masterserver.cpp: game setup menu as it appears to +// to the host // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published -// by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version -// ============================================================== +// This file is part of ZetaGlest +// +// Copyright (C) 2018 The ZetaGlest team +// +// ZetaGlest is a fork of MegaGlest +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see #include "menu_state_masterserver.h" @@ -1205,7 +1217,7 @@ namespace Glest if (playServerFoundSound) { SoundRenderer::getInstance ().playFx (CoreData::getInstance (). - getAttentionSound ()); + getNewServerSound ()); //switch on music again!! Config & config = Config::getInstance (); float configVolume = (config.getInt ("SoundVolumeMusic") / 100.f); diff --git a/source/glest_game/menu/menu_state_masterserver.h b/source/glest_game/menu/menu_state_masterserver.h index 47a48043d..3820a0d52 100644 --- a/source/glest_game/menu/menu_state_masterserver.h +++ b/source/glest_game/menu/menu_state_masterserver.h @@ -1,13 +1,25 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// menu_state_masterserver.h: game setup menu as it appears to +// to the host // -// You can redistribute this code and/or modify it under -// the terms of the GNU General Public License as published -// by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version -// ============================================================== +// This file is part of ZetaGlest +// +// Copyright (C) 2018 The ZetaGlest team +// +// ZetaGlest is a fork of MegaGlest +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see #ifndef _GLEST_GAME_MENUSTATEMASTERSERVER_H_ # define _GLEST_GAME_MENUSTATEMASTERSERVER_H_