mirror of https://github.com/PCSX2/pcsx2.git
gsdx: linux: * fix some issue with empty string in configuration
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4553 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
56bb1c50b4
commit
4619941b9e
|
@ -75,8 +75,17 @@ bool RunLinuxDialog()
|
|||
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "1280x960@60");
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "And a few other values like that.");
|
||||
|
||||
// Or whatever the default value is.
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 2);
|
||||
// A little hackish but enough for the moment.
|
||||
// Better drop this setting and lets the user resize the windows like any applications
|
||||
// You need only to constrain it with the aspect ratio -- greg
|
||||
int width = theApp.GetConfig("ModeWidth", 640);
|
||||
switch(width) {
|
||||
case 1280: gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 3); break;
|
||||
case 1024: gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 2); break;
|
||||
case 800: gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 1); break;
|
||||
case 640: gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 0); break;
|
||||
default: gtk_combo_box_set_active(GTK_COMBO_BOX(res_combo_box), 0); break;
|
||||
}
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(main_box), res_label);
|
||||
gtk_container_add(GTK_CONTAINER(main_box), res_combo_box);
|
||||
|
@ -196,11 +205,11 @@ bool RunLinuxDialog()
|
|||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(res_combo_box)) != -1) {
|
||||
int resolution = gtk_combo_box_get_active(GTK_COMBO_BOX(res_combo_box));
|
||||
switch (resolution) {
|
||||
case 0: theApp.SetConfig("w", 640); theApp.SetConfig("h", 480); break;
|
||||
case 1: theApp.SetConfig("w", 800); theApp.SetConfig("h", 600); break;
|
||||
case 2: theApp.SetConfig("w", 1024); theApp.SetConfig("h", 768); break;
|
||||
case 3: theApp.SetConfig("w", 1280); theApp.SetConfig("h", 960); break;
|
||||
default: theApp.SetConfig("w", 640); theApp.SetConfig("h", 480);
|
||||
case 0: theApp.SetConfig("ModeWidth", 640); theApp.SetConfig("ModeHeight", 480); break;
|
||||
case 1: theApp.SetConfig("ModeWidth", 800); theApp.SetConfig("ModeHeight", 600); break;
|
||||
case 2: theApp.SetConfig("ModeWidth", 1024); theApp.SetConfig("ModeHeight", 768); break;
|
||||
case 3: theApp.SetConfig("ModeWidth", 1280); theApp.SetConfig("ModeHeight", 960); break;
|
||||
default: theApp.SetConfig("ModeWidth", 640); theApp.SetConfig("ModeHeight", 480);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -341,8 +341,8 @@ bool GSWnd::Create(const string& title, int w, int h)
|
|||
if(m_window != NULL) return false;
|
||||
|
||||
if(w <= 0 || h <= 0) {
|
||||
w = theApp.GetConfig("w", 640);
|
||||
h = theApp.GetConfig("h", 480);
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
h = theApp.GetConfig("ModeHeight", 480);
|
||||
}
|
||||
|
||||
m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
|
@ -368,8 +368,8 @@ GSVector4i GSWnd::GetClientRect()
|
|||
{
|
||||
// TODO
|
||||
int h, w;
|
||||
w = theApp.GetConfig("w", 640);
|
||||
h = theApp.GetConfig("h", 480);
|
||||
w = theApp.GetConfig("ModeWidth", 640);
|
||||
h = theApp.GetConfig("ModeHeight", 480);
|
||||
|
||||
return GSVector4i(0, 0, w, h);
|
||||
}
|
||||
|
|
|
@ -49,9 +49,11 @@ size_t GSdxApp::GetPrivateProfileString(const char* lpAppName, const char* lpKey
|
|||
|
||||
std::string key(lpKeyName);
|
||||
std::string value = m_configuration_map[key];
|
||||
if (value.empty())
|
||||
if (value.empty()) {
|
||||
// save the value for futur call
|
||||
m_configuration_map[key] = std::string(lpDefault);
|
||||
strcpy(lpReturnedString, lpDefault);
|
||||
else
|
||||
} else
|
||||
strcpy(lpReturnedString, value.c_str());
|
||||
|
||||
return 0;
|
||||
|
@ -75,6 +77,7 @@ bool GSdxApp::WritePrivateProfileString(const char* lpAppName, const char* lpKey
|
|||
// Do not save the inifile key which is not an option
|
||||
if (it->first.compare("inifile") == 0) continue;
|
||||
|
||||
if (!it->second.empty())
|
||||
fprintf(f, "%s = %s\n", it->first.c_str(), it->second.c_str());
|
||||
}
|
||||
fclose(f);
|
||||
|
@ -87,9 +90,11 @@ int GSdxApp::GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName,
|
|||
BuildConfigurationMap(lpFileName);
|
||||
|
||||
std::string value = m_configuration_map[std::string(lpKeyName)];
|
||||
if (value.empty())
|
||||
if (value.empty()) {
|
||||
// save the value for futur call
|
||||
SetConfig(lpKeyName, nDefault);
|
||||
return nDefault;
|
||||
else
|
||||
} else
|
||||
return atoi(value.c_str());
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue