mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 06:01:17 +02:00
improved resolution change in options menu
This commit is contained in:
@@ -46,7 +46,9 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
int buttonRowPos=80;
|
||||
int captionOffset=75;
|
||||
|
||||
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
mainMessageBoxState=0;
|
||||
|
||||
labelAudioSection.init(leftLabelStart+captionOffset, leftline);
|
||||
labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
@@ -119,7 +121,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
for(list<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){
|
||||
listBoxScreenModes.pushBackItem((*it).getString());
|
||||
}
|
||||
listBoxScreenModes.setSelectedItem(config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight"));
|
||||
listBoxScreenModes.setSelectedItem(config.getString("ScreenWidth")+"x"+
|
||||
config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits")));
|
||||
leftline-=30;
|
||||
|
||||
//filter
|
||||
@@ -180,14 +183,58 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
|
||||
}
|
||||
|
||||
void MenuStateOptions::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 MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
||||
Config &config= Config::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
|
||||
if(buttonOk.mouseClick(x, y)){
|
||||
if(mainMessageBox.getEnabled()){
|
||||
int button= 1;
|
||||
if(mainMessageBox.mouseClick(x, y, button))
|
||||
{
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
if(button==1)
|
||||
{
|
||||
if(mainMessageBoxState==1)
|
||||
{
|
||||
mainMessageBox.setEnabled(false);
|
||||
saveConfig();
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
}
|
||||
else
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(buttonOk.mouseClick(x, y)){
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
|
||||
string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight")+"-"+intToStr(config.getInt("ColorBits"));
|
||||
string selectedResolution=listBoxScreenModes.getSelectedItem();
|
||||
if(currentResolution!=selectedResolution){
|
||||
mainMessageBoxState=1;
|
||||
Lang &lang= Lang::getInstance();
|
||||
showMessageBox(lang.get("RestartNeeded"), lang.get("ResolutionChanged"), false);
|
||||
return;
|
||||
}
|
||||
saveConfig();
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
}
|
||||
@@ -220,6 +267,9 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
}
|
||||
|
||||
void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){
|
||||
if (mainMessageBox.getEnabled()) {
|
||||
mainMessageBox.mouseMove(x, y);
|
||||
}
|
||||
buttonOk.mouseMove(x, y);
|
||||
buttonAbort.mouseMove(x, y);
|
||||
buttonAutoConfig.mouseMove(x, y);
|
||||
@@ -269,6 +319,11 @@ void MenuStateOptions::keyPress(char c){
|
||||
void MenuStateOptions::render(){
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
if(mainMessageBox.getEnabled()){
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.renderButton(&buttonOk);
|
||||
renderer.renderButton(&buttonAbort);
|
||||
renderer.renderButton(&buttonAutoConfig);
|
||||
@@ -298,6 +353,7 @@ void MenuStateOptions::render(){
|
||||
renderer.renderLabel(&labelScreenModes);
|
||||
renderer.renderListBox(&listBoxScreenModes);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateOptions::saveConfig(){
|
||||
Config &config= Config::getInstance();
|
||||
@@ -333,6 +389,7 @@ void MenuStateOptions::saveConfig(){
|
||||
{
|
||||
config.setInt("ScreenWidth",(*it).width);
|
||||
config.setInt("ScreenHeight",(*it).height);
|
||||
config.setInt("ColorBits",(*it).depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -56,6 +56,9 @@ private:
|
||||
GraphicLabel labelAudioSection;
|
||||
GraphicLabel labelMiscSection;
|
||||
|
||||
GraphicMessageBox mainMessageBox;
|
||||
int mainMessageBoxState;
|
||||
|
||||
|
||||
public:
|
||||
MenuStateOptions(Program *program, MainMenu *mainMenu);
|
||||
@@ -70,6 +73,7 @@ public:
|
||||
private:
|
||||
void saveConfig();
|
||||
void setActiveInputLable(GraphicLabel* newLable);
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -576,7 +576,7 @@ void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
||||
uniqueResList[lookupKey] = true;
|
||||
modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel));
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel);
|
||||
}
|
||||
/* Check if our resolution is restricted */
|
||||
else if (modes == (SDL_Rect**)-1) {
|
||||
@@ -588,7 +588,7 @@ void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
||||
uniqueResList[lookupKey] = true;
|
||||
modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel));
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel);
|
||||
}
|
||||
else{
|
||||
/* Print valid modes */
|
||||
@@ -597,12 +597,19 @@ void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
||||
int bestW = -1;
|
||||
int bestH = -1;
|
||||
for(int i=0; modes[i]; ++i) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h,modes[i]->x);
|
||||
string lookupKey = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(modes[i]->x);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h,bpp);
|
||||
string lookupKey = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(bpp);
|
||||
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
||||
uniqueResList[lookupKey] = true;
|
||||
modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,modes[i]->x));
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h);
|
||||
modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,bpp));
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h,bpp);
|
||||
}
|
||||
// fake the missing 16 bit resolutions in linux
|
||||
string lookupKey16 = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(16);
|
||||
if(uniqueResList.find(lookupKey16) == uniqueResList.end()) {
|
||||
uniqueResList[lookupKey16] = true;
|
||||
modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,16));
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h,16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -706,7 +713,7 @@ ModeInfo::ModeInfo(int w, int h, int d) {
|
||||
}
|
||||
|
||||
string ModeInfo::getString() const{
|
||||
return intToStr(width)+"x"+intToStr(height);
|
||||
return intToStr(width)+"x"+intToStr(height)+"-"+intToStr(depth);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
Reference in New Issue
Block a user