summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-11-28 15:41:04 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-11-28 15:41:04 +0000
commit676eb630fbb2ac830a0befdd30a3a16705af7e86 (patch)
treef2586fbf4d2ad8f293397faf9034ccdb7a5bdef6 /gui
parent99bc6308ba92d0bf8bf158f032b21b7aa17a3bf2 (diff)
downloadpcsxr-676eb630fbb2ac830a0befdd30a3a16705af7e86.tar.gz
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@38411 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'gui')
-rw-r--r--gui/ConfDlg.c896
-rw-r--r--gui/ConfDlg.h50
-rw-r--r--gui/Gtk2Gui.c1086
-rw-r--r--gui/Linux.h17
-rw-r--r--gui/LnxMain.c8
-rw-r--r--gui/Makefile.am1
-rw-r--r--gui/Makefile.in5
-rw-r--r--gui/MemcardDlg.c142
8 files changed, 1142 insertions, 1063 deletions
diff --git a/gui/ConfDlg.c b/gui/ConfDlg.c
new file mode 100644
index 00000000..5320629b
--- /dev/null
+++ b/gui/ConfDlg.c
@@ -0,0 +1,896 @@
+/* Pcsx - Pc Psx Emulator
+ * Copyright (C) 1999-2002 Pcsx Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <sys/stat.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <regex.h>
+#include "Linux.h"
+#include "ConfDlg.h"
+
+#include "../libpcsxcore/plugins.h"
+
+static void OnBiosPath_Changed(GtkWidget *wdg, gpointer data);
+static void OnConf_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data);
+static void OnPluginPath_Changed(GtkWidget *wdg, gpointer data);
+static void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data);
+static void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data);
+static void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data);
+static void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data);
+static void OnNet_Conf(GtkWidget *widget, gpointer user_data);
+static void OnNet_About(GtkWidget *widget, gpointer user_data);
+static void on_configure_plugin(GtkWidget *widget, gpointer user_data);
+static void on_about_plugin(GtkWidget *widget, gpointer user_data);
+static void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml);
+static void FindNetPlugin(GladeXML *xml);
+
+PSEgetLibType PSE_getLibType = NULL;
+PSEgetLibVersion PSE_getLibVersion = NULL;
+PSEgetLibName PSE_getLibName = NULL;
+
+GtkWidget *ConfDlg = NULL;
+GtkWidget *NetDlg = NULL;
+GtkWidget *controlwidget = NULL;
+
+PluginConf GpuConfS;
+PluginConf SpuConfS;
+PluginConf CdrConfS;
+PluginConf Pad1ConfS;
+PluginConf Pad2ConfS;
+PluginConf NetConfS;
+PluginConf BiosConfS;
+
+#define FindComboText(combo, list, conf) \
+ if (strlen(conf) > 0) { \
+ int i; \
+ for (i = 2; i < 255; i += 2) { \
+ if (!strcmp(conf, list[i - 2])) { \
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i / 2 - 1); \
+ break; \
+ } \
+ } \
+ }
+
+#define GetComboText(combo, list, conf) \
+ { \
+ int row; \
+ row = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); \
+ strcpy(conf, (char *)list[row * 2]); \
+ }
+
+void ConfigurePlugins() {
+ if (!UseGui) {
+ /* How do we get here if we're not running the GUI? */
+ /* Ryan: we're going to imagine that someday, there will be a way
+ * to configure plugins from the commandline */
+ printf("ERROR: Plugins cannot be configured without the GUI.");
+ return;
+ }
+
+ GladeXML *xml;
+ GtkWidget *widget;
+
+ gchar *path;
+
+ UpdatePluginsBIOS();
+
+ xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "ConfDlg", NULL);
+
+ if (!xml) {
+ g_warning(_("Error: Glade interface could not be loaded!"));
+ return;
+ }
+
+ UpdatePluginsBIOS_UpdateGUI(xml);
+
+ ConfDlg = glade_xml_get_widget(xml, "ConfDlg");
+
+ gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configure PCSX"));
+
+ /* Set the paths in the file choosers to be based on the saved configurations */
+ widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.BiosDir);
+
+ widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.PluginsDir);
+
+ if (strlen(Config.PluginsDir) == 0) {
+ if((path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget))) != NULL) {
+ strcpy(Config.PluginsDir, path);
+ g_free(path);
+ }
+ }
+
+ widget = glade_xml_get_widget(xml, "btn_ConfGpu");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_ConfSpu");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
+
+ /* ADB TODO Does pad 1 and 2 need to be different? */
+ widget = glade_xml_get_widget(xml, "btn_ConfPad1");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnConfConf_Pad1Conf), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_ConfPad2");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnConfConf_Pad2Conf), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_ConfCdr");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutGpu");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutSpu");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutPad1");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnConfConf_Pad1About), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutPad2");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnConfConf_Pad2About), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutCdr");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
+ g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
+ GTK_SIGNAL_FUNC(OnBiosPath_Changed), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
+ g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
+ GTK_SIGNAL_FUNC(OnPluginPath_Changed), xml, NULL, G_CONNECT_AFTER);
+
+ g_signal_connect_data(GTK_OBJECT(ConfDlg), "response",
+ GTK_SIGNAL_FUNC(OnConf_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
+}
+
+void OnNet_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
+ if (arg1 == GTK_RESPONSE_OK) {
+ GetComboText(NetConfS.Combo, NetConfS.plist, Config.Net);
+ SaveConfig();
+ }
+
+ gtk_widget_destroy(GTK_WIDGET (dialog));
+ NetDlg = NULL;
+}
+
+void OnConf_Net() {
+ GladeXML *xml;
+ GtkWidget *widget;
+
+ if (NetDlg != NULL) {
+ gtk_window_present (GTK_WINDOW (NetDlg));
+ return;
+ }
+
+ xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "NetDlg", NULL);
+
+ if (!xml) {
+ g_warning(_("Error: Glade interface could not be loaded!"));
+ return;
+ }
+
+ NetDlg = glade_xml_get_widget(xml, "NetDlg");
+
+ FindNetPlugin(xml);
+
+ /* Setup a handler for when Close or Cancel is clicked */
+ g_signal_connect_data(GTK_OBJECT(NetDlg), "response",
+ GTK_SIGNAL_FUNC(OnNet_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_ConfNet");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnNet_Conf), xml, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btn_AboutNet");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnNet_About), xml, NULL, G_CONNECT_AFTER);
+}
+
+void OnConf_Graphics() {
+ void *drv;
+ GPUconfigure conf;
+ char Plugin[MAXPATHLEN];
+
+ sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);
+ drv = SysLoadLibrary(Plugin);
+ if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
+
+ while (gtk_events_pending()) gtk_main_iteration();
+
+ conf = (GPUconfigure)SysLoadSym(drv, "GPUconfigure");
+ if (conf != NULL) {
+ conf();
+ }
+ else
+ SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
+
+ SysCloseLibrary(drv);
+}
+
+void OnConf_Sound() {
+ void *drv;
+ SPUconfigure conf;
+ char Plugin[MAXPATHLEN];
+
+ sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);
+ drv = SysLoadLibrary(Plugin);
+ if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
+
+ while (gtk_events_pending()) gtk_main_iteration();
+
+ conf = (GPUconfigure)SysLoadSym(drv, "SPUconfigure");
+ if (conf != NULL) {
+ conf();
+ }
+ else
+ SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
+
+ SysCloseLibrary(drv);
+}
+
+void OnConf_CdRom() {
+ void *drv;
+ CDRconfigure conf;
+ char Plugin[MAXPATHLEN];
+
+ sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
+ drv = SysLoadLibrary(Plugin);
+ if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
+
+ while (gtk_events_pending()) gtk_main_iteration();
+
+ conf = (GPUconfigure)SysLoadSym(drv, "CDRconfigure");
+ if (conf != NULL) {
+ conf();
+ }
+ else
+ SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
+
+ SysCloseLibrary(drv);
+}
+
+void OnConf_Pad() {
+ void *drv;
+ PADconfigure conf;
+ char Plugin[MAXPATHLEN];
+
+ sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);
+ drv = SysLoadLibrary(Plugin);
+ if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
+
+ while (gtk_events_pending()) gtk_main_iteration();
+
+ conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
+ if (conf != NULL) {
+ conf();
+ }
+ else
+ SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
+
+ SysCloseLibrary(drv);
+
+ if (strcmp(Config.Pad1, Config.Pad2) != 0) {
+ sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);
+ drv = SysLoadLibrary(Plugin);
+ if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
+
+ while (gtk_events_pending()) gtk_main_iteration();
+
+ conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
+ if (conf != NULL) {
+ conf();
+ }
+
+ SysCloseLibrary(drv);
+ }
+}
+
+static int all_config_set() {
+ int retval;
+
+ if ((strlen(Config.Gpu) != 0) &&
+ (strlen(Config.Spu) != 0) &&
+ (strlen(Config.Cdr) != 0) &&
+ (strlen(Config.Pad1) != 0) &&
+ (strlen(Config.Pad2) != 0))
+ retval = TRUE;
+ else
+ retval = FALSE;
+
+ return retval;
+}
+
+/* TODO Check whether configuration is required when we choose the plugin, and set the state of the
+ button appropriately. New gtk tooltip API should allow us to put a tooltip explanation for
+ disabled widgets */
+/* TODO If combo screen hasn't been opened and the user chooses the menu config option, confs.Combo will be null and cause a segfault */
+#define ConfPlugin(src, confs, plugin, name, parent) { \
+ void *drv; \
+ src conf; \
+ gchar *filename; \
+ \
+ GetComboText(confs.Combo, confs.plist, plugin); \
+ filename = g_build_filename (getenv("HOME"), PLUGINS_DIR, plugin, NULL); \
+ /*printf("Configuring plugin %s\n", filename);*/ \
+ drv = SysLoadLibrary(filename); \
+ if (drv == NULL) {printf("Error with file %s\n", filename);return; } \
+\
+ while (gtk_events_pending()) gtk_main_iteration(); \
+ conf = (src) SysLoadSym(drv, name); \
+ if (conf) { \
+ conf(); \
+ } else \
+ SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured.")); \
+ SysCloseLibrary(drv); \
+ g_free (filename); \
+}
+
+static void on_configure_plugin(GtkWidget *widget, gpointer user_data) {
+ gint plugin_type = (int) user_data;
+
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ if (all_config_set() == TRUE) {
+ switch (plugin_type) {
+ case PSE_LT_GPU:
+ ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUconfigure", ConfDlg);
+ break;
+ case PSE_LT_SPU:
+ ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUconfigure", ConfDlg);
+ break;
+ case PSE_LT_CDR:
+ ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRconfigure", ConfDlg);
+ break;
+ }
+ } else
+ ConfigurePlugins();
+}
+
+static void on_about_plugin(GtkWidget *widget, gpointer user_data) {
+ gint plugin_type = (int) user_data;
+
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ if (all_config_set() == TRUE) {
+ switch (plugin_type) {
+ case PSE_LT_GPU:
+ ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUabout", ConfDlg);
+ break;
+ case PSE_LT_SPU:
+ ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUabout", ConfDlg);
+ break;
+ case PSE_LT_CDR:
+ ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRabout", ConfDlg);
+ break;
+ }
+ } else
+ ConfigurePlugins();
+}
+
+static void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADabout", ConfDlg);
+}
+
+static void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADabout", ConfDlg);
+}
+
+static void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADconfigure", ConfDlg);
+}
+
+static void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADconfigure", ConfDlg);
+}
+
+static void OnNet_Conf(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(NETconfigure, NetConfS, Config.Net, "NETconfigure", NetDlg);
+}
+
+static void OnNet_About(GtkWidget *widget, gpointer user_data) {
+ ConfPlugin(NETabout, NetConfS, Config.Net, "NETabout", NetDlg);
+}
+
+static void OnPluginPath_Changed(GtkWidget *wdg, gpointer data) {
+ gchar *path;
+
+ path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
+ strcpy(Config.PluginsDir, path);
+ UpdatePluginsBIOS();
+ UpdatePluginsBIOS_UpdateGUI(data);
+
+ g_free(path);
+}
+
+static void OnBiosPath_Changed(GtkWidget *wdg, gpointer data) {
+ gchar *foldername;
+
+ foldername = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
+ strcpy(Config.BiosDir, foldername);
+
+ UpdatePluginsBIOS();
+ UpdatePluginsBIOS_UpdateGUI(data);
+
+ g_free(foldername);
+}
+
+void OnConf_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
+ if (arg1 == GTK_RESPONSE_OK) {
+ GetComboText(GpuConfS.Combo, GpuConfS.plist, Config.Gpu);
+ GetComboText(SpuConfS.Combo, SpuConfS.plist, Config.Spu);
+ GetComboText(CdrConfS.Combo, CdrConfS.plist, Config.Cdr);
+ GetComboText(Pad1ConfS.Combo, Pad1ConfS.plist, Config.Pad1);
+ GetComboText(Pad2ConfS.Combo, Pad2ConfS.plist, Config.Pad2);
+ GetComboText(BiosConfS.Combo, BiosConfS.plist, Config.Bios);
+
+ SaveConfig();
+ }
+
+ gtk_widget_destroy(ConfDlg);
+ ConfDlg = NULL;
+}
+
+#define ComboAddPlugin(type) { \
+ type##ConfS.plugins += 2; \
+ strcpy(type##ConfS.plist[type##ConfS.plugins - 1], name); \
+ strcpy(type##ConfS.plist[type##ConfS.plugins - 2], ent->d_name); \
+ type##ConfS.glist = g_list_append(type##ConfS.glist, type##ConfS.plist[type##ConfS.plugins-1]); \
+}
+
+void populate_combo_box(GtkWidget *widget, GList *list) {
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ store = gtk_list_store_new(1, G_TYPE_STRING);
+
+ // Clear existing data from combo box
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(widget));
+
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, FALSE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
+
+ while (list != NULL) {
+ GtkTreeIter iter;
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, (char *)list->data, -1);
+ list = list->next;
+ }
+
+ gtk_combo_box_set_model(GTK_COMBO_BOX(widget), GTK_TREE_MODEL(store));
+}
+
+#define ConfCreatePConf(name, type) \
+ /* Populate the relevant combo widget with the list of plugins. \
+ If no plugins available, disable the combo and its controls. \
+ Note that the Bios plugin has no About/Conf control. */ \
+ type##ConfS.Combo = glade_xml_get_widget(xml, "GtkCombo_" name); \
+ if (type##ConfS.glist != NULL) { \
+ populate_combo_box (type##ConfS.Combo, type##ConfS.glist); \
+ FindComboText(type##ConfS.Combo, type##ConfS.plist, Config.type); \
+ gtk_widget_set_sensitive (type##ConfS.Combo, TRUE); \
+ if (g_ascii_strcasecmp (name, "Bios") != 0) { \
+ controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
+ gtk_widget_set_sensitive (controlwidget, TRUE); \
+ controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
+ gtk_widget_set_sensitive (controlwidget, TRUE); \
+ } \
+ } else { \
+ if (g_ascii_strcasecmp (name, "Bios") != 0) { \
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (type##ConfS.Combo)); \
+ gtk_widget_set_sensitive (type##ConfS.Combo, FALSE); \
+ controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
+ gtk_widget_set_sensitive (controlwidget, FALSE); \
+ controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
+ gtk_widget_set_sensitive (controlwidget, FALSE); \
+ } \
+ }
+
+int plugin_is_available(gchar *plugin) {
+ int retval;
+ gchar *pluginfile;
+ struct stat stbuf;
+
+ pluginfile = g_strconcat(getenv("HOME"), PLUGINS_DIR, plugin, NULL);
+
+ if (stat(pluginfile, &stbuf) == -1)
+ retval = FALSE;
+ else
+ retval = TRUE;
+
+ g_free(pluginfile);
+
+ return retval;
+}
+
+int plugins_configured() {
+ // make sure there are choices for all of the plugins!!
+ if (all_config_set() == FALSE)
+ return FALSE;
+
+ // and make sure they can all be accessed
+ // if they can't be, wipe the variable and return FALSE
+ if (plugin_is_available (Config.Gpu) == FALSE) { Config.Gpu[0] = '\0'; return FALSE; }
+ if (plugin_is_available (Config.Spu) == FALSE) { Config.Spu[0] = '\0'; return FALSE; }
+ if (plugin_is_available (Config.Cdr) == FALSE) { Config.Cdr[0] = '\0'; return FALSE; }
+ if (plugin_is_available (Config.Pad1) == FALSE) { Config.Pad1[0] = '\0'; return FALSE; }
+ if (plugin_is_available (Config.Pad2) == FALSE) { Config.Pad2[0] = '\0'; return FALSE; }
+
+ // if everything is happy, return TRUE
+ return TRUE;
+}
+
+int is_valid_bios_file(gchar *filename) {
+ int valid;
+ struct stat buf;
+
+ if ((stat(filename, &buf) == -1) || (buf.st_size != (1024*512)))
+ valid = FALSE;
+ else {
+ valid = TRUE;
+ }
+
+ return valid;
+}
+
+// Add the name of the BIOS file to the drop-down list. This will
+// be the filename, not the full path to the file
+void add_bios_to_list(gchar *bios_name, gchar *internal_name) {
+ BiosConfS.plugins += 2;
+ strcpy(BiosConfS.plist[BiosConfS.plugins - 1], bios_name);
+ strcpy(BiosConfS.plist[BiosConfS.plugins - 2], internal_name);
+ BiosConfS.glist = g_list_append(BiosConfS.glist, BiosConfS.plist[BiosConfS.plugins - 1]);
+}
+
+void scan_bios_dir(gchar *dirname) {
+ DIR *dir;
+ struct dirent *ent;
+ gchar *filename;
+
+ dir = opendir(dirname);
+ if (dir == NULL) {
+ SysMessage(_("Could not open BIOS directory: '%s'\n"), dirname);
+ return;
+ }
+
+ while ((ent = readdir(dir)) != NULL) {
+ filename = g_build_filename(dirname, ent->d_name, NULL);
+ if (is_valid_bios_file(filename))
+ add_bios_to_list(g_path_get_basename(filename), g_path_get_basename (filename));
+ g_free(filename);
+ }
+ closedir(dir);
+}
+
+void UpdatePluginsBIOS() {
+ DIR *dir;
+ struct dirent *ent;
+ void *Handle;
+ char name[256];
+ gchar *linkname;
+
+ GpuConfS.plugins = 0; SpuConfS.plugins = 0; CdrConfS.plugins = 0;
+ Pad1ConfS.plugins = 0; Pad2ConfS.plugins = 0; BiosConfS.plugins = 0;
+ GpuConfS.glist = NULL; SpuConfS.glist = NULL; CdrConfS.glist = NULL;
+ Pad1ConfS.glist = NULL; Pad2ConfS.glist = NULL; BiosConfS.glist = NULL;
+ GpuConfS.plist[0][0] = '\0'; SpuConfS.plist[0][0] = '\0'; CdrConfS.plist[0][0] = '\0';
+ Pad1ConfS.plist[0][0] = '\0'; Pad2ConfS.plist[0][0] = '\0'; BiosConfS.plist[0][0] = '\0';
+
+ // Load and get plugin info
+ dir = opendir(Config.PluginsDir);
+ if (dir == NULL) {
+ printf(_("Could not open directory: '%s'\n"), Config.PluginsDir);
+ return;
+ }
+ while ((ent = readdir(dir)) != NULL) {
+ long type, v;
+ linkname = g_build_filename(Config.PluginsDir, ent->d_name, NULL);
+
+ // only libraries past this point, not config tools
+ if (strstr(linkname, ".so") == NULL && strstr(linkname, ".dylib") == NULL)
+ continue;
+
+ Handle = dlopen(linkname, RTLD_NOW);
+ if (Handle == NULL) {
+ printf("%s\n", dlerror());
+ g_free(linkname);
+ continue;
+ }
+
+ PSE_getLibType = (PSEgetLibType)dlsym(Handle, "PSEgetLibType");
+ if (dlerror() != NULL) {
+ if (strstr(linkname, "gpu") != NULL) type = PSE_LT_GPU;
+ else if (strstr(linkname, "cdr") != NULL) type = PSE_LT_CDR;
+ else if (strstr(linkname, "spu") != NULL) type = PSE_LT_SPU;
+ else if (strstr(linkname, "pad") != NULL) type = PSE_LT_PAD;
+ else { g_free(linkname); continue; }
+ }
+ else type = PSE_getLibType();
+
+ PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
+ if (dlerror() == NULL) {
+ sprintf(name, "%s", PSE_getLibName());
+ PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
+ if (dlerror() == NULL) {
+ char ver[32];
+
+ v = PSE_getLibVersion();
+ sprintf(ver, " %ld.%ld.%ld", v >> 16, (v >> 8) & 0xff, v & 0xff);
+ strcat(name, ver);
+ }
+ }
+ else strcpy(name, ent->d_name);
+
+ if (type & PSE_LT_CDR)
+ ComboAddPlugin(Cdr);
+ if (type & PSE_LT_GPU)
+ ComboAddPlugin(Gpu);
+ if (type & PSE_LT_SPU)
+ ComboAddPlugin(Spu);
+ if (type & PSE_LT_PAD) {
+ PADquery query = (PADquery)dlsym(Handle, "PADquery");
+ if (query() & 0x1) {
+ ComboAddPlugin(Pad1);
+ }
+ if (query() & 0x2) {
+ ComboAddPlugin(Pad2);
+ }
+ }
+ g_free(linkname);
+ }
+ closedir(dir);
+
+ scan_bios_dir(Config.BiosDir);
+
+ // The BIOS list always contains the PCSX internal BIOS
+ add_bios_to_list(_("Internal HLE Bios"), "HLE");
+}
+
+static void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml) {
+ // Populate the plugin combo boxes
+ ConfCreatePConf("Gpu", Gpu);
+ ConfCreatePConf("Spu", Spu);
+ ConfCreatePConf("Pad1", Pad1);
+ ConfCreatePConf("Pad2", Pad2);
+ ConfCreatePConf("Cdr", Cdr);
+ ConfCreatePConf("Bios", Bios);
+}
+
+static void FindNetPlugin(GladeXML *xml) {
+ DIR *dir;
+ struct dirent *ent;
+ void *Handle;
+ char plugin[MAXPATHLEN],name[MAXPATHLEN];
+
+ NetConfS.plugins = 0;
+ NetConfS.glist = NULL;
+
+ NetConfS.plugins += 2;
+ strcpy(NetConfS.plist[NetConfS.plugins - 1], "Disabled");
+ strcpy(NetConfS.plist[NetConfS.plugins - 2], "Disabled");
+ NetConfS.glist = g_list_append(NetConfS.glist, NetConfS.plist[NetConfS.plugins - 1]);
+
+ dir = opendir(Config.PluginsDir);
+ if (dir == NULL)
+ SysMessage(_("Could not open directory: '%s'\n"), Config.PluginsDir);
+ else {
+ /* ADB TODO Replace the following with a function */
+ while ((ent = readdir(dir)) != NULL) {
+ long type, v;
+
+ sprintf(plugin, "%s/%s", Config.PluginsDir, ent->d_name);
+
+ if (strstr(plugin, ".so") == NULL && strstr(plugin, ".dylib") == NULL)
+ continue;
+ Handle = dlopen(plugin, RTLD_NOW);
+ if (Handle == NULL) continue;
+
+ PSE_getLibType = (PSEgetLibType) dlsym(Handle, "PSEgetLibType");
+ if (dlerror() != NULL) {
+ if (strstr(plugin, "net") != NULL) type = PSE_LT_NET;
+ else continue;
+ }
+ else type = PSE_getLibType();
+
+ PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
+ if (dlerror() == NULL) {
+ sprintf(name, "%s", PSE_getLibName());
+ PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
+ if (dlerror() == NULL) {
+ char ver[32];
+
+ v = PSE_getLibVersion();
+ sprintf(ver, " %ld.%ld.%ld",v>>16,(v>>8)&0xff,v&0xff);
+ strcat(name, ver);
+ }
+ }
+ else strcpy(name, ent->d_name);
+
+ if (type & PSE_LT_NET) {
+ ComboAddPlugin(Net);
+ }
+ }
+ closedir(dir);
+
+ ConfCreatePConf("Net", Net);
+ }
+}
+
+GtkWidget *CpuDlg;
+GtkWidget *PsxCombo;
+GList *psxglist;
+char *psxtypes[] = {
+ "NTSC",
+ "PAL"
+};
+
+// When the auto-detect CPU type is selected, disable the NTSC/PAL selection
+static void OnCpu_PsxAutoClicked (GtkWidget *widget, gpointer user_data) {
+ GtkWidget *combo;
+ GladeXML *xml = user_data;
+ combo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
+
+ gtk_widget_set_sensitive (combo,
+ !(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))));
+}
+
+// When the interpreter core is deselected, disable the debugger checkbox
+static void OnCpu_CpuClicked(GtkWidget *widget, gpointer user_data) {
+ GtkWidget *check;
+ GladeXML *xml = user_data;
+ check = glade_xml_get_widget(xml, "GtkCheckButton_Dbg");
+
+ // Debugger is only working with interpreter not recompiler, so let's set it
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
+
+ gtk_widget_set_sensitive (check,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+}
+
+void OnCpu_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
+ if (arg1 == GTK_RESPONSE_OK) {
+ GtkWidget *widget;
+ GladeXML *xml = user_data;
+ int tmp;
+ long t;
+
+ widget = glade_xml_get_widget(xml, "GtkCombo_PsxType");
+
+ // If nothing chosen, default to NTSC
+ tmp = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ if (tmp == -1)
+ tmp = PSX_TYPE_NTSC;
+
+ if (!strcmp("NTSC", psxtypes[tmp]))
+ Config.PsxType = PSX_TYPE_NTSC;
+ else
+ Config.PsxType = PSX_TYPE_PAL;
+
+ Config.Xa = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Xa")));
+ Config.Sio = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Sio")));
+ Config.Mdec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Mdec")));
+ Config.Cdda = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_CDDA")));
+ Config.PsxAuto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")));
+
+ t = Config.Debug;
+ Config.Debug = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Dbg")));
+ if (t != Config.Debug) {
+ if (Config.Debug) StartDebugger();
+ else StopDebugger();
+ }
+
+ t = Config.Cpu;
+ Config.Cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")));
+ if (t != Config.Cpu) {
+ psxCpu->Shutdown();
+#ifdef PSXREC
+ if (Config.Cpu) {
+ psxCpu = &psxInt;
+ }
+ else psxCpu = &psxRec;
+#else
+ psxCpu = &psxInt;
+#endif
+ if (psxCpu->Init() == -1) {
+ SysClose();
+ exit(1);
+ }
+ psxCpu->Reset();
+ }
+
+ Config.PsxOut = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")));
+ Config.SpuIrq = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")));
+ Config.RCntFix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")));
+ Config.VSyncWA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")));
+
+ SaveConfig();
+ }
+
+ gtk_widget_destroy(CpuDlg);
+ CpuDlg = NULL;
+}
+
+void OnConf_Cpu() {
+ GladeXML *xml;
+
+ xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "CpuDlg", NULL);
+
+ if (!xml) {
+ g_warning("We could not load the interface!");
+ return;
+ }
+
+ CpuDlg = glade_xml_get_widget(xml, "CpuDlg");
+
+ PsxCombo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
+ gtk_combo_box_set_active(GTK_COMBO_BOX (PsxCombo), Config.PsxType);
+ gtk_widget_set_sensitive(GTK_WIDGET (PsxCombo), !Config.PsxAuto);
+
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Xa")), Config.Xa);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Sio")), Config.Sio);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Mdec")), Config.Mdec);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_CDDA")), Config.Cdda);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), Config.PsxAuto);
+
+ g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), "toggled",
+ GTK_SIGNAL_FUNC(OnCpu_PsxAutoClicked), xml, NULL, G_CONNECT_AFTER);
+
+#ifdef PSXREC
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), Config.Cpu);
+
+ g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), "toggled",
+ GTK_SIGNAL_FUNC(OnCpu_CpuClicked), xml, NULL, G_CONNECT_AFTER);
+#else
+ Config.Cpu = 1;
+
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), FALSE);
+#endif
+
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu && Config.Debug);
+ gtk_widget_set_sensitive(GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu);
+
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")), Config.PsxOut);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")), Config.SpuIrq);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")), Config.RCntFix);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")), Config.VSyncWA);
+
+ // Setup a handler for when Close or Cancel is clicked
+ g_signal_connect_data(GTK_OBJECT(CpuDlg), "response",
+ GTK_SIGNAL_FUNC(OnCpu_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
+}
diff --git a/gui/ConfDlg.h b/gui/ConfDlg.h
new file mode 100644
index 00000000..00e10c10
--- /dev/null
+++ b/gui/ConfDlg.h
@@ -0,0 +1,50 @@
+/* Pcsx - Pc Psx Emulator
+ * Copyright (C) 1999-2002 Pcsx Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
+ */
+
+#ifndef CONFDLG_H
+#define CONFDLG_H
+
+// Helper Functions
+void UpdatePluginsBIOS();
+
+// Functions Callbacks
+void OnConf_Graphics();
+void OnConf_Sound();
+void OnConf_CdRom();
+void OnConf_Pad();
+void OnConf_Cpu();
+void OnConf_Net();
+
+void ConfigurePlugins();
+
+typedef struct {
+ GtkWidget *Combo;
+ GList *glist;
+ char plist[255][255]; /* TODO Comment this out */
+ int plugins; /* TODO Comment this out and replace with glist count */
+} PluginConf;
+
+extern PluginConf GpuConfS;
+extern PluginConf SpuConfS;
+extern PluginConf CdrConfS;
+extern PluginConf Pad1ConfS;
+extern PluginConf Pad2ConfS;
+extern PluginConf NetConfS;
+extern PluginConf BiosConfS;
+
+#endif
diff --git a/gui/Gtk2Gui.c b/gui/Gtk2Gui.c
index dbccbf35..0bc5bf24 100644
--- a/gui/Gtk2Gui.c
+++ b/gui/Gtk2Gui.c
@@ -33,22 +33,10 @@
#include "Linux.h"
#include "../libpcsxcore/plugins.h"
-#include "../libpcsxcore/sio.h"
#include "../libpcsxcore/cheat.h"
#include "MemcardDlg.h"
-
-PSEgetLibType PSE_getLibType = NULL;
-PSEgetLibVersion PSE_getLibVersion = NULL;
-PSEgetLibName PSE_getLibName = NULL;
-
-// Helper Functions
-void UpdatePluginsBIOS();
-void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml);
-void FindNetPlugin(GladeXML *xml);
-
-void OnNet_Conf(GtkWidget *widget, gpointer user_data);
-void OnNet_About(GtkWidget *widget, gpointer user_data);
+#include "ConfDlg.h"
// Functions Callbacks
void OnFile_RunCd();
@@ -58,62 +46,22 @@ void OnFile_RunImage();
void OnEmu_Run();
void OnEmu_Reset();
void OnEmu_SwitchImage();
-void OnConf_Graphics();
-void OnConf_Sound();
-void OnConf_CdRom();
-void OnConf_Pad();
-void OnConf_Cpu();
-void OnConf_Net();
void OnHelp_Help();
void OnHelp_About();
void OnDestroy();
void OnFile_Exit();
-void OnBiosPath_Changed(GtkWidget *wdg, gpointer data);
-void OnConf_Clicked (GtkDialog *dialog, gint arg1, gpointer user_data);
-void OnPluginPath_Changed(GtkWidget *wdg, gpointer data);
-void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data);
-void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data);
-void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data);
-void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data);
-
void on_states_load(GtkWidget *widget, gpointer user_data);
void on_states_load_other();
void on_states_save(GtkWidget *widget, gpointer user_data);
void on_states_save_other();
-void on_configure_plugin(GtkWidget *widget, gpointer user_data);
-void on_about_plugin(GtkWidget *widget, gpointer user_data);
-
GtkWidget *Window = NULL;
-GtkWidget *ConfDlg = NULL;
-
-//GtkAccelGroup *AccelGroup;
-
-GtkWidget *controlwidget;
int destroy = 0;
#define MAX_SLOTS 5
-#define FindComboText(combo, list, conf) \
- if (strlen(conf) > 0) { \
- int i; \
- for (i = 2; i < 255; i += 2) { \
- if (!strcmp(conf, list[i - 2])) { \
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i / 2 - 1); \
- break; \
- } \
- } \
- }
-
-#define GetComboText(combo, list, conf) \
- { \
- int row; \
- row = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); \
- strcpy(conf, (char *)list[row * 2]); \
- }
-
/* TODO - If MAX_SLOTS changes, need to find a way to automatically set all positions */
int Slots[MAX_SLOTS] = { -1, -1, -1, -1, -1 };
@@ -123,7 +71,7 @@ void ResetMenuSlots(GladeXML *xml) {
int i;
if (CdromId[0] == '\0') {
- /* disable state saving/loading if no CD is loaded */
+ // disable state saving/loading if no CD is loaded
for (i = 0; i < MAX_SLOTS; i++) {
str = g_strdup_printf("GtkMenuItem_SaveSlot%d", i+1);
widget = glade_xml_get_widget(xml, str);
@@ -132,24 +80,26 @@ void ResetMenuSlots(GladeXML *xml) {
gtk_widget_set_sensitive(widget, FALSE);
str = g_strdup_printf("GtkMenuItem_LoadSlot%d", i+1);
- widget = glade_xml_get_widget (xml, str);
- g_free (str);
+ widget = glade_xml_get_widget(xml, str);
+ g_free(str);
gtk_widget_set_sensitive(widget, FALSE);
}
- /* also disable certain menu items */
- widget = glade_xml_get_widget (xml, "other1");
+ // also disable certain menu/toolbar items
+ widget = glade_xml_get_widget(xml, "other1");
+ gtk_widget_set_sensitive(widget, FALSE);
+ widget = glade_xml_get_widget(xml, "other2");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "other2");
+ widget = glade_xml_get_widget(xml, "run1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "run1");
+ widget = glade_xml_get_widget(xml, "reset1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "reset1");
+ widget = glade_xml_get_widget(xml, "search1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "search1");
+ widget = glade_xml_get_widget(xml, "SwitchImage");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "SwitchImage");
+ widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
gtk_widget_set_sensitive(widget, FALSE);
}
else {
@@ -164,20 +114,30 @@ void ResetMenuSlots(GladeXML *xml) {
gtk_widget_set_sensitive(widget, TRUE);
}
- widget = glade_xml_get_widget (xml, "plugins_bios");
+ widget = glade_xml_get_widget(xml, "plugins_bios");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "graphics1");
+ widget = glade_xml_get_widget(xml, "graphics1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "sound1");
+ widget = glade_xml_get_widget(xml, "sound1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "cdrom1");
+ widget = glade_xml_get_widget(xml, "cdrom1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "pad1");
+ widget = glade_xml_get_widget(xml, "pad1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "net1");
+ widget = glade_xml_get_widget(xml, "net1");
gtk_widget_set_sensitive(widget, FALSE);
- widget = glade_xml_get_widget (xml, "SwitchImage");
+ widget = glade_xml_get_widget(xml, "SwitchImage");
gtk_widget_set_sensitive(widget, cdrfilename[0]);
+ widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
+ gtk_widget_set_sensitive(widget, cdrfilename[0]);
+ widget = glade_xml_get_widget(xml, "toolbutton_graphics");
+ gtk_widget_set_sensitive(widget, FALSE);
+ widget = glade_xml_get_widget(xml, "toolbutton_sound");
+ gtk_widget_set_sensitive(widget, FALSE);
+ widget = glade_xml_get_widget(xml, "toolbutton_cdrom");
+ gtk_widget_set_sensitive(widget, FALSE);
+ widget = glade_xml_get_widget(xml, "toolbutton_controllers");
+ gtk_widget_set_sensitive(widget, FALSE);
}
}
@@ -185,7 +145,7 @@ int match(const char *string, char *pattern) {
int status;
regex_t re;
- if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
+ if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB) != 0) {
return 0;
}
status = regexec(&re, string, (size_t) 0, NULL, 0);
@@ -197,7 +157,7 @@ int match(const char *string, char *pattern) {
return 1;
}
-gchar* get_state_filename (int i) {
+gchar* get_state_filename(int i) {
gchar *state_filename;
char SStateFile[64];
char trimlabel[33];
@@ -252,11 +212,11 @@ void StartGui() {
gtk_window_set_default_icon_from_file(PIXMAPDIR "pcsx-icon.png", NULL);
ResetMenuSlots(xml);
- /* Set up callbacks */
+ // Set up callbacks
g_signal_connect_data(GTK_OBJECT(Window), "delete-event",
GTK_SIGNAL_FUNC(OnDestroy), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
- /* File menu */
+ // File menu
widget = glade_xml_get_widget(xml, "RunCd");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunCd), NULL, NULL, G_CONNECT_AFTER);
@@ -273,15 +233,11 @@ void StartGui() {
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunImage), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "SwitchImage");
- g_signal_connect_data(GTK_OBJECT(widget), "activate",
- GTK_SIGNAL_FUNC(OnEmu_SwitchImage), NULL, NULL, G_CONNECT_AFTER);
-
widget = glade_xml_get_widget(xml, "exit2");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_Exit), NULL, NULL, G_CONNECT_AFTER);
- /* States */
+ // States
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 0, NULL, G_CONNECT_AFTER);
@@ -320,15 +276,18 @@ void StartGui() {
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save_other), NULL, NULL, G_CONNECT_AFTER);
- /* Emulation menu */
+ // Emulation menu
widget = glade_xml_get_widget(xml, "run1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnEmu_Run), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "reset1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnEmu_Reset), NULL, NULL, G_CONNECT_AFTER);
+ widget = glade_xml_get_widget(xml, "SwitchImage");
+ g_signal_connect_data(GTK_OBJECT(widget), "activate",
+ GTK_SIGNAL_FUNC(OnEmu_SwitchImage), NULL, NULL, G_CONNECT_AFTER);
- /* Configuration menu */
+ // Configuration menu
widget = glade_xml_get_widget(xml, "plugins_bios");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(ConfigurePlugins), NULL, NULL, G_CONNECT_AFTER);
@@ -354,7 +313,7 @@ void StartGui() {
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Net), NULL, NULL, G_CONNECT_AFTER);
- /* Cheat menu */
+ // Cheat menu
widget = glade_xml_get_widget(xml, "browse1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(RunCheatListDialog), NULL, NULL, G_CONNECT_AFTER);
@@ -362,114 +321,49 @@ void StartGui() {
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(RunCheatSearchDialog), NULL, NULL, G_CONNECT_AFTER);
- /* Help menu */
+ // Help menu
widget = glade_xml_get_widget(xml, "about_pcsx1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnHelp_About), NULL, NULL, G_CONNECT_AFTER);
- gtk_main();
-}
-
-void OnDestroy() {
- if (!destroy) OnFile_Exit();
-}
-
-void ConfigurePlugins() {
- if (!UseGui) {
- /* How do we get here if we're not running the GUI? */
- /* Ryan: we're going to imagine that someday, there will be a way
- * to configure plugins from the commandline */
- printf("ERROR: Plugins cannot be configured without the GUI.");
- return;
- }
-
- GladeXML *xml;
- GtkWidget *widget;
-
- gchar *path;
-
- UpdatePluginsBIOS();
-
- xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "ConfDlg", NULL);
-
- if (!xml) {
- g_warning(_("Error: Glade interface could not be loaded!"));
- return;
- }
-
- UpdatePluginsBIOS_UpdateGUI(xml);
-
- ConfDlg = glade_xml_get_widget(xml, "ConfDlg");
-
- gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configure PCSX"));
-
- /* Set the paths in the file choosers to be based on the saved configurations */
- widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget),
- Config.BiosDir);
-
- widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget),
- Config.PluginsDir);
-
- if (strlen(Config.PluginsDir) == 0) {
- if((path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget))) != NULL) {
- strcpy(Config.PluginsDir, path);
- g_free(path);
- }
- }
-
- widget = glade_xml_get_widget(xml, "btn_ConfGpu");
- g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
-
- widget = glade_xml_get_widget(xml, "btn_ConfSpu");
- g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
-
- /* ADB TODO Does pad 1 and 2 need to be different? */
- widget = glade_xml_get_widget(xml, "btn_ConfPad1");
+ // Toolbar
+ widget = glade_xml_get_widget(xml, "toolbutton_runcd");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnConfConf_Pad1Conf), xml, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnFile_RunCd), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_ConfPad2");
+ widget = glade_xml_get_widget(xml, "toolbutton_runimage");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnConfConf_Pad2Conf), xml, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnFile_RunImage), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_ConfCdr");
+ widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnEmu_SwitchImage), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_AboutGpu");
+ widget = glade_xml_get_widget(xml, "toolbutton_memcards");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnConf_Mcds), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_AboutSpu");
+ widget = glade_xml_get_widget(xml, "toolbutton_graphics");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnConf_Graphics), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_AboutPad1");
+ widget = glade_xml_get_widget(xml, "toolbutton_sound");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnConfConf_Pad1About), xml, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnConf_Sound), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_AboutPad2");
+ widget = glade_xml_get_widget(xml, "toolbutton_cdrom");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnConfConf_Pad2About), xml, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnConf_CdRom), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "btn_AboutCdr");
+ widget = glade_xml_get_widget(xml, "toolbutton_controllers");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
-
- widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
- g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
- GTK_SIGNAL_FUNC(OnBiosPath_Changed), xml, NULL, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnConf_Pad), NULL, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
- g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
- GTK_SIGNAL_FUNC(OnPluginPath_Changed), xml, NULL, G_CONNECT_AFTER);
+ gtk_main();
+}
- g_signal_connect_data(GTK_OBJECT(ConfDlg), "response",
- GTK_SIGNAL_FUNC(OnConf_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
+void OnDestroy() {
+ if (!destroy) OnFile_Exit();
}
void destroy_main_window () {
@@ -493,7 +387,7 @@ void OnFile_RunExe() {
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
- /* Add file filter */
+ // Add file filters
GtkFileFilter *exefilter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (exefilter, "*.exe");
gtk_file_filter_add_pattern (exefilter, "*.psx");
@@ -508,8 +402,8 @@ void OnFile_RunExe() {
gtk_file_filter_set_name (allfilter, _("All Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser), allfilter);
- /* Set this to the config object and retain it - maybe LastUsedDir */
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (file_chooser), getenv("HOME"));
+ // Set this to the config object and retain it - maybe LastUsedDir
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), getenv("HOME"));
if (gtk_dialog_run(GTK_DIALOG(file_chooser)) == GTK_RESPONSE_ACCEPT) {
gchar *file;
@@ -573,10 +467,10 @@ void OnFile_RunCd() {
return;
}
- /* Read main executable directly from CDRom and start it */
+ // Read main executable directly from CDRom and start it
if (LoadCdrom() == -1) {
ClosePlugins();
- SysErrorMessage(_("Could not load CD-ROM!"), _("The CD ROM could not be loaded"));
+ SysErrorMessage(_("Could not load CD-ROM!"), _("The CD-ROM could not be loaded"));
SysRunGui();
}
@@ -691,17 +585,17 @@ void OnFile_RunImage() {
SysReset();
if (CheckCdrom() == -1) {
- /* Only check the CD if we are starting the console with a CD */
+ // Only check the CD if we are starting the console with a CD
ClosePlugins();
SysErrorMessage (_("CD ROM failed"), _("The CD does not appear to be a valid Playstation CD"));
SysRunGui();
return;
}
- /* Read main executable directly from CDRom and start it */
+ // Read main executable directly from CDRom and start it
if (LoadCdrom() == -1) {
ClosePlugins();
- SysErrorMessage(_("Could not load CD-ROM!"), "The CD ROM could not be loaded");
+ SysErrorMessage(_("Could not load CD-ROM!"), _("The CD-ROM could not be loaded"));
SysRunGui();
}
@@ -814,27 +708,26 @@ void OnFile_Exit() {
exit(0);
}
-void state_load (gchar *state_filename) {
+void state_load(gchar *state_filename) {
int ret;
- char Text[MAXPATHLEN+20];
+ char Text[MAXPATHLEN + 20];
FILE *fp;
- /* check if the state file actually exists */
+ // check if the state file actually exists
fp = fopen(state_filename, "rb");
if (fp == NULL) {
- /* file does not exist */
+ // file does not exist
return;
}
fclose(fp);
- /* If the window exists, then we are loading the state from within
- within the PCSX GUI. We need to initialise the plugins first */
+ // If the window exists, then we are loading the state from within
+ // within the PCSX GUI. We need to initialise the plugins first
if (Window) {
destroy_main_window();
if (OpenPlugins() == -1) {
- /* TODO Error message */
SysRunGui();
return;
}
@@ -844,35 +737,13 @@ void state_load (gchar *state_filename) {
ret = LoadState(state_filename);
if (ret == 0) {
- /* Check the CD ROM is valid */
+ // Check the CD-ROM is valid
if (CheckCdrom() == -1) {
- /* TODO Error message */
- ClosePlugins ();
+ ClosePlugins();
SysRunGui();
return;
}
-#if 0 /* Whistler: this will cause crash when using the "Load Other" option */
- /* Check that the currently loaded CD ROM ID matches that of the CD
- used when saving the state file. The latter is stored in the filename */
- gchar *cmp = g_strrstr (g_path_get_basename (state_filename), "-");
- cmp++;
- if (g_ascii_strncasecmp (cmp, CdromId, 9) != 0) {
- ClosePlugins ();
- gchar *error_desc, *label;
- gint pos;
- label = g_strdup_printf("%.9s", state_filename);
- error_desc = g_strdup_printf ("The Playstation CD that is currently in use is %s. It is not the same CD as that used when saving the state file. The state file is looking for %s.",
- label,
- CdromLabel);
- SysErrorMessage ("The CD does not match the state file",
- error_desc);
- g_free (error_desc);
- g_free (label);
- SysRunGui();
- return;
- }
-#endif
sprintf(Text, _("Loaded state %s."), state_filename);
GPU_displayText(Text);
psxCpu->Execute();
@@ -882,7 +753,7 @@ void state_load (gchar *state_filename) {
}
}
-void state_save (gchar *state_filename) {
+void state_save(gchar *state_filename) {
char Text[MAXPATHLEN + 20];
GPU_updateLace();
@@ -897,27 +768,26 @@ void state_save (gchar *state_filename) {
void on_states_load (GtkWidget *widget, gpointer user_data) {
gchar *state_filename;
- gint state = (int) user_data;
+ gint state = (int)user_data;
- state_filename = get_state_filename (state);
+ state_filename = get_state_filename(state);
- state_load (state_filename);
+ state_load(state_filename);
- g_free (state_filename);
+ g_free(state_filename);
}
void on_states_save (GtkWidget *widget, gpointer user_data) {
gchar *state_filename;
- gint state = (int) user_data;
+ gint state = (int)user_data;
- state_filename = get_state_filename (state);
+ state_filename = get_state_filename(state);
- state_save (state_filename);
+ state_save(state_filename);
- g_free (state_filename);
+ g_free(state_filename);
}
-
void on_states_load_other() {
GtkWidget *file_chooser;
gchar *SStateFile;
@@ -956,477 +826,28 @@ void on_states_save_other() {
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), SStateFile);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), SStateFile);
- if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_OK) {
+ if (gtk_dialog_run (GTK_DIALOG(file_chooser)) == GTK_RESPONSE_OK) {
gchar *filename;
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (file_chooser));
gtk_widget_destroy(file_chooser);
- state_save (filename);
+ state_save(filename);
- g_free (filename);
+ g_free(filename);
}
else
- gtk_widget_destroy (file_chooser);
+ gtk_widget_destroy(file_chooser);
- g_free (SStateFile);
+ g_free(SStateFile);
}
-int all_config_set () {
- int retval;
-
- if ((strlen(Config.Gpu) != 0) &&
- (strlen(Config.Spu) != 0) &&
- (strlen(Config.Cdr) != 0) &&
- (strlen(Config.Pad1) != 0) &&
- (strlen(Config.Pad2) != 0))
- retval = TRUE;
- else
- retval = FALSE;
-
- return retval;
-}
-
-GtkWidget *NetDlg;
-
-void OnNet_Clicked (GtkDialog *dialog, gint arg1, gpointer user_data) {
- if (arg1 == GTK_RESPONSE_OK) {
- GetComboText(NetConfS.Combo, NetConfS.plist, Config.Net);
- SaveConfig();
- }
-
- gtk_widget_destroy(GTK_WIDGET (dialog));
- NetDlg = NULL;
-}
-
-void OnConf_Net() {
- GladeXML *xml;
- GtkWidget *widget;
-
- if (NetDlg != NULL) {
- gtk_window_present (GTK_WINDOW (NetDlg));
- return;
- }
-
- xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "NetDlg", NULL);
-
- if (!xml) {
- g_warning(_("Error: Glade interface could not be loaded!"));
- return;
- }
-
- NetDlg = glade_xml_get_widget(xml, "NetDlg");
-
- FindNetPlugin(xml);
-
- /* Setup a handler for when Close or Cancel is clicked */
- g_signal_connect_data(GTK_OBJECT(NetDlg), "response",
- GTK_SIGNAL_FUNC(OnNet_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
-
- widget = glade_xml_get_widget(xml, "btn_ConfNet");
- g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnNet_Conf), xml, NULL, G_CONNECT_AFTER);
-
- widget = glade_xml_get_widget(xml, "btn_AboutNet");
- g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnNet_About), xml, NULL, G_CONNECT_AFTER);
-}
-
-void OnConf_Graphics() {
- void *drv;
- GPUconfigure conf;
- char Plugin[MAXPATHLEN];
-
- sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);
- drv = SysLoadLibrary(Plugin);
- if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
-
- while (gtk_events_pending()) gtk_main_iteration();
-
- conf = (GPUconfigure)SysLoadSym(drv, "GPUconfigure");
- if (conf != NULL) {
- conf();
- }
- else
- SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
-
- SysCloseLibrary(drv);
-}
-
-void OnConf_Sound() {
- void *drv;
- SPUconfigure conf;
- char Plugin[MAXPATHLEN];
-
- sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);
- drv = SysLoadLibrary(Plugin);
- if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
-
- while (gtk_events_pending()) gtk_main_iteration();
-
- conf = (GPUconfigure)SysLoadSym(drv, "SPUconfigure");
- if (conf != NULL) {
- conf();
- }
- else
- SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
-
- SysCloseLibrary(drv);
-}
-
-void OnConf_CdRom() {
- void *drv;
- CDRconfigure conf;
- char Plugin[MAXPATHLEN];
-
- sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
- drv = SysLoadLibrary(Plugin);
- if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
-
- while (gtk_events_pending()) gtk_main_iteration();
-
- conf = (GPUconfigure)SysLoadSym(drv, "CDRconfigure");
- if (conf != NULL) {
- conf();
- }
- else
- SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
-
- SysCloseLibrary(drv);
-}
-
-void OnConf_Pad() {
- void *drv;
- PADconfigure conf;
- char Plugin[MAXPATHLEN];
-
- sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);
- drv = SysLoadLibrary(Plugin);
- if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
-
- while (gtk_events_pending()) gtk_main_iteration();
-
- conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
- if (conf != NULL) {
- conf();
- }
- else
- SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
-
- SysCloseLibrary(drv);
-
- if (strcmp(Config.Pad1, Config.Pad2) != 0) {
- sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);
- drv = SysLoadLibrary(Plugin);
- if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
-
- while (gtk_events_pending()) gtk_main_iteration();
-
- conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
- if (conf != NULL) {
- conf();
- }
-
- SysCloseLibrary(drv);
- }
-}
-
-GtkWidget *CpuDlg;
-GtkWidget *PsxCombo;
-GList *psxglist;
-char *psxtypes[] = {
- "NTSC",
- "PAL"
-};
-
-/* When the auto-detect CPU type is selected, disable the NTSC/PAL selection */
-static void OnCpu_PsxAutoClicked (GtkWidget *widget, gpointer user_data) {
- GtkWidget *combo;
- GladeXML *xml = user_data;
- combo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
-
- gtk_widget_set_sensitive (combo,
- !(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))));
-}
-
-/* When the interpreter core is deselected, disable the debugger checkbox */
-static void OnCpu_CpuClicked (GtkWidget *widget, gpointer user_data) {
- GtkWidget *check;
- GladeXML *xml = user_data;
- check = glade_xml_get_widget(xml, "GtkCheckButton_Dbg");
-
- // Debugger is only working with interpreter not recompiler, so let's set it
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
-
- gtk_widget_set_sensitive (check,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
-}
-
-void OnCpu_Clicked (GtkDialog *dialog, gint arg1, gpointer user_data) {
- if (arg1 == GTK_RESPONSE_OK) {
- GtkWidget *widget;
- GladeXML *xml = user_data;
- int tmp;
- long t;
-
- widget = glade_xml_get_widget(xml, "GtkCombo_PsxType");
-
- /* If nothing chosen, default to NTSC */
- tmp = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
- if (tmp == -1)
- tmp = PSX_TYPE_NTSC;
-
- if (!strcmp("NTSC",psxtypes[tmp]))
- Config.PsxType = PSX_TYPE_NTSC;
- else
- Config.PsxType = PSX_TYPE_PAL;
-
- Config.Xa = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Xa")));
-
- Config.Sio = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Sio")));
-
- Config.Mdec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Mdec")));
-
- Config.Cdda = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_CDDA")));
-
- Config.PsxAuto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")));
-
- t = Config.Debug;
- Config.Debug = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Dbg")));
- if (t != Config.Debug) {
- if (Config.Debug) StartDebugger();
- else StopDebugger();
- }
-
- t = Config.Cpu;
- Config.Cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")));
- if (t != Config.Cpu) {
- psxCpu->Shutdown();
-#ifdef PSXREC
- if (Config.Cpu) {
- psxCpu = &psxInt;
- }
- else psxCpu = &psxRec;
-#else
- psxCpu = &psxInt;
-#endif
- if (psxCpu->Init() == -1) {
- SysClose();
- exit(1);
- }
- psxCpu->Reset();
- }
-
- Config.PsxOut = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")));
-
- Config.SpuIrq = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")));
-
- Config.RCntFix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")));
-
- Config.VSyncWA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")));
-
- SaveConfig();
- }
-
- gtk_widget_destroy(CpuDlg);
- CpuDlg = NULL;
-}
-
-void OnConf_Cpu() {
- GladeXML *xml;
-
- xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "CpuDlg", NULL);
-
- if (!xml) {
- g_warning("We could not load the interface!");
- return;
- }
-
- CpuDlg = glade_xml_get_widget(xml, "CpuDlg");
-
- PsxCombo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
- gtk_combo_box_set_active (GTK_COMBO_BOX (PsxCombo), Config.PsxType);
- gtk_widget_set_sensitive (GTK_WIDGET (PsxCombo), !Config.PsxAuto);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Xa")), Config.Xa);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Sio")), Config.Sio);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Mdec")), Config.Mdec);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_CDDA")), Config.Cdda);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), Config.PsxAuto);
-
- g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), "toggled",
- GTK_SIGNAL_FUNC(OnCpu_PsxAutoClicked), xml, NULL, G_CONNECT_AFTER);
-
-#ifdef PSXREC
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), Config.Cpu);
-
- g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), "toggled",
- GTK_SIGNAL_FUNC(OnCpu_CpuClicked), xml, NULL, G_CONNECT_AFTER);
-#else
- Config.Cpu = 1;
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), FALSE);
-#endif
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu && Config.Debug);
- gtk_widget_set_sensitive (GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")), Config.PsxOut);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")), Config.SpuIrq);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")), Config.RCntFix);
-
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")), Config.VSyncWA);
-
- /* Setup a handler for when Close or Cancel is clicked */
- g_signal_connect_data(GTK_OBJECT(CpuDlg), "response",
- GTK_SIGNAL_FUNC(OnCpu_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
-}
-
-/* TODO Check whether configuration is required when we choose the plugin, and set the state of the
- button appropriately. New gtk tooltip API should allow us to put a tooltip explanation for
- disabled widgets */
-/* TODO If combo screen hasn't been opened and the user chooses the menu config option, confs.Combo will be null and cause a segfault */
-#define ConfPlugin(src, confs, plugin, name, parent) { \
- void *drv; \
- src conf; \
- gchar *filename; \
- \
- GetComboText(confs.Combo, confs.plist, plugin); \
- filename = g_build_filename (getenv("HOME"), PLUGINS_DIR, plugin, NULL); \
- /*printf("Configuring plugin %s\n", filename);*/ \
- drv = SysLoadLibrary(filename); \
- if (drv == NULL) {printf("Error with file %s\n", filename);return; } \
-\
- while (gtk_events_pending()) gtk_main_iteration(); \
- conf = (src) SysLoadSym(drv, name); \
- if (conf) { \
- conf(); \
- } else \
- SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured.")); \
- SysCloseLibrary(drv); \
- g_free (filename); \
-}
-
-void on_configure_plugin (GtkWidget *widget, gpointer user_data) {
- gint plugin_type = (int) user_data;
-
- while (gtk_events_pending())
- gtk_main_iteration();
- if (all_config_set() == TRUE) {
- switch (plugin_type) {
- case PSE_LT_GPU:
- ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUconfigure", ConfDlg);
- break;
- case PSE_LT_SPU:
- ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUconfigure", ConfDlg);
- break;
- case PSE_LT_CDR:
- ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRconfigure", ConfDlg);
- break;
- }
- } else
- ConfigurePlugins();
-}
-
-void on_about_plugin (GtkWidget *widget, gpointer user_data) {
- gint plugin_type = (int) user_data;
-
- while (gtk_events_pending())
- gtk_main_iteration();
- if (all_config_set() == TRUE) {
- switch (plugin_type) {
- case PSE_LT_GPU:
- ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUabout", ConfDlg);
- break;
- case PSE_LT_SPU:
- ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUabout", ConfDlg);
- break;
- case PSE_LT_CDR:
- ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRabout", ConfDlg);
- break;
- }
- } else
- ConfigurePlugins();
-}
-
-void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADabout", ConfDlg);
-}
-
-void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADabout", ConfDlg);
-}
-
-void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADconfigure", ConfDlg);
-}
-
-void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADconfigure", ConfDlg);
-}
-
-void OnNet_Conf(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(NETconfigure, NetConfS, Config.Net, "NETconfigure", NetDlg);
-}
-
-void OnNet_About(GtkWidget *widget, gpointer user_data) {
- ConfPlugin(NETabout, NetConfS, Config.Net, "NETabout", NetDlg);
-}
-
-void OnPluginPath_Changed(GtkWidget *wdg, gpointer data) {
- gchar *path;
-
- path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
- strcpy(Config.PluginsDir, path);
- UpdatePluginsBIOS();
- UpdatePluginsBIOS_UpdateGUI(data);
-
- g_free (path);
-}
-
-void OnBiosPath_Changed(GtkWidget *wdg, gpointer data) {
- gchar *foldername;
-
- foldername = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
- strcpy(Config.BiosDir, foldername);
-
- UpdatePluginsBIOS();
- UpdatePluginsBIOS_UpdateGUI(data);
-
- g_free (foldername);
-}
-
-void OnConf_Clicked (GtkDialog *dialog, gint arg1, gpointer user_data) {
- if (arg1 == GTK_RESPONSE_OK) {
- GetComboText(GpuConfS.Combo, GpuConfS.plist, Config.Gpu);
- GetComboText(SpuConfS.Combo, SpuConfS.plist, Config.Spu);
- GetComboText(CdrConfS.Combo, CdrConfS.plist, Config.Cdr);
- GetComboText(Pad1ConfS.Combo, Pad1ConfS.plist, Config.Pad1);
- GetComboText(Pad2ConfS.Combo, Pad2ConfS.plist, Config.Pad2);
- GetComboText(BiosConfS.Combo, BiosConfS.plist, Config.Bios);
- /* TODO Validation */
-
- SaveConfig();
- }
-
- gtk_widget_destroy (ConfDlg);
- ConfDlg = NULL;
-}
-
void OnHelp_About(GtkWidget *widget, gpointer user_data) {
GladeXML *xml;
GtkWidget *about_dialog;
-
+
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "AboutDlg", NULL);
if (!xml) {
@@ -1435,302 +856,9 @@ void OnHelp_About(GtkWidget *widget, gpointer user_data) {
}
about_dialog = glade_xml_get_widget(xml, "AboutDlg");
-
- gtk_dialog_run (GTK_DIALOG (about_dialog));
- gtk_widget_destroy (about_dialog);
-}
-
-#define ComboAddPlugin(type) { \
- type##ConfS.plugins += 2; \
- strcpy(type##ConfS.plist[type##ConfS.plugins - 1], name); \
- strcpy(type##ConfS.plist[type##ConfS.plugins - 2], ent->d_name); \
- type##ConfS.glist = g_list_append(type##ConfS.glist, type##ConfS.plist[type##ConfS.plugins-1]); \
-}
-
-void populate_combo_box (GtkWidget *widget, GList *list) {
- GtkListStore *store;
- GtkCellRenderer *renderer;
- store = gtk_list_store_new (1, G_TYPE_STRING);
- /* Clear existing data from combo box */
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
-
- renderer = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, FALSE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (widget), renderer, "text", 0);
-
- while (list != NULL) {
- GtkTreeIter iter;
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, (char *)list->data, -1);
- list = list->next;
- }
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
-}
-
-#define ConfCreatePConf(name, type) \
- /* Populate the relevant combo widget with the list of plugins. \
- If no plugins available, disable the combo and its controls. \
- Note that the Bios plugin has no About/Conf control. */ \
- type##ConfS.Combo = glade_xml_get_widget(xml, "GtkCombo_" name); \
- if (type##ConfS.glist != NULL) { \
- populate_combo_box (type##ConfS.Combo, type##ConfS.glist); \
- FindComboText(type##ConfS.Combo, type##ConfS.plist, Config.type); \
- gtk_widget_set_sensitive (type##ConfS.Combo, TRUE); \
- if (g_ascii_strcasecmp (name, "Bios") != 0) { \
- controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
- gtk_widget_set_sensitive (controlwidget, TRUE); \
- controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
- gtk_widget_set_sensitive (controlwidget, TRUE); \
- } \
- } else { \
- if (g_ascii_strcasecmp (name, "Bios") != 0) { \
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (type##ConfS.Combo)); \
- gtk_widget_set_sensitive (type##ConfS.Combo, FALSE); \
- controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
- gtk_widget_set_sensitive (controlwidget, FALSE); \
- controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
- gtk_widget_set_sensitive (controlwidget, FALSE); \
- } \
- }
-
-int plugin_is_available (gchar *plugin) {
- int retval;
- gchar *pluginfile;
- struct stat stbuf;
-
-// printf("Checking plugin_is_available - %s\n", plugin);
- pluginfile = g_strconcat (getenv("HOME"), PLUGINS_DIR, plugin, NULL);
-
- if (stat(pluginfile, &stbuf) == -1)
- retval = FALSE;
- else
- retval = TRUE;
-
- g_free (pluginfile);
-
- return retval;
-}
-
-/* TODO Combine this with all_config_set() */
-int plugins_configured() {
- // make sure there are choices for all of the plugins!!
-// if ((strlen(Config.Gpu) == 0) || (strlen(Config.Spu) == 0) || (strlen(Config.Cdr) == 0) || (strlen(Config.Pad1) == 0) || (strlen(Config.Pad2) == 0)) {
- if (all_config_set() == FALSE)
- return FALSE;
-// }
- // and make sure they can all be accessed
- // if they can't be, wipe the variable and return FALSE
- if (plugin_is_available (Config.Gpu) == FALSE) { Config.Gpu[0] = '\0'; return FALSE; }
- if (plugin_is_available (Config.Spu) == FALSE) { Config.Spu[0] = '\0'; return FALSE; }
- if (plugin_is_available (Config.Cdr) == FALSE) { Config.Cdr[0] = '\0'; return FALSE; }
- if (plugin_is_available (Config.Pad1) == FALSE) { Config.Pad1[0] = '\0'; return FALSE; }
- if (plugin_is_available (Config.Pad2) == FALSE) { Config.Pad2[0] = '\0'; return FALSE; }
-
- // if everything is happy, return TRUE
- return TRUE;
-}
-
-int is_valid_bios_file (gchar *filename) {
- int valid;
- struct stat buf;
-
-// printf(" Checking is_valid_bios_file - %s\n", filename);
- if ((stat(filename, &buf) == -1) || (buf.st_size != (1024*512)))
- valid = FALSE;
- else {
- valid = TRUE;
-// printf(" %s is a valid BIOS file\n", filename);
- }
-
- return valid;
-}
-
-/* Add the name of the BIOS file to the drop-down list. This will
- be the filename, not the full path to the file */
-void add_bios_to_list (gchar *bios_name, gchar *internal_name) {
- BiosConfS.plugins+=2;
- strcpy(BiosConfS.plist[BiosConfS.plugins-1], bios_name);
- strcpy(BiosConfS.plist[BiosConfS.plugins-2], internal_name);
- /* Error handling - BIOS
- strcpy(BiosConfS.plist[BiosConfS.plugins-1], internal_name);
- strcpy(BiosConfS.plist[BiosConfS.plugins-2], bios_name);*/
- BiosConfS.glist = g_list_append(BiosConfS.glist, BiosConfS.plist[BiosConfS.plugins-1]);
-}
-
-void scan_bios_dir (gchar *dirname) {
- DIR *dir;
- struct dirent *ent;
- gchar *filename;
-
- dir = opendir(dirname);
- if (dir == NULL) {
- SysMessage(_("Could not open BIOS directory: '%s'\n"), dirname);
- return;
- }
-
- while ((ent = readdir(dir)) != NULL) {
- filename = g_build_filename(dirname, ent->d_name, NULL);
- if (is_valid_bios_file(filename))
- add_bios_to_list(g_path_get_basename(filename), g_path_get_basename (filename));
- g_free(filename);
- }
- closedir(dir);
-}
-
-void UpdatePluginsBIOS() {
- DIR *dir;
- struct dirent *ent;
- void *Handle;
- char name[256];
- gchar *linkname;
-
- GpuConfS.plugins = 0; SpuConfS.plugins = 0; CdrConfS.plugins = 0;
- Pad1ConfS.plugins = 0; Pad2ConfS.plugins = 0; BiosConfS.plugins = 0;
- GpuConfS.glist = NULL; SpuConfS.glist = NULL; CdrConfS.glist = NULL;
- Pad1ConfS.glist = NULL; Pad2ConfS.glist = NULL; BiosConfS.glist = NULL;
- GpuConfS.plist[0][0] = '\0'; SpuConfS.plist[0][0] = '\0'; CdrConfS.plist[0][0] = '\0';
- Pad1ConfS.plist[0][0] = '\0'; Pad2ConfS.plist[0][0] = '\0'; BiosConfS.plist[0][0] = '\0';
-
- /* Load and get plugin info */
- dir = opendir(Config.PluginsDir);
- if (dir == NULL) {
- printf(_("Could not open directory: '%s'\n"), Config.PluginsDir);
- return;
- }
- while ((ent = readdir(dir)) != NULL) {
- long type, v;
- linkname = g_build_filename(Config.PluginsDir, ent->d_name, NULL);
-
- // only libraries past this point, not config tools
- if (strstr(linkname, ".so") == NULL && strstr(linkname, ".dylib") == NULL)
- continue;
-
- Handle = dlopen(linkname, RTLD_NOW);
- if (Handle == NULL) {
- printf("%s\n", dlerror());
- g_free(linkname);
- continue;
- }
-
- PSE_getLibType = (PSEgetLibType)dlsym(Handle, "PSEgetLibType");
- if (dlerror() != NULL) {
- if (strstr(linkname, "gpu") != NULL) type = PSE_LT_GPU;
- else if (strstr(linkname, "cdr") != NULL) type = PSE_LT_CDR;
- else if (strstr(linkname, "spu") != NULL) type = PSE_LT_SPU;
- else if (strstr(linkname, "pad") != NULL) type = PSE_LT_PAD;
- else { g_free(linkname); continue; }
- }
- else type = PSE_getLibType();
-
- PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
- if (dlerror() == NULL) {
- sprintf(name, "%s", PSE_getLibName());
- PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
- if (dlerror() == NULL) {
- char ver[32];
-
- v = PSE_getLibVersion();
- sprintf(ver, " %ld.%ld.%ld", v >> 16, (v >> 8) & 0xff, v & 0xff);
- strcat(name, ver);
- }
- }
- else strcpy(name, ent->d_name);
-
- if (type & PSE_LT_CDR)
- ComboAddPlugin(Cdr);
- if (type & PSE_LT_GPU)
- ComboAddPlugin(Gpu);
- if (type & PSE_LT_SPU)
- ComboAddPlugin(Spu);
- if (type & PSE_LT_PAD) {
- PADquery query = (PADquery)dlsym(Handle, "PADquery");
- if (query() & 0x1) {
- ComboAddPlugin(Pad1);
- }
- if (query() & 0x2) {
- ComboAddPlugin(Pad2);
- }
- }
- g_free(linkname);
- }
- closedir(dir);
-
- scan_bios_dir(Config.BiosDir);
-
- /* The BIOS list always contains the PCSX internal BIOS */
- add_bios_to_list(_("Internal HLE Bios"), "HLE");
-}
-
-void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml) {
- /* Populate the plugin combo boxes */
- ConfCreatePConf("Gpu", Gpu);
- ConfCreatePConf("Spu", Spu);
- ConfCreatePConf("Pad1", Pad1);
- ConfCreatePConf("Pad2", Pad2);
- ConfCreatePConf("Cdr", Cdr);
- ConfCreatePConf("Bios", Bios);
-}
-
-void FindNetPlugin(GladeXML *xml) {
- DIR *dir;
- struct dirent *ent;
- void *Handle;
- char plugin[MAXPATHLEN],name[MAXPATHLEN];
-
- NetConfS.plugins = 0;
- NetConfS.glist = NULL;
-
- NetConfS.plugins += 2;
- strcpy(NetConfS.plist[NetConfS.plugins - 1], "Disabled");
- strcpy(NetConfS.plist[NetConfS.plugins - 2], "Disabled");
- NetConfS.glist = g_list_append(NetConfS.glist, NetConfS.plist[NetConfS.plugins - 1]);
-
- dir = opendir(Config.PluginsDir);
- if (dir == NULL)
- SysMessage(_("Could not open directory: '%s'\n"), Config.PluginsDir);
- else {
- /* ADB TODO Replace the following with a function */
- while ((ent = readdir(dir)) != NULL) {
- long type, v;
-
- sprintf(plugin, "%s/%s", Config.PluginsDir, ent->d_name);
-
- if (strstr(plugin, ".so") == NULL && strstr(plugin, ".dylib") == NULL)
- continue;
- Handle = dlopen(plugin, RTLD_NOW);
- if (Handle == NULL) continue;
-
- PSE_getLibType = (PSEgetLibType) dlsym(Handle, "PSEgetLibType");
- if (dlerror() != NULL) {
- if (strstr(plugin, "net") != NULL) type = PSE_LT_NET;
- else continue;
- }
- else type = PSE_getLibType();
-
- PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
- if (dlerror() == NULL) {
- sprintf(name, "%s", PSE_getLibName());
- PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
- if (dlerror() == NULL) {
- char ver[32];
-
- v = PSE_getLibVersion();
- sprintf(ver, " %ld.%ld.%ld",v>>16,(v>>8)&0xff,v&0xff);
- strcat(name, ver);
- }
- }
- else strcpy(name, ent->d_name);
-
- if (type & PSE_LT_NET) {
- ComboAddPlugin(Net);
- }
- }
- closedir(dir);
-
- ConfCreatePConf("Net", Net);
- }
+ gtk_dialog_run(GTK_DIALOG (about_dialog));
+ gtk_widget_destroy(about_dialog);
}
void SysMessage(char *fmt, ...) {
@@ -1750,7 +878,7 @@ void SysMessage(char *fmt, ...) {
return;
}
- MsgDlg = gtk_dialog_new_with_buttons (_("Notice"), NULL,
+ MsgDlg = gtk_dialog_new_with_buttons(_("Notice"), NULL,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_NONE, NULL);
gtk_window_set_position (GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
@@ -1770,17 +898,17 @@ void SysErrorMessage(gchar *primary, gchar *secondary) {
if (!UseGui)
printf ("%s - %s\n", primary, secondary);
else {
- message_dialog = gtk_message_dialog_new (NULL,
+ message_dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
primary,
NULL);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
secondary);
- gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
+ gtk_dialog_run(GTK_DIALOG(message_dialog));
+ gtk_widget_destroy(message_dialog);
}
}
@@ -1789,16 +917,16 @@ void SysInfoMessage(gchar *primary, gchar *secondary) {
if (!UseGui)
printf ("%s - %s\n", primary, secondary);
else {
- message_dialog = gtk_message_dialog_new (NULL,
+ message_dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
primary,
NULL);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
secondary);
- gtk_dialog_run (GTK_DIALOG (message_dialog));
- gtk_widget_destroy (message_dialog);
+ gtk_dialog_run(GTK_DIALOG(message_dialog));
+ gtk_widget_destroy(message_dialog);
}
}
diff --git a/gui/Linux.h b/gui/Linux.h
index 5048f7f1..a592bc19 100644
--- a/gui/Linux.h
+++ b/gui/Linux.h
@@ -45,8 +45,6 @@ void SaveConfig();
void StartGui();
-void ConfigurePlugins();
-
void PADhandleKey(int key);
void UpdateMenuSlots();
@@ -64,19 +62,4 @@ void UpdatePluginsBIOS();
void SysErrorMessage(gchar *primary, gchar *secondary);
void SysInfoMessage(gchar *primary, gchar *secondary);
-typedef struct {
- GtkWidget *Combo;
- GList *glist;
- char plist[255][255]; /* TODO Comment this out */
- int plugins; /* TODO Comment this out and replace with glist count */
-} PluginConf;
-
-PluginConf GpuConfS;
-PluginConf SpuConfS;
-PluginConf CdrConfS;
-PluginConf Pad1ConfS;
-PluginConf Pad2ConfS;
-PluginConf NetConfS;
-PluginConf BiosConfS;
-
#endif /* __LINUX_H__ */
diff --git a/gui/LnxMain.c b/gui/LnxMain.c
index f3561472..26497cc1 100644
--- a/gui/LnxMain.c
+++ b/gui/LnxMain.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -29,12 +31,10 @@
#include <pthread.h>
#include <dirent.h>
#include <sys/stat.h>
-
-#include "Linux.h"
-
#include "../libpcsxcore/sio.h"
-#include "config.h"
+#include "Linux.h"
+#include "ConfDlg.h"
#ifdef ENABLE_NLS
#include <locale.h>
diff --git a/gui/Makefile.am b/gui/Makefile.am
index c649e4f2..eacfd672 100644
--- a/gui/Makefile.am
+++ b/gui/Makefile.am
@@ -14,6 +14,7 @@ pcsx_SOURCES = \
Config.c \
Gtk2Gui.c \
MemcardDlg.c \
+ ConfDlg.c \
Cheat.c
pcsx_LDADD = \
diff --git a/gui/Makefile.in b/gui/Makefile.in
index db624692..6d0254bd 100644
--- a/gui/Makefile.in
+++ b/gui/Makefile.in
@@ -47,7 +47,8 @@ am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_pcsx_OBJECTS = LnxMain.$(OBJEXT) Plugin.$(OBJEXT) Config.$(OBJEXT) \
- Gtk2Gui.$(OBJEXT) MemcardDlg.$(OBJEXT) Cheat.$(OBJEXT)
+ Gtk2Gui.$(OBJEXT) MemcardDlg.$(OBJEXT) ConfDlg.$(OBJEXT) \
+ Cheat.$(OBJEXT)
pcsx_OBJECTS = $(am_pcsx_OBJECTS)
am__DEPENDENCIES_1 =
pcsx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
@@ -232,6 +233,7 @@ pcsx_SOURCES = \
Config.c \
Gtk2Gui.c \
MemcardDlg.c \
+ ConfDlg.c \
Cheat.c
pcsx_LDADD = \
@@ -310,6 +312,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cheat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfDlg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gtk2Gui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LnxMain.Po@am__quote@
diff --git a/gui/MemcardDlg.c b/gui/MemcardDlg.c
index bdefbe64..d6a42bd3 100644
--- a/gui/MemcardDlg.c
+++ b/gui/MemcardDlg.c
@@ -172,6 +172,31 @@ static void LoadListItems(int mcd, GtkWidget *widget) {
gtk_widget_show(List);
}
+static void UpdateFilenameButtons(GtkWidget *widget) {
+ int i;
+ GladeXML *xml;
+ GtkWidget *dialog;
+ const char *filename;
+ gchar *p;
+
+ xml = glade_get_widget_tree(widget);
+ dialog = glade_xml_get_widget(xml, "McdsDlg");
+
+ for (i = 0; i < 2; i++) {
+ if (i == 0) {
+ widget = glade_xml_get_widget(xml, "Mcd1Label");
+ filename = Config.Mcd1;
+ } else {
+ widget = glade_xml_get_widget(xml, "Mcd2Label");
+ filename = Config.Mcd2;
+ }
+
+ p = g_path_get_basename(filename);
+ gtk_label_set_text(GTK_LABEL(widget), p);
+ g_free(p);
+ }
+}
+
static void LoadMcdDlg(GtkWidget *widget) {
int i;
@@ -182,6 +207,8 @@ static void LoadMcdDlg(GtkWidget *widget) {
LoadListItems(1, widget);
LoadListItems(2, widget);
+
+ UpdateFilenameButtons(widget);
}
static void OnTreeSelectionChanged(GtkTreeSelection *selection, gpointer user_data);
@@ -252,54 +279,57 @@ static void UpdateMcdDlg(GtkWidget *widget) {
UpdateListItems(1, widget);
UpdateListItems(2, widget);
+
+ UpdateFilenameButtons(widget);
}
-static void OnMcd_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
- GladeXML *xml = user_data;
+static void OnMcd_Close(GtkDialog *dialog, gint arg1, gpointer user_data) {
+ SaveConfig();
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+}
- if (arg1 == GTK_RESPONSE_OK) {
- gchar *tmp;
- GtkWidget *widget;
+static void OnMcd_FileChange(GtkWidget *widget, gpointer user_data) {
+ gint memcard = (int)user_data;
+ gchar *filename;
+ GtkWidget *chooser;
- widget = glade_xml_get_widget(xml, "GtkMcd1FSButton");
- if ((tmp = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget))) != NULL) {
- strcpy(Config.Mcd1, tmp);
- g_free(tmp);
- }
+ // Ask for name of memory card
+ chooser = gtk_file_chooser_dialog_new(_("Select A File"),
+ NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
- widget = glade_xml_get_widget(xml, "GtkMcd2FSButton");
- if ((tmp = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (widget))) != NULL) {
- strcpy(Config.Mcd2, tmp);
- g_free(tmp);
- }
+ if (memcard == 1)
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), Config.Mcd1);
+ else
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), Config.Mcd2);
- SaveConfig();
- LoadMcds(Config.Mcd1, Config.Mcd2);
- }
+ if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_OK) {
+ gtk_widget_hide(chooser);
- gtk_widget_destroy(GTK_WIDGET(dialog));
-}
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
-static void OnMemcardFileChanged(GtkWidget *widget, gpointer user_data) {
- gint memcard = (int) user_data;
- gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ if (filename != NULL) {
+ if (memcard == 1) strncpy(Config.Mcd1, filename, MAXPATHLEN);
+ else strncpy(Config.Mcd2, filename, MAXPATHLEN);
- if (filename != NULL) {
- LoadMcd(memcard, filename);
- UpdateMcdDlg(widget);
- gtk_widget_set_sensitive(widget, TRUE);
+ LoadMcd(memcard, filename);
+ UpdateMcdDlg(widget);
+
+ g_free(filename);
+ }
}
- g_free(filename);
+ gtk_widget_destroy(chooser);
}
// create a new, formatted memory card
static void OnMcd_Format(GtkWidget *widget, gpointer user_data) {
GladeXML *xml;
- GtkWidget *memcard_fs;
GtkWidget *message_dialog;
gint result;
- gchar *str;
+ char *str;
gint memcard = (int)user_data;
@@ -308,7 +338,7 @@ static void OnMcd_Format(GtkWidget *widget, gpointer user_data) {
_("Format this Memory Card?"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
_("If you format the memory card, the card will be empty, and any existing data overwritten."));
- gtk_dialog_add_buttons(GTK_DIALOG (message_dialog),
+ gtk_dialog_add_buttons(GTK_DIALOG(message_dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Format card"), GTK_RESPONSE_YES, NULL);
@@ -317,17 +347,14 @@ static void OnMcd_Format(GtkWidget *widget, gpointer user_data) {
if (result == GTK_RESPONSE_YES) {
xml = glade_get_widget_tree(widget);
- if (memcard == 1)
- memcard_fs = glade_xml_get_widget(xml, "GtkMcd1FSButton");
- else
- memcard_fs = glade_xml_get_widget(xml, "GtkMcd2FSButton");
- str = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(memcard_fs));
+ if (memcard == 1) str = Config.Mcd1;
+ else str = Config.Mcd2;
CreateMcd(str);
LoadMcd(memcard, str);
+
UpdateMcdDlg(widget);
- g_free(str);
}
}
@@ -350,26 +377,19 @@ static void OnMcd_New(GtkWidget *widget, gpointer user_data) {
if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_OK) {
gchar *name;
- gchar *widget_name;
- GladeXML *xml;
gtk_widget_hide(chooser);
-
name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
CreateMcd(name);
- // Set the name on the FileChooserButton - this will trigger the
- // callback to load the card and update the dialog
- widget_name = g_strdup_printf("GtkMcd%dFSButton", (int)user_data);
- xml = glade_get_widget_tree(widget);
+ if ((int)user_data == 1) strncpy(Config.Mcd1, name, MAXPATHLEN);
+ else strncpy(Config.Mcd2, name, MAXPATHLEN);
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml, widget_name)), name);
+ LoadMcd((int)user_data, name);
+ UpdateMcdDlg(widget);
- g_free(widget_name);
g_free(name);
-
- UpdateMcdDlg(widget);
}
gtk_widget_destroy(chooser);
@@ -383,7 +403,7 @@ static int GetFreeMemcardSlot(int target_card) {
gboolean found = FALSE;
int i = 0;
- while (i < 15 && found == FALSE) {
+ while (i < 15 && found == FALSE) {
Info = &Blocks[target_card][i];
if (g_ascii_strcasecmp(Info->Title, "") == 0) {
found = TRUE;
@@ -461,11 +481,11 @@ static void OnMcd_CopyTo(GtkWidget *widget, gpointer user_data) {
xml = glade_get_widget_tree(GtkCList_McdList1);
if (mcd == 1) {
- str = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml, "GtkMcd1FSButton")));
+ str = Config.Mcd1;
source = Mcd2Data;
destination = Mcd1Data;
} else {
- str = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml, "GtkMcd2FSButton")));
+ str = Config.Mcd2;
source = Mcd1Data;
destination = Mcd2Data;
}
@@ -496,13 +516,13 @@ static void OnMemcardDelete(GtkWidget *widget, gpointer user_data) {
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree));
selected = gtk_tree_selection_get_selected (sel, &model, &iter);
data = Mcd1Data;
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml, "GtkMcd1FSButton")));
+ filename = Config.Mcd1;
} else {
tree = glade_xml_get_widget(xml, "GtkCList_McdList2");
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree));
selected = gtk_tree_selection_get_selected(sel, &model, &iter);
data = Mcd2Data;
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(glade_xml_get_widget(xml, "GtkMcd2FSButton")));
+ filename = Config.Mcd2;
}
if (selected) {
@@ -644,7 +664,7 @@ void OnConf_Mcds() {
// Setup a handler for when Close or Cancel is clicked
g_signal_connect_data(GTK_OBJECT(dialog), "response",
- GTK_SIGNAL_FUNC(OnMcd_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
+ GTK_SIGNAL_FUNC(OnMcd_Close), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_Format1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
@@ -654,15 +674,13 @@ void OnConf_Mcds() {
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_Format), (gpointer)2, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "GtkMcd1FSButton");
- g_signal_connect_data(GTK_OBJECT(widget), "selection-changed",
- GTK_SIGNAL_FUNC(OnMemcardFileChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
- gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(widget), Config.Mcd1);
+ widget = glade_xml_get_widget(xml, "Mcd1Button");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnMcd_FileChange), (gpointer)1, NULL, G_CONNECT_AFTER);
- widget = glade_xml_get_widget(xml, "GtkMcd2FSButton");
- g_signal_connect_data(GTK_OBJECT(widget), "selection-changed",
- GTK_SIGNAL_FUNC(OnMemcardFileChanged), (gpointer) 2, NULL, G_CONNECT_AFTER);
- gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(widget), Config.Mcd2);
+ widget = glade_xml_get_widget(xml, "Mcd2Button");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnMcd_FileChange), (gpointer)2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_New1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",