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

View File

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

View File

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

View File

@@ -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 <https://github.com/ZetaGlest>
//
// 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 <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 "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(),

View File

@@ -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 <https://github.com/ZetaGlest>
//
// 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 <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_COREDATA_H_
#define _GLEST_GAME_COREDATA_H_

View File

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