From a6a02af157604e90cbe96187c4f629901f829431 Mon Sep 17 00:00:00 2001 From: andy5995 Date: Mon, 19 Feb 2018 07:33:22 -0600 Subject: [PATCH] core_data.cpp:allow user-configurable sfx This allows users to set their own sound effects using glestuser.ini Any values from glest.ini can be used in glestuser.ini, and when in glestuser.ini, they override the values in glest.ini. Not yet documented. This adds only 2 sfx, and shows how to do it. This will change how #63 is done --- mk/linux/glest.ini | 4 +++ mk/macos/glest.ini | 4 +++ mk/windows/glest.ini | 10 ++++-- source/glest_game/global/core_data.cpp | 35 +++++++++++-------- source/glest_game/global/core_data.h | 29 +++++++++------ .../menu/menu_state_connected_game.cpp | 2 +- 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index e2db29064..b3e745941 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -94,3 +94,7 @@ UnitParticles=true UserData_Root=$HOME/.zetaglest/ VersionURL=http://zetaglest.dreamhosters.com/files/versions/ Windowed=false + +; sfx +PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav +PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav diff --git a/mk/macos/glest.ini b/mk/macos/glest.ini index 1db432160..6ba0e6cbe 100644 --- a/mk/macos/glest.ini +++ b/mk/macos/glest.ini @@ -92,3 +92,7 @@ UnitParticles=true UserData_Root=$HOME/.zetaglest/ VersionURL=http://zetaglest.dreamhosters.com/files/versions/ Windowed=true + +; sfx +PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav +PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav diff --git a/mk/windows/glest.ini b/mk/windows/glest.ini index 319609787..9329ab7f6 100644 --- a/mk/windows/glest.ini +++ b/mk/windows/glest.ini @@ -1,11 +1,11 @@ -; === propertyMap File === -; This file defines default properties and values. Do not edit this file, +; === propertyMap File === +; This file defines default properties and values. Do not edit this file, ; instead, to modify, copy any properties to glestuser.ini, then change these as ; needed. Values contained in glestuser.ini will overwrite values found here. ; ; For explanation of these properties, please refer to the MegaGlest wiki at ; http://wiki.megaglest.org/ -; +; AiLog=0 AiRedir=false AllowDownloadDataSynch=false @@ -94,3 +94,7 @@ UnitParticles=true UserData_Root=$APPDATA\zetaglest\ VersionURL=http://zetaglest.dreamhosters.com/files/versions/ Windowed=false + +; sfx +PlaySoundAttention=..\..\..\zetaglest-data\data\core\menu\sound\attention.wav +PlaySoundHighlight=..\..\..\zetaglest-data\data\core\menu\sound\highlight.wav diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index 72716e978..9e696585a 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -1,13 +1,22 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) +// core_data.cpp: game setup menu as it appears to +// connected clients (not the host or user setting up the game) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2018 The ZetaGlest team // -// 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 -// ============================================================== +// 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 "core_data.h" @@ -614,9 +623,8 @@ StaticSound *CoreData::getAttentionSound() { itemLoadAttempted[loadAttemptLookupKey] = true; try { - string data_path = getDataPath(); - attentionSound.load(getGameCustomCoreDataPath(data_path, - CORE_MENU_SOUND_PATH + "attention.wav")); + static Config &config = Config::getInstance(); + attentionSound.load(config.getString ("PlaySoundAttention", "")); } catch (const megaglest_runtime_error& ex) { message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(), @@ -633,9 +641,8 @@ StaticSound *CoreData::getHighlightSound() { itemLoadAttempted[loadAttemptLookupKey] = true; try { - string data_path = getDataPath(); - highlightSound.load(getGameCustomCoreDataPath(data_path, - CORE_MENU_SOUND_PATH + "highlight.wav")); + static Config &config = Config::getInstance(); + highlightSound.load(config.getString ("PlaySoundHighlight", "")); } catch (const megaglest_runtime_error& ex) { message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(), diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index 601dff7b9..8baf9d47c 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -1,13 +1,22 @@ -// ============================================================== -// This file is part of Glest (www.glest.org) +// core_data.h: game setup menu as it appears to +// connected clients (not the host or user setting up the game) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2018 The ZetaGlest team // -// 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 -// ============================================================== +// 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_COREDATA_H_ #define _GLEST_GAME_COREDATA_H_ @@ -37,7 +46,7 @@ using ::Shared::Sound::StaticSound; // ===================================================== -// class CoreData +// class CoreData // /// Data shared among all the ProgramStates // ===================================================== @@ -57,7 +66,7 @@ private: StaticSound highlightSound; StaticSound markerSound; SoundContainer waterSounds; - + Texture2D *logoTexture; std::vector logoTextureList; Texture2D *backgroundTexture; diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 40c0f587a..de1a69796 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -9,7 +9,7 @@ // 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