QTfrontend/gameuiconfig.cpp
changeset 8434 4821897a0f10
parent 8387 f9d1191476ce
child 8444 75db7bb8dce8
child 8609 3f6c08223aa1
equal deleted inserted replaced
8432:f2d57e987ba9 8434:4821897a0f10
    81             Form->ui.pageOptions->CBResolution->setCurrentIndex(1);
    81             Form->ui.pageOptions->CBResolution->setCurrentIndex(1);
    82         else
    82         else
    83             Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
    83             Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
    84     }
    84     }
    85     else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);
    85     else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);
    86     
    86 
    87     // Default the windowed resolution to 5/6 of the screen size
    87     // Default the windowed resolution to 5/6 of the screen size
    88     int screenWidth = SDL_GetVideoInfo()->current_w * 5 / 6;
    88     int screenWidth = SDL_GetVideoInfo()->current_w * 5 / 6;
    89     int screenHeight = SDL_GetVideoInfo()->current_h * 5 / 6;
    89     int screenHeight = SDL_GetVideoInfo()->current_h * 5 / 6;
    90     QString widthStr; widthStr.setNum(screenWidth);
    90     QString widthStr; widthStr.setNum(screenWidth);
    91     QString heightStr; heightStr.setNum(screenHeight);
    91     QString heightStr; heightStr.setNum(screenHeight);
    94     // If left blank reset the resolution to the default
    94     // If left blank reset the resolution to the default
    95     wWidth = (wWidth == "" ? widthStr : wWidth);
    95     wWidth = (wWidth == "" ? widthStr : wWidth);
    96     wHeight = (wHeight == "" ? heightStr : wHeight);
    96     wHeight = (wHeight == "" ? heightStr : wHeight);
    97     Form->ui.pageOptions->windowWidthEdit->setText(wWidth);
    97     Form->ui.pageOptions->windowWidthEdit->setText(wWidth);
    98     Form->ui.pageOptions->windowHeightEdit->setText(wHeight);
    98     Form->ui.pageOptions->windowHeightEdit->setText(wHeight);
    99     
    99 
   100     Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
   100     Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
   101     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
   101     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
   102     bool ffscr=value("frontend/fullscreen", false).toBool();
   102     bool ffscr=value("frontend/fullscreen", false).toBool();
   103     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
   103     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
   104 
   104 
   261     setValue("frontend/music", isFrontendMusicEnabled());
   261     setValue("frontend/music", isFrontendMusicEnabled());
   262     setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());
   262     setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());
   263 
   263 
   264     setValue("net/nick", netNick());
   264     setValue("net/nick", netNick());
   265     if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
   265     if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
   266 	setPasswordHash(netPasswordHash());
   266         setPasswordHash(netPasswordHash());
   267     }
   267     }
   268     else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
   268     else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
   269         clearPasswordHash();
   269         clearPasswordHash();
   270     }
   270     }
   271 
   271 
   370 QRect GameUIConfig::vid_Resolution()
   370 QRect GameUIConfig::vid_Resolution()
   371 {
   371 {
   372     std::pair<QRect, QRect> result = vid_ResolutionPair();
   372     std::pair<QRect, QRect> result = vid_ResolutionPair();
   373     if(Form->ui.pageOptions->CBFullscreen->isChecked())
   373     if(Form->ui.pageOptions->CBFullscreen->isChecked())
   374         return result.first;
   374         return result.first;
   375     else 
   375     else
   376         return result.second;
   376         return result.second;
   377 }
   377 }
   378 
   378 
   379 bool GameUIConfig::vid_Fullscreen()
   379 bool GameUIConfig::vid_Fullscreen()
   380 {
   380 {
   513 bool GameUIConfig::netPasswordIsValid()
   513 bool GameUIConfig::netPasswordIsValid()
   514 {
   514 {
   515     return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*'));
   515     return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*'));
   516 }
   516 }
   517 
   517 
   518 void GameUIConfig::clearPasswordHash() 
   518 void GameUIConfig::clearPasswordHash()
   519 {
   519 {
   520     setValue("net/passwordhash", QString());
   520     setValue("net/passwordhash", QString());
   521     setValue("net/passwordlength", 0);
   521     setValue("net/passwordlength", 0);
   522     setValue("net/savepassword", false); //changes the savepassword value to false in order to not let the user save an empty password in PAGE_SETUP
   522     setValue("net/savepassword", false); //changes the savepassword value to false in order to not let the user save an empty password in PAGE_SETUP
   523     reloadValues(); //reloads the values of PAGE_SETUP
   523     reloadValues(); //reloads the values of PAGE_SETUP
   533 QString GameUIConfig::passwordHash()
   533 QString GameUIConfig::passwordHash()
   534 {
   534 {
   535     return value("net/passwordhash").toString();
   535     return value("net/passwordhash").toString();
   536 }
   536 }
   537 
   537 
   538 void GameUIConfig::clearTempHash() 
   538 void GameUIConfig::clearTempHash()
   539 {
   539 {
   540     setTempHash(QString());
   540     setTempHash(QString());
   541 }
   541 }
   542 
   542 
   543 void GameUIConfig::setTempHash(const QString & temphash)
   543 void GameUIConfig::setTempHash(const QString & temphash)