mirror of https://github.com/PCSX2/pcsx2.git
GSdx linux:
* Add a map to handle the configuration * Connect the window size option to the gui option git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4539 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
490b5f6a7f
commit
e1592788c0
|
@ -71,6 +71,7 @@ bool RunLinuxDialog()
|
||||||
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "640x480@60");
|
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "640x480@60");
|
||||||
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "800x600@60");
|
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "800x600@60");
|
||||||
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "1024x768@60");
|
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "1024x768@60");
|
||||||
|
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.");
|
gtk_combo_box_append_text(GTK_COMBO_BOX(res_combo_box), "And a few other values like that.");
|
||||||
|
|
||||||
// Or whatever the default value is.
|
// Or whatever the default value is.
|
||||||
|
@ -180,6 +181,17 @@ bool RunLinuxDialog()
|
||||||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(aspect_combo_box)) != -1)
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(aspect_combo_box)) != -1)
|
||||||
aspect = gtk_combo_box_get_active(GTK_COMBO_BOX(aspect_combo_box));
|
aspect = gtk_combo_box_get_active(GTK_COMBO_BOX(aspect_combo_box));
|
||||||
#endif
|
#endif
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check)));
|
theApp.SetConfig("filter", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_check)));
|
||||||
theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check)));
|
theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logz_check)));
|
||||||
|
|
|
@ -340,7 +340,10 @@ bool GSWnd::Create(const string& title, int w, int h)
|
||||||
{
|
{
|
||||||
if(m_window != NULL) return false;
|
if(m_window != NULL) return false;
|
||||||
|
|
||||||
if(w <= 0 || h <= 0) {w = 640; h = 480;}
|
if(w <= 0 || h <= 0) {
|
||||||
|
w = theApp.GetConfig("w", 640);
|
||||||
|
h = theApp.GetConfig("h", 480);
|
||||||
|
}
|
||||||
|
|
||||||
m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
m_window = SDL_CreateWindow(title.c_str(), 100, 100, w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
|
@ -364,8 +367,11 @@ Display* GSWnd::GetDisplay()
|
||||||
GSVector4i GSWnd::GetClientRect()
|
GSVector4i GSWnd::GetClientRect()
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
int h, w;
|
||||||
|
w = theApp.GetConfig("w", 640);
|
||||||
|
h = theApp.GetConfig("h", 480);
|
||||||
|
|
||||||
return GSVector4i(0, 0, 640, 480);
|
return GSVector4i(0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns FALSE if the window has no title, or if th window title is under the strict
|
// Returns FALSE if the window has no title, or if th window title is under the strict
|
||||||
|
|
|
@ -43,25 +43,54 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
size_t GetPrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName)
|
size_t GSdxApp::GetPrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName)
|
||||||
{
|
{
|
||||||
// TODO: linux
|
BuildConfigurationMap(lpFileName);
|
||||||
|
|
||||||
|
std::string key(lpKeyName);
|
||||||
|
std::string value = m_configuration_map[key];
|
||||||
|
if (value.empty())
|
||||||
|
strcpy(lpReturnedString, lpDefault);
|
||||||
|
else
|
||||||
|
strcpy(lpReturnedString, value.c_str());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WritePrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName)
|
bool GSdxApp::WritePrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName)
|
||||||
{
|
{
|
||||||
// TODO: linux
|
BuildConfigurationMap(lpFileName);
|
||||||
|
|
||||||
return false;
|
std::string key(lpKeyName);
|
||||||
|
std::string value(pString);
|
||||||
|
m_configuration_map[key] = value;
|
||||||
|
|
||||||
|
// Save config to a file
|
||||||
|
FILE* f = fopen(lpFileName, "w");
|
||||||
|
|
||||||
|
if (f == NULL) return false; // FIXME print a nice message
|
||||||
|
|
||||||
|
map<std::string,std::string>::iterator it;
|
||||||
|
for (it = m_configuration_map.begin(); it != m_configuration_map.end(); ++it) {
|
||||||
|
// Do not save the inifile key which is not an option
|
||||||
|
if (it->first.compare("inifile") == 0) continue;
|
||||||
|
|
||||||
|
fprintf(f, "%s = %s\n", it->first.c_str(), it->second.c_str());
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName)
|
int GSdxApp::GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName)
|
||||||
{
|
{
|
||||||
// TODO: linux
|
BuildConfigurationMap(lpFileName);
|
||||||
|
|
||||||
return nDefault;
|
std::string value = m_configuration_map[std::string(lpKeyName)];
|
||||||
|
if (value.empty())
|
||||||
|
return nDefault;
|
||||||
|
else
|
||||||
|
return atoi(value.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -128,6 +157,31 @@ GSdxApp::GSdxApp()
|
||||||
m_gpu_scale.push_back(GSSetting(2 | (2 << 2), "H x 4 - V x 4", ""));
|
m_gpu_scale.push_back(GSSetting(2 | (2 << 2), "H x 4 - V x 4", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _LINUX
|
||||||
|
void GSdxApp::BuildConfigurationMap(const char* lpFileName)
|
||||||
|
{
|
||||||
|
// Check if the map was already built
|
||||||
|
std::string inifile_value(lpFileName);
|
||||||
|
if ( inifile_value.compare(m_configuration_map["inifile"]) == 0 ) return;
|
||||||
|
m_configuration_map["inifile"] = inifile_value;
|
||||||
|
|
||||||
|
// Load config from file
|
||||||
|
char value[255];
|
||||||
|
char key[255];
|
||||||
|
FILE* f = fopen(lpFileName, "r");
|
||||||
|
|
||||||
|
if (f == NULL) return false; // FIXME print a nice message
|
||||||
|
|
||||||
|
while( fscanf(f, "%s = %s\n", key, value) != EOF ) {
|
||||||
|
std::string key_s(key);
|
||||||
|
std::string value_s(value);
|
||||||
|
m_configuration_map[key_s] = value_s;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* GSdxApp::GetModuleHandlePtr()
|
void* GSdxApp::GetModuleHandlePtr()
|
||||||
{
|
{
|
||||||
return s_hModule;
|
return s_hModule;
|
||||||
|
|
|
@ -27,6 +27,9 @@ class GSdxApp
|
||||||
{
|
{
|
||||||
std::string m_ini;
|
std::string m_ini;
|
||||||
std::string m_section;
|
std::string m_section;
|
||||||
|
#ifdef _LINUX
|
||||||
|
std::map< std::string, std::string > m_configuration_map;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSdxApp();
|
GSdxApp();
|
||||||
|
@ -36,6 +39,12 @@ public:
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
HMODULE GetModuleHandle() {return (HMODULE)GetModuleHandlePtr();}
|
HMODULE GetModuleHandle() {return (HMODULE)GetModuleHandlePtr();}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _LINUX
|
||||||
|
void BuildConfigurationMap(const char* lpFileName);
|
||||||
|
size_t GetPrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName);
|
||||||
|
bool WritePrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName);
|
||||||
|
int GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName);
|
||||||
|
#endif
|
||||||
|
|
||||||
string GetConfig(const char* entry, const char* value);
|
string GetConfig(const char* entry, const char* value);
|
||||||
void SetConfig(const char* entry, const char* value);
|
void SetConfig(const char* entry, const char* value);
|
||||||
|
|
Loading…
Reference in New Issue