/[pcsx2_0.9.7]/trunk/plugins/zerospu2/Linux/Linux.cpp
ViewVC logotype

Contents of /trunk/plugins/zerospu2/Linux/Linux.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 290 - (show annotations) (download)
Sat Dec 25 02:51:30 2010 UTC (9 years ago) by william
File size: 6329 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4139 local: v0.9.7.283-latest) in ./trunk
1 /* ZeroSPU2
2 * Copyright (C) 2006-2010 zerofrog
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 // Modified by arcum42@gmail.com
20
21 #include <gtk/gtk.h>
22
23 #include "Linux.h"
24 #include "zerospu2.h"
25
26 extern char *libraryName;
27
28 void SysMessage(const char *fmt, ...)
29 {
30 va_list list;
31 char msg[512];
32
33 va_start(list, fmt);
34 vsprintf(msg, fmt, list);
35 va_end(list);
36
37 if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
38
39 GtkWidget *dialog;
40 dialog = gtk_message_dialog_new (NULL,
41 GTK_DIALOG_DESTROY_WITH_PARENT,
42 GTK_MESSAGE_INFO,
43 GTK_BUTTONS_OK,
44 "%s", msg);
45 gtk_dialog_run (GTK_DIALOG (dialog));
46 gtk_widget_destroy (dialog);
47 }
48
49 void SaveConfig()
50 {
51 string iniFile( s_strIniPath + "zerospu2.ini" );
52
53 FILE* f = fopen(iniFile.c_str(),"w");
54 if (f == NULL)
55 {
56 ERROR_LOG("Failed to open %s\n", iniFile.c_str());
57 return;
58 }
59
60 fprintf(f, "log = %d\n", conf.Log);
61 //fprintf(f, "options = %d\n", conf.options);
62
63 fprintf(f, "realtime = %d\n", (conf.options & OPTION_REALTIME));
64 fprintf(f, "timestretch = %d\n", (conf.options & OPTION_TIMESTRETCH));
65 fprintf(f, "recording = %d\n", (conf.options & OPTION_RECORDING));
66 fprintf(f, "mute = %d\n", (conf.options & OPTION_MUTE));
67
68 fclose(f);
69 }
70
71 void LoadConfig()
72 {
73 int temp;
74
75 memset(&conf, 0, sizeof(conf));
76
77 string iniFile( s_strIniPath + "zerospu2.ini" );
78
79 FILE* f = fopen(iniFile.c_str(), "r");
80 if (f == NULL)
81 {
82 ERROR_LOG("Failed to open %s\n", iniFile.c_str());
83 conf.Log = 0;
84 conf.options = 0;
85 SaveConfig();//save and return
86 return;
87 }
88
89 fscanf(f, "log = %d\n", &conf.Log);
90
91 fscanf(f, "realtime = %d\n", &temp);
92 if (temp) conf.options |= OPTION_REALTIME;
93
94 fscanf(f, "timestretch = %d\n", &temp);
95 if (temp) conf.options |= OPTION_TIMESTRETCH;
96
97 fscanf(f, "recording = %d\n", &temp);
98 if (temp) conf.options |= OPTION_RECORDING;
99
100 fscanf(f, "mute = %d\n", &temp);
101 if (temp) conf.options |= OPTION_MUTE;
102
103 fscanf(f, "options = %d\n", &conf.options);
104
105 fclose(f);
106 }
107
108 void DisplayDialog()
109 {
110 int return_value;
111
112 GtkWidget *dialog;
113 GtkWidget *main_box;
114 GtkWidget *time_scaling_check, *real_time_check, *recording_check, *mute_check, *logging_check;
115
116 LoadConfig();
117
118 /* Create the widgets */
119 dialog = gtk_dialog_new_with_buttons (
120 "ZeroSPU2 Config",
121 NULL, /* parent window*/
122 (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
123 GTK_STOCK_OK,
124 GTK_RESPONSE_ACCEPT,
125 GTK_STOCK_CANCEL,
126 GTK_RESPONSE_REJECT,
127 NULL);
128
129 time_scaling_check = gtk_check_button_new_with_label("Time Scaling (recommended)");
130 gtk_widget_set_tooltip_text(time_scaling_check, "Slows down or speeds up sound with respect to the game's real speed.\nEnabling this produces higher quality sound with less cracking, but can reduce speed.");
131
132 real_time_check = gtk_check_button_new_with_label("Real Time Mode");
133 gtk_widget_set_tooltip_text(real_time_check, "Tries to reduce delays in music as much as possible.\nUse when a game is already fast, and needs sound tightly syncronized. (like in DDR, Guitar Hero, & Guitaroo Man)");
134
135 recording_check = gtk_check_button_new_with_label("Recording");
136 gtk_widget_set_tooltip_text(recording_check, "Saves the raw 16 bit stereo wave data to zerospu2.wav. Timed to ps2 time.");
137
138 mute_check = gtk_check_button_new_with_label("Mute");
139 gtk_widget_set_tooltip_text(mute_check, "ZeroSPU2 will not output sound (fast).");
140
141 logging_check = gtk_check_button_new_with_label("Enable logging");
142 gtk_widget_set_tooltip_text(logging_check, "For development use only.");
143
144 main_box = gtk_vbox_new(false, 5);
145
146 gtk_container_add(GTK_CONTAINER(main_box), time_scaling_check);
147 gtk_container_add(GTK_CONTAINER(main_box), real_time_check);
148 gtk_container_add(GTK_CONTAINER(main_box), recording_check);
149 gtk_container_add(GTK_CONTAINER(main_box), mute_check);
150 gtk_container_add(GTK_CONTAINER(main_box), logging_check);
151
152 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(time_scaling_check), (conf.options & OPTION_TIMESTRETCH));
153 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(real_time_check), (conf.options & OPTION_REALTIME));
154 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(recording_check), (conf.options & OPTION_RECORDING));
155 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_check), (conf.options & OPTION_MUTE));
156 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logging_check), (conf.Log));
157
158 gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
159 gtk_widget_show_all (dialog);
160
161 return_value = gtk_dialog_run (GTK_DIALOG (dialog));
162
163 if (return_value == GTK_RESPONSE_ACCEPT)
164 {
165 conf.options = 0;
166
167 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(time_scaling_check)))
168 conf.options |= OPTION_TIMESTRETCH;
169
170 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(real_time_check)))
171 conf.options |= OPTION_REALTIME;
172
173 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recording_check)))
174 conf.options |= OPTION_RECORDING;
175
176 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mute_check)))
177 conf.options |= OPTION_MUTE;
178
179 conf.Log = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(logging_check));
180 SaveConfig();
181 }
182
183 gtk_widget_destroy (dialog);
184 }
185
186 void CALLBACK SPU2configure()
187 {
188 LOG_CALLBACK("SPU2configure()\n");
189 DisplayDialog();
190 }
191
192 void CALLBACK SPU2about()
193 {
194 LOG_CALLBACK("SPU2about()\n");
195 SysMessage("%s %d.%d\ndeveloper: zerofrog", libraryName, SPU2_VERSION, SPU2_BUILD);
196 }
197

  ViewVC Help
Powered by ViewVC 1.1.22