- allow changing screen resolution and fullscreen mode in options menu with confirmation
This commit is contained in:
parent
f8ef92213d
commit
46869536bb
|
@ -27,19 +27,29 @@ Metrics::Metrics() {
|
||||||
reloadData();
|
reloadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::reload() {
|
void Metrics::reload(int resWidth, int resHeight) {
|
||||||
Metrics *metrics = getInstancePtr();
|
Metrics *metrics = getInstancePtr();
|
||||||
metrics->reloadData();
|
metrics->reloadData(resWidth, resHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::reloadData() {
|
void Metrics::reloadData(int resWidth, int resHeight) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
virtualW= 1000;
|
virtualW= 1000;
|
||||||
virtualH= 750;
|
virtualH= 750;
|
||||||
|
|
||||||
|
if(resWidth > 0) {
|
||||||
|
screenW= resWidth;
|
||||||
|
}
|
||||||
|
else {
|
||||||
screenW= config.getInt("ScreenWidth");
|
screenW= config.getInt("ScreenWidth");
|
||||||
|
}
|
||||||
|
if(resHeight > 0) {
|
||||||
|
screenH= resHeight;
|
||||||
|
}
|
||||||
|
else {
|
||||||
screenH= config.getInt("ScreenHeight");
|
screenH= config.getInt("ScreenHeight");
|
||||||
|
}
|
||||||
|
|
||||||
minimapX= 10;
|
minimapX= 10;
|
||||||
minimapY= 750-128-30+16;
|
minimapY= 750-128-30+16;
|
||||||
|
|
|
@ -44,7 +44,7 @@ private:
|
||||||
private:
|
private:
|
||||||
Metrics();
|
Metrics();
|
||||||
static Metrics *getInstancePtr();
|
static Metrics *getInstancePtr();
|
||||||
void reloadData();
|
void reloadData(int resWidth=-1, int resHeight=-1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const Metrics &getInstance();
|
static const Metrics &getInstance();
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
bool isInDisplay(int x, int y) const;
|
bool isInDisplay(int x, int y) const;
|
||||||
bool isInMinimap(int x, int y) const;
|
bool isInMinimap(int x, int y) const;
|
||||||
|
|
||||||
static void reload();
|
static void reload(int resWidth=-1, int resHeight=-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -866,12 +866,53 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
if(button == 0) {
|
if(button == 0) {
|
||||||
if(mainMessageBoxState == 1) {
|
if(mainMessageBoxState == 1) {
|
||||||
|
mainMessageBoxState=0;
|
||||||
mainMessageBox.setEnabled(false);
|
mainMessageBox.setEnabled(false);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"));
|
||||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mainMessageBox.setEnabled(false);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -901,13 +942,62 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(buttonOk.mouseClick(x, y)){
|
else if(buttonOk.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
||||||
|
bool selectedFullscreenWindowed = checkBoxFullscreenWindowed.getValue();
|
||||||
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
|
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
|
||||||
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||||
if(currentResolution != selectedResolution){
|
if(currentResolution != selectedResolution){
|
||||||
//mainMessageBoxState=1;
|
// if(currentResolution != selectedResolution ||
|
||||||
//Lang &lang= Lang::getInstance();
|
// 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;
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
mainMessageBox.init(lang.get("Ok"),lang.get("Cancel"));
|
||||||
//showMessageBox(lang.get("RestartNeeded"), lang.get("ResolutionChanged"), false);
|
//showMessageBox(lang.get("RestartNeeded"), lang.get("ResolutionChanged"), false);
|
||||||
//return;
|
showMessageBox(lang.get("ResolutionChanged"), lang.get("Notice"), false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
string currentFontSizeAdjustment=config.getString("FontSizeAdjustment");
|
string currentFontSizeAdjustment=config.getString("FontSizeAdjustment");
|
||||||
string selectedFontSizeAdjustment=listFontSizeAdjustment.getSelectedItem();
|
string selectedFontSizeAdjustment=listFontSizeAdjustment.getSelectedItem();
|
||||||
|
@ -919,38 +1009,50 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool currentFullscreenWindowed=config.getBool("Windowed");
|
bool currentFullscreenWindowed=config.getBool("Windowed");
|
||||||
bool selectedFullscreenWindowed = checkBoxFullscreenWindowed.getValue();
|
//bool selectedFullscreenWindowed = checkBoxFullscreenWindowed.getValue();
|
||||||
if(currentFullscreenWindowed != selectedFullscreenWindowed) {
|
if(currentFullscreenWindowed != selectedFullscreenWindowed) {
|
||||||
//mainMessageBoxState=1;
|
//mainMessageBoxState=1;
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false);
|
//showMessageBox(lang.get("RestartNeeded"), lang.get("DisplaySettingsChanged"), false);
|
||||||
//return;
|
//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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveConfig();
|
|
||||||
|
|
||||||
if(currentResolution != selectedResolution ||
|
|
||||||
currentFullscreenWindowed != selectedFullscreenWindowed) {
|
|
||||||
|
|
||||||
changeVideoModeFullScreen(!config.getBool("Windowed"));
|
|
||||||
WindowGl *window = this->program->getWindow();
|
WindowGl *window = this->program->getWindow();
|
||||||
window->ChangeVideoMode(true,
|
window->ChangeVideoMode(true,
|
||||||
config.getInt("ScreenWidth"),
|
selectedMode->width,
|
||||||
config.getInt("ScreenHeight"),
|
selectedMode->height,
|
||||||
!config.getBool("Windowed"),
|
!selectedFullscreenWindowed,
|
||||||
config.getInt("ColorBits"),
|
selectedMode->depth,
|
||||||
config.getInt("DepthBits"),
|
config.getInt("DepthBits"),
|
||||||
config.getInt("StencilBits"),
|
config.getInt("StencilBits"),
|
||||||
config.getBool("HardwareAcceleration","false"),
|
config.getBool("HardwareAcceleration","false"),
|
||||||
config.getBool("FullScreenAntiAliasing","false"),
|
config.getBool("FullScreenAntiAliasing","false"),
|
||||||
config.getFloat("GammaValue","0.0"));
|
strToFloat(listBoxGammaCorrection.getSelectedItem()));
|
||||||
|
|
||||||
Metrics::reload();
|
Metrics::reload(selectedMode->width,selectedMode->height);
|
||||||
this->mainMenu->init();
|
this->mainMenu->init();
|
||||||
|
|
||||||
|
mainMessageBoxState=1;
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
//saveConfig();
|
||||||
return;
|
//mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||||
|
//return;
|
||||||
}
|
}
|
||||||
else if(buttonAbort.mouseClick(x, y)){
|
else if(buttonAbort.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
|
|
|
@ -62,6 +62,8 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//printf("In [%s::%s %d] PlatformCommon::Private::shouldBeFullscreen = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,PlatformCommon::Private::shouldBeFullscreen);
|
||||||
|
|
||||||
int flags = SDL_OPENGL;
|
int flags = SDL_OPENGL;
|
||||||
if(PlatformCommon::Private::shouldBeFullscreen) {
|
if(PlatformCommon::Private::shouldBeFullscreen) {
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user