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
This commit is contained in:
andy5995
2018-02-19 07:33:22 -06:00
parent f974fcf15a
commit a6a02af157
6 changed files with 56 additions and 28 deletions

View File

@@ -94,3 +94,7 @@ UnitParticles=true
UserData_Root=$HOME/.zetaglest/ UserData_Root=$HOME/.zetaglest/
VersionURL=http://zetaglest.dreamhosters.com/files/versions/ VersionURL=http://zetaglest.dreamhosters.com/files/versions/
Windowed=false Windowed=false
; sfx
PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav
PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav

View File

@@ -92,3 +92,7 @@ UnitParticles=true
UserData_Root=$HOME/.zetaglest/ UserData_Root=$HOME/.zetaglest/
VersionURL=http://zetaglest.dreamhosters.com/files/versions/ VersionURL=http://zetaglest.dreamhosters.com/files/versions/
Windowed=true Windowed=true
; sfx
PlaySoundAttention=../../../zetaglest-data/data/core/menu/sound/attention.wav
PlaySoundHighlight=../../../zetaglest-data/data/core/menu/sound/highlight.wav

View File

@@ -1,11 +1,11 @@
; === propertyMap File === ; === propertyMap File ===
; This file defines default properties and values. Do not edit this 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 ; instead, to modify, copy any properties to glestuser.ini, then change these as
; needed. Values contained in glestuser.ini will overwrite values found here. ; needed. Values contained in glestuser.ini will overwrite values found here.
; ;
; For explanation of these properties, please refer to the MegaGlest wiki at ; For explanation of these properties, please refer to the MegaGlest wiki at
; http://wiki.megaglest.org/ ; http://wiki.megaglest.org/
; ;
AiLog=0 AiLog=0
AiRedir=false AiRedir=false
AllowDownloadDataSynch=false AllowDownloadDataSynch=false
@@ -94,3 +94,7 @@ UnitParticles=true
UserData_Root=$APPDATA\zetaglest\ UserData_Root=$APPDATA\zetaglest\
VersionURL=http://zetaglest.dreamhosters.com/files/versions/ VersionURL=http://zetaglest.dreamhosters.com/files/versions/
Windowed=false Windowed=false
; sfx
PlaySoundAttention=..\..\..\zetaglest-data\data\core\menu\sound\attention.wav
PlaySoundHighlight=..\..\..\zetaglest-data\data\core\menu\sound\highlight.wav

View File

@@ -1,13 +1,22 @@
// ============================================================== // core_data.cpp: game setup menu as it appears to
// This file is part of Glest (www.glest.org) // connected clients (not the host or user setting up the game)
// //
// Copyright (C) 2001-2008 Martiño Figueroa // Copyright (C) 2018 The ZetaGlest team <https://github.com/ZetaGlest>
// //
// You can redistribute this code and/or modify it under // ZetaGlest is a fork of MegaGlest <https://megaglest.org>
// the terms of the GNU General Public License as published //
// by the Free Software Foundation; either version 2 of the // This program is free software: you can redistribute it and/or modify
// License, or (at your option) any later version // 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 "core_data.h" #include "core_data.h"
@@ -614,9 +623,8 @@ StaticSound *CoreData::getAttentionSound() {
itemLoadAttempted[loadAttemptLookupKey] = true; itemLoadAttempted[loadAttemptLookupKey] = true;
try { try {
string data_path = getDataPath(); static Config &config = Config::getInstance();
attentionSound.load(getGameCustomCoreDataPath(data_path, attentionSound.load(config.getString ("PlaySoundAttention", ""));
CORE_MENU_SOUND_PATH + "attention.wav"));
} }
catch (const megaglest_runtime_error& ex) { catch (const megaglest_runtime_error& ex) {
message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(), message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
@@ -633,9 +641,8 @@ StaticSound *CoreData::getHighlightSound() {
itemLoadAttempted[loadAttemptLookupKey] = true; itemLoadAttempted[loadAttemptLookupKey] = true;
try { try {
string data_path = getDataPath(); static Config &config = Config::getInstance();
highlightSound.load(getGameCustomCoreDataPath(data_path, highlightSound.load(config.getString ("PlaySoundHighlight", ""));
CORE_MENU_SOUND_PATH + "highlight.wav"));
} }
catch (const megaglest_runtime_error& ex) { catch (const megaglest_runtime_error& ex) {
message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(), message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),

View File

@@ -1,13 +1,22 @@
// ============================================================== // core_data.h: game setup menu as it appears to
// This file is part of Glest (www.glest.org) // connected clients (not the host or user setting up the game)
// //
// Copyright (C) 2001-2008 Martiño Figueroa // Copyright (C) 2018 The ZetaGlest team <https://github.com/ZetaGlest>
// //
// You can redistribute this code and/or modify it under // ZetaGlest is a fork of MegaGlest <https://megaglest.org>
// the terms of the GNU General Public License as published //
// by the Free Software Foundation; either version 2 of the // This program is free software: you can redistribute it and/or modify
// License, or (at your option) any later version // 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_COREDATA_H_ #ifndef _GLEST_GAME_COREDATA_H_
#define _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 /// Data shared among all the ProgramStates
// ===================================================== // =====================================================
@@ -57,7 +66,7 @@ private:
StaticSound highlightSound; StaticSound highlightSound;
StaticSound markerSound; StaticSound markerSound;
SoundContainer waterSounds; SoundContainer waterSounds;
Texture2D *logoTexture; Texture2D *logoTexture;
std::vector<Texture2D *> logoTextureList; std::vector<Texture2D *> logoTextureList;
Texture2D *backgroundTexture; Texture2D *backgroundTexture;

View File

@@ -9,7 +9,7 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the