void GameSettings::readConfiguration() { wxString value; int index; // Open the Configfile conf = new wxFileConfig(wxEmptyString, wxEmptyString, wxT("keeperfx.cfg"), wxEmptyString, wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); // There's no point in editing these value = conf->Read(wxT("INSTALL_PATH"), wxT("./")); installPath = value; value = conf->Read(wxT("INSTALL_TYPE"), wxT("MAX")); installType = value; value = conf->Read(wxT("KEYBOARD"), wxT("101")); keybLayout = value; value = conf->Read(wxT("LANGUAGE"), supported_languages_code[0]); index = optionIndexInArray(supported_languages_code, WXSIZEOF(supported_languages_code), value); langRadio->SetSelection((index>=0)?index:0); value = conf->Read(wxT("SCREENSHOT"), supported_scrshotfmt_code[0]); index = optionIndexInArray(supported_scrshotfmt_code, WXSIZEOF(supported_scrshotfmt_code), value); scrshotRadio->SetSelection((index>=0)?index:0); value = conf->Read(wxT("INGAME_RES"), wxT("640x480 1024x768")); { int config_index = 0; wxStringTokenizer tokenz(value, wxT(" \t\r\n")); while ( tokenz.HasMoreTokens() && (config_index < 3) ) { wxString param = tokenz.GetNextToken(); config_index++; wxString resSuffix1 = wxT("w32"); wxString resSuffix2 = wxT("x32"); // Try remove suffix unsigned int i = param.find(resSuffix1); if (i != wxString::npos) { param.erase(i, param.length()); // Temporarily we make the 'windowed' setting of the first configration as generalized one. if (scrnControlChkBx && (config_index == 1)) { scrnControlChkBx->SetValue(true); } } i = param.find(resSuffix2); if (i != wxString::npos) { param.erase(i, param.length()); } switch (config_index) { case 1: if (resPrimaryCombo) { resPrimaryCombo->SetValue(param); } break; case 2: if (resSecondaryCombo) { resSecondaryChkBx->SetValue(true); resSecondaryCombo->SetValue(param); } break; case 3: if (resTertiaryCombo) { resTertiaryChkBx->SetValue(true); resTertiaryCombo->SetValue(param); } break; default: break; } } // SetSelection() doesn't generate event to update resolution options, so lrt's call it: ChangeResolutionOptions(index); Layout(); } value = conf->Read(wxT("WINDOWED_MODE"), supported_boolean_code[0]); index = optionIndexInArray(supported_boolean_code, WXSIZEOF(supported_boolean_code), value); scrnControlChkBx->SetValue((index >= 0) ? index : 0); index = conf->Read(wxT("POINTER_SENSITIVITY"), 100); value = wxString::Format(wxT("%d"), (int)index); mouseSensitvTxtCtrl->SetValue(value); value = conf->Read(wxT("CENSORSHIP"), supported_boolean_code[0]); index = optionIndexInArray(supported_boolean_code, WXSIZEOF(supported_boolean_code), value); censorChkBx->SetValue((index>=0)?index:0); }
void GameSettings::readConfiguration() { wxString value; int index; // Open the Configfile conf = new wxFileConfig(wxEmptyString, wxEmptyString, wxT("keeperfx.cfg"), wxEmptyString, wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); // There's no point in editing these value = conf->Read(wxT("INSTALL_PATH"), wxT("./")); installPath = value; value = conf->Read(wxT("INSTALL_TYPE"), wxT("MAX")); installType = value; value = conf->Read(wxT("KEYBOARD"), wxT("101")); keybLayout = value; value = conf->Read(wxT("LANGUAGE"), supported_languages_code[0]); index = optionIndexInArray(supported_languages_code, WXSIZEOF(supported_languages_code), value); langRadio->SetSelection((index>=0)?index:0); value = conf->Read(wxT("SCREENSHOT"), supported_scrshotfmt_code[0]); index = optionIndexInArray(supported_scrshotfmt_code, WXSIZEOF(supported_scrshotfmt_code), value); scrshotRadio->SetSelection((index>=0)?index:0); int res_full_num = 0, res_wind_num = 0; value = conf->Read(wxT("FRONTEND_RES"), wxT("640x480x32 640x480x32 640x480x32")); { wxStringTokenizer tokenz(value, wxT(" \t\r\n")); index = 0; while ( tokenz.HasMoreTokens() ) { wxString param = tokenz.GetNextToken(); if (param.rfind('w') != wxString::npos) res_wind_num++; else res_full_num++; switch (index) { case 0: resFailCombo->SetValue(param); break; case 1: resMovieCombo->SetValue(param); break; case 2: resMenuCombo->SetValue(param); break; } index++; } } value = conf->Read(wxT("INGAME_RES"), wxT("640x480x32 1024x768x32")); { wxString selected_resolutions[5]; size_t selected_num; wxString disabled_resolution; wxStringTokenizer tokenz(value, wxT(" \t\r\n")); disabled_resolution = resFailCombo->GetValue(); selected_num=0; while ( tokenz.HasMoreTokens() && (selected_num < 5) ) { wxString param = tokenz.GetNextToken(); if (param.rfind('w') != wxString::npos) res_wind_num++; else res_full_num++; if (param.CmpNoCase(disabled_resolution) != 0) { selected_resolutions[selected_num] = param; selected_num++; } } // Now we have the amount of fullscreen and windowed resolutions ready if ((res_wind_num > 0) && (res_full_num > 0)) index = 2; else if (res_wind_num > 0) index = 1; else index = 0; scrnControlRadio->SetSelection(index); // SetSelection() doesn't generate event to update resolution options, so lrt's call it: ChangeResolutionOptions(index); Layout(); // Set in-game resolutions resIngameBox->SetSelected(4, selected_resolutions, selected_num); } index = conf->Read(wxT("POINTER_SENSITIVITY"), 100); value = wxString::Format(wxT("%d"), (int)index); mouseSensitvTxtCtrl->SetValue(value); value = conf->Read(wxT("CENSORSHIP"), supported_boolean_code[0]); index = optionIndexInArray(supported_boolean_code, WXSIZEOF(supported_boolean_code), value); censorChkBx->SetValue((index>=0)?index:0); }
void GameSettings::OnScreenCtrlChange(wxCommandEvent& event) { // Change screen control ChangeResolutionOptions(event.GetInt()); Layout(); }
GameSettings::GameSettings(wxFrame *parent) : wxDialog (parent, -1, wxT("Settings editor"), wxDefaultPosition, wxSize(460, 480)) { topsizer = new wxBoxSizer( wxVERTICAL ); resIngameBox = new wxCheckRadioBox(this, wxID_ANY, wxT("In-game resolutions"), NULL, NULL, 0, 0 ); resIngameBox->SetToolTip(tooltips_eng[1],tooltips_eng[2]); resIngameBoxSizer = new wxStaticBoxSizer( resIngameBox, wxHORIZONTAL ); resIngameBoxSizer->Add(resIngameBox->rbPanel, 1, wxEXPAND); // for wxStaticBox, we're adding sizer instead of the actual wxStaticBox instance topsizer->Add(resIngameBoxSizer, 1, wxEXPAND); resOtherPanel = new wxPanel(this, wxID_ANY); wxBoxSizer *resOtherPanelSizer = new wxBoxSizer( wxHORIZONTAL ); { wxStaticBox *resMenuBox = new wxStaticBox(resOtherPanel, wxID_ANY, wxT("Menu resolution") ); resMenuBox->SetToolTip(tooltips_eng[4]); resMenuBoxSizer = new wxStaticBoxSizer(resMenuBox, wxVERTICAL); resMenuCombo = NULL; resOtherPanelSizer->Add(resMenuBoxSizer, 1, wxALIGN_CENTER); wxStaticBox *resMovieBox = new wxStaticBox(resOtherPanel, wxID_ANY, wxT("Movies resolution") ); resMovieBox->SetToolTip(tooltips_eng[3]); resMovieBoxSizer = new wxStaticBoxSizer(resMovieBox, wxHORIZONTAL); resMovieCombo = NULL; resOtherPanelSizer->Add(resMovieBoxSizer, 1, wxALIGN_CENTER); wxStaticBox *resFailBox = new wxStaticBox(resOtherPanel, wxID_ANY, wxT("Failure resolution") ); resFailBox->SetToolTip(tooltips_eng[5]); resFailBoxSizer = new wxStaticBoxSizer(resFailBox, wxVERTICAL); resFailCombo = NULL; resOtherPanelSizer->Add(resFailBoxSizer, 1, wxALIGN_CENTER); ChangeResolutionOptions(2); } resOtherPanel->SetSizer(resOtherPanelSizer); topsizer->Add(resOtherPanel, 0, wxEXPAND); scrnControlRadio = new wxRadioBox( this, eventID_ScrnCtrlChange, wxT("Screen control"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(screen_control_mode_text), screen_control_mode_text, 3, wxRA_SPECIFY_COLS ); scrnControlRadio->SetToolTip(tooltips_eng[10]); topsizer->Add(scrnControlRadio, 0, wxEXPAND); langRadio = new wxRadioBox( this, wxID_ANY, wxT("Language"), wxDefaultPosition, wxSize(-1, -1), WXSIZEOF(supported_languages_text), supported_languages_text, 4, wxRA_SPECIFY_COLS); langRadio->SetToolTip(tooltips_eng[6]); topsizer->Add(langRadio, 0, wxEXPAND); wxStaticBox *otherSettingsBox = new wxStaticBox( this, wxID_ANY, wxT("Other settings") ); wxStaticBoxSizer* otherSettingsSizer = new wxStaticBoxSizer( otherSettingsBox, wxVERTICAL ); { { censorChkBx = new wxCheckBox(this, wxID_ANY, wxT("Censorship (limit amount of blood and flesh)")); censorChkBx->SetToolTip(tooltips_eng[7]); censorChkBx->SetValue(false); otherSettingsSizer->Add(censorChkBx, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); } { wxPanel *mouseSensitivityPanel = new wxPanel(this, wxID_ANY); wxBoxSizer *mouseSensitivityPanelSizer = new wxBoxSizer( wxHORIZONTAL ); { wxStaticText *statTxt = new wxStaticText(mouseSensitivityPanel, wxID_ANY, wxT("Mouse sensitivity")); statTxt->SetToolTip(tooltips_eng[8]); mouseSensitivityPanelSizer->Add(statTxt, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); mouseSensitivityPanelSizer->AddSpacer(16); wxIntegerValidator<long> mouseSensitivityVal(NULL, wxNUM_VAL_THOUSANDS_SEPARATOR); mouseSensitivityVal.SetRange(-10000,10000); mouseSensitvTxtCtrl = new wxTextCtrl(mouseSensitivityPanel, wxID_ANY, wxT("100"), wxDefaultPosition, wxSize(64, -1), 0, mouseSensitivityVal); mouseSensitvTxtCtrl->SetToolTip(tooltips_eng[8]); mouseSensitivityPanelSizer->Add(mouseSensitvTxtCtrl, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); } mouseSensitivityPanel->SetSizer(mouseSensitivityPanelSizer); otherSettingsSizer->Add(mouseSensitivityPanel, 1, wxEXPAND); } otherSettingsSizer->SetMinSize(386, 64); } topsizer->Add(otherSettingsSizer, 0, wxEXPAND); // for wxStaticBox, we're adding sizer instead of the actual wxStaticBox instance scrshotRadio = new wxRadioBox( this, wxID_ANY, wxT("Screenshots"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(supported_scrshotfmt_text), supported_scrshotfmt_text, 2, wxRA_SPECIFY_COLS ); scrshotRadio->SetToolTip(tooltips_eng[9]); topsizer->Add(scrshotRadio, 0, wxEXPAND); wxPanel *dlgBottomPanel = new wxPanel(this, wxID_ANY); wxBoxSizer *dlgBottomPanelSizer = new wxBoxSizer( wxHORIZONTAL ); { dlgBottomPanelSizer->AddStretchSpacer(1); wxButton *saveBtn = new wxButton(dlgBottomPanel, eventID_Save, _T("&Save") ); saveBtn->SetToolTip(tooltips_eng[11]); dlgBottomPanelSizer->Add(saveBtn, 0, wxEXPAND); dlgBottomPanelSizer->AddStretchSpacer(1); wxButton *exitBtn = new wxButton(dlgBottomPanel, eventID_Cancel, _T("&Cancel") ); exitBtn->SetToolTip(tooltips_eng[12]); dlgBottomPanelSizer->Add(exitBtn, 0, wxEXPAND); dlgBottomPanelSizer->AddStretchSpacer(1); } dlgBottomPanel->SetSizer(dlgBottomPanelSizer); topsizer->Add(dlgBottomPanel, 0, wxEXPAND); SetSizer(topsizer); Centre(wxBOTH); }