2013-04-21 19:04:36 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#include "menu_state_options_sound.h"
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "sound_renderer.h"
|
|
|
|
#include "core_data.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "menu_state_root.h"
|
|
|
|
#include "menu_state_options.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "menu_state_keysetup.h"
|
|
|
|
#include "menu_state_options_graphics.h"
|
|
|
|
#include "menu_state_options_network.h"
|
|
|
|
#include "menu_state_options_sound.h"
|
|
|
|
#include "string_utils.h"
|
|
|
|
#include "metrics.h"
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
using namespace Shared::Util;
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class MenuStateOptions
|
|
|
|
// =====================================================
|
|
|
|
MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMenu, ProgramState **parentUI):
|
|
|
|
MenuState(program, mainMenu, "config")
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
containerName = "Options";
|
|
|
|
this->parentUI=parentUI;
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
Config &config= Config::getInstance();
|
|
|
|
this->console.setOnlyChatMessagesInStoredLines(false);
|
|
|
|
|
2015-02-06 01:29:13 +01:00
|
|
|
int leftLabelStart=100;
|
|
|
|
int leftColumnStart=leftLabelStart+300;
|
2013-05-17 07:21:14 +02:00
|
|
|
//int rightLabelStart=450;
|
2013-05-17 07:01:23 +02:00
|
|
|
//int rightColumnStart=rightLabelStart+280;
|
2013-04-21 19:04:36 +02:00
|
|
|
int buttonRowPos=50;
|
|
|
|
int buttonStartPos=170;
|
2013-05-17 05:59:34 +02:00
|
|
|
//int captionOffset=75;
|
2013-05-26 08:03:32 +02:00
|
|
|
//int currentLabelStart=leftLabelStart;
|
|
|
|
//int currentColumnStart=leftColumnStart;
|
|
|
|
//int currentLine=700;
|
2013-05-03 00:35:54 +02:00
|
|
|
int lineOffset=30;
|
2013-04-21 19:04:36 +02:00
|
|
|
int tabButtonWidth=200;
|
|
|
|
int tabButtonHeight=30;
|
|
|
|
|
|
|
|
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
2013-10-29 07:13:38 +01:00
|
|
|
mainMessageBox.init(lang.getString("Ok"));
|
2013-04-21 19:04:36 +02:00
|
|
|
mainMessageBox.setEnabled(false);
|
|
|
|
mainMessageBoxState=0;
|
|
|
|
|
|
|
|
buttonAudioSection.registerGraphicComponent(containerName,"buttonAudioSection");
|
|
|
|
buttonAudioSection.init(0, 700,tabButtonWidth,tabButtonHeight+20);
|
|
|
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonAudioSection.setText(lang.getString("Audio"));
|
2013-04-21 19:04:36 +02:00
|
|
|
// Video Section
|
|
|
|
buttonVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
|
|
|
buttonVideoSection.init(200, 720,tabButtonWidth,tabButtonHeight);
|
|
|
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonVideoSection.setText(lang.getString("Video"));
|
2013-04-21 19:04:36 +02:00
|
|
|
//currentLine-=lineOffset;
|
|
|
|
//MiscSection
|
|
|
|
buttonMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
|
|
|
buttonMiscSection.init(400, 720,tabButtonWidth,tabButtonHeight);
|
|
|
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonMiscSection.setText(lang.getString("Misc"));
|
2013-04-21 19:04:36 +02:00
|
|
|
//NetworkSettings
|
|
|
|
buttonNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
|
|
|
|
buttonNetworkSettings.init(600, 720,tabButtonWidth,tabButtonHeight);
|
|
|
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonNetworkSettings.setText(lang.getString("Network"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
//KeyboardSetup
|
|
|
|
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
|
|
|
|
buttonKeyboardSetup.init(800, 720,tabButtonWidth,tabButtonHeight);
|
|
|
|
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonKeyboardSetup.setText(lang.getString("Keyboardsetup"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
2013-05-26 08:03:32 +02:00
|
|
|
int currentLine=650; // reset line pos
|
|
|
|
int currentLabelStart=leftLabelStart; // set to right side
|
|
|
|
int currentColumnStart=leftColumnStart; // set to right side
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
//soundboxes
|
|
|
|
labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory");
|
|
|
|
labelSoundFactory.init(currentLabelStart, currentLine);
|
2015-02-06 01:29:13 +01:00
|
|
|
labelSoundFactory.setText(lang.getString("SoundAndMusic2"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory");
|
2015-02-06 01:29:13 +01:00
|
|
|
listBoxSoundFactory.init(currentColumnStart, currentLine, 175);
|
|
|
|
listBoxSoundFactory.pushBackItem(lang.getString("None"));
|
2013-04-21 19:04:36 +02:00
|
|
|
listBoxSoundFactory.pushBackItem("OpenAL");
|
|
|
|
|
|
|
|
listBoxSoundFactory.setSelectedItem(config.getString("FactorySound"));
|
|
|
|
currentLine-=lineOffset;
|
|
|
|
|
|
|
|
labelVolumeFx.registerGraphicComponent(containerName,"labelVolumeFx");
|
|
|
|
labelVolumeFx.init(currentLabelStart, currentLine);
|
2013-10-29 07:13:38 +01:00
|
|
|
labelVolumeFx.setText(lang.getString("FxVolume"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx");
|
|
|
|
listBoxVolumeFx.init(currentColumnStart, currentLine, 80);
|
|
|
|
currentLine-=lineOffset;
|
|
|
|
|
|
|
|
labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient");
|
|
|
|
labelVolumeAmbient.init(currentLabelStart, currentLine);
|
|
|
|
|
|
|
|
listBoxVolumeAmbient.registerGraphicComponent(containerName,"listBoxVolumeAmbient");
|
|
|
|
listBoxVolumeAmbient.init(currentColumnStart, currentLine, 80);
|
2013-10-29 07:13:38 +01:00
|
|
|
labelVolumeAmbient.setText(lang.getString("AmbientVolume"));
|
2013-04-21 19:04:36 +02:00
|
|
|
currentLine-=lineOffset;
|
|
|
|
|
|
|
|
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
|
|
|
|
labelVolumeMusic.init(currentLabelStart, currentLine);
|
|
|
|
|
|
|
|
listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic");
|
|
|
|
listBoxVolumeMusic.init(currentColumnStart, currentLine, 80);
|
2013-10-29 07:13:38 +01:00
|
|
|
labelVolumeMusic.setText(lang.getString("MusicVolume"));
|
2013-05-17 07:21:14 +02:00
|
|
|
//currentLine-=lineOffset;
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
for(int i=0; i<=100; i+=5){
|
|
|
|
listBoxVolumeFx.pushBackItem(intToStr(i));
|
|
|
|
listBoxVolumeAmbient.pushBackItem(intToStr(i));
|
|
|
|
listBoxVolumeMusic.pushBackItem(intToStr(i));
|
|
|
|
}
|
|
|
|
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
|
|
|
|
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
|
|
|
|
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
|
|
|
|
|
2013-05-17 06:06:39 +02:00
|
|
|
//currentLine-=lineOffset/2;
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
///////// RIGHT SIDE
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-05-17 05:59:34 +02:00
|
|
|
//currentLine=700; // reset line pos
|
|
|
|
//currentLabelStart=rightLabelStart; // set to right side
|
|
|
|
//currentColumnStart=rightColumnStart; // set to right side
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
|
|
|
buttonOk.init(buttonStartPos, buttonRowPos, 100);
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonOk.setText(lang.getString("Save"));
|
|
|
|
buttonReturn.setText(lang.getString("Return"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
buttonReturn.registerGraphicComponent(containerName,"buttonAbort");
|
|
|
|
buttonReturn.init(buttonStartPos+110, buttonRowPos, 100);
|
|
|
|
|
|
|
|
GraphicComponent::applyAllCustomProperties(containerName);
|
|
|
|
}
|
|
|
|
catch(exception &e) {
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error loading options: %s\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
|
|
|
throw megaglest_runtime_error(string("Error loading options msg: ") + e.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::reloadUI() {
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
|
|
|
|
console.resetFonts();
|
2013-10-29 07:13:38 +01:00
|
|
|
mainMessageBox.init(lang.getString("Ok"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonAudioSection.setText(lang.getString("Audio"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonVideoSection.setText(lang.getString("Video"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonMiscSection.setText(lang.getString("Misc"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
|
|
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonNetworkSettings.setText(lang.getString("Network"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
2015-02-06 01:29:13 +01:00
|
|
|
labelSoundFactory.setText(lang.getString("SoundAndMusic2"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
std::vector<string> listboxData;
|
2015-02-06 01:29:13 +01:00
|
|
|
listboxData.push_back(lang.getString("None"));
|
2013-04-21 19:04:36 +02:00
|
|
|
listboxData.push_back("OpenAL");
|
|
|
|
|
|
|
|
listBoxSoundFactory.setItems(listboxData);
|
|
|
|
|
2013-10-29 07:13:38 +01:00
|
|
|
labelVolumeFx.setText(lang.getString("FxVolume"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
2013-10-29 07:13:38 +01:00
|
|
|
labelVolumeAmbient.setText(lang.getString("AmbientVolume"));
|
|
|
|
labelVolumeMusic.setText(lang.getString("MusicVolume"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
listboxData.clear();
|
|
|
|
|
2013-10-29 07:13:38 +01:00
|
|
|
buttonOk.setText(lang.getString("Save"));
|
|
|
|
buttonReturn.setText(lang.getString("Return"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-25 07:45:54 +02:00
|
|
|
//void MenuStateOptionsSound::showMessageBox(const string &text, const string &header, bool toggle){
|
|
|
|
// if(!toggle){
|
|
|
|
// mainMessageBox.setEnabled(false);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(!mainMessageBox.getEnabled()){
|
|
|
|
// mainMessageBox.setText(text);
|
|
|
|
// mainMessageBox.setHeader(header);
|
|
|
|
// mainMessageBox.setEnabled(true);
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// mainMessageBox.setEnabled(false);
|
|
|
|
// }
|
|
|
|
//}
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::mouseClick(int x, int y, MouseButton mouseButton){
|
|
|
|
|
2013-05-17 05:59:34 +02:00
|
|
|
//Config &config= Config::getInstance();
|
2013-04-21 19:04:36 +02:00
|
|
|
CoreData &coreData= CoreData::getInstance();
|
|
|
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
|
|
|
|
|
|
|
if(mainMessageBox.getEnabled()) {
|
|
|
|
int button= 0;
|
|
|
|
if(mainMessageBox.mouseClick(x, y, button)) {
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
if(button == 0) {
|
|
|
|
if(mainMessageBoxState == 1) {
|
|
|
|
mainMessageBoxState=0;
|
|
|
|
mainMessageBox.setEnabled(false);
|
|
|
|
saveConfig();
|
|
|
|
|
|
|
|
Lang &lang= Lang::getInstance();
|
2013-10-29 07:13:38 +01:00
|
|
|
mainMessageBox.init(lang.getString("Ok"));
|
2013-04-21 19:04:36 +02:00
|
|
|
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mainMessageBox.setEnabled(false);
|
|
|
|
|
|
|
|
Lang &lang= Lang::getInstance();
|
2013-10-29 07:13:38 +01:00
|
|
|
mainMessageBox.init(lang.getString("Ok"));
|
2013-04-21 19:04:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(mainMessageBoxState == 1) {
|
|
|
|
mainMessageBoxState=0;
|
|
|
|
mainMessageBox.setEnabled(false);
|
|
|
|
|
|
|
|
Lang &lang= Lang::getInstance();
|
2013-10-29 07:13:38 +01:00
|
|
|
mainMessageBox.init(lang.getString("Ok"));
|
2013-04-21 19:04:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
this->mainMenu->init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(buttonOk.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
saveConfig();
|
|
|
|
//mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonReturn.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
if(this->parentUI != NULL) {
|
|
|
|
*this->parentUI = NULL;
|
|
|
|
delete *this->parentUI;
|
|
|
|
}
|
|
|
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonKeyboardSetup.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
//mainMenu->setState(new MenuStateKeysetup(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
//mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
//mainMenu->setState(new MenuStateOptionsNetwork(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
mainMenu->setState(new MenuStateKeysetup(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
//showMessageBox("Not implemented yet", "Keyboard setup", false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonAudioSection.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
//mainMenu->setState(new MenuStateOptionsSound(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonNetworkSettings.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
mainMenu->setState(new MenuStateOptionsNetwork(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonMiscSection.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
mainMenu->setState(new MenuStateOptions(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(buttonVideoSection.mouseClick(x, y)){
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundA());
|
|
|
|
mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu)); // open keyboard shortcuts setup screen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listBoxSoundFactory.mouseClick(x, y);
|
|
|
|
listBoxVolumeFx.mouseClick(x, y);
|
|
|
|
listBoxVolumeAmbient.mouseClick(x, y);
|
|
|
|
listBoxVolumeMusic.mouseClick(x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::mouseMove(int x, int y, const MouseState *ms){
|
|
|
|
if (mainMessageBox.getEnabled()) {
|
|
|
|
mainMessageBox.mouseMove(x, y);
|
|
|
|
}
|
|
|
|
buttonOk.mouseMove(x, y);
|
|
|
|
buttonReturn.mouseMove(x, y);
|
|
|
|
buttonKeyboardSetup.mouseMove(x, y);
|
|
|
|
buttonAudioSection.mouseMove(x, y);
|
|
|
|
buttonNetworkSettings.mouseMove(x, y);
|
|
|
|
buttonMiscSection.mouseMove(x, y);
|
|
|
|
buttonVideoSection.mouseMove(x, y);
|
|
|
|
|
|
|
|
listBoxSoundFactory.mouseMove(x, y);
|
|
|
|
listBoxVolumeFx.mouseMove(x, y);
|
|
|
|
listBoxVolumeAmbient.mouseMove(x, y);
|
|
|
|
listBoxVolumeMusic.mouseMove(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
//bool MenuStateOptionsSound::isInSpecialKeyCaptureEvent() {
|
|
|
|
// return (activeInputLabel != NULL);
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void MenuStateOptionsSound::keyDown(SDL_KeyboardEvent key) {
|
|
|
|
// if(activeInputLabel != NULL) {
|
|
|
|
// keyDownEditLabel(key, &activeInputLabel);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::keyPress(SDL_KeyboardEvent c) {
|
|
|
|
// if(activeInputLabel != NULL) {
|
|
|
|
// //printf("[%d]\n",c); fflush(stdout);
|
|
|
|
// if( &labelPlayerName == activeInputLabel ||
|
|
|
|
// &labelTransifexUser == activeInputLabel ||
|
|
|
|
// &labelTransifexPwd == activeInputLabel ||
|
|
|
|
// &labelTransifexI18N == activeInputLabel) {
|
|
|
|
// keyPressEditLabel(c, &activeInputLabel);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
|
|
|
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),c) == true) {
|
|
|
|
GraphicComponent::saveAllCustomProperties(containerName);
|
|
|
|
//Lang &lang= Lang::getInstance();
|
2013-10-29 07:13:38 +01:00
|
|
|
//console.addLine(lang.getString("GUILayoutSaved") + " [" + (saved ? lang.getString("Yes") : lang.getString("No"))+ "]");
|
2013-04-21 19:04:36 +02:00
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::render(){
|
|
|
|
Renderer &renderer= Renderer::getInstance();
|
|
|
|
|
|
|
|
if(mainMessageBox.getEnabled()){
|
|
|
|
renderer.renderMessageBox(&mainMessageBox);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderer.renderButton(&buttonOk);
|
|
|
|
renderer.renderButton(&buttonReturn);
|
|
|
|
renderer.renderButton(&buttonKeyboardSetup);
|
|
|
|
renderer.renderButton(&buttonVideoSection);
|
|
|
|
renderer.renderButton(&buttonAudioSection);
|
|
|
|
renderer.renderButton(&buttonMiscSection);
|
|
|
|
renderer.renderButton(&buttonNetworkSettings);
|
|
|
|
renderer.renderListBox(&listBoxSoundFactory);
|
|
|
|
renderer.renderLabel(&labelSoundFactory);
|
|
|
|
|
|
|
|
|
|
|
|
renderer.renderListBox(&listBoxVolumeFx);
|
|
|
|
renderer.renderLabel(&labelVolumeFx);
|
|
|
|
renderer.renderListBox(&listBoxVolumeAmbient);
|
|
|
|
renderer.renderLabel(&labelVolumeAmbient);
|
|
|
|
renderer.renderListBox(&listBoxVolumeMusic);
|
|
|
|
renderer.renderLabel(&labelVolumeMusic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-10-31 01:08:12 +01:00
|
|
|
renderer.renderConsole(&console);
|
2013-04-21 19:04:36 +02:00
|
|
|
if(program != NULL) program->renderProgramMsgBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::saveConfig(){
|
|
|
|
Config &config= Config::getInstance();
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
setActiveInputLable(NULL);
|
|
|
|
|
|
|
|
config.setString("FactorySound", listBoxSoundFactory.getSelectedItem());
|
|
|
|
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
|
|
|
config.setString("SoundVolumeAmbient", listBoxVolumeAmbient.getSelectedItem());
|
|
|
|
CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f);
|
|
|
|
config.setString("SoundVolumeMusic", listBoxVolumeMusic.getSelectedItem());
|
|
|
|
|
|
|
|
config.save();
|
|
|
|
|
|
|
|
if(config.getBool("DisableLuaSandbox","false") == true) {
|
|
|
|
LuaScript::setDisableSandbox(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
|
|
|
soundRenderer.stopAllSounds();
|
|
|
|
program->stopSoundSystem();
|
|
|
|
soundRenderer.init(program->getWindow());
|
|
|
|
soundRenderer.loadConfig();
|
|
|
|
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
|
|
|
program->startSoundSystem();
|
|
|
|
|
|
|
|
if(CoreData::getInstance().hasMainMenuVideoFilename() == false) {
|
|
|
|
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
|
|
|
}
|
|
|
|
|
|
|
|
Renderer::getInstance().loadConfig();
|
2013-10-29 07:13:38 +01:00
|
|
|
console.addLine(lang.getString("SettingsSaved"));
|
2013-04-21 19:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuStateOptionsSound::setActiveInputLable(GraphicLabel *newLable) {
|
|
|
|
}
|
|
|
|
|
|
|
|
}}//end namespace
|