Пример #1
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);

    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);
}
Пример #2
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);
}