2009-02-06 19:52:59 +00:00
/* ZeroSPU2
2010-01-16 16:08:17 +00:00
* Copyright ( C ) 2006 - 2010 zerofrog
2009-02-06 19:52:59 +00:00
*
* 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
2010-07-04 22:49:00 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA
2009-02-06 19:52:59 +00:00
*/
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
// Modified by arcum42@gmail.com
# include <gtk/gtk.h>
# include "Linux.h"
2009-02-27 04:54:07 +00:00
# include "zerospu2.h"
2009-02-06 19:52:59 +00:00
2009-02-22 12:08:05 +00:00
extern char * libraryName ;
2010-07-05 15:43:21 +00:00
void SysMessage ( const char * fmt , . . . )
2009-02-27 03:30:25 +00:00
{
2010-06-11 08:56:54 +00:00
va_list list ;
char msg [ 512 ] ;
va_start ( list , fmt ) ;
vsprintf ( msg , fmt , list ) ;
va_end ( list ) ;
if ( msg [ strlen ( msg ) - 1 ] = = ' \n ' ) msg [ strlen ( msg ) - 1 ] = 0 ;
GtkWidget * dialog ;
dialog = gtk_message_dialog_new ( NULL ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_INFO ,
GTK_BUTTONS_OK ,
" %s " , msg ) ;
gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
2009-02-06 19:52:59 +00:00
}
2010-04-25 00:31:27 +00:00
void SaveConfig ( )
2009-02-20 03:22:19 +00:00
{
2009-12-19 18:30:56 +00:00
string iniFile ( s_strIniPath + " zerospu2.ini " ) ;
2010-04-25 00:31:27 +00:00
2009-12-19 18:30:56 +00:00
FILE * f = fopen ( iniFile . c_str ( ) , " w " ) ;
2010-04-25 00:31:27 +00:00
if ( f = = NULL )
2009-02-20 03:22:19 +00:00
{
2009-12-19 18:30:56 +00:00
ERROR_LOG ( " Failed to open %s \n " , iniFile . c_str ( ) ) ;
2009-02-06 19:52:59 +00:00
return ;
}
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
fprintf ( f , " log = %d \n " , conf . Log ) ;
2009-02-27 03:30:25 +00:00
//fprintf(f, "options = %d\n", conf.options);
2010-04-25 00:31:27 +00:00
2010-06-11 08:56:54 +00:00
fprintf ( f , " realtime = %d \n " , ( conf . options & OPTION_REALTIME ) ) ;
fprintf ( f , " timestretch = %d \n " , ( conf . options & OPTION_TIMESTRETCH ) ) ;
fprintf ( f , " recording = %d \n " , ( conf . options & OPTION_RECORDING ) ) ;
fprintf ( f , " mute = %d \n " , ( conf . options & OPTION_MUTE ) ) ;
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
fclose ( f ) ;
}
2009-12-19 18:30:56 +00:00
void LoadConfig ( )
2009-02-20 03:22:19 +00:00
{
2009-02-27 03:30:25 +00:00
int temp ;
2009-02-06 19:52:59 +00:00
memset ( & conf , 0 , sizeof ( conf ) ) ;
2009-12-19 18:30:56 +00:00
string iniFile ( s_strIniPath + " zerospu2.ini " ) ;
2010-04-25 00:31:27 +00:00
2009-12-19 18:30:56 +00:00
FILE * f = fopen ( iniFile . c_str ( ) , " r " ) ;
2010-04-25 00:31:27 +00:00
if ( f = = NULL )
2009-02-20 03:22:19 +00:00
{
2009-12-19 18:30:56 +00:00
ERROR_LOG ( " Failed to open %s \n " , iniFile . c_str ( ) ) ;
2009-02-06 19:52:59 +00:00
conf . Log = 0 ;
conf . options = 0 ;
SaveConfig ( ) ; //save and return
return ;
}
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
fscanf ( f , " log = %d \n " , & conf . Log ) ;
2010-04-25 00:31:27 +00:00
2009-02-27 03:30:25 +00:00
fscanf ( f , " realtime = %d \n " , & temp ) ;
if ( temp ) conf . options | = OPTION_REALTIME ;
2010-04-25 00:31:27 +00:00
2009-02-27 03:30:25 +00:00
fscanf ( f , " timestretch = %d \n " , & temp ) ;
if ( temp ) conf . options | = OPTION_TIMESTRETCH ;
2010-04-25 00:31:27 +00:00
2009-02-27 03:30:25 +00:00
fscanf ( f , " recording = %d \n " , & temp ) ;
if ( temp ) conf . options | = OPTION_RECORDING ;
2010-04-25 00:31:27 +00:00
2009-02-27 03:30:25 +00:00
fscanf ( f , " mute = %d \n " , & temp ) ;
if ( temp ) conf . options | = OPTION_MUTE ;
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
fscanf ( f , " options = %d \n " , & conf . options ) ;
2010-04-25 00:31:27 +00:00
2009-02-06 19:52:59 +00:00
fclose ( f ) ;
}
2010-06-11 08:56:54 +00:00
void DisplayDialog ( )
{
int return_value ;
GtkWidget * dialog ;
GtkWidget * main_box ;
GtkWidget * time_scaling_check , * real_time_check , * recording_check , * mute_check , * logging_check ;
LoadConfig ( ) ;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (
" ZeroSPU2 Config " ,
NULL , /* parent window*/
( GtkDialogFlags ) ( GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT ) ,
GTK_STOCK_OK ,
GTK_RESPONSE_ACCEPT ,
GTK_STOCK_CANCEL ,
GTK_RESPONSE_REJECT ,
NULL ) ;
time_scaling_check = gtk_check_button_new_with_label ( " Time Scaling (recommended) " ) ;
gtk_widget_set_tooltip_text ( time_scaling_check , " Slows down or speeds up sound with respect to the game's real speed. \n Enabling this produces higher quality sound with less cracking, but can reduce speed. " ) ;
real_time_check = gtk_check_button_new_with_label ( " Real Time Mode " ) ;
gtk_widget_set_tooltip_text ( real_time_check , " Tries to reduce delays in music as much as possible. \n Use when a game is already fast, and needs sound tightly syncronized. (like in DDR, Guitar Hero, & Guitaroo Man) " ) ;
recording_check = gtk_check_button_new_with_label ( " Recording " ) ;
gtk_widget_set_tooltip_text ( recording_check , " Saves the raw 16 bit stereo wave data to zerospu2.wav. Timed to ps2 time. " ) ;
mute_check = gtk_check_button_new_with_label ( " Mute " ) ;
gtk_widget_set_tooltip_text ( mute_check , " ZeroSPU2 will not output sound (fast). " ) ;
logging_check = gtk_check_button_new_with_label ( " Enable logging " ) ;
gtk_widget_set_tooltip_text ( logging_check , " For development use only. " ) ;
main_box = gtk_vbox_new ( false , 5 ) ;
gtk_container_add ( GTK_CONTAINER ( main_box ) , time_scaling_check ) ;
gtk_container_add ( GTK_CONTAINER ( main_box ) , real_time_check ) ;
gtk_container_add ( GTK_CONTAINER ( main_box ) , recording_check ) ;
gtk_container_add ( GTK_CONTAINER ( main_box ) , mute_check ) ;
gtk_container_add ( GTK_CONTAINER ( main_box ) , logging_check ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( time_scaling_check ) , ( conf . options & OPTION_TIMESTRETCH ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( real_time_check ) , ( conf . options & OPTION_REALTIME ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( recording_check ) , ( conf . options & OPTION_RECORDING ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( mute_check ) , ( conf . options & OPTION_MUTE ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( logging_check ) , ( conf . Log ) ) ;
2010-12-24 23:58:56 +00:00
gtk_container_add ( GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ) , main_box ) ;
2010-06-11 08:56:54 +00:00
gtk_widget_show_all ( dialog ) ;
return_value = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
if ( return_value = = GTK_RESPONSE_ACCEPT )
{
conf . options = 0 ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( time_scaling_check ) ) )
conf . options | = OPTION_TIMESTRETCH ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( real_time_check ) ) )
conf . options | = OPTION_REALTIME ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( recording_check ) ) )
conf . options | = OPTION_RECORDING ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( mute_check ) ) )
conf . options | = OPTION_MUTE ;
conf . Log = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( logging_check ) ) ;
SaveConfig ( ) ;
}
gtk_widget_destroy ( dialog ) ;
}
void CALLBACK SPU2configure ( )
{
LOG_CALLBACK ( " SPU2configure() \n " ) ;
DisplayDialog ( ) ;
}
void CALLBACK SPU2about ( )
{
LOG_CALLBACK ( " SPU2about() \n " ) ;
SysMessage ( " %s %d.%d \n developer: zerofrog " , libraryName , SPU2_VERSION , SPU2_BUILD ) ;
}