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
This commit is contained in:
andy5995
2018-02-21 08:38:19 -06:00
parent dbe6697f16
commit 1f1233e0db
10 changed files with 113 additions and 33 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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 ();

View File

@@ -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 <https://github.com/ZetaGlest>
//
// Copyright (C) 2018 The ZetaGlest team
//
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
//
// 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 <https://www.gnu.org/licenses/>
#ifndef _GLEST_GAME_MENUSTATECONNECTEDGAME_H_
# define _GLEST_GAME_MENUSTATECONNECTEDGAME_H_

View File

@@ -20,6 +20,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
#include "menu_state_custom_game.h"
#include "renderer.h"

View File

@@ -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 <https://github.com/ZetaGlest>
//
// Copyright (C) 2018 The ZetaGlest team
//
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
//
// 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 <https://www.gnu.org/licenses/>
#ifndef _GLEST_GAME_MENUSTATECUSTOMGAME_H_
# define _GLEST_GAME_MENUSTATECUSTOMGAME_H_

View File

@@ -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 <https://github.com/ZetaGlest>
//
// Copyright (C) 2018 The ZetaGlest team
//
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
//
// 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 <https://www.gnu.org/licenses/>
#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);

View File

@@ -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 <https://github.com/ZetaGlest>
//
// Copyright (C) 2018 The ZetaGlest team
//
// ZetaGlest is a fork of MegaGlest <https://megaglest.org>
//
// 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 <https://www.gnu.org/licenses/>
#ifndef _GLEST_GAME_MENUSTATEMASTERSERVER_H_
# define _GLEST_GAME_MENUSTATEMASTERSERVER_H_