QTfrontend/gameuiconfig.cpp
changeset 6616 f77bb02b669f
parent 6583 4218782d8ca0
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    42     resizeToConfigValues();
    42     resizeToConfigValues();
    43 
    43 
    44     Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());
    44     Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());
    45 
    45 
    46     int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString());
    46     int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString());
    47     if (t < 0) {
    47     if (t < 0)
       
    48     {
    48         if (Form->ui.pageOptions->CBResolution->count() > 1)
    49         if (Form->ui.pageOptions->CBResolution->count() > 1)
    49             Form->ui.pageOptions->CBResolution->setCurrentIndex(1);
    50             Form->ui.pageOptions->CBResolution->setCurrentIndex(1);
    50         else 
    51         else
    51             Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
    52             Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
    52     }
    53     }
    53     else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);
    54     else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);
    54     Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
    55     Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
    55     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
    56     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
    65     Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("frontend/music", true).toBool());
    66     Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("frontend/music", true).toBool());
    66     Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
    67     Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
    67 
    68 
    68     QString netNick = value("net/nick", "").toString();
    69     QString netNick = value("net/nick", "").toString();
    69     Form->ui.pageOptions->editNetNick->setText(netNick);
    70     Form->ui.pageOptions->editNetNick->setText(netNick);
    70     
    71 
    71     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
    72     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
    72     
    73 
    73     int passLength = value("net/passwordlength", 0).toInt();
    74     int passLength = value("net/passwordlength", 0).toInt();
    74     setNetPasswordLength(passLength);
    75     setNetPasswordLength(passLength);
    75 
    76 
    76     delete netHost;
    77     delete netHost;
    77     netHost = new QString(value("net/ip", "").toString());
    78     netHost = new QString(value("net/ip", "").toString());
    85 
    86 
    86     Form->ui.pageOptions->CBAltDamage->setChecked(value("misc/altdamage", false).toBool());
    87     Form->ui.pageOptions->CBAltDamage->setChecked(value("misc/altdamage", false).toBool());
    87     Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool());
    88     Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool());
    88 
    89 
    89 #ifdef SPARKLE_ENABLED
    90 #ifdef SPARKLE_ENABLED
    90         Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool());
    91     Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool());
    91 #endif
    92 #endif
    92 
    93 
    93     Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString()));
    94     Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString()));
    94 
    95 
    95     depth = HWApplication::desktop()->depth();
    96     depth = HWApplication::desktop()->depth();
   101 {
   102 {
   102     QDir teamdir;
   103     QDir teamdir;
   103     teamdir.cd(cfgdir->absolutePath() + "/Teams");
   104     teamdir.cd(cfgdir->absolutePath() + "/Teams");
   104     QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden);
   105     QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden);
   105     QStringList cleanedList;
   106     QStringList cleanedList;
   106     for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
   107     for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
   107             QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1");
   108     {
   108             cleanedList.push_back(tmpTeamStr);
   109         QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1");
       
   110         cleanedList.push_back(tmpTeamStr);
   109     }
   111     }
   110     return cleanedList;
   112     return cleanedList;
   111 }
   113 }
   112 
   114 
   113 void GameUIConfig::resizeToConfigValues()
   115 void GameUIConfig::resizeToConfigValues()
   114 {
   116 {
   115         Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt());
   117     Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt());
   116 }
   118 }
   117 
   119 
   118 void GameUIConfig::SaveOptions()
   120 void GameUIConfig::SaveOptions()
   119 {
   121 {
   120     setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
   122     setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
   128     setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());
   130     setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());
   129 
   131 
   130     bool ffscr = isFrontendFullscreen();
   132     bool ffscr = isFrontendFullscreen();
   131     setValue("frontend/fullscreen", ffscr);
   133     setValue("frontend/fullscreen", ffscr);
   132     emit frontendFullscreen(ffscr);
   134     emit frontendFullscreen(ffscr);
   133     if (!ffscr) {
   135     if (!ffscr)
   134       setValue("frontend/width", Form->width());
   136     {
   135       setValue("frontend/height", Form->height());
   137         setValue("frontend/width", Form->width());
   136     } else {
   138         setValue("frontend/height", Form->height());
   137       //resizeToConfigValues(); // TODO: why this has been made?
   139     }
       
   140     else
       
   141     {
       
   142         //resizeToConfigValues(); // TODO: why this has been made?
   138     }
   143     }
   139 
   144 
   140     setValue("audio/sound", isSoundEnabled());
   145     setValue("audio/sound", isSoundEnabled());
   141     setValue("frontend/sound", isFrontendSoundEnabled());
   146     setValue("frontend/sound", isFrontendSoundEnabled());
   142     setValue("audio/music", isMusicEnabled());
   147     setValue("audio/music", isMusicEnabled());
   154     setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
   159     setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
   155     setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());
   160     setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());
   156 
   161 
   157     setValue("fps/show", isShowFPSEnabled());
   162     setValue("fps/show", isShowFPSEnabled());
   158     setValue("fps/limit", Form->ui.pageOptions->fpsedit->value());
   163     setValue("fps/limit", Form->ui.pageOptions->fpsedit->value());
   159     
   164 
   160     setValue("misc/altdamage", isAltDamageEnabled());
   165     setValue("misc/altdamage", isAltDamageEnabled());
   161     setValue("misc/appendTimeToRecords", appendDateTimeToRecordName());
   166     setValue("misc/appendTimeToRecords", appendDateTimeToRecordName());
   162     setValue("misc/locale", language());
   167     setValue("misc/locale", language());
   163 
   168 
   164 #ifdef SPARKLE_ENABLED
   169 #ifdef SPARKLE_ENABLED
   165         setValue("misc/autoUpdate", isAutoUpdateEnabled());
   170     setValue("misc/autoUpdate", isAutoUpdateEnabled());
   166 #endif
   171 #endif
   167     Form->gameSettings->sync();
   172     Form->gameSettings->sync();
   168 }
   173 }
   169 
   174 
   170 QString GameUIConfig::language()
   175 QString GameUIConfig::language()
   202     quint32 rqSlowMenu = 0x00000080;  // ammomenu appears with no animation
   207     quint32 rqSlowMenu = 0x00000080;  // ammomenu appears with no animation
   203     quint32 rqPlainSplash = 0x00000100;  // no droplets
   208     quint32 rqPlainSplash = 0x00000100;  // no droplets
   204     quint32 rqClampLess = 0x00000200;  // don't clamp textures
   209     quint32 rqClampLess = 0x00000200;  // don't clamp textures
   205     quint32 rqTooltipsOff = 0x00000400;  // tooltips are not drawn
   210     quint32 rqTooltipsOff = 0x00000400;  // tooltips are not drawn
   206     quint32 rqDesyncVBlank = 0x00000800;  // don't sync on vblank
   211     quint32 rqDesyncVBlank = 0x00000800;  // don't sync on vblank
   207     
   212 
   208     quint32 result = (Form->ui.pageOptions->WeaponTooltip->isChecked()) ? rqNone : rqTooltipsOff;
   213     quint32 result = (Form->ui.pageOptions->WeaponTooltip->isChecked()) ? rqNone : rqTooltipsOff;
   209     
   214 
   210     switch (Form->ui.pageOptions->SLQuality->value()) {
   215     switch (Form->ui.pageOptions->SLQuality->value())
   211       case 5:
   216     {
   212         break;
   217         case 5:
   213       case 4:
   218             break;
   214         result |= rqBlurryLand;
   219         case 4:
   215         break;
   220             result |= rqBlurryLand;
   216       case 3:
   221             break;
   217         result |= rqBlurryLand | rqKillFlakes | rqPlainSplash;
   222         case 3:
   218         break;
   223             result |= rqBlurryLand | rqKillFlakes | rqPlainSplash;
   219       case 2:
   224             break;
   220         result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   225         case 2:
   221                   rqAntiBoom | rqSlowMenu;
   226             result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   222         break;
   227                       rqAntiBoom | rqSlowMenu;
   223       case 1:
   228             break;
   224         result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   229         case 1:
   225                   rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank;
   230             result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   226         break;
   231                       rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank;
   227       case 0:
   232             break;
   228         result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   233         case 0:
   229                   rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank |
   234             result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater |
   230                   rqNoBackground | rqClampLess;
   235                       rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank |
   231         break;
   236                       rqNoBackground | rqClampLess;
   232       default:
   237             break;
   233         fprintf(stderr,"unset value from slider");
   238         default:
   234         break;
   239             fprintf(stderr,"unset value from slider");
   235     }
   240             break;
   236     
   241     }
       
   242 
   237     return result;
   243     return result;
   238 }
   244 }
   239 
   245 
   240 bool GameUIConfig::isFrontendEffects() const
   246 bool GameUIConfig::isFrontendEffects() const
   241 {
   247 {
   242   return Form->ui.pageOptions->CBFrontendEffects->isChecked();
   248     return Form->ui.pageOptions->CBFrontendEffects->isChecked();
   243 }
   249 }
   244 
   250 
   245 bool GameUIConfig::isFrontendFullscreen() const
   251 bool GameUIConfig::isFrontendFullscreen() const
   246 {
   252 {
   247   return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
   253     return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
   248 }
   254 }
   249 
   255 
   250 bool GameUIConfig::isSoundEnabled()
   256 bool GameUIConfig::isSoundEnabled()
   251 {
   257 {
   252     return Form->ui.pageOptions->CBEnableSound->isChecked();
   258     return Form->ui.pageOptions->CBEnableSound->isChecked();
   338             {
   344             {
   339                 Form->ui.pageOptions->editNetPassword->clear();
   345                 Form->ui.pageOptions->editNetPassword->clear();
   340             }
   346             }
   341         }
   347         }
   342     }
   348     }
   343     
   349 
   344     // Don't filter anything
   350     // Don't filter anything
   345     return false;
   351     return false;
   346 }
   352 }
   347 
   353 
   348 void GameUIConfig::setNetPasswordLength(int passwordLength)
   354 void GameUIConfig::setNetPasswordLength(int passwordLength)