new options menu(s)
This commit is contained in:
parent
883cfbbd27
commit
1884fc5653
|
@ -14,7 +14,7 @@
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "sound_renderer.h"
|
#include "sound_renderer.h"
|
||||||
#include "core_data.h"
|
#include "core_data.h"
|
||||||
#include "menu_state_options.h"
|
#include "menu_state_options_graphics.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
@ -123,7 +123,7 @@ void MenuStateGraphicInfo::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
if(buttonReturn.mouseClick(x,y)){
|
if(buttonReturn.mouseClick(x,y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "menu_state_options.h"
|
#include "menu_state_options.h"
|
||||||
#include "menu_state_root.h"
|
#include "menu_state_root.h"
|
||||||
|
#include "menu_state_keysetup.h"
|
||||||
|
#include "menu_state_options_graphics.h"
|
||||||
|
#include "menu_state_options_sound.h"
|
||||||
|
#include "menu_state_options_network.h"
|
||||||
|
#include "menu_state_options_sound.h"
|
||||||
#include "metrics.h"
|
#include "metrics.h"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
@ -38,26 +43,63 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu,
|
||||||
containerName = "KeySetup";
|
containerName = "KeySetup";
|
||||||
|
|
||||||
this->parentUI = parentUI;
|
this->parentUI = parentUI;
|
||||||
|
this->console.setOnlyChatMessagesInStoredLines(false);
|
||||||
hotkeyIndex = -1;
|
hotkeyIndex = -1;
|
||||||
hotkeyChar = SDLK_UNKNOWN;
|
hotkeyChar = SDLK_UNKNOWN;
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
int buttonRowPos=80;
|
int buttonRowPos=80;
|
||||||
|
if(this->parentUI==NULL){
|
||||||
|
int tabButtonWidth=200;
|
||||||
|
int tabButtonHeight=30;
|
||||||
|
|
||||||
|
buttonAudioSection.registerGraphicComponent(containerName,"buttonAudioSection");
|
||||||
|
buttonAudioSection.init(0, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
// Video Section
|
||||||
|
buttonVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||||
|
buttonVideoSection.init(200, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
//currentLine-=lineOffset;
|
||||||
|
//MiscSection
|
||||||
|
buttonMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
||||||
|
buttonMiscSection.init(400, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
//NetworkSettings
|
||||||
|
buttonNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
|
||||||
|
buttonNetworkSettings.init(600, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
//KeyboardSetup
|
||||||
|
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
|
||||||
|
buttonKeyboardSetup.init(800, 700,tabButtonWidth,tabButtonHeight+20);
|
||||||
|
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
|
||||||
|
}
|
||||||
// header
|
// header
|
||||||
labelTitle.registerGraphicComponent(containerName,"labelTitle");
|
labelTitle.registerGraphicComponent(containerName,"labelTitle");
|
||||||
labelTitle.init(330,700);
|
labelTitle.init(330,670);
|
||||||
labelTitle.setFont(CoreData::getInstance().getMenuFontBig());
|
labelTitle.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelTitle.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
labelTitle.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||||
labelTitle.setText(lang.get("Keyboardsetup"));
|
labelTitle.setText(lang.get("Keyboardsetup"));
|
||||||
|
|
||||||
labelTestTitle.registerGraphicComponent(containerName,"labelTestTitle");
|
labelTestTitle.registerGraphicComponent(containerName,"labelTestTitle");
|
||||||
labelTestTitle.init(50,700);
|
labelTestTitle.init(50,670);
|
||||||
labelTestTitle.setFont(CoreData::getInstance().getMenuFontBig());
|
labelTestTitle.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelTestTitle.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
labelTestTitle.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||||
labelTestTitle.setText(lang.get("KeyboardsetupTest"));
|
labelTestTitle.setText(lang.get("KeyboardsetupTest"));
|
||||||
|
|
||||||
labelTestValue.registerGraphicComponent(containerName,"labelTestValue");
|
labelTestValue.registerGraphicComponent(containerName,"labelTestValue");
|
||||||
labelTestValue.init(50,670);
|
labelTestValue.init(50,640);
|
||||||
labelTestValue.setFont(CoreData::getInstance().getMenuFontBig());
|
labelTestValue.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelTestValue.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
labelTestValue.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||||
labelTestValue.setText("");
|
labelTestValue.setText("");
|
||||||
|
@ -78,7 +120,7 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu,
|
||||||
// buttons
|
// buttons
|
||||||
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||||
buttonOk.init(200, buttonRowPos, 100);
|
buttonOk.init(200, buttonRowPos, 100);
|
||||||
buttonOk.setText(lang.get("Ok"));
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
|
||||||
buttonDefaults.registerGraphicComponent(containerName,"buttonDefaults");
|
buttonDefaults.registerGraphicComponent(containerName,"buttonDefaults");
|
||||||
buttonDefaults.init(310, buttonRowPos, 100);
|
buttonDefaults.init(310, buttonRowPos, 100);
|
||||||
|
@ -86,7 +128,7 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu,
|
||||||
|
|
||||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||||
buttonReturn.init(420, buttonRowPos, 100);
|
buttonReturn.init(420, buttonRowPos, 100);
|
||||||
buttonReturn.setText(lang.get("Abort"));
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
keyButtonsLineHeight=25;
|
keyButtonsLineHeight=25;
|
||||||
keyButtonsHeight=20;
|
keyButtonsHeight=20;
|
||||||
|
@ -178,12 +220,11 @@ void MenuStateKeysetup::reloadUI() {
|
||||||
// mainMassegeBox
|
// mainMassegeBox
|
||||||
mainMessageBox.init(lang.get("Ok"));
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
buttonOk.setText(lang.get("Ok"));
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
buttonDefaults.setText(lang.get("Defaults"));
|
buttonDefaults.setText(lang.get("Defaults"));
|
||||||
|
|
||||||
buttonReturn.setText(lang.get("Abort"));
|
|
||||||
|
|
||||||
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,18 +321,19 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
configKeys.setUserProperties(userProperties);
|
configKeys.setUserProperties(userProperties);
|
||||||
configKeys.save();
|
configKeys.save();
|
||||||
configKeys.reload();
|
configKeys.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->parentUI != NULL) {
|
Lang &lang= Lang::getInstance();
|
||||||
*this->parentUI = NULL;
|
console.addLine(lang.get("SettingsSaved"));
|
||||||
delete *this->parentUI;
|
// if(this->parentUI != NULL) {
|
||||||
}
|
// *this->parentUI = NULL;
|
||||||
|
// delete *this->parentUI;
|
||||||
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
// }
|
||||||
|
//
|
||||||
|
// mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else {
|
else if ( keyScrollBar.getElementCount() != 0) {
|
||||||
if ( keyScrollBar.getElementCount() != 0) {
|
|
||||||
for (int i = keyScrollBar.getVisibleStart(); i
|
for (int i = keyScrollBar.getVisibleStart(); i
|
||||||
<= keyScrollBar.getVisibleEnd(); ++i) {
|
<= keyScrollBar.getVisibleEnd(); ++i) {
|
||||||
if (keyButtons[i]->mouseClick(x, y)) {
|
if (keyButtons[i]->mouseClick(x, y)) {
|
||||||
|
@ -301,7 +343,38 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if(this->parentUI==NULL){
|
||||||
|
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,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonNetworkSettings.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptionsNetwork(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonMiscSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptions(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonVideoSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateKeysetup::mouseUp(int x, int y, const MouseButton mouseButton){
|
void MenuStateKeysetup::mouseUp(int x, int y, const MouseButton mouseButton){
|
||||||
|
@ -313,6 +386,13 @@ void MenuStateKeysetup::mouseUp(int x, int y, const MouseButton mouseButton){
|
||||||
void MenuStateKeysetup::mouseMove(int x, int y, const MouseState *ms){
|
void MenuStateKeysetup::mouseMove(int x, int y, const MouseState *ms){
|
||||||
buttonReturn.mouseMove(x, y);
|
buttonReturn.mouseMove(x, y);
|
||||||
buttonOk.mouseMove(x, y);
|
buttonOk.mouseMove(x, y);
|
||||||
|
if(this->parentUI==NULL){
|
||||||
|
buttonKeyboardSetup.mouseMove(x, y);
|
||||||
|
buttonAudioSection.mouseMove(x, y);
|
||||||
|
buttonNetworkSettings.mouseMove(x, y);
|
||||||
|
buttonMiscSection.mouseMove(x, y);
|
||||||
|
buttonVideoSection.mouseMove(x, y);
|
||||||
|
}
|
||||||
if (ms->get(mbLeft)) {
|
if (ms->get(mbLeft)) {
|
||||||
keyScrollBar.mouseDown(x, y);
|
keyScrollBar.mouseDown(x, y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -341,6 +421,13 @@ void MenuStateKeysetup::render(){
|
||||||
renderer.renderButton(&buttonReturn);
|
renderer.renderButton(&buttonReturn);
|
||||||
renderer.renderButton(&buttonDefaults);
|
renderer.renderButton(&buttonDefaults);
|
||||||
renderer.renderButton(&buttonOk);
|
renderer.renderButton(&buttonOk);
|
||||||
|
if(this->parentUI==NULL){
|
||||||
|
renderer.renderButton(&buttonKeyboardSetup);
|
||||||
|
renderer.renderButton(&buttonVideoSection);
|
||||||
|
renderer.renderButton(&buttonAudioSection);
|
||||||
|
renderer.renderButton(&buttonMiscSection);
|
||||||
|
renderer.renderButton(&buttonNetworkSettings);
|
||||||
|
}
|
||||||
renderer.renderLabel(&labelTitle);
|
renderer.renderLabel(&labelTitle);
|
||||||
renderer.renderLabel(&labelTestTitle);
|
renderer.renderLabel(&labelTestTitle);
|
||||||
renderer.renderLabel(&labelTestValue);
|
renderer.renderLabel(&labelTestValue);
|
||||||
|
|
|
@ -32,6 +32,12 @@ private:
|
||||||
GraphicButton buttonDefaults;
|
GraphicButton buttonDefaults;
|
||||||
GraphicButton buttonReturn;
|
GraphicButton buttonReturn;
|
||||||
|
|
||||||
|
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
||||||
|
GraphicButton buttonVideoSection;
|
||||||
|
GraphicButton buttonAudioSection;
|
||||||
|
GraphicButton buttonMiscSection;
|
||||||
|
GraphicButton buttonNetworkSettings;
|
||||||
|
|
||||||
GraphicLabel labelTitle;
|
GraphicLabel labelTitle;
|
||||||
|
|
||||||
GraphicScrollBar keyScrollBar;
|
GraphicScrollBar keyScrollBar;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,89 +25,30 @@ class MenuStateOptions: public MenuState{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GraphicButton buttonOk;
|
GraphicButton buttonOk;
|
||||||
GraphicButton buttonAbort;
|
GraphicButton buttonReturn;
|
||||||
GraphicButton buttonAutoConfig;
|
|
||||||
GraphicButton buttonVideoInfo;
|
|
||||||
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
|
||||||
|
|
||||||
GraphicLabel labelLang;
|
GraphicLabel labelLang;
|
||||||
GraphicLabel labelShadows;
|
|
||||||
GraphicLabel labelFilter;
|
|
||||||
GraphicLabel labelTextures3D;
|
|
||||||
GraphicLabel labelLights;
|
|
||||||
GraphicLabel labelUnitParticles;
|
|
||||||
GraphicLabel labelTilesetParticles;
|
|
||||||
GraphicLabel labelSoundFactory;
|
|
||||||
GraphicLabel labelVolumeFx;
|
|
||||||
GraphicLabel labelVolumeAmbient;
|
|
||||||
GraphicLabel labelVolumeMusic;
|
|
||||||
GraphicListBox listBoxLang;
|
GraphicListBox listBoxLang;
|
||||||
GraphicListBox listBoxShadows;
|
|
||||||
GraphicListBox listBoxFilter;
|
|
||||||
GraphicCheckBox checkBoxTextures3D;
|
|
||||||
GraphicListBox listBoxLights;
|
|
||||||
GraphicCheckBox checkBoxUnitParticles;
|
|
||||||
GraphicCheckBox checkBoxTilesetParticles;
|
|
||||||
GraphicListBox listBoxSoundFactory;
|
|
||||||
GraphicListBox listBoxVolumeFx;
|
|
||||||
GraphicListBox listBoxVolumeAmbient;
|
|
||||||
GraphicListBox listBoxVolumeMusic;
|
|
||||||
GraphicLabel labelPlayerName;
|
GraphicLabel labelPlayerName;
|
||||||
GraphicLabel labelPlayerNameLabel;
|
GraphicLabel labelPlayerNameLabel;
|
||||||
GraphicLabel *activeInputLabel;
|
GraphicLabel *activeInputLabel;
|
||||||
GraphicLabel labelExternalPort;
|
|
||||||
GraphicLabel labelServerPortLabel;
|
|
||||||
|
|
||||||
|
|
||||||
GraphicLabel labelScreenModes;
|
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
||||||
GraphicListBox listBoxScreenModes;
|
GraphicButton buttonVideoSection;
|
||||||
vector<ModeInfo> modeInfos;
|
GraphicButton buttonAudioSection;
|
||||||
|
GraphicButton buttonMiscSection;
|
||||||
GraphicLabel labelFullscreenWindowed;
|
GraphicButton buttonNetworkSettings;
|
||||||
GraphicCheckBox checkBoxFullscreenWindowed;
|
|
||||||
|
|
||||||
GraphicLabel labelVideoSection;
|
|
||||||
GraphicLabel labelAudioSection;
|
|
||||||
GraphicLabel labelMiscSection;
|
|
||||||
GraphicLabel labelNetworkSettings;
|
|
||||||
|
|
||||||
GraphicLabel labelFontSizeAdjustment;
|
GraphicLabel labelFontSizeAdjustment;
|
||||||
GraphicListBox listFontSizeAdjustment;
|
GraphicListBox listFontSizeAdjustment;
|
||||||
|
|
||||||
GraphicLabel labelMapPreview;
|
|
||||||
GraphicCheckBox checkBoxMapPreview;
|
|
||||||
|
|
||||||
GraphicMessageBox mainMessageBox;
|
GraphicMessageBox mainMessageBox;
|
||||||
int mainMessageBoxState;
|
int mainMessageBoxState;
|
||||||
|
|
||||||
GraphicLabel labelPublishServerExternalPort;
|
|
||||||
GraphicListBox listBoxServerPort;
|
|
||||||
|
|
||||||
|
|
||||||
GraphicLabel labelEnableFTP;
|
|
||||||
GraphicCheckBox checkBoxEnableFTP;
|
|
||||||
|
|
||||||
GraphicLabel labelEnableFTPServer;
|
|
||||||
GraphicCheckBox checkBoxEnableFTPServer;
|
|
||||||
|
|
||||||
GraphicLabel labelFTPServerPortLabel;
|
|
||||||
GraphicLabel labelFTPServerPort;
|
|
||||||
|
|
||||||
GraphicLabel labelFTPServerDataPortsLabel;
|
|
||||||
GraphicLabel labelFTPServerDataPorts;
|
|
||||||
|
|
||||||
GraphicLabel labelEnableFTPServerInternetTilesetXfer;
|
|
||||||
GraphicCheckBox checkBoxEnableFTPServerInternetTilesetXfer;
|
|
||||||
|
|
||||||
GraphicLabel labelEnableFTPServerInternetTechtreeXfer;
|
|
||||||
GraphicCheckBox checkBoxEnableFTPServerInternetTechtreeXfer;
|
|
||||||
|
|
||||||
GraphicLabel labelEnablePrivacy;
|
|
||||||
GraphicCheckBox checkBoxEnablePrivacy;
|
|
||||||
|
|
||||||
GraphicLabel labelEnableTextureCompression;
|
|
||||||
GraphicCheckBox checkBoxEnableTextureCompression;
|
|
||||||
|
|
||||||
GraphicLabel labelScreenShotType;
|
GraphicLabel labelScreenShotType;
|
||||||
GraphicListBox listBoxScreenShotType;
|
GraphicListBox listBoxScreenShotType;
|
||||||
|
|
||||||
|
@ -124,20 +65,6 @@ private:
|
||||||
GraphicLabel labelChatStaysActive;
|
GraphicLabel labelChatStaysActive;
|
||||||
GraphicCheckBox checkBoxChatStaysActive;
|
GraphicCheckBox checkBoxChatStaysActive;
|
||||||
|
|
||||||
GraphicLabel labelRainEffect;
|
|
||||||
GraphicLabel labelRainEffectSeparator;
|
|
||||||
GraphicCheckBox checkBoxRainEffect;
|
|
||||||
GraphicCheckBox checkBoxRainEffectMenu;
|
|
||||||
|
|
||||||
GraphicLabel labelGammaCorrection;
|
|
||||||
GraphicListBox listBoxGammaCorrection;
|
|
||||||
|
|
||||||
GraphicLabel labelShadowTextureSize;
|
|
||||||
GraphicListBox listBoxShadowTextureSize;
|
|
||||||
|
|
||||||
GraphicLabel labelVideos;
|
|
||||||
GraphicCheckBox checkBoxVideos;
|
|
||||||
|
|
||||||
GraphicLabel labelLuaDisableSecuritySandbox;
|
GraphicLabel labelLuaDisableSecuritySandbox;
|
||||||
GraphicCheckBox checkBoxLuaDisableSecuritySandbox;
|
GraphicCheckBox checkBoxLuaDisableSecuritySandbox;
|
||||||
|
|
||||||
|
@ -158,12 +85,10 @@ private:
|
||||||
GraphicLabel labelTransifexI18NLabel;
|
GraphicLabel labelTransifexI18NLabel;
|
||||||
GraphicLabel labelTransifexI18N;
|
GraphicLabel labelTransifexI18N;
|
||||||
|
|
||||||
GraphicLabel labelSelectionType;
|
ProgramState **parentUI;
|
||||||
GraphicListBox listBoxSelectionType;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateOptions(Program *program, MainMenu *mainMenu);
|
MenuStateOptions(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);
|
||||||
|
|
||||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
|
|
900
source/glest_game/menu/menu_state_options_graphics.cpp
Normal file
900
source/glest_game/menu/menu_state_options_graphics.cpp
Normal file
|
@ -0,0 +1,900 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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_graphics.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_graphic_info.h"
|
||||||
|
#include "menu_state_keysetup.h"
|
||||||
|
#include "menu_state_options_graphics.h"
|
||||||
|
#include "menu_state_options_sound.h"
|
||||||
|
#include "menu_state_options_network.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include "metrics.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
using namespace Shared::Util;
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class MenuStateOptions
|
||||||
|
// =====================================================
|
||||||
|
MenuStateOptionsGraphics::MenuStateOptionsGraphics(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);
|
||||||
|
//modeinfos=list<ModeInfo> ();
|
||||||
|
Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos,!config.getBool("Windowed"));
|
||||||
|
|
||||||
|
int leftLabelStart=50;
|
||||||
|
int leftColumnStart=leftLabelStart+180;
|
||||||
|
int rightLabelStart=450;
|
||||||
|
int rightColumnStart=rightLabelStart+280;
|
||||||
|
int buttonRowPos=50;
|
||||||
|
int buttonStartPos=170;
|
||||||
|
int captionOffset=75;
|
||||||
|
int currentLabelStart=leftLabelStart;
|
||||||
|
int currentColumnStart=leftColumnStart;
|
||||||
|
int currentLine=700;
|
||||||
|
int lineOffset=27;
|
||||||
|
int tabButtonWidth=200;
|
||||||
|
int tabButtonHeight=30;
|
||||||
|
|
||||||
|
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
mainMessageBoxState=0;
|
||||||
|
|
||||||
|
buttonAudioSection.registerGraphicComponent(containerName,"buttonAudioSection");
|
||||||
|
buttonAudioSection.init(0, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
// Video Section
|
||||||
|
buttonVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||||
|
buttonVideoSection.init(200, 700,tabButtonWidth,tabButtonHeight+20);
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
//currentLine-=lineOffset;
|
||||||
|
//MiscSection
|
||||||
|
buttonMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
||||||
|
buttonMiscSection.init(400, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
//NetworkSettings
|
||||||
|
buttonNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
|
||||||
|
buttonNetworkSettings.init(600, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
//KeyboardSetup
|
||||||
|
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
|
||||||
|
buttonKeyboardSetup.init(800, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
|
||||||
|
|
||||||
|
currentLine=650; // reset line pos
|
||||||
|
currentLabelStart=leftLabelStart; // set to right side
|
||||||
|
currentColumnStart=leftColumnStart; // set to right side
|
||||||
|
|
||||||
|
//resolution
|
||||||
|
labelScreenModes.registerGraphicComponent(containerName,"labelScreenModes");
|
||||||
|
labelScreenModes.init(currentLabelStart, currentLine);
|
||||||
|
labelScreenModes.setText(lang.get("Resolution"));
|
||||||
|
|
||||||
|
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
|
||||||
|
listBoxScreenModes.init(currentColumnStart, currentLine, 170);
|
||||||
|
|
||||||
|
string currentResString = config.getString("ScreenWidth") + "x" +
|
||||||
|
config.getString("ScreenHeight") + "-" +
|
||||||
|
intToStr(config.getInt("ColorBits"));
|
||||||
|
bool currentResolutionFound = false;
|
||||||
|
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){
|
||||||
|
if((*it).getString() == currentResString) {
|
||||||
|
currentResolutionFound = true;
|
||||||
|
}
|
||||||
|
listBoxScreenModes.pushBackItem((*it).getString());
|
||||||
|
}
|
||||||
|
if(currentResolutionFound == false) {
|
||||||
|
listBoxScreenModes.pushBackItem(currentResString);
|
||||||
|
}
|
||||||
|
listBoxScreenModes.setSelectedItem(currentResString);
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
|
||||||
|
//FullscreenWindowed
|
||||||
|
labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed");
|
||||||
|
labelFullscreenWindowed.init(currentLabelStart, currentLine);
|
||||||
|
|
||||||
|
checkBoxFullscreenWindowed.registerGraphicComponent(containerName,"checkBoxFullscreenWindowed");
|
||||||
|
checkBoxFullscreenWindowed.init(currentColumnStart, currentLine);
|
||||||
|
labelFullscreenWindowed.setText(lang.get("Windowed"));
|
||||||
|
checkBoxFullscreenWindowed.setValue(config.getBool("Windowed"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//gammaCorrection
|
||||||
|
labelGammaCorrection.registerGraphicComponent(containerName,"labelGammaCorrection");
|
||||||
|
labelGammaCorrection.init(currentLabelStart, currentLine);
|
||||||
|
labelGammaCorrection.setText(lang.get("GammaCorrection"));
|
||||||
|
|
||||||
|
listBoxGammaCorrection.registerGraphicComponent(containerName,"listBoxGammaCorrection");
|
||||||
|
listBoxGammaCorrection.init(currentColumnStart, currentLine, 170);
|
||||||
|
for (float f=0.5;f<3.0f;f=f+0.1f) {
|
||||||
|
listBoxGammaCorrection.pushBackItem(floatToStr(f));
|
||||||
|
}
|
||||||
|
float gammaValue=config.getFloat("GammaValue","1.0");
|
||||||
|
if(gammaValue==0.0f) gammaValue=1.0f;
|
||||||
|
listBoxGammaCorrection.setSelectedItem(floatToStr(gammaValue));
|
||||||
|
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//filter
|
||||||
|
labelFilter.registerGraphicComponent(containerName,"labelFilter");
|
||||||
|
labelFilter.init(currentLabelStart, currentLine);
|
||||||
|
labelFilter.setText(lang.get("Filter"));
|
||||||
|
|
||||||
|
listBoxFilter.registerGraphicComponent(containerName,"listBoxFilter");
|
||||||
|
listBoxFilter.init(currentColumnStart, currentLine, 170);
|
||||||
|
listBoxFilter.pushBackItem("Bilinear");
|
||||||
|
listBoxFilter.pushBackItem("Trilinear");
|
||||||
|
listBoxFilter.setSelectedItem(config.getString("Filter"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//selectionType
|
||||||
|
labelSelectionType.registerGraphicComponent(containerName,"labelSelectionType");
|
||||||
|
labelSelectionType.init(currentLabelStart, currentLine);
|
||||||
|
labelSelectionType.setText(lang.get("SelectionType"));
|
||||||
|
|
||||||
|
listBoxSelectionType.registerGraphicComponent(containerName,"listBoxSelectionType");
|
||||||
|
listBoxSelectionType.init(currentColumnStart, currentLine, 170);
|
||||||
|
listBoxSelectionType.pushBackItem("SelectBuffer");
|
||||||
|
listBoxSelectionType.pushBackItem("ColorPicking");
|
||||||
|
listBoxSelectionType.pushBackItem("FrustumPicking");
|
||||||
|
|
||||||
|
const string selectionType=toLower(config.getString("SelectionType",Config::selectBufPicking));
|
||||||
|
if( selectionType==Config::colorPicking)
|
||||||
|
listBoxSelectionType.setSelectedItemIndex(1);
|
||||||
|
else if ( selectionType==Config::frustumPicking )
|
||||||
|
listBoxSelectionType.setSelectedItemIndex(2);
|
||||||
|
else
|
||||||
|
listBoxSelectionType.setSelectedItemIndex(0);
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//shadows
|
||||||
|
labelShadows.registerGraphicComponent(containerName,"labelShadows");
|
||||||
|
labelShadows.init(currentLabelStart, currentLine);
|
||||||
|
labelShadows.setText(lang.get("Shadows"));
|
||||||
|
|
||||||
|
listBoxShadows.registerGraphicComponent(containerName,"listBoxShadows");
|
||||||
|
listBoxShadows.init(currentColumnStart, currentLine, 170);
|
||||||
|
for(int i= 0; i<Renderer::sCount; ++i){
|
||||||
|
listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
||||||
|
}
|
||||||
|
string str= config.getString("Shadows");
|
||||||
|
listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//shadows
|
||||||
|
labelShadowTextureSize.registerGraphicComponent(containerName,"labelShadowTextureSize");
|
||||||
|
labelShadowTextureSize.init(currentLabelStart, currentLine);
|
||||||
|
labelShadowTextureSize.setText(lang.get("ShadowTextureSize"));
|
||||||
|
|
||||||
|
listBoxShadowTextureSize.registerGraphicComponent(containerName,"listBoxShadowTextureSize");
|
||||||
|
listBoxShadowTextureSize.init(currentColumnStart, currentLine, 170);
|
||||||
|
listBoxShadowTextureSize.pushBackItem("256");
|
||||||
|
listBoxShadowTextureSize.pushBackItem("512");
|
||||||
|
listBoxShadowTextureSize.pushBackItem("1024");
|
||||||
|
listBoxShadowTextureSize.setSelectedItemIndex(1,false);
|
||||||
|
listBoxShadowTextureSize.setSelectedItem(intToStr(config.getInt("ShadowTextureSize","512")),false);
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//textures 3d
|
||||||
|
labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D");
|
||||||
|
labelTextures3D.init(currentLabelStart, currentLine);
|
||||||
|
|
||||||
|
checkBoxTextures3D.registerGraphicComponent(containerName,"checkBoxTextures3D");
|
||||||
|
checkBoxTextures3D.init(currentColumnStart, currentLine);
|
||||||
|
labelTextures3D.setText(lang.get("Textures3D"));
|
||||||
|
checkBoxTextures3D.setValue(config.getBool("Textures3D"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//lights
|
||||||
|
labelLights.registerGraphicComponent(containerName,"labelLights");
|
||||||
|
labelLights.init(currentLabelStart, currentLine);
|
||||||
|
labelLights.setText(lang.get("MaxLights"));
|
||||||
|
|
||||||
|
listBoxLights.registerGraphicComponent(containerName,"listBoxLights");
|
||||||
|
listBoxLights.init(currentColumnStart, currentLine, 80);
|
||||||
|
for(int i= 1; i<=8; ++i){
|
||||||
|
listBoxLights.pushBackItem(intToStr(i));
|
||||||
|
}
|
||||||
|
listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//unit particles
|
||||||
|
labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles");
|
||||||
|
labelUnitParticles.init(currentLabelStart,currentLine);
|
||||||
|
labelUnitParticles.setText(lang.get("ShowUnitParticles"));
|
||||||
|
|
||||||
|
checkBoxUnitParticles.registerGraphicComponent(containerName,"checkBoxUnitParticles");
|
||||||
|
checkBoxUnitParticles.init(currentColumnStart,currentLine);
|
||||||
|
checkBoxUnitParticles.setValue(config.getBool("UnitParticles","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//tileset particles
|
||||||
|
labelTilesetParticles.registerGraphicComponent(containerName,"labelTilesetParticles");
|
||||||
|
labelTilesetParticles.init(currentLabelStart,currentLine);
|
||||||
|
labelTilesetParticles.setText(lang.get("ShowTilesetParticles"));
|
||||||
|
|
||||||
|
checkBoxTilesetParticles.registerGraphicComponent(containerName,"checkBoxTilesetParticles");
|
||||||
|
checkBoxTilesetParticles.init(currentColumnStart,currentLine);
|
||||||
|
checkBoxTilesetParticles.setValue(config.getBool("TilesetParticles","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
//unit particles
|
||||||
|
labelMapPreview.registerGraphicComponent(containerName,"labelMapPreview");
|
||||||
|
labelMapPreview.init(currentLabelStart,currentLine);
|
||||||
|
labelMapPreview.setText(lang.get("ShowMapPreview"));
|
||||||
|
|
||||||
|
checkBoxMapPreview.registerGraphicComponent(containerName,"checkBoxMapPreview");
|
||||||
|
checkBoxMapPreview.init(currentColumnStart,currentLine);
|
||||||
|
checkBoxMapPreview.setValue(config.getBool("MapPreview","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
// Texture Compression flag
|
||||||
|
labelEnableTextureCompression.registerGraphicComponent(containerName,"labelEnableTextureCompression");
|
||||||
|
labelEnableTextureCompression.init(currentLabelStart ,currentLine);
|
||||||
|
labelEnableTextureCompression.setText(lang.get("EnableTextureCompression"));
|
||||||
|
|
||||||
|
checkBoxEnableTextureCompression.registerGraphicComponent(containerName,"checkBoxEnableTextureCompression");
|
||||||
|
checkBoxEnableTextureCompression.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableTextureCompression.setValue(config.getBool("EnableTextureCompression","false"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelRainEffect.registerGraphicComponent(containerName,"labelRainEffect");
|
||||||
|
labelRainEffect.init(currentLabelStart ,currentLine);
|
||||||
|
labelRainEffect.setText(lang.get("RainEffectMenuGame"));
|
||||||
|
|
||||||
|
checkBoxRainEffectMenu.registerGraphicComponent(containerName,"checkBoxRainEffectMenu");
|
||||||
|
checkBoxRainEffectMenu.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxRainEffectMenu.setValue(config.getBool("RainEffectMenu","true"));
|
||||||
|
|
||||||
|
labelRainEffectSeparator.registerGraphicComponent(containerName,"labelRainEffect");
|
||||||
|
labelRainEffectSeparator.init(currentColumnStart+30 ,currentLine);
|
||||||
|
labelRainEffectSeparator.setText("/");
|
||||||
|
|
||||||
|
checkBoxRainEffect.registerGraphicComponent(containerName,"checkBoxRainEffect");
|
||||||
|
checkBoxRainEffect.init(currentColumnStart+42 ,currentLine );
|
||||||
|
checkBoxRainEffect.setValue(config.getBool("RainEffect","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelVideos.registerGraphicComponent(containerName,"labelVideos");
|
||||||
|
labelVideos.init(currentLabelStart ,currentLine);
|
||||||
|
labelVideos.setText(lang.get("EnableVideos"));
|
||||||
|
|
||||||
|
checkBoxVideos.registerGraphicComponent(containerName,"checkBoxVideos");
|
||||||
|
checkBoxVideos.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxVideos.setValue(config.getBool("EnableVideos","true"));
|
||||||
|
|
||||||
|
// end
|
||||||
|
|
||||||
|
// external server port
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||||
|
buttonOk.init(buttonStartPos, buttonRowPos, 100);
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
buttonReturn.registerGraphicComponent(containerName,"buttonAbort");
|
||||||
|
buttonReturn.init(buttonStartPos+110, buttonRowPos, 100);
|
||||||
|
buttonAutoConfig.setText(lang.get("AutoConfig"));
|
||||||
|
|
||||||
|
buttonAutoConfig.registerGraphicComponent(containerName,"buttonAutoConfig");
|
||||||
|
buttonAutoConfig.init(buttonStartPos+250, buttonRowPos, 125);
|
||||||
|
|
||||||
|
buttonVideoInfo.setText(lang.get("VideoInfo"));
|
||||||
|
buttonVideoInfo.registerGraphicComponent(containerName,"buttonVideoInfo");
|
||||||
|
buttonVideoInfo.init(buttonStartPos+385, buttonRowPos, 125); // was 620
|
||||||
|
|
||||||
|
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 MenuStateOptionsGraphics::reloadUI() {
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
console.resetFonts();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
std::vector<string> listboxData;
|
||||||
|
listboxData.push_back("None");
|
||||||
|
listboxData.push_back("OpenAL");
|
||||||
|
// deprecated as of 3.6.1
|
||||||
|
//#ifdef WIN32
|
||||||
|
// listboxData.push_back("DirectSound8");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
labelScreenModes.setText(lang.get("Resolution"));
|
||||||
|
|
||||||
|
labelFullscreenWindowed.setText(lang.get("Windowed"));
|
||||||
|
labelFilter.setText(lang.get("Filter"));
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
listboxData.push_back("Bilinear");
|
||||||
|
listboxData.push_back("Trilinear");
|
||||||
|
listBoxFilter.setItems(listboxData);
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
for (float f=0.0;f<2.1f;f=f+0.1f) {
|
||||||
|
listboxData.push_back(floatToStr(f));
|
||||||
|
}
|
||||||
|
listBoxGammaCorrection.setItems(listboxData);
|
||||||
|
|
||||||
|
|
||||||
|
labelShadows.setText(lang.get("Shadows"));
|
||||||
|
labelShadowTextureSize.setText(lang.get("ShadowTextureSize"));
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
for(int i= 0; i<Renderer::sCount; ++i){
|
||||||
|
listboxData.push_back(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
||||||
|
}
|
||||||
|
listBoxShadows.setItems(listboxData);
|
||||||
|
|
||||||
|
labelTextures3D.setText(lang.get("Textures3D"));
|
||||||
|
|
||||||
|
labelLights.setText(lang.get("MaxLights"));
|
||||||
|
|
||||||
|
labelUnitParticles.setText(lang.get("ShowUnitParticles"));
|
||||||
|
|
||||||
|
labelTilesetParticles.setText(lang.get("ShowTilesetParticles"));
|
||||||
|
|
||||||
|
labelMapPreview.setText(lang.get("ShowMapPreview"));
|
||||||
|
|
||||||
|
labelEnableTextureCompression.setText(lang.get("EnableTextureCompression"));
|
||||||
|
|
||||||
|
|
||||||
|
labelRainEffect.setText(lang.get("RainEffect"));
|
||||||
|
|
||||||
|
labelVideos.setText(lang.get("EnableVideos"));
|
||||||
|
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
buttonAutoConfig.setText(lang.get("AutoConfig"));
|
||||||
|
|
||||||
|
buttonVideoInfo.setText(lang.get("VideoInfo"));
|
||||||
|
|
||||||
|
labelSelectionType.setText(lang.get("SelectionType"));
|
||||||
|
|
||||||
|
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
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();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
//mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(mainMessageBoxState == 1) {
|
||||||
|
mainMessageBoxState=0;
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
|
//!!!
|
||||||
|
// Revert resolution or fullscreen
|
||||||
|
checkBoxFullscreenWindowed.setValue(config.getBool("Windowed"));
|
||||||
|
string currentResString = config.getString("ScreenWidth") + "x" +
|
||||||
|
config.getString("ScreenHeight") + "-" +
|
||||||
|
intToStr(config.getInt("ColorBits"));
|
||||||
|
listBoxScreenModes.setSelectedItem(currentResString);
|
||||||
|
|
||||||
|
|
||||||
|
changeVideoModeFullScreen(!config.getBool("Windowed"));
|
||||||
|
WindowGl *window = this->program->getWindow();
|
||||||
|
window->ChangeVideoMode(true,
|
||||||
|
config.getInt("ScreenWidth"),
|
||||||
|
config.getInt("ScreenHeight"),
|
||||||
|
!config.getBool("Windowed"),
|
||||||
|
config.getInt("ColorBits"),
|
||||||
|
config.getInt("DepthBits"),
|
||||||
|
config.getInt("StencilBits"),
|
||||||
|
config.getBool("HardwareAcceleration","false"),
|
||||||
|
config.getBool("FullScreenAntiAliasing","false"),
|
||||||
|
config.getFloat("GammaValue","0.0"));
|
||||||
|
|
||||||
|
Metrics::reload();
|
||||||
|
this->mainMenu->init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(buttonOk.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
bool selectedFullscreenWindowed = checkBoxFullscreenWindowed.getValue();
|
||||||
|
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
|
||||||
|
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||||
|
if(currentResolution != selectedResolution){
|
||||||
|
// if(currentResolution != selectedResolution ||
|
||||||
|
// currentFullscreenWindowed != selectedFullscreenWindowed) {
|
||||||
|
//
|
||||||
|
// changeVideoModeFullScreen(!config.getBool("Windowed"));
|
||||||
|
// WindowGl *window = this->program->getWindow();
|
||||||
|
// window->ChangeVideoMode(true,
|
||||||
|
// config.getInt("ScreenWidth"),
|
||||||
|
// config.getInt("ScreenHeight"),
|
||||||
|
// !config.getBool("Windowed"),
|
||||||
|
// config.getInt("ColorBits"),
|
||||||
|
// config.getInt("DepthBits"),
|
||||||
|
// config.getInt("StencilBits"),
|
||||||
|
// config.getBool("HardwareAcceleration","false"),
|
||||||
|
// config.getBool("FullScreenAntiAliasing","false"),
|
||||||
|
// config.getFloat("GammaValue","0.0"));
|
||||||
|
//
|
||||||
|
// Metrics::reload();
|
||||||
|
// this->mainMenu->init();
|
||||||
|
// }
|
||||||
|
|
||||||
|
changeVideoModeFullScreen(!selectedFullscreenWindowed);
|
||||||
|
const ModeInfo *selectedMode = NULL;
|
||||||
|
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it) {
|
||||||
|
if((*it).getString() == selectedResolution) {
|
||||||
|
//config.setInt("ScreenWidth",(*it).width);
|
||||||
|
//config.setInt("ScreenHeight",(*it).height);
|
||||||
|
//config.setInt("ColorBits",(*it).depth);
|
||||||
|
selectedMode = &(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowGl *window = this->program->getWindow();
|
||||||
|
window->ChangeVideoMode(true,
|
||||||
|
selectedMode->width,
|
||||||
|
selectedMode->height,
|
||||||
|
!selectedFullscreenWindowed,
|
||||||
|
selectedMode->depth,
|
||||||
|
config.getInt("DepthBits"),
|
||||||
|
config.getInt("StencilBits"),
|
||||||
|
config.getBool("HardwareAcceleration","false"),
|
||||||
|
config.getBool("FullScreenAntiAliasing","false"),
|
||||||
|
strToFloat(listBoxGammaCorrection.getSelectedItem()));
|
||||||
|
|
||||||
|
//Metrics::reload(selectedMode->width,selectedMode->height);
|
||||||
|
//this->mainMenu->init();
|
||||||
|
|
||||||
|
mainMessageBoxState=1;
|
||||||
|
mainMessageBox.init(lang.get("Ok"),lang.get("Cancel"));
|
||||||
|
//showMessageBox(lang.get("RestartNeeded"), lang.get("ResolutionChanged"), false);
|
||||||
|
showMessageBox(lang.get("ResolutionChanged"), lang.get("Notice"), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool currentFullscreenWindowed=config.getBool("Windowed");
|
||||||
|
//bool selectedFullscreenWindowed = checkBoxFullscreenWindowed.getValue();
|
||||||
|
if(currentFullscreenWindowed != selectedFullscreenWindowed) {
|
||||||
|
//mainMessageBoxState=1;
|
||||||
|
//Lang &lang= Lang::getInstance();
|
||||||
|
//showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false);
|
||||||
|
//return;
|
||||||
|
|
||||||
|
changeVideoModeFullScreen(!selectedFullscreenWindowed);
|
||||||
|
const ModeInfo *selectedMode = NULL;
|
||||||
|
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it) {
|
||||||
|
if((*it).getString() == selectedResolution) {
|
||||||
|
//config.setInt("ScreenWidth",(*it).width);
|
||||||
|
//config.setInt("ScreenHeight",(*it).height);
|
||||||
|
//config.setInt("ColorBits",(*it).depth);
|
||||||
|
selectedMode = &(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowGl *window = this->program->getWindow();
|
||||||
|
window->ChangeVideoMode(true,
|
||||||
|
selectedMode->width,
|
||||||
|
selectedMode->height,
|
||||||
|
!selectedFullscreenWindowed,
|
||||||
|
selectedMode->depth,
|
||||||
|
config.getInt("DepthBits"),
|
||||||
|
config.getInt("StencilBits"),
|
||||||
|
config.getBool("HardwareAcceleration","false"),
|
||||||
|
config.getBool("FullScreenAntiAliasing","false"),
|
||||||
|
strToFloat(listBoxGammaCorrection.getSelectedItem()));
|
||||||
|
|
||||||
|
Metrics::reload(selectedMode->width,selectedMode->height);
|
||||||
|
this->mainMenu->init();
|
||||||
|
|
||||||
|
mainMessageBoxState=1;
|
||||||
|
mainMessageBox.init(lang.get("Ok"),lang.get("Cancel"));
|
||||||
|
//showMessageBox(lang.get("RestartNeeded"), lang.get("ResolutionChanged"), false);
|
||||||
|
showMessageBox(lang.get("DisplaySettingsChanged"), lang.get("Notice"), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveConfig();
|
||||||
|
//mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonReturn.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
||||||
|
// reset the gamma to former value
|
||||||
|
string currentGammaCorrection=config.getString("GammaValue","1.0");
|
||||||
|
string selectedGammaCorrection=listBoxGammaCorrection.getSelectedItem();
|
||||||
|
if(currentGammaCorrection!=selectedGammaCorrection){
|
||||||
|
float gammaValue=strToFloat(currentGammaCorrection);
|
||||||
|
if(gammaValue==0.0f) gammaValue=1.0f;
|
||||||
|
if(gammaValue!=0.0){
|
||||||
|
program->getWindow()->setGamma(gammaValue);
|
||||||
|
SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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,this->parentUI)); // 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,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonNetworkSettings.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptionsNetwork(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonMiscSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptions(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonVideoSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
//mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonAutoConfig.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
Renderer::getInstance().autoConfig();
|
||||||
|
//saveConfig();
|
||||||
|
mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonVideoInfo.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateGraphicInfo(program, mainMenu));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listBoxSelectionType.mouseClick(x, y);
|
||||||
|
listBoxShadows.mouseClick(x, y);
|
||||||
|
listBoxShadowTextureSize.mouseClick(x, y);
|
||||||
|
listBoxFilter.mouseClick(x, y);
|
||||||
|
if(listBoxGammaCorrection.mouseClick(x, y)){
|
||||||
|
float gammaValue=strToFloat(listBoxGammaCorrection.getSelectedItem());
|
||||||
|
if(gammaValue!=0.0){
|
||||||
|
program->getWindow()->setGamma(gammaValue);
|
||||||
|
SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkBoxTextures3D.mouseClick(x, y);
|
||||||
|
checkBoxUnitParticles.mouseClick(x, y);
|
||||||
|
checkBoxTilesetParticles.mouseClick(x, y);
|
||||||
|
checkBoxMapPreview.mouseClick(x, y);
|
||||||
|
listBoxLights.mouseClick(x, y);
|
||||||
|
listBoxScreenModes.mouseClick(x, y);
|
||||||
|
checkBoxFullscreenWindowed.mouseClick(x, y);
|
||||||
|
checkBoxEnableTextureCompression.mouseClick(x, y);
|
||||||
|
checkBoxRainEffect.mouseClick(x,y);
|
||||||
|
checkBoxRainEffectMenu.mouseClick(x,y);
|
||||||
|
|
||||||
|
checkBoxVideos.mouseClick(x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::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);
|
||||||
|
buttonAutoConfig.mouseMove(x, y);
|
||||||
|
buttonVideoInfo.mouseMove(x, y);
|
||||||
|
listBoxFilter.mouseMove(x, y);
|
||||||
|
listBoxGammaCorrection.mouseMove(x, y);
|
||||||
|
listBoxSelectionType.mouseMove(x, y);
|
||||||
|
listBoxShadows.mouseMove(x, y);
|
||||||
|
checkBoxTextures3D.mouseMove(x, y);
|
||||||
|
checkBoxUnitParticles.mouseMove(x, y);
|
||||||
|
checkBoxTilesetParticles.mouseMove(x, y);
|
||||||
|
checkBoxMapPreview.mouseMove(x, y);
|
||||||
|
listBoxLights.mouseMove(x, y);
|
||||||
|
listBoxScreenModes.mouseMove(x, y);
|
||||||
|
checkBoxFullscreenWindowed.mouseMove(x, y);
|
||||||
|
checkBoxEnableTextureCompression.mouseMove(x, y);
|
||||||
|
|
||||||
|
checkBoxRainEffect.mouseMove(x, y);
|
||||||
|
checkBoxRainEffectMenu.mouseMove(x, y);
|
||||||
|
|
||||||
|
checkBoxVideos.mouseMove(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool MenuStateOptionsGraphics::isInSpecialKeyCaptureEvent() {
|
||||||
|
// return (activeInputLabel != NULL);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void MenuStateOptionsGraphics::keyDown(SDL_KeyboardEvent key) {
|
||||||
|
// if(activeInputLabel != NULL) {
|
||||||
|
// keyDownEditLabel(key, &activeInputLabel);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::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();
|
||||||
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::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.renderButton(&buttonAutoConfig);
|
||||||
|
renderer.renderButton(&buttonVideoInfo);
|
||||||
|
renderer.renderListBox(&listBoxShadows);
|
||||||
|
renderer.renderCheckBox(&checkBoxTextures3D);
|
||||||
|
renderer.renderCheckBox(&checkBoxUnitParticles);
|
||||||
|
renderer.renderCheckBox(&checkBoxTilesetParticles);
|
||||||
|
renderer.renderCheckBox(&checkBoxMapPreview);
|
||||||
|
renderer.renderListBox(&listBoxLights);
|
||||||
|
renderer.renderListBox(&listBoxFilter);
|
||||||
|
renderer.renderListBox(&listBoxGammaCorrection);
|
||||||
|
renderer.renderLabel(&labelShadows);
|
||||||
|
renderer.renderLabel(&labelTextures3D);
|
||||||
|
renderer.renderLabel(&labelUnitParticles);
|
||||||
|
renderer.renderLabel(&labelTilesetParticles);
|
||||||
|
renderer.renderLabel(&labelMapPreview);
|
||||||
|
renderer.renderLabel(&labelLights);
|
||||||
|
renderer.renderLabel(&labelFilter);
|
||||||
|
renderer.renderLabel(&labelGammaCorrection);
|
||||||
|
renderer.renderLabel(&labelScreenModes);
|
||||||
|
renderer.renderListBox(&listBoxScreenModes);
|
||||||
|
renderer.renderLabel(&labelFullscreenWindowed);
|
||||||
|
renderer.renderCheckBox(&checkBoxFullscreenWindowed);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnableTextureCompression);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableTextureCompression);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelRainEffect);
|
||||||
|
renderer.renderCheckBox(&checkBoxRainEffect);
|
||||||
|
renderer.renderLabel(&labelRainEffectSeparator);
|
||||||
|
renderer.renderCheckBox(&checkBoxRainEffectMenu);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelShadowTextureSize);
|
||||||
|
renderer.renderListBox(&listBoxShadowTextureSize);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelSelectionType);
|
||||||
|
renderer.renderListBox(&listBoxSelectionType);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelVideos);
|
||||||
|
renderer.renderCheckBox(&checkBoxVideos);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.renderConsole(&console,false,true);
|
||||||
|
if(program != NULL) program->renderProgramMsgBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsGraphics::saveConfig(){
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
//setActiveInputLable(NULL);
|
||||||
|
|
||||||
|
int selectionTypeindex= listBoxSelectionType.getSelectedItemIndex();
|
||||||
|
if(selectionTypeindex==0){
|
||||||
|
config.setString("SelectionType",Config::selectBufPicking);
|
||||||
|
}
|
||||||
|
else if (selectionTypeindex==1){
|
||||||
|
config.setString("SelectionType",Config::colorPicking);
|
||||||
|
}
|
||||||
|
else if (selectionTypeindex==2){
|
||||||
|
config.setString("SelectionType",Config::frustumPicking);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index= listBoxShadows.getSelectedItemIndex();
|
||||||
|
config.setString("Shadows", Renderer::shadowsToStr(static_cast<Renderer::Shadows>(index)));
|
||||||
|
|
||||||
|
string texSizeString= listBoxShadowTextureSize.getSelectedItem();
|
||||||
|
config.setInt("ShadowTextureSize",strToInt(texSizeString) );
|
||||||
|
|
||||||
|
config.setBool("Windowed", checkBoxFullscreenWindowed.getValue());
|
||||||
|
config.setString("Filter", listBoxFilter.getSelectedItem());
|
||||||
|
config.setFloat("GammaValue", strToFloat(listBoxGammaCorrection.getSelectedItem()));
|
||||||
|
config.setBool("Textures3D", checkBoxTextures3D.getValue());
|
||||||
|
config.setBool("UnitParticles", (checkBoxUnitParticles.getValue()));
|
||||||
|
config.setBool("TilesetParticles", (checkBoxTilesetParticles.getValue()));
|
||||||
|
config.setBool("MapPreview", checkBoxMapPreview.getValue());
|
||||||
|
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
||||||
|
|
||||||
|
config.setBool("RainEffect", checkBoxRainEffect.getValue());
|
||||||
|
config.setBool("RainEffectMenu", checkBoxRainEffectMenu.getValue());
|
||||||
|
|
||||||
|
config.setBool("EnableVideos", checkBoxVideos.getValue());
|
||||||
|
|
||||||
|
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight");
|
||||||
|
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||||
|
if(currentResolution!=selectedResolution){
|
||||||
|
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){
|
||||||
|
if((*it).getString()==selectedResolution)
|
||||||
|
{
|
||||||
|
config.setInt("ScreenWidth",(*it).width);
|
||||||
|
config.setInt("ScreenHeight",(*it).height);
|
||||||
|
config.setInt("ColorBits",(*it).depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
console.addLine(lang.get("SettingsSaved"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//void MenuStateOptionsGraphics::setActiveInputLable(GraphicLabel *newLable) {
|
||||||
|
// MenuState::setActiveInputLabel(newLable,&activeInputLabel);
|
||||||
|
//
|
||||||
|
// if(newLable == &labelTransifexPwd) {
|
||||||
|
// labelTransifexPwd.setIsPassword(false);
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// labelTransifexPwd.setIsPassword(true);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
}}//end namespace
|
110
source/glest_game/menu/menu_state_options_graphics.h
Normal file
110
source/glest_game/menu/menu_state_options_graphics.h
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _GLEST_GAME_MENUSTATEOPTIONS_GRAPHICS_H_
|
||||||
|
#define _GLEST_GAME_MENUSTATEOPTIONS_GRAPHICS_H_
|
||||||
|
|
||||||
|
#include "main_menu.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// ===============================
|
||||||
|
// class MenuStateOptionsGraphics
|
||||||
|
// ===============================
|
||||||
|
|
||||||
|
class MenuStateOptionsGraphics: public MenuState{
|
||||||
|
private:
|
||||||
|
|
||||||
|
GraphicButton buttonOk;
|
||||||
|
GraphicButton buttonReturn;
|
||||||
|
GraphicButton buttonAutoConfig;
|
||||||
|
GraphicButton buttonVideoInfo;
|
||||||
|
|
||||||
|
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
||||||
|
GraphicButton buttonVideoSection;
|
||||||
|
GraphicButton buttonAudioSection;
|
||||||
|
GraphicButton buttonMiscSection;
|
||||||
|
GraphicButton buttonNetworkSettings;
|
||||||
|
|
||||||
|
GraphicLabel labelShadows;
|
||||||
|
GraphicListBox listBoxShadows;
|
||||||
|
GraphicLabel labelFilter;
|
||||||
|
GraphicListBox listBoxFilter;
|
||||||
|
GraphicLabel labelTextures3D;
|
||||||
|
GraphicCheckBox checkBoxTextures3D;
|
||||||
|
GraphicLabel labelLights;
|
||||||
|
GraphicListBox listBoxLights;
|
||||||
|
GraphicLabel labelUnitParticles;
|
||||||
|
GraphicCheckBox checkBoxUnitParticles;
|
||||||
|
GraphicLabel labelTilesetParticles;
|
||||||
|
GraphicCheckBox checkBoxTilesetParticles;
|
||||||
|
|
||||||
|
GraphicLabel labelScreenModes;
|
||||||
|
GraphicListBox listBoxScreenModes;
|
||||||
|
vector<ModeInfo> modeInfos;
|
||||||
|
|
||||||
|
GraphicLabel labelFullscreenWindowed;
|
||||||
|
GraphicCheckBox checkBoxFullscreenWindowed;
|
||||||
|
|
||||||
|
|
||||||
|
GraphicLabel labelMapPreview;
|
||||||
|
GraphicCheckBox checkBoxMapPreview;
|
||||||
|
|
||||||
|
GraphicMessageBox mainMessageBox;
|
||||||
|
int mainMessageBoxState;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableTextureCompression;
|
||||||
|
GraphicCheckBox checkBoxEnableTextureCompression;
|
||||||
|
|
||||||
|
GraphicLabel labelRainEffect;
|
||||||
|
GraphicLabel labelRainEffectSeparator;
|
||||||
|
GraphicCheckBox checkBoxRainEffect;
|
||||||
|
GraphicCheckBox checkBoxRainEffectMenu;
|
||||||
|
|
||||||
|
GraphicLabel labelGammaCorrection;
|
||||||
|
GraphicListBox listBoxGammaCorrection;
|
||||||
|
|
||||||
|
GraphicLabel labelShadowTextureSize;
|
||||||
|
GraphicListBox listBoxShadowTextureSize;
|
||||||
|
|
||||||
|
GraphicLabel labelVideos;
|
||||||
|
GraphicCheckBox checkBoxVideos;
|
||||||
|
|
||||||
|
GraphicLabel labelSelectionType;
|
||||||
|
GraphicListBox listBoxSelectionType;
|
||||||
|
|
||||||
|
ProgramState **parentUI;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MenuStateOptionsGraphics(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);
|
||||||
|
|
||||||
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
|
void render();
|
||||||
|
//virtual void keyDown(SDL_KeyboardEvent key);
|
||||||
|
virtual void keyPress(SDL_KeyboardEvent c);
|
||||||
|
//virtual bool isInSpecialKeyCaptureEvent();
|
||||||
|
|
||||||
|
virtual void reloadUI();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void saveConfig();
|
||||||
|
void setActiveInputLable(GraphicLabel* newLable);
|
||||||
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
|
|
||||||
|
void setupTransifexUI();
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
550
source/glest_game/menu/menu_state_options_network.cpp
Normal file
550
source/glest_game/menu/menu_state_options_network.cpp
Normal file
|
@ -0,0 +1,550 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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_network.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
|
||||||
|
// =====================================================
|
||||||
|
MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program, MainMenu *mainMenu, ProgramState **parentUI):
|
||||||
|
MenuState(program, mainMenu, "config")
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
containerName = "Options";
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
this->parentUI=parentUI;
|
||||||
|
this->console.setOnlyChatMessagesInStoredLines(false);
|
||||||
|
//modeinfos=list<ModeInfo> ();
|
||||||
|
int leftLabelStart=50;
|
||||||
|
int leftColumnStart=leftLabelStart+180;
|
||||||
|
int rightLabelStart=450;
|
||||||
|
int rightColumnStart=rightLabelStart+280;
|
||||||
|
int buttonRowPos=50;
|
||||||
|
int buttonStartPos=170;
|
||||||
|
int captionOffset=75;
|
||||||
|
int currentLabelStart=leftLabelStart;
|
||||||
|
int currentColumnStart=leftColumnStart;
|
||||||
|
int currentLine=700;
|
||||||
|
int lineOffset=27;
|
||||||
|
int tabButtonWidth=200;
|
||||||
|
int tabButtonHeight=30;
|
||||||
|
|
||||||
|
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
mainMessageBoxState=0;
|
||||||
|
|
||||||
|
buttonAudioSection.registerGraphicComponent(containerName,"buttonAudioSection");
|
||||||
|
buttonAudioSection.init(0, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
// Video Section
|
||||||
|
buttonVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||||
|
buttonVideoSection.init(200, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
//currentLine-=lineOffset;
|
||||||
|
//MiscSection
|
||||||
|
buttonMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
||||||
|
buttonMiscSection.init(400, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
//NetworkSettings
|
||||||
|
buttonNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
|
||||||
|
buttonNetworkSettings.init(600, 700,tabButtonWidth,tabButtonHeight+20);
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
//KeyboardSetup
|
||||||
|
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
|
||||||
|
buttonKeyboardSetup.init(800, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
|
||||||
|
|
||||||
|
currentLine=650; // reset line pos
|
||||||
|
currentLabelStart=leftLabelStart; // set to right side
|
||||||
|
currentColumnStart=leftColumnStart; // set to right side
|
||||||
|
|
||||||
|
|
||||||
|
// external server port
|
||||||
|
labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort");
|
||||||
|
labelPublishServerExternalPort.init(currentLabelStart, currentLine, 150);
|
||||||
|
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
|
||||||
|
|
||||||
|
labelExternalPort.init(currentColumnStart,currentLine);
|
||||||
|
string extPort= config.getString("PortExternal","not set");
|
||||||
|
if(extPort == "not set" || extPort == "0"){
|
||||||
|
extPort=" --- ";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
extPort="!!! "+extPort+" !!!";
|
||||||
|
}
|
||||||
|
labelExternalPort.setText(extPort);
|
||||||
|
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
// server port
|
||||||
|
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
|
||||||
|
labelServerPortLabel.init(currentLabelStart,currentLine);
|
||||||
|
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||||
|
|
||||||
|
listBoxServerPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort");
|
||||||
|
listBoxServerPort.init(currentColumnStart, currentLine, 170);
|
||||||
|
|
||||||
|
string portListString = config.getString("PortList",intToStr(GameConstants::serverPort).c_str());
|
||||||
|
std::vector<std::string> portList;
|
||||||
|
Tokenize(portListString,portList,",");
|
||||||
|
|
||||||
|
string currentPort=config.getString("PortServer", intToStr(GameConstants::serverPort).c_str());
|
||||||
|
int portSelectionIndex=0;
|
||||||
|
for(int idx = 0; idx < portList.size(); idx++) {
|
||||||
|
if(portList[idx] != "" && IsNumeric(portList[idx].c_str(),false)) {
|
||||||
|
listBoxServerPort.pushBackItem(portList[idx]);
|
||||||
|
if(currentPort==portList[idx])
|
||||||
|
{
|
||||||
|
portSelectionIndex=idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listBoxServerPort.setSelectedItemIndex(portSelectionIndex);
|
||||||
|
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
labelFTPServerPortLabel.registerGraphicComponent(containerName,"labelFTPServerPortLabel");
|
||||||
|
labelFTPServerPortLabel.init(currentLabelStart ,currentLine );
|
||||||
|
labelFTPServerPortLabel.setText(lang.get("FTPServerPort"));
|
||||||
|
|
||||||
|
int FTPPort = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
||||||
|
labelFTPServerPort.registerGraphicComponent(containerName,"labelFTPServerPort");
|
||||||
|
labelFTPServerPort.init(currentColumnStart ,currentLine );
|
||||||
|
labelFTPServerPort.setText(intToStr(FTPPort));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
labelFTPServerDataPortsLabel.registerGraphicComponent(containerName,"labelFTPServerDataPortsLabel");
|
||||||
|
labelFTPServerDataPortsLabel.init(currentLabelStart ,currentLine );
|
||||||
|
labelFTPServerDataPortsLabel.setText(lang.get("FTPServerDataPort"));
|
||||||
|
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8096,"%d - %d",FTPPort + 1, FTPPort + GameConstants::maxPlayers);
|
||||||
|
|
||||||
|
labelFTPServerDataPorts.registerGraphicComponent(containerName,"labelFTPServerDataPorts");
|
||||||
|
labelFTPServerDataPorts.init(currentColumnStart,currentLine );
|
||||||
|
labelFTPServerDataPorts.setText(szBuf);
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
labelEnableFTPServer.registerGraphicComponent(containerName,"labelEnableFTPServer");
|
||||||
|
labelEnableFTPServer.init(currentLabelStart ,currentLine);
|
||||||
|
labelEnableFTPServer.setText(lang.get("EnableFTPServer"));
|
||||||
|
|
||||||
|
checkBoxEnableFTPServer.registerGraphicComponent(containerName,"checkBoxEnableFTPServer");
|
||||||
|
checkBoxEnableFTPServer.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTPServer.setValue(config.getBool("EnableFTPServer","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
// FTP Config - start
|
||||||
|
labelEnableFTP.registerGraphicComponent(containerName,"labelEnableFTP");
|
||||||
|
labelEnableFTP.init(currentLabelStart ,currentLine);
|
||||||
|
labelEnableFTP.setText(lang.get("EnableFTP"));
|
||||||
|
|
||||||
|
checkBoxEnableFTP.registerGraphicComponent(containerName,"checkBoxEnableFTP");
|
||||||
|
checkBoxEnableFTP.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTP.setValue(config.getBool("EnableFTPXfer","true"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTilesetXfer");
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.init(currentLabelStart ,currentLine );
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.setText(lang.get("EnableFTPServerInternetTilesetXfer"));
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTilesetXfer");
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.setValue(config.getBool("EnableFTPServerInternetTilesetXfer","true"));
|
||||||
|
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTechtreeXfer");
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.init(currentLabelStart ,currentLine );
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.setText(lang.get("EnableFTPServerInternetTechtreeXfer"));
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTechtreeXfer");
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.setValue(config.getBool("EnableFTPServerInternetTechtreeXfer","true"));
|
||||||
|
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
|
||||||
|
// FTP config end
|
||||||
|
|
||||||
|
// Privacy flag
|
||||||
|
labelEnablePrivacy.registerGraphicComponent(containerName,"labelEnablePrivacy");
|
||||||
|
labelEnablePrivacy.init(currentLabelStart ,currentLine);
|
||||||
|
labelEnablePrivacy.setText(lang.get("PrivacyPlease"));
|
||||||
|
|
||||||
|
checkBoxEnablePrivacy.registerGraphicComponent(containerName,"checkBoxEnablePrivacy");
|
||||||
|
checkBoxEnablePrivacy.init(currentColumnStart ,currentLine );
|
||||||
|
checkBoxEnablePrivacy.setValue(config.getBool("PrivacyPlease","false"));
|
||||||
|
//currentLine-=lineOffset;
|
||||||
|
// end
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||||
|
buttonOk.init(buttonStartPos, buttonRowPos, 100);
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
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 MenuStateOptionsNetwork::reloadUI() {
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
console.resetFonts();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
std::vector<string> listboxData;
|
||||||
|
listboxData.push_back("None");
|
||||||
|
listboxData.push_back("OpenAL");
|
||||||
|
// deprecated as of 3.6.1
|
||||||
|
//#ifdef WIN32
|
||||||
|
// listboxData.push_back("DirectSound8");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
listboxData.push_back("Bilinear");
|
||||||
|
listboxData.push_back("Trilinear");
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
for (float f=0.0;f<2.1f;f=f+0.1f) {
|
||||||
|
listboxData.push_back(floatToStr(f));
|
||||||
|
}
|
||||||
|
listboxData.clear();
|
||||||
|
for(int i= 0; i<Renderer::sCount; ++i){
|
||||||
|
listboxData.push_back(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||||
|
|
||||||
|
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
|
||||||
|
|
||||||
|
labelEnableFTP.setText(lang.get("EnableFTP"));
|
||||||
|
|
||||||
|
labelEnableFTPServer.setText(lang.get("EnableFTPServer"));
|
||||||
|
|
||||||
|
labelFTPServerPortLabel.setText(lang.get("FTPServerPort"));
|
||||||
|
|
||||||
|
labelFTPServerDataPortsLabel.setText(lang.get("FTPServerDataPort"));
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTilesetXfer.setText(lang.get("EnableFTPServerInternetTilesetXfer"));
|
||||||
|
|
||||||
|
labelEnableFTPServerInternetTechtreeXfer.setText(lang.get("EnableFTPServerInternetTechtreeXfer"));
|
||||||
|
|
||||||
|
labelEnablePrivacy.setText(lang.get("PrivacyPlease"));
|
||||||
|
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
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();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(buttonOk.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
saveConfig();
|
||||||
|
//mainMenu->setState(new MenuStateOptions(program, mainMenu,this->parentUI));
|
||||||
|
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(buttonAudioSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptionsSound(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonNetworkSettings.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
//mainMenu->setState(new MenuStateOptionsNetwork(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonMiscSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptions(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonVideoSection.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateOptionsGraphics(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(buttonKeyboardSetup.mouseClick(x, y)){
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
mainMenu->setState(new MenuStateKeysetup(program, mainMenu,this->parentUI)); // open keyboard shortcuts setup screen
|
||||||
|
//showMessageBox("Not implemented yet", "Keyboard setup", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(listBoxServerPort.mouseClick(x, y)){
|
||||||
|
int selectedPort=strToInt(listBoxServerPort.getSelectedItem());
|
||||||
|
if(selectedPort<10000){
|
||||||
|
selectedPort=GameConstants::serverPort;
|
||||||
|
}
|
||||||
|
// use the following ports for ftp
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8096,"%d - %d",selectedPort + 2, selectedPort + 1 + GameConstants::maxPlayers);
|
||||||
|
labelFTPServerPort.setText(intToStr(selectedPort+1));
|
||||||
|
labelFTPServerDataPorts.setText(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkBoxEnableFTP.mouseClick(x, y);
|
||||||
|
checkBoxEnableFTPServer.mouseClick(x, y);
|
||||||
|
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.mouseClick(x, y);
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.mouseClick(x, y);
|
||||||
|
|
||||||
|
checkBoxEnablePrivacy.mouseClick(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::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);
|
||||||
|
listBoxServerPort.mouseMove(x, y);
|
||||||
|
checkBoxEnableFTP.mouseMove(x, y);
|
||||||
|
checkBoxEnableFTPServer.mouseMove(x, y);
|
||||||
|
checkBoxEnableFTPServerInternetTilesetXfer.mouseMove(x, y);
|
||||||
|
checkBoxEnableFTPServerInternetTechtreeXfer.mouseMove(x, y);
|
||||||
|
checkBoxEnablePrivacy.mouseMove(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool MenuStateOptionsNetwork::isInSpecialKeyCaptureEvent() {
|
||||||
|
// return (activeInputLabel != NULL);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void MenuStateOptionsNetwork::keyDown(SDL_KeyboardEvent key) {
|
||||||
|
// if(activeInputLabel != NULL) {
|
||||||
|
// keyDownEditLabel(key, &activeInputLabel);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::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();
|
||||||
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::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.renderLabel(&labelServerPortLabel);
|
||||||
|
renderer.renderLabel(&labelExternalPort);
|
||||||
|
renderer.renderLabel(&labelPublishServerExternalPort);
|
||||||
|
renderer.renderListBox(&listBoxServerPort);
|
||||||
|
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnableFTP);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTP);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnableFTPServer);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTPServer);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelFTPServerPortLabel);
|
||||||
|
renderer.renderLabel(&labelFTPServerPort);
|
||||||
|
renderer.renderLabel(&labelFTPServerDataPortsLabel);
|
||||||
|
renderer.renderLabel(&labelFTPServerDataPorts);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnableFTPServerInternetTilesetXfer);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTPServerInternetTilesetXfer);
|
||||||
|
renderer.renderLabel(&labelEnableFTPServerInternetTechtreeXfer);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnableFTPServerInternetTechtreeXfer);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelEnablePrivacy);
|
||||||
|
renderer.renderCheckBox(&checkBoxEnablePrivacy);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.renderConsole(&console,false,true);
|
||||||
|
if(program != NULL) program->renderProgramMsgBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::saveConfig(){
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
setActiveInputLable(NULL);
|
||||||
|
|
||||||
|
|
||||||
|
lang.loadStrings(config.getString("Lang"));
|
||||||
|
|
||||||
|
config.setString("PortServer", listBoxServerPort.getSelectedItem());
|
||||||
|
config.setInt("FTPServerPort",config.getInt("PortServer")+1);
|
||||||
|
config.setBool("EnableFTPXfer", checkBoxEnableFTP.getValue());
|
||||||
|
config.setBool("EnableFTPServer", checkBoxEnableFTPServer.getValue());
|
||||||
|
|
||||||
|
config.setBool("EnableFTPServerInternetTilesetXfer", checkBoxEnableFTPServerInternetTilesetXfer.getValue());
|
||||||
|
config.setBool("EnableFTPServerInternetTechtreeXfer", checkBoxEnableFTPServerInternetTechtreeXfer.getValue());
|
||||||
|
|
||||||
|
config.setBool("PrivacyPlease", checkBoxEnablePrivacy.getValue());
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
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();
|
||||||
|
console.addLine(lang.get("SettingsSaved"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsNetwork::setActiveInputLable(GraphicLabel *newLable) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}}//end namespace
|
90
source/glest_game/menu/menu_state_options_network.h
Normal file
90
source/glest_game/menu/menu_state_options_network.h
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _GLEST_GAME_MENUSTATEOPTIONS_NETWORK_H_
|
||||||
|
#define _GLEST_GAME_MENUSTATEOPTIONS_NETWORK_H_
|
||||||
|
|
||||||
|
#include "main_menu.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// ===============================
|
||||||
|
// class MenuStateOptionsNetwork
|
||||||
|
// ===============================
|
||||||
|
|
||||||
|
class MenuStateOptionsNetwork: public MenuState{
|
||||||
|
private:
|
||||||
|
|
||||||
|
GraphicButton buttonOk;
|
||||||
|
GraphicButton buttonReturn;
|
||||||
|
|
||||||
|
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
||||||
|
GraphicButton buttonVideoSection;
|
||||||
|
GraphicButton buttonAudioSection;
|
||||||
|
GraphicButton buttonMiscSection;
|
||||||
|
GraphicButton buttonNetworkSettings;
|
||||||
|
|
||||||
|
|
||||||
|
GraphicMessageBox mainMessageBox;
|
||||||
|
int mainMessageBoxState;
|
||||||
|
|
||||||
|
GraphicLabel labelExternalPort;
|
||||||
|
GraphicLabel labelServerPortLabel;
|
||||||
|
|
||||||
|
GraphicLabel labelPublishServerExternalPort;
|
||||||
|
GraphicListBox listBoxServerPort;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTP;
|
||||||
|
GraphicCheckBox checkBoxEnableFTP;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTPServer;
|
||||||
|
GraphicCheckBox checkBoxEnableFTPServer;
|
||||||
|
|
||||||
|
GraphicLabel labelFTPServerPortLabel;
|
||||||
|
GraphicLabel labelFTPServerPort;
|
||||||
|
|
||||||
|
GraphicLabel labelFTPServerDataPortsLabel;
|
||||||
|
GraphicLabel labelFTPServerDataPorts;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTPServerInternetTilesetXfer;
|
||||||
|
GraphicCheckBox checkBoxEnableFTPServerInternetTilesetXfer;
|
||||||
|
|
||||||
|
GraphicLabel labelEnableFTPServerInternetTechtreeXfer;
|
||||||
|
GraphicCheckBox checkBoxEnableFTPServerInternetTechtreeXfer;
|
||||||
|
|
||||||
|
GraphicLabel labelEnablePrivacy;
|
||||||
|
GraphicCheckBox checkBoxEnablePrivacy;
|
||||||
|
|
||||||
|
ProgramState **parentUI;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MenuStateOptionsNetwork(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);
|
||||||
|
|
||||||
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
|
void render();
|
||||||
|
//virtual void keyDown(SDL_KeyboardEvent key);
|
||||||
|
virtual void keyPress(SDL_KeyboardEvent c);
|
||||||
|
//virtual bool isInSpecialKeyCaptureEvent();
|
||||||
|
|
||||||
|
virtual void reloadUI();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void saveConfig();
|
||||||
|
void setActiveInputLable(GraphicLabel* newLable);
|
||||||
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
461
source/glest_game/menu/menu_state_options_sound.cpp
Normal file
461
source/glest_game/menu/menu_state_options_sound.cpp
Normal file
|
@ -0,0 +1,461 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
int leftLabelStart=50;
|
||||||
|
int leftColumnStart=leftLabelStart+180;
|
||||||
|
int rightLabelStart=450;
|
||||||
|
int rightColumnStart=rightLabelStart+280;
|
||||||
|
int buttonRowPos=50;
|
||||||
|
int buttonStartPos=170;
|
||||||
|
int captionOffset=75;
|
||||||
|
int currentLabelStart=leftLabelStart;
|
||||||
|
int currentColumnStart=leftColumnStart;
|
||||||
|
int currentLine=700;
|
||||||
|
int lineOffset=27;
|
||||||
|
int tabButtonWidth=200;
|
||||||
|
int tabButtonHeight=30;
|
||||||
|
|
||||||
|
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
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());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
// Video Section
|
||||||
|
buttonVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
|
||||||
|
buttonVideoSection.init(200, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
//currentLine-=lineOffset;
|
||||||
|
//MiscSection
|
||||||
|
buttonMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
|
||||||
|
buttonMiscSection.init(400, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
//NetworkSettings
|
||||||
|
buttonNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
|
||||||
|
buttonNetworkSettings.init(600, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
//KeyboardSetup
|
||||||
|
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
|
||||||
|
buttonKeyboardSetup.init(800, 720,tabButtonWidth,tabButtonHeight);
|
||||||
|
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
|
||||||
|
|
||||||
|
currentLine=650; // reset line pos
|
||||||
|
currentLabelStart=leftLabelStart; // set to right side
|
||||||
|
currentColumnStart=leftColumnStart; // set to right side
|
||||||
|
|
||||||
|
//soundboxes
|
||||||
|
labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory");
|
||||||
|
labelSoundFactory.init(currentLabelStart, currentLine);
|
||||||
|
labelSoundFactory.setText(lang.get("SoundAndMusic"));
|
||||||
|
|
||||||
|
listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory");
|
||||||
|
listBoxSoundFactory.init(currentColumnStart, currentLine, 100);
|
||||||
|
listBoxSoundFactory.pushBackItem("None");
|
||||||
|
listBoxSoundFactory.pushBackItem("OpenAL");
|
||||||
|
// deprecated as of 3.6.1
|
||||||
|
//#ifdef WIN32
|
||||||
|
//listBoxSoundFactory.pushBackItem("DirectSound8");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
listBoxSoundFactory.setSelectedItem(config.getString("FactorySound"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelVolumeFx.registerGraphicComponent(containerName,"labelVolumeFx");
|
||||||
|
labelVolumeFx.init(currentLabelStart, currentLine);
|
||||||
|
labelVolumeFx.setText(lang.get("FxVolume"));
|
||||||
|
|
||||||
|
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);
|
||||||
|
labelVolumeAmbient.setText(lang.get("AmbientVolume"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
|
||||||
|
labelVolumeMusic.init(currentLabelStart, currentLine);
|
||||||
|
|
||||||
|
listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic");
|
||||||
|
listBoxVolumeMusic.init(currentColumnStart, currentLine, 80);
|
||||||
|
labelVolumeMusic.setText(lang.get("MusicVolume"));
|
||||||
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
currentLine-=lineOffset/2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
///////// RIGHT SIDE
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
currentLine=700; // reset line pos
|
||||||
|
currentLabelStart=rightLabelStart; // set to right side
|
||||||
|
currentColumnStart=rightColumnStart; // set to right side
|
||||||
|
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
buttonOk.registerGraphicComponent(containerName,"buttonOk");
|
||||||
|
buttonOk.init(buttonStartPos, buttonRowPos, 100);
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
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();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
|
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonAudioSection.setText(lang.get("Audio"));
|
||||||
|
|
||||||
|
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonVideoSection.setText(lang.get("Video"));
|
||||||
|
|
||||||
|
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonMiscSection.setText(lang.get("Misc"));
|
||||||
|
|
||||||
|
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
buttonNetworkSettings.setText(lang.get("Network"));
|
||||||
|
|
||||||
|
labelSoundFactory.setText(lang.get("SoundAndMusic"));
|
||||||
|
|
||||||
|
std::vector<string> listboxData;
|
||||||
|
listboxData.push_back("None");
|
||||||
|
listboxData.push_back("OpenAL");
|
||||||
|
// deprecated as of 3.6.1
|
||||||
|
//#ifdef WIN32
|
||||||
|
// listboxData.push_back("DirectSound8");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
listBoxSoundFactory.setItems(listboxData);
|
||||||
|
|
||||||
|
labelVolumeFx.setText(lang.get("FxVolume"));
|
||||||
|
|
||||||
|
labelVolumeAmbient.setText(lang.get("AmbientVolume"));
|
||||||
|
labelVolumeMusic.setText(lang.get("MusicVolume"));
|
||||||
|
|
||||||
|
|
||||||
|
listboxData.clear();
|
||||||
|
|
||||||
|
buttonOk.setText(lang.get("Save"));
|
||||||
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
|
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuStateOptionsSound::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
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();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(mainMessageBoxState == 1) {
|
||||||
|
mainMessageBoxState=0;
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer.renderConsole(&console,false,true);
|
||||||
|
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();
|
||||||
|
console.addLine(lang.get("SettingsSaved"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuStateOptionsSound::setActiveInputLable(GraphicLabel *newLable) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}}//end namespace
|
74
source/glest_game/menu/menu_state_options_sound.h
Normal file
74
source/glest_game/menu/menu_state_options_sound.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
// ==============================================================
|
||||||
|
// 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
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _GLEST_GAME_MENUSTATEOPTIONS_SOUND_H_
|
||||||
|
#define _GLEST_GAME_MENUSTATEOPTIONS_SOUND_H_
|
||||||
|
|
||||||
|
#include "main_menu.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// ===============================
|
||||||
|
// class MenuStateOptionsSound
|
||||||
|
// ===============================
|
||||||
|
|
||||||
|
class MenuStateOptionsSound: public MenuState{
|
||||||
|
private:
|
||||||
|
|
||||||
|
GraphicButton buttonOk;
|
||||||
|
GraphicButton buttonReturn;
|
||||||
|
|
||||||
|
GraphicButton buttonKeyboardSetup; // configure the keyboard
|
||||||
|
GraphicButton buttonVideoSection;
|
||||||
|
GraphicButton buttonAudioSection;
|
||||||
|
GraphicButton buttonMiscSection;
|
||||||
|
GraphicButton buttonNetworkSettings;
|
||||||
|
|
||||||
|
GraphicLabel labelSoundFactory;
|
||||||
|
GraphicListBox listBoxSoundFactory;
|
||||||
|
|
||||||
|
GraphicLabel labelVolumeFx;
|
||||||
|
GraphicListBox listBoxVolumeFx;
|
||||||
|
|
||||||
|
GraphicLabel labelVolumeAmbient;
|
||||||
|
GraphicListBox listBoxVolumeAmbient;
|
||||||
|
|
||||||
|
GraphicLabel labelVolumeMusic;
|
||||||
|
GraphicListBox listBoxVolumeMusic;
|
||||||
|
|
||||||
|
GraphicMessageBox mainMessageBox;
|
||||||
|
int mainMessageBoxState;
|
||||||
|
|
||||||
|
ProgramState **parentUI;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MenuStateOptionsSound(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);
|
||||||
|
|
||||||
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
|
void render();
|
||||||
|
//virtual void keyDown(SDL_KeyboardEvent key);
|
||||||
|
virtual void keyPress(SDL_KeyboardEvent c);
|
||||||
|
//virtual bool isInSpecialKeyCaptureEvent();
|
||||||
|
|
||||||
|
virtual void reloadUI();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void saveConfig();
|
||||||
|
void setActiveInputLable(GraphicLabel* newLable);
|
||||||
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user