00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <wxdialogs/DisplayDialog.h>
00022 #include <wxdialogs/MainDialog.h>
00023 #include <wxdialogs/KeyDialog.h>
00024 #include <net/NetInterface.h>
00025 #include <engine/ModDirs.h>
00026 #include <engine/ModFiles.h>
00027 #include <graph/OptionsDisplay.h>
00028 #include <common/Defines.h>
00029 #include <common/Keyboard.h>
00030 #include <common/KeyTranslateWx.h>
00031 #include <client/UniqueIdStore.h>
00032 #include <wx/wx.h>
00033 #include <wx/image.h>
00034 #include <wx/notebook.h>
00035 #include <wx/grid.h>
00036 #include <wx/listbox.h>
00037 #include <wx/sizer.h>
00038 #include <set>
00039 #include <stdio.h>
00040 #include "Display.cpp"
00041
00042 extern char scorched3dAppName[128];
00043 extern char *displayOptions;
00044
00045 class DisplayFrame: public wxDialog
00046 {
00047 public:
00048 DisplayFrame();
00049
00050 virtual bool TransferDataToWindow();
00051 virtual bool TransferDataFromWindow();
00052
00053 void onLoadDefaultsButton(wxCommandEvent &event);
00054 void onLoadFastestButton(wxCommandEvent &event);
00055 void onLoadMediumButton(wxCommandEvent &event);
00056 void onLoadSafeButton(wxCommandEvent &event);
00057 void onLoadDefaultKeysButton(wxCommandEvent &event);
00058 void onKeyButton(wxCommandEvent &event);
00059 void onImportMod(wxCommandEvent &event);
00060 void onExportMod(wxCommandEvent &event);
00061 void onMoreRes(wxCommandEvent &event);
00062 void onPageChange(wxNotebookEvent &event);
00063 void onKey();
00064
00065 wxNotebook *book_;
00066 wxPanel *mainPanel_;
00067 wxPanel *troublePanel_;
00068 wxPanel *otherPanel_;
00069 wxPanel *identPanel_;
00070 wxPanel *keysPanel_;
00071 wxPanel *modsPanel_;
00072
00073 protected:
00074 DECLARE_EVENT_TABLE()
00075
00076 void refreshScreen();
00077 void refreshResolutions();
00078 void refreshKeysControls();
00079 };
00080
00081 BEGIN_EVENT_TABLE(DisplayFrame, wxDialog)
00082 EVT_BUTTON(ID_LOADDEFAULTS, DisplayFrame::onLoadDefaultsButton)
00083 EVT_BUTTON(ID_LOADFASTEST, DisplayFrame::onLoadFastestButton)
00084 EVT_BUTTON(ID_LOADMEDIUM, DisplayFrame::onLoadMediumButton)
00085 EVT_BUTTON(ID_KEYDEFAULTS, DisplayFrame::onLoadDefaultKeysButton)
00086 EVT_BUTTON(ID_LOADSAFE, DisplayFrame::onLoadSafeButton)
00087 EVT_BUTTON(ID_KEY, DisplayFrame::onKeyButton)
00088 EVT_BUTTON(ID_IMPORT, DisplayFrame::onImportMod)
00089 EVT_BUTTON(ID_EXPORT, DisplayFrame::onExportMod)
00090 EVT_CHECKBOX(ID_MORERES, DisplayFrame::onMoreRes)
00091 EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, DisplayFrame::onPageChange)
00092 END_EVENT_TABLE()
00093
00094 DisplayFrame::DisplayFrame() :
00095 wxDialog(getMainDialog(), -1, wxString(scorched3dAppName, wxConvUTF8))
00096 {
00097 #ifdef _WIN32
00098
00099 wxIcon icon(convertString(S3D::getDataFile("data/windows/tank2.ico")), wxBITMAP_TYPE_ICO);
00100 SetIcon(icon);
00101 #endif
00102
00103
00104 wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
00105
00106
00107 book_ = new wxNotebook(this, ID_NOTEBOOK);
00108 #if wxCHECK_VERSION(2,6,0)
00109 wxBoxSizer *nbs = new wxBoxSizer(wxVERTICAL);
00110 nbs->Add(book_);
00111 #else
00112 wxNotebookSizer *nbs = new wxNotebookSizer(book_);
00113 #endif
00114
00115
00116 mainPanel_ = new wxPanel(book_, -1);
00117 book_->AddPage(mainPanel_, wxT("Main"));
00118 wxSizer *mainPanelSizer = new wxBoxSizer(wxVERTICAL);
00119 createMainControls(mainPanel_, mainPanelSizer);
00120
00121 std::string settingsFileStr = S3D::getSettingsFile("");
00122 std::string settingsFileStd =
00123 S3D::formatStringBuffer("Settings Dir : %s", settingsFileStr.c_str());
00124 wxString settingsFile(settingsFileStd.c_str(), wxConvUTF8);
00125 settingsFile.Replace(wxT("//"), wxT("/"));
00126 #ifdef _WIN32
00127 settingsFile.Replace(wxT("/"), wxT("\\"));
00128 #endif
00129
00130 mainPanelSizer->Add(new wxStaticText(
00131 mainPanel_, -1, settingsFile), 0, wxTOP, 10);
00132 mainPanel_->SetAutoLayout(TRUE);
00133 mainPanel_->SetSizer(mainPanelSizer);
00134
00135
00136 troublePanel_ = new wxPanel(book_, -1);
00137 wxSizer *troublePanelSizer = new wxBoxSizer(wxVERTICAL);
00138 createTroubleControls(troublePanel_, troublePanelSizer);
00139 book_->AddPage(troublePanel_, wxT("&Speed/Troubleshooting"));
00140 troublePanel_->SetAutoLayout(TRUE);
00141 troublePanel_->SetSizer(troublePanelSizer);
00142
00143
00144 otherPanel_ = new wxPanel(book_, -1);
00145 wxSizer *otherPanelSizer = new wxBoxSizer(wxVERTICAL);
00146 createOtherControls(otherPanel_, otherPanelSizer);
00147 book_->AddPage(otherPanel_, wxT("&Other"));
00148 otherPanel_->SetAutoLayout(TRUE);
00149 otherPanel_->SetSizer(otherPanelSizer);
00150
00151
00152 keysPanel_ = new wxPanel(book_, -1);
00153 wxSizer *keysPanelSizer = new wxBoxSizer(wxVERTICAL);
00154 createKeysControls(keysPanel_, keysPanelSizer);
00155 book_->AddPage(keysPanel_, wxT("&Keys"));
00156 keysPanel_->SetAutoLayout(TRUE);
00157 #if wxCHECK_VERSION(2,6,0)
00158 keysPanel_->SetSizer(keysPanelSizer);
00159 #else
00160 #if wxCHECK_VERSION(2,5,0)
00161 #else
00162 keysPanel_->SetSizer(keysPanelSizer);
00163 #endif
00164 #endif
00165
00166
00167 identPanel_ = new wxPanel(book_, ID_PANEL_IDENT);
00168 wxSizer *identPanelSizer = new wxBoxSizer(wxVERTICAL);
00169 createIdentControls(identPanel_, identPanelSizer);
00170 book_->AddPage(identPanel_, wxT("&Identity"));
00171 identPanel_->SetAutoLayout(TRUE);
00172 identPanel_->SetSizer(identPanelSizer);
00173
00174
00175 modsPanel_ = new wxPanel(book_, -1);
00176 wxSizer *modsPanelSizer = new wxBoxSizer(wxVERTICAL);
00177 createModsControls(modsPanel_, modsPanelSizer);
00178 book_->AddPage(modsPanel_, wxT("&Mods"));
00179 modsPanel_->SetAutoLayout(TRUE);
00180 modsPanel_->SetSizer(modsPanelSizer);
00181
00182
00183 topsizer->Add(nbs, 0, wxALL, 10);
00184
00185
00186 wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
00187 IDCANCEL_CTRL = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
00188 IDOK_CTRL = new wxButton(this, wxID_OK, wxT("&Ok"));
00189 buttonSizer->Add(IDCANCEL_CTRL, 0, wxRIGHT, 5);
00190 buttonSizer->Add(IDOK_CTRL, 0, wxLEFT, 5);
00191 topsizer->Add(buttonSizer, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
00192
00193 SetSizer(topsizer);
00194 topsizer->SetSizeHints(this);
00195
00196 CentreOnScreen();
00197 }
00198
00199 void DisplayFrame::onLoadDefaultsButton(wxCommandEvent &event)
00200 {
00201 OptionsDisplay::instance()->loadDefaultValues();
00202 refreshScreen();
00203 }
00204
00205 void DisplayFrame::onLoadFastestButton(wxCommandEvent &event)
00206 {
00207 OptionsDisplay::instance()->loadDefaultValues();
00208 OptionsDisplay::instance()->loadFastestValues();
00209 refreshScreen();
00210 }
00211
00212 void DisplayFrame::onLoadMediumButton(wxCommandEvent &event)
00213 {
00214 OptionsDisplay::instance()->loadDefaultValues();
00215 OptionsDisplay::instance()->loadMediumValues();
00216 refreshScreen();
00217 }
00218
00219 void DisplayFrame::onLoadSafeButton(wxCommandEvent &event)
00220 {
00221 OptionsDisplay::instance()->loadDefaultValues();
00222 OptionsDisplay::instance()->loadSafeValues();
00223 refreshScreen();
00224 }
00225
00226 void DisplayFrame::onLoadDefaultKeysButton(wxCommandEvent &event)
00227 {
00228 Keyboard::instance()->loadKeyFile(true);
00229 refreshKeysControls();
00230 }
00231
00232 void DisplayFrame::onMoreRes(wxCommandEvent &event)
00233 {
00234 refreshResolutions();
00235 }
00236
00237 void DisplayFrame::onPageChange(wxNotebookEvent &event)
00238 {
00239 if (event.GetSelection() == 4)
00240 {
00241 refreshIdentControls();
00242 }
00243 }
00244
00245 void DisplayFrame::onKeyButton(wxCommandEvent &event)
00246 {
00247
00248 wxButton *chosenButton = (wxButton *) event.GetEventObject();
00249 KeyButtonData *chosenData = (KeyButtonData *) chosenButton->GetRefData();
00250 KeyboardKey *chosenKey = Keyboard::instance()->getKey(chosenData->key_.c_str());
00251 unsigned int chosenPosition = chosenData->position_;
00252 if (!chosenKey) return;
00253
00254
00255 showKeyDialog(this);
00256
00257
00258 unsigned int resultKey = getKeyDialogKey();
00259 unsigned int wxKey = (unsigned int) resultKey;
00260 unsigned int sdlKey = 0;
00261
00262 for (int i=0; i<int(sizeof(KeyTranslationTableWx)/sizeof(KeyTranslationWx)); i++)
00263 {
00264 if (KeyTranslationTableWx[i].wxKeySym == wxKey)
00265 {
00266 sdlKey = KeyTranslationTableWx[i].keySym;
00267 break;
00268 }
00269 }
00270
00271 if (sdlKey == 0) return;
00272
00273 unsigned int sdlState = 0;
00274 if (getKeyDialogAlt()) sdlState = KMOD_LALT;
00275 else if (getKeyDialogControl()) sdlState = KMOD_LCTRL;
00276 else if (getKeyDialogShift()) sdlState = KMOD_LSHIFT;
00277
00278
00279
00280 bool found = false;
00281 std::list<wxButton *>::iterator itor;
00282 for (itor = keyboardKeyList.begin();
00283 itor != keyboardKeyList.end();
00284 itor++)
00285 {
00286 wxButton *button = (*itor);
00287 KeyButtonData *data = (KeyButtonData *) button->GetRefData();
00288 KeyboardKey *key = Keyboard::instance()->getKey(data->key_.c_str());
00289 unsigned int position = data->position_;
00290
00291 if (key)
00292 {
00293 std::vector<KeyboardKey::KeyEntry> &keyEntries = key->getKeys();
00294 if (position < keyEntries.size())
00295 {
00296 if (keyEntries[position].key == sdlKey &&
00297 keyEntries[position].state == sdlState)
00298 {
00299 if (key == chosenKey) found = true;
00300 else key->removeKey(position);
00301 }
00302 }
00303 }
00304 }
00305
00306
00307 if (!found)
00308 {
00309 chosenKey->addKey(chosenPosition, sdlKey, sdlState);
00310 }
00311
00312
00313 refreshKeysControls();
00314 }
00315
00316 void DisplayFrame::refreshKeysControls()
00317 {
00318 std::list<wxButton *>::iterator buttonitor;
00319 for (buttonitor = keyboardKeyList.begin();
00320 buttonitor != keyboardKeyList.end();
00321 buttonitor++)
00322 {
00323 wxButton *button = (*buttonitor);
00324
00325 KeyButtonData *data = (KeyButtonData *) button->GetRefData();
00326 KeyboardKey *key = Keyboard::instance()->getKey(data->key_.c_str());
00327 unsigned int position = data->position_;
00328
00329 char buffer[256];
00330 buffer[0] = '\0';
00331 if (key && position < key->getKeys().size())
00332 {
00333 const char *keyName = "";
00334 const char *stateName = "";
00335 KeyboardKey::translateKeyNameValue(key->getKeys()[position].key, keyName);
00336 KeyboardKey::translateKeyStateValue(key->getKeys()[position].state, stateName);
00337 if (strcmp(stateName, "NONE") == 0) snprintf(buffer, 256, "%s", keyName);
00338 else snprintf(buffer, 256, "<%s> %s", stateName, keyName);
00339 }
00340 button->SetLabel(wxString(buffer, wxConvUTF8));
00341 }
00342 }
00343
00344 bool DisplayFrame::TransferDataToWindow()
00345 {
00346
00347 OptionsDisplay::instance()->readOptionsFromFile();
00348
00349 refreshScreen();
00350 return true;
00351 }
00352
00353 void DisplayFrame::refreshScreen()
00354 {
00355 IDC_NOEXT_CTRL->SetValue(OptionsDisplay::instance()->getNoGLExt());
00356 IDC_NOEXT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLExtEntry().getDescription(), wxConvUTF8));
00357 IDC_NOCUBEMAP_CTRL->SetValue(OptionsDisplay::instance()->getNoGLCubeMap());
00358 IDC_NOCUBEMAP_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLCubeMapEntry().getDescription(), wxConvUTF8));
00359 IDC_NOSPHEREMAP_CTRL->SetValue(OptionsDisplay::instance()->getNoGLSphereMap());
00360 IDC_NOSPHEREMAP_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLSphereMapEntry().getDescription(), wxConvUTF8));
00361 IDC_NOLANDSCAPESCORCH_CTRL->SetValue(OptionsDisplay::instance()->getNoGLTexSubImage());
00362 IDC_NOLANDSCAPESCORCH_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLTexSubImageEntry().getDescription(), wxConvUTF8));
00363 IDC_NOMULTITEX_CTRL->SetValue(OptionsDisplay::instance()->getNoGLMultiTex());
00364 IDC_NOMULTITEX_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLMultiTexEntry().getDescription(), wxConvUTF8));
00365 IDC_NOENVCOMBINE_CTRL->SetValue(OptionsDisplay::instance()->getNoGLEnvCombine());
00366 IDC_NOENVCOMBINE_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLEnvCombineEntry().getDescription(), wxConvUTF8));
00367 IDC_NOSHADERS_CTRL->SetValue(OptionsDisplay::instance()->getNoGLShaders());
00368 IDC_NOSHADERS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLShadersEntry().getDescription(), wxConvUTF8));
00369 IDC_SIMPLEWATERSHADERS_CTRL->SetValue(OptionsDisplay::instance()->getSimpleWaterShaders());
00370 IDC_SIMPLEWATERSHADERS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getSimpleWaterShadersEntry().getDescription(), wxConvUTF8));
00371 IDC_NOSHADOWS_CTRL->SetValue(OptionsDisplay::instance()->getNoGLShadows());
00372 IDC_NOSHADOWS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLShadowsEntry().getDescription(), wxConvUTF8));
00373 IDC_NOOBJECTSHADOWS_CTRL->SetValue(OptionsDisplay::instance()->getNoGLObjectShadows());
00374 IDC_NOOBJECTSHADOWS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLObjectShadowsEntry().getDescription(), wxConvUTF8));
00375 IDC_NOVBO_CTRL->SetValue(OptionsDisplay::instance()->getNoVBO());
00376 IDC_NOVBO_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoVBOEntry().getDescription(), wxConvUTF8));
00377 IDC_NOMIPMAPS_CTRL->SetValue(OptionsDisplay::instance()->getNoGLHardwareMipmaps());
00378 IDC_NOMIPMAPS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoGLHardwareMipmapsEntry().getDescription(), wxConvUTF8));
00379 IDC_NOSOUND_CTRL->SetValue(OptionsDisplay::instance()->getNoSound());
00380 IDC_NOSOUND_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoSoundEntry().getDescription(), wxConvUTF8));
00381 IDC_NOMUSIC_CTRL->SetValue(OptionsDisplay::instance()->getNoMusic());
00382 IDC_NOMUSIC_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoMusicEntry().getDescription(), wxConvUTF8));
00383 IDC_NOSKINS_CTRL->SetValue(OptionsDisplay::instance()->getNoSkins());
00384 IDC_NOSKINS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoSkinsEntry().getDescription(), wxConvUTF8));
00385 IDC_NODYNAMICLIGHT_CTRL->SetValue(OptionsDisplay::instance()->getNoModelLighting());
00386 IDC_NODYNAMICLIGHT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoModelLightingEntry().getDescription(), wxConvUTF8));
00387 IDC_FULLSCREEN_CTRL->SetValue(OptionsDisplay::instance()->getFullScreen());
00388 IDC_FULLSCREEN_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getFullScreenEntry().getDescription(), wxConvUTF8));
00389 IDC_SINGLESKYLAYER_CTRL->SetValue(OptionsDisplay::instance()->getNoSkyLayers());
00390 IDC_SINGLESKYLAYER_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoSkyLayersEntry().getDescription(), wxConvUTF8));
00391 IDC_NOSKYANI_CTRL->SetValue(OptionsDisplay::instance()->getNoSkyMovement());
00392 IDC_NOSKYANI_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoSkyMovementEntry().getDescription(), wxConvUTF8));
00393 IDC_NOWATERMOVEMENT_CTRL->SetValue(OptionsDisplay::instance()->getNoWaterMovement());
00394 IDC_NOWATERMOVEMENT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoWaterMovementEntry().getDescription(), wxConvUTF8));
00395 IDC_NOWATERLOD_CTRL->SetValue(OptionsDisplay::instance()->getNoWaterLOD());
00396 IDC_NOWATERLOD_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoWaterLODEntry().getDescription(), wxConvUTF8));
00397 IDC_NOWATERWAVES_CTRL->SetValue(OptionsDisplay::instance()->getNoWaterWaves());
00398 IDC_NOWATERWAVES_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoWaterWavesEntry().getDescription(), wxConvUTF8));
00399 IDC_NOWATERREF_CTRL->SetValue(OptionsDisplay::instance()->getNoWaterReflections());
00400 IDC_NOWATERREF_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoWaterReflectionsEntry().getDescription(), wxConvUTF8));
00401 IDC_NOWATER_CTRL->SetValue(!OptionsDisplay::instance()->getDrawWater());
00402 IDC_NOWATER_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDrawWaterEntry().getDescription(), wxConvUTF8));
00403 IDC_NOSURROUND_CTRL->SetValue(!OptionsDisplay::instance()->getDrawSurround());
00404 IDC_NOSURROUND_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDrawSurroundEntry().getDescription(), wxConvUTF8));
00405 IDC_NOPRECIPITATION_CTRL->SetValue(OptionsDisplay::instance()->getNoPrecipitation());
00406 IDC_NOPRECIPITATION_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoPrecipitationEntry().getDescription(), wxConvUTF8));
00407 IDC_NODEPTHSORT_CTRL->SetValue(OptionsDisplay::instance()->getNoDepthSorting());
00408 IDC_NODEPTHSORT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoDepthSortingEntry().getDescription(), wxConvUTF8));
00409 IDC_NOBACKDROP_CTRL->SetValue(OptionsDisplay::instance()->getNoProgressBackdrop());
00410 IDC_NOBACKDROP_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getNoProgressBackdropEntry().getDescription(), wxConvUTF8));
00411 IDC_INVERT_CTRL->SetValue(OptionsDisplay::instance()->getInvertElevation());
00412 IDC_INVERT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getInvertElevationEntry().getDescription(), wxConvUTF8));
00413 IDC_INVERTMOUSE_CTRL->SetValue(OptionsDisplay::instance()->getInvertMouse());
00414 IDC_INVERTMOUSE_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getInvertMouseEntry().getDescription(), wxConvUTF8));
00415 IDC_SMOUSE_CTRL->SetValue(OptionsDisplay::instance()->getSoftwareMouse());
00416 IDC_SMOUSE_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getSoftwareMouseEntry().getDescription(), wxConvUTF8));
00417 IDC_TIMER_CTRL->SetValue(OptionsDisplay::instance()->getFrameTimer());
00418 IDC_TIMER_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getFrameTimerEntry().getDescription(), wxConvUTF8));
00419 IDC_SIDESCROLL_CTRL->SetValue(OptionsDisplay::instance()->getSideScroll());
00420 IDC_SIDESCROLL_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getSideScrollEntry().getDescription(), wxConvUTF8));
00421 IDC_PLAYERCAMERA_CTRL->SetValue(OptionsDisplay::instance()->getStorePlayerCamera());
00422 IDC_PLAYERCAMERA_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getStorePlayerCameraEntry().getDescription(), wxConvUTF8));
00423 IDC_VALIDATESERVER_CTRL->SetValue(OptionsDisplay::instance()->getValidateServerIp());
00424 IDC_VALIDATESERVER_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getValidateServerIpEntry().getDescription(), wxConvUTF8));
00425 IDC_SLIDER1_CTRL->SetRange(3, 40);
00426 IDC_SLIDER1_CTRL->SetValue(OptionsDisplay::instance()->getBrightness());
00427 IDC_SLIDER1_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getBrightnessEntry().getDescription(), wxConvUTF8));
00428 IDC_VOLUME_CTRL->SetRange(0, 128);
00429 IDC_VOLUME_CTRL->SetTickFreq(4, 0);
00430 IDC_VOLUME_CTRL->SetValue(OptionsDisplay::instance()->getSoundVolume());
00431 IDC_VOLUME_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getSoundVolumeEntry().getDescription(), wxConvUTF8));
00432 IDC_MUSICVOLUME_CTRL->SetRange(0, 128);
00433 IDC_MUSICVOLUME_CTRL->SetTickFreq(4, 0);
00434 IDC_MUSICVOLUME_CTRL->SetValue(OptionsDisplay::instance()->getMusicVolume());
00435 IDC_MUSICVOLUME_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getMusicVolumeEntry().getDescription(), wxConvUTF8));
00436 IDC_AMBIENTVOLUME_CTRL->SetRange(0, 128);
00437 IDC_AMBIENTVOLUME_CTRL->SetTickFreq(4, 0);
00438 IDC_AMBIENTVOLUME_CTRL->SetValue(OptionsDisplay::instance()->getAmbientSoundVolume());
00439 IDC_AMBIENTVOLUME_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getAmbientSoundVolumeEntry().getDescription(), wxConvUTF8));
00440 IDC_USERNAME_CTRL->SetValue(wxString(OptionsDisplay::instance()->getOnlineUserName(), wxConvUTF8));
00441 IDC_USERNAME_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getOnlineUserNameEntry().getDescription(), wxConvUTF8));
00442 IDC_TANKMODEL_CTRL->SetValue(wxString(OptionsDisplay::instance()->getOnlineTankModel(), wxConvUTF8));
00443 IDC_TANKMODEL_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getOnlineTankModelEntry().getDescription(), wxConvUTF8));
00444 IDC_HOSTDESC_CTRL->SetValue(wxString(OptionsDisplay::instance()->getHostDescription(), wxConvUTF8));
00445 IDC_HOSTDESC_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getHostDescriptionEntry().getDescription(), wxConvUTF8));
00446 IDC_NODETAILTEX_CTRL->SetValue(!OptionsDisplay::instance()->getDetailTexture());
00447 IDC_NODETAILTEX_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDetailTextureEntry().getDescription(), wxConvUTF8));
00448 IDC_MORERES_CTRL->SetValue(OptionsDisplay::instance()->getMoreRes());
00449 IDC_MORERES_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getMoreResEntry().getDescription(), wxConvUTF8));
00450
00451
00452 IDC_LOGGING_CTRL->SetValue(OptionsDisplay::instance()->getClientLogToFile());
00453 IDC_LOGGING_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getClientLogToFileEntry().getDescription(), wxConvUTF8));
00454
00455 IDC_ANTIALIAS_CTRL->Clear();
00456 IDC_ANTIALIAS_CTRL->Append(wxT("0"));
00457 IDC_ANTIALIAS_CTRL->Append(wxT("1"));
00458 IDC_ANTIALIAS_CTRL->Append(wxT("2"));
00459 IDC_ANTIALIAS_CTRL->Append(wxT("4"));
00460 IDC_ANTIALIAS_CTRL->SetValue(convertString(S3D::formatStringBuffer("%i",
00461 OptionsDisplay::instance()->getAntiAlias())));
00462 IDC_ANTIALIAS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getAntiAliasEntry().getDescription(), wxConvUTF8));
00463
00464 IDC_FOCUSPAUSE_CTRL->SetValue(OptionsDisplay::instance()->getFocusPause());
00465 IDC_FOCUSPAUSE_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getFocusPauseEntry().getDescription(), wxConvUTF8));
00466
00467 IDC_FRAMELIMIT_CTRL->SetValue(
00468 convertString(S3D::formatStringBuffer("%i", OptionsDisplay::instance()->getFramesPerSecondLimit())));
00469 IDC_FRAMELIMIT_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getFramesPerSecondLimitEntry().getDescription(), wxConvUTF8));
00470
00471 IDC_SOUNDCHANNELS_CTRL->Clear();
00472 for (int i=2; i<=64; i+=2)
00473 {
00474 IDC_SOUNDCHANNELS_CTRL->Append(
00475 convertString(S3D::formatStringBuffer("%i", i)));
00476 }
00477 IDC_SOUNDCHANNELS_CTRL->SetValue(
00478 convertString(S3D::formatStringBuffer("%i", OptionsDisplay::instance()->getSoundChannels())));
00479
00480 refreshResolutions();
00481
00482 IDC_TINYDIALOGS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDialogSizeEntry().getDescription(), wxConvUTF8));
00483 IDC_SMALLDIALOGS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDialogSizeEntry().getDescription(), wxConvUTF8));
00484 IDC_MEDIUMDIALOGS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDialogSizeEntry().getDescription(), wxConvUTF8));
00485 IDC_LARGEDIALOGS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getDialogSizeEntry().getDescription(), wxConvUTF8));
00486 switch (OptionsDisplay::instance()->getDialogSize())
00487 {
00488 case 0:
00489 IDC_TINYDIALOGS_CTRL->SetValue(true);
00490 break;
00491 case 1:
00492 IDC_SMALLDIALOGS_CTRL->SetValue(true);
00493 break;
00494 case 2:
00495 IDC_MEDIUMDIALOGS_CTRL->SetValue(true);
00496 break;
00497 case 3:
00498 IDC_LARGEDIALOGS_CTRL->SetValue(true);
00499 break;
00500 }
00501
00502 IDC_SMALLTEX_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTexSizeEntry().getDescription(), wxConvUTF8));
00503 IDC_MEDIUMTEX_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTexSizeEntry().getDescription(), wxConvUTF8));
00504 IDC_LARGETEX_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTexSizeEntry().getDescription(), wxConvUTF8));
00505 switch (OptionsDisplay::instance()->getTexSize())
00506 {
00507 case 0:
00508 IDC_SMALLTEX_CTRL->SetValue(true);
00509 break;
00510 case 1:
00511 IDC_MEDIUMTEX_CTRL->SetValue(true);
00512 break;
00513 default:
00514 IDC_LARGETEX_CTRL->SetValue(true);
00515 break;
00516 };
00517
00518 IDC_LOWEFFECTS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getEffectsDetailEntry().getDescription(), wxConvUTF8));
00519 IDC_MEDIUMEFFECTS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getEffectsDetailEntry().getDescription(), wxConvUTF8));
00520 IDC_HIGHEFFECTS_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getEffectsDetailEntry().getDescription(), wxConvUTF8));
00521 switch (OptionsDisplay::instance()->getEffectsDetail())
00522 {
00523 case 0:
00524 IDC_LOWEFFECTS_CTRL->SetValue(true);
00525 break;
00526 case 1:
00527 IDC_MEDIUMEFFECTS_CTRL->SetValue(true);
00528 break;
00529 default:
00530 IDC_HIGHEFFECTS_CTRL->SetValue(true);
00531 break;
00532 };
00533
00534 IDC_LOWTANK_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTankDetailEntry().getDescription(), wxConvUTF8));
00535 IDC_MEDIUMTANK_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTankDetailEntry().getDescription(), wxConvUTF8));
00536 IDC_HIGHTANK_CTRL->SetToolTip(wxString(OptionsDisplay::instance()->getTankDetailEntry().getDescription(), wxConvUTF8));
00537 switch (OptionsDisplay::instance()->getTankDetail())
00538 {
00539 case 0:
00540 IDC_LOWTANK_CTRL->SetValue(true);
00541 break;
00542 case 1:
00543 IDC_MEDIUMTANK_CTRL->SetValue(true);
00544 break;
00545 default:
00546 IDC_HIGHTANK_CTRL->SetValue(true);
00547 break;
00548 };
00549
00550 refreshKeysControls();
00551
00552 IDOK_CTRL->SetDefault();
00553 }
00554
00555 void DisplayFrame::refreshResolutions()
00556 {
00557 IDC_DISPLAY_CTRL->Clear();
00558
00559 std::set<std::string> displaySet;
00560 char string[256];
00561 SDL_Rect **modes = SDL_ListModes(NULL,SDL_FULLSCREEN|SDL_HWSURFACE);
00562 if((modes != (SDL_Rect **)0) && (modes != (SDL_Rect **)-1))
00563 {
00564 for(int i=0;modes[i];++i)
00565 {
00566 snprintf(string, 256, "%i x %i",
00567 modes[i]->w, modes[i]->h);
00568
00569 std::string newDisplay(string);
00570 if (displaySet.find(newDisplay) == displaySet.end())
00571 {
00572 IDC_DISPLAY_CTRL->Append(wxString(string, wxConvUTF8));
00573 displaySet.insert(newDisplay);
00574 }
00575 }
00576 }
00577
00578 if (IDC_MORERES_CTRL->GetValue())
00579 {
00580 const char *extraModes[] =
00581 { "320 x 200", "320 x 240", "512 x 384",
00582 "640 x 480", "800 x 600", "1024 x 768", "1024 x 384" };
00583 for (int i=0; i<int(sizeof(extraModes)/sizeof(const char *)); i++)
00584 {
00585 std::string newDisplay(extraModes[i]);
00586 if (displaySet.find(newDisplay) == displaySet.end())
00587 {
00588 IDC_DISPLAY_CTRL->Append(wxString(newDisplay.c_str(), wxConvUTF8));
00589 displaySet.insert(newDisplay);
00590 }
00591 }
00592 }
00593
00594 snprintf(string, 256, "%i x %i",
00595 OptionsDisplay::instance()->getScreenWidth(),
00596 OptionsDisplay::instance()->getScreenHeight());
00597 IDC_DISPLAY_CTRL->SetValue(wxString(string, wxConvUTF8));
00598 }
00599
00600 bool DisplayFrame::TransferDataFromWindow()
00601 {
00602 OptionsDisplay::instance()->getNoGLTexSubImageEntry().setValue(IDC_NOLANDSCAPESCORCH_CTRL->GetValue());
00603 OptionsDisplay::instance()->getNoGLExtEntry().setValue(IDC_NOEXT_CTRL->GetValue());
00604 OptionsDisplay::instance()->getNoGLMultiTexEntry().setValue(IDC_NOMULTITEX_CTRL->GetValue());
00605 OptionsDisplay::instance()->getNoGLEnvCombineEntry().setValue(IDC_NOENVCOMBINE_CTRL->GetValue());
00606 OptionsDisplay::instance()->getNoGLShadersEntry().setValue(IDC_NOSHADERS_CTRL->GetValue());
00607 OptionsDisplay::instance()->getSimpleWaterShadersEntry().setValue(IDC_SIMPLEWATERSHADERS_CTRL->GetValue());
00608 OptionsDisplay::instance()->getNoGLShadowsEntry().setValue(IDC_NOSHADOWS_CTRL->GetValue());
00609 OptionsDisplay::instance()->getNoGLObjectShadowsEntry().setValue(IDC_NOOBJECTSHADOWS_CTRL->GetValue());
00610 OptionsDisplay::instance()->getNoGLCubeMapEntry().setValue(IDC_NOCUBEMAP_CTRL->GetValue());
00611 OptionsDisplay::instance()->getNoGLSphereMapEntry().setValue(IDC_NOSPHEREMAP_CTRL->GetValue());
00612 OptionsDisplay::instance()->getNoVBOEntry().setValue(IDC_NOVBO_CTRL->GetValue());
00613 OptionsDisplay::instance()->getNoGLHardwareMipmapsEntry().setValue(IDC_NOMIPMAPS_CTRL->GetValue());
00614 OptionsDisplay::instance()->getNoSoundEntry().setValue(IDC_NOSOUND_CTRL->GetValue());
00615 OptionsDisplay::instance()->getNoMusicEntry().setValue(IDC_NOMUSIC_CTRL->GetValue());
00616 OptionsDisplay::instance()->getSoundChannelsEntry().setValue(atoi(IDC_SOUNDCHANNELS_CTRL->GetValue().mb_str(wxConvUTF8)));
00617 OptionsDisplay::instance()->getNoSkinsEntry().setValue(IDC_NOSKINS_CTRL->GetValue());
00618 OptionsDisplay::instance()->getNoModelLightingEntry().setValue(IDC_NODYNAMICLIGHT_CTRL->GetValue());
00619 OptionsDisplay::instance()->getNoPrecipitationEntry().setValue(IDC_NOPRECIPITATION_CTRL->GetValue());
00620 OptionsDisplay::instance()->getNoDepthSortingEntry().setValue(IDC_NODEPTHSORT_CTRL->GetValue());
00621 OptionsDisplay::instance()->getNoProgressBackdropEntry().setValue(IDC_NOBACKDROP_CTRL->GetValue());
00622 OptionsDisplay::instance()->getFullScreenEntry().setValue(IDC_FULLSCREEN_CTRL->GetValue());
00623 OptionsDisplay::instance()->getNoSkyLayersEntry().setValue(IDC_SINGLESKYLAYER_CTRL->GetValue());
00624 OptionsDisplay::instance()->getNoSkyMovementEntry().setValue(IDC_NOSKYANI_CTRL->GetValue());
00625 OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(IDC_NOWATERMOVEMENT_CTRL->GetValue());
00626 OptionsDisplay::instance()->getNoWaterLODEntry().setValue(IDC_NOWATERLOD_CTRL->GetValue());
00627 OptionsDisplay::instance()->getNoWaterWavesEntry().setValue(IDC_NOWATERWAVES_CTRL->GetValue());
00628 OptionsDisplay::instance()->getNoWaterReflectionsEntry().setValue(IDC_NOWATERREF_CTRL->GetValue());
00629 OptionsDisplay::instance()->getBrightnessEntry().setValue(IDC_SLIDER1_CTRL->GetValue());
00630 OptionsDisplay::instance()->getSoundVolumeEntry().setValue(IDC_VOLUME_CTRL->GetValue());
00631 OptionsDisplay::instance()->getMusicVolumeEntry().setValue(IDC_MUSICVOLUME_CTRL->GetValue());
00632 OptionsDisplay::instance()->getAmbientSoundVolumeEntry().setValue(IDC_AMBIENTVOLUME_CTRL->GetValue());
00633 OptionsDisplay::instance()->getDrawWaterEntry().setValue(!IDC_NOWATER_CTRL->GetValue());
00634 OptionsDisplay::instance()->getDrawSurroundEntry().setValue(!IDC_NOSURROUND_CTRL->GetValue());
00635 OptionsDisplay::instance()->getInvertElevationEntry().setValue(IDC_INVERT_CTRL->GetValue());
00636 OptionsDisplay::instance()->getInvertMouseEntry().setValue(IDC_INVERTMOUSE_CTRL->GetValue());
00637 OptionsDisplay::instance()->getSoftwareMouseEntry().setValue(IDC_SMOUSE_CTRL->GetValue());
00638 OptionsDisplay::instance()->getFrameTimerEntry().setValue(IDC_TIMER_CTRL->GetValue());
00639 OptionsDisplay::instance()->getSideScrollEntry().setValue(IDC_SIDESCROLL_CTRL->GetValue());
00640 OptionsDisplay::instance()->getStorePlayerCameraEntry().setValue(IDC_PLAYERCAMERA_CTRL->GetValue());
00641 OptionsDisplay::instance()->getValidateServerIpEntry().setValue(IDC_VALIDATESERVER_CTRL->GetValue());
00642 OptionsDisplay::instance()->getOnlineUserNameEntry().setValue(std::string(IDC_USERNAME_CTRL->GetValue().mb_str(wxConvUTF8)));
00643 OptionsDisplay::instance()->getOnlineTankModelEntry().setValue(std::string(IDC_TANKMODEL_CTRL->GetValue().mb_str(wxConvUTF8)));
00644 OptionsDisplay::instance()->getHostDescriptionEntry().setValue(std::string(IDC_HOSTDESC_CTRL->GetValue().mb_str(wxConvUTF8)));
00645 OptionsDisplay::instance()->getDetailTextureEntry().setValue(!IDC_NODETAILTEX_CTRL->GetValue());
00646 OptionsDisplay::instance()->getMoreResEntry().setValue(IDC_MORERES_CTRL->GetValue());
00647
00648 OptionsDisplay::instance()->getClientLogToFileEntry().setValue(IDC_LOGGING_CTRL->GetValue());
00649
00650 OptionsDisplay::instance()->getAntiAliasEntry().setValue(
00651 atoi(IDC_ANTIALIAS_CTRL->GetValue().mb_str(wxConvUTF8)));
00652 OptionsDisplay::instance()->getFocusPauseEntry().setValue(IDC_FOCUSPAUSE_CTRL->GetValue());
00653 OptionsDisplay::instance()->getFramesPerSecondLimitEntry().setValue(atoi(IDC_FRAMELIMIT_CTRL->GetValue().mb_str(wxConvUTF8)));
00654 wxString buffer = IDC_DISPLAY_CTRL->GetValue();
00655 int windowWidth, windowHeight;
00656 if (sscanf(buffer.mb_str(wxConvUTF8),
00657 "%i x %i",
00658 &windowWidth,
00659 &windowHeight) == 2)
00660 {
00661 OptionsDisplay::instance()->getScreenWidthEntry().setValue(windowWidth);
00662 OptionsDisplay::instance()->getScreenHeightEntry().setValue(windowHeight);
00663 }
00664
00665 int dialogSize = 0;
00666 if (IDC_SMALLDIALOGS_CTRL->GetValue()) dialogSize = 1;
00667 if (IDC_MEDIUMDIALOGS_CTRL->GetValue()) dialogSize = 2;
00668 if (IDC_LARGEDIALOGS_CTRL->GetValue()) dialogSize = 3;
00669 OptionsDisplay::instance()->getDialogSizeEntry().setValue(dialogSize);
00670
00671 int texSize = 1;
00672 if (IDC_SMALLTEX_CTRL->GetValue()) texSize = 0;
00673 if (IDC_LARGETEX_CTRL->GetValue()) texSize = 2;
00674 OptionsDisplay::instance()->getTexSizeEntry().setValue(texSize);
00675
00676 int effectsDetail = 1;
00677 if (IDC_LOWEFFECTS_CTRL->GetValue()) effectsDetail = 0;
00678 if (IDC_HIGHEFFECTS_CTRL->GetValue()) effectsDetail = 2;
00679 OptionsDisplay::instance()->getEffectsDetailEntry().setValue(effectsDetail);
00680
00681 int tankDetail = 1;
00682 if (IDC_LOWTANK_CTRL->GetValue()) tankDetail = 0;
00683 if (IDC_HIGHTANK_CTRL->GetValue()) tankDetail = 2;
00684 OptionsDisplay::instance()->getTankDetailEntry().setValue(tankDetail);
00685
00686
00687 OptionsDisplay::instance()->writeOptionsToFile();
00688
00689
00690 Keyboard::instance()->saveKeyFile();
00691
00692 return true;
00693 }
00694
00695 void DisplayFrame::onExportMod(wxCommandEvent &event)
00696 {
00697 int selectionNo = modbox->GetSelection();
00698 if (selectionNo < 0) return;
00699 wxString selection = modbox->GetString(selectionNo);
00700 if (selection.empty()) return;
00701
00702 wxString file = ::wxFileSelector(wxT("Please choose the export file to save"),
00703 convertString(S3D::getSettingsFile("")),
00704 convertString(S3D::formatStringBuffer("%s.s3m", (const char *) (selection.mb_str(wxConvUTF8)))),
00705 wxT(""),
00706 wxT("*.s3m"),
00707 wxSAVE);
00708 if (file.empty()) return;
00709 ModFiles files;
00710 if (!files.loadModFiles(std::string(selection.mb_str(wxConvUTF8)), false))
00711 {
00712 S3D::dialogMessage("Export Mod", "Failed to load mod files");
00713 return;
00714 }
00715 if (!files.exportModFiles(
00716 std::string(selection.mb_str(wxConvUTF8)),
00717 std::string(file.mb_str(wxConvUTF8))))
00718 {
00719 S3D::dialogMessage("Export Mod", "Failed to write mod export file");
00720 return;
00721 }
00722 }
00723
00724 void DisplayFrame::onImportMod(wxCommandEvent &event)
00725 {
00726 wxString file = ::wxFileSelector(wxT("Please choose the import file to open"),
00727 convertString(S3D::getSettingsFile("")),
00728 wxT(""),
00729 wxT(""),
00730 wxT("*.s3m"),
00731 wxOPEN | wxFILE_MUST_EXIST);
00732 if (file.empty()) return;
00733 ModFiles files;
00734 std::string mod;
00735 if (!files.importModFiles(mod, std::string(file.mb_str(wxConvUTF8))))
00736 {
00737 S3D::dialogMessage("Import Mod", "Failed to read mod export file");
00738 return;
00739 }
00740 if (!files.writeModFiles(mod))
00741 {
00742 S3D::dialogMessage("Import Mod", "Failed to write mod files");
00743 return;
00744 }
00745 updateModList();
00746 }
00747
00748 void showDisplayDialog()
00749 {
00750 DisplayFrame frame;
00751 frame.ShowModal();
00752 }