2010-03-19 00:31:15 +00:00
/* ZeroGS
* Copyright ( C ) 2002 - 2004 GSsoft 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
2010-07-04 22:49:00 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA
2010-03-19 00:31:15 +00:00
*/
# include <stdarg.h>
# include <stdlib.h>
# include <string.h>
# include <gtk/gtk.h>
# include <dlfcn.h>
# include "GS.h"
# include "Linux.h"
2010-09-01 10:28:37 +00:00
# include "GLWin.h"
2010-03-19 00:31:15 +00:00
# include <map>
2010-06-11 11:48:07 +00:00
extern u32 THR_KeyEvent ; // value for passing out key events beetwen threads
extern bool THR_bShift ;
2011-06-12 14:48:36 +00:00
extern bool THR_bCtrl ;
2010-06-11 11:48:07 +00:00
2010-03-19 00:31:15 +00:00
static map < string , confOptsStruct > mapConfOpts ;
2010-07-31 00:29:49 +00:00
static gameHacks tempHacks ;
2010-03-19 00:31:15 +00:00
2012-04-19 21:22:08 +00:00
EXPORT_C_ ( void ) GSkeyEvent ( keyEvent * ev )
2010-03-19 00:31:15 +00:00
{
2010-05-01 20:33:53 +00:00
switch ( ev - > evt )
{
2010-03-19 00:31:15 +00:00
case KEYPRESS :
2010-05-01 20:33:53 +00:00
switch ( ev - > key )
{
2010-03-19 00:31:15 +00:00
case XK_F5 :
case XK_F6 :
case XK_F7 :
case XK_F9 :
2010-07-11 03:30:35 +00:00
THR_KeyEvent = ev - > key ;
2010-03-19 00:31:15 +00:00
break ;
2010-05-01 20:33:53 +00:00
2010-03-19 00:31:15 +00:00
case XK_Shift_L :
case XK_Shift_R :
THR_bShift = true ;
break ;
2010-05-01 20:33:53 +00:00
2011-06-12 14:48:36 +00:00
case XK_Control_L :
case XK_Control_R :
THR_bCtrl = true ;
break ;
2010-05-01 20:33:53 +00:00
}
2010-03-19 00:31:15 +00:00
break ;
2010-05-01 20:33:53 +00:00
2010-03-19 00:31:15 +00:00
case KEYRELEASE :
2010-05-01 20:33:53 +00:00
switch ( ev - > key )
{
2010-03-19 00:31:15 +00:00
case XK_Shift_L :
case XK_Shift_R :
THR_bShift = false ;
break ;
2010-05-01 20:33:53 +00:00
2011-06-12 14:48:36 +00:00
case XK_Control_L :
case XK_Control_R :
THR_bCtrl = false ;
break ;
2010-03-19 00:31:15 +00:00
}
}
}
2010-03-27 02:21:09 +00:00
void add_map_entry ( u32 option , const char * key , const char * desc )
{
confOpts . value = option ;
confOpts . desc = desc ;
mapConfOpts [ key ] = confOpts ;
}
2010-07-31 00:29:49 +00:00
void CreateGameHackTable ( GtkWidget * treeview , gameHacks hacks )
2010-03-19 00:31:15 +00:00
{
char descbuf [ 255 ] ;
bool itval ;
GtkCellRenderer * treerend ;
GtkListStore * treestore ; //Gets typecast as GtkTreeModel as needed.
GtkTreeIter treeiter ;
GtkTreeViewColumn * treecol ;
2010-04-25 00:31:27 +00:00
2010-03-19 00:31:15 +00:00
//--------- Let's build a treeview for our advanced options! --------//
2010-05-01 20:33:53 +00:00
treestore = gtk_list_store_new ( 2 , G_TYPE_BOOLEAN , G_TYPE_STRING ) ;
2010-03-19 00:31:15 +00:00
//setup columns in treeview
//COLUMN 0 is the checkboxes
treecol = gtk_tree_view_column_new ( ) ;
gtk_tree_view_column_set_title ( treecol , " Select " ) ;
gtk_tree_view_append_column ( GTK_TREE_VIEW ( treeview ) , treecol ) ;
treerend = gtk_cell_renderer_toggle_new ( ) ;
2010-05-01 23:34:44 +00:00
gtk_tree_view_column_pack_start ( treecol , treerend , true ) ;
2010-03-19 00:31:15 +00:00
gtk_tree_view_column_add_attribute ( treecol , treerend , " active " , 0 ) ; //link 'active' attrib to first column of model
2010-05-01 23:34:44 +00:00
g_object_set ( treerend , " activatable " , true , NULL ) ; //set 'activatable' attrib true by default for all rows regardless of model.
2010-03-19 00:31:15 +00:00
g_signal_connect ( treerend , " toggled " , ( GCallback ) OnToggle_advopts , treestore ) ; //set a global callback, we also pass a reference to our treestore.
2010-04-25 00:31:27 +00:00
2010-03-19 00:31:15 +00:00
//COLUMN 1 is the text descriptions
treecol = gtk_tree_view_column_new ( ) ;
gtk_tree_view_column_set_title ( treecol , " Description " ) ;
gtk_tree_view_append_column ( GTK_TREE_VIEW ( treeview ) , treecol ) ;
treerend = gtk_cell_renderer_text_new ( ) ;
2010-05-01 23:34:44 +00:00
gtk_tree_view_column_pack_start ( treecol , treerend , true ) ;
2010-03-19 00:31:15 +00:00
gtk_tree_view_column_add_attribute ( treecol , treerend , " text " , 1 ) ; //link 'text' attrib to second column of model
//setup the model with all our rows of option data
mapConfOpts . clear ( ) ;
2010-04-25 00:31:27 +00:00
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_TEXTURETARGS , " 00000001 " , " Tex Target checking - 00000001 \n Lego Racers " ) ;
2010-09-18 10:20:10 +00:00
add_map_entry ( GAME_AUTORESET , " 00000002 " , " Auto reset targs - 00000002 \n Use when game is slow and toggling AA fixes it. Samurai Warriors. (Automatically on for Shadow Hearts) " ) ;
add_map_entry ( GAME_INTERLACE2X , " 00000004 " , " Interlace 2X - 00000004 \n Fixes 2x bigger screen. Gradius 3. " ) ;
//GAME_TEXAHACK (still implemented)
add_map_entry ( GAME_NOTARGETRESOLVE , " 00000010 " , " No target resolves - 00000010 \n Stops all resolving of targets. Try this first for really slow games. (Automatically on for Dark Cloud 1.) " ) ;
add_map_entry ( GAME_EXACTCOLOR , " 00000020 " , " Exact color testing - 00000020 \n Fixes overbright or shadow/black artifacts. Crash 'n Burn. " ) ;
//add_map_entry(GAME_NOCOLORCLAMP, "00000040", "No color clamping - 00000040\nSpeeds up games, but might be too bright or too dim.");
//GAME_FFXHACK
add_map_entry ( GAME_NOALPHAFAIL , " 00000100 " , " Alpha Fail hack - 00000100 \n Remove vertical stripes or other coloring artifacts. Breaks Persona 4 and MGS3. (Automatically on for Sonic Unleashed, Shadow the Hedgehog, & Ghost in the Shell.) " ) ;
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_NODEPTHUPDATE , " 00000200 " , " Disable depth updates - 00000200 " ) ;
2010-09-18 10:20:10 +00:00
add_map_entry ( GAME_QUICKRESOLVE1 , " 00000400 " , " Resolve Hack #1 - 00000400 \n Speeds some games. Kingdom Hearts. " ) ;
add_map_entry ( GAME_NOQUICKRESOLVE , " 00000800 " , " Resolve Hack #2 - 00000800 \n Shadow Hearts, Urbz. Destroys FFX. " ) ;
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_NOTARGETCLUT , " 00001000 " , " No target CLUT - 00001000 \n Resident Evil 4, or foggy scenes. " ) ;
2010-09-18 10:20:10 +00:00
add_map_entry ( GAME_NOSTENCIL , " 00002000 " , " Disable stencil buffer - 00002000 \n Usually safe to do for simple scenes. Harvest Moon. " ) ;
//GAME_VSSHACKOFF (still implemented)
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_NODEPTHRESOLVE , " 00008000 " , " No depth resolve - 00008000 \n Might give z buffer artifacts. " ) ;
add_map_entry ( GAME_FULL16BITRES , " 00010000 " , " Full 16 bit resolution - 00010000 \n Use when half the screen is missing. " ) ;
add_map_entry ( GAME_RESOLVEPROMOTED , " 00020000 " , " Resolve Hack #3 - 00020000 \n Neopets " ) ;
2010-09-18 10:20:10 +00:00
add_map_entry ( GAME_FASTUPDATE , " 00040000 " , " Fast Update - 00040000 \n Speeds some games. Needed for Sonic Unleashed. Okami. " ) ;
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_NOALPHATEST , " 00080000 " , " Disable alpha testing - 00080000 " ) ;
add_map_entry ( GAME_DISABLEMRTDEPTH , " 00100000 " , " Enable Multiple RTs - 00100000 " ) ;
2010-09-18 10:20:10 +00:00
//GAME_32BITTARGS
2010-09-18 12:20:01 +00:00
//GAME_PATH3HACK
2010-09-18 10:20:10 +00:00
//GAME_DOPARALLELCTX
add_map_entry ( GAME_XENOSPECHACK , " 01000000 " , " Specular Highlights - 01000000 \n Makes graphics faster by removing highlights. (Automatically on for Xenosaga, Okami, & Okage.) " ) ;
//add_map_entry(GAME_PARTIALPOINTERS, "02000000", "Partial targets - 02000000");
2010-04-03 12:48:27 +00:00
add_map_entry ( GAME_PARTIALDEPTH , " 04000000 " , " Partial depth - 04000000 " ) ;
2010-09-18 10:20:10 +00:00
//GAME_REGETHACK (commented out in code)
add_map_entry ( GAME_GUSTHACK , " 10000000 " , " Gust fix - 10000000. Makes gust games cleaner and faster. (Automatically on for most Gust games) " ) ;
add_map_entry ( GAME_NOLOGZ , " 20000000 " , " No logarithmic Z - 20000000. Could decrease number of Z-artifacts. " ) ;
2010-08-21 22:31:32 +00:00
add_map_entry ( GAME_AUTOSKIPDRAW , " 40000000 " , " Remove blur effect on some games \n Slow games. " ) ;
2010-03-19 00:31:15 +00:00
2010-05-01 20:33:53 +00:00
for ( map < string , confOptsStruct > : : iterator it = mapConfOpts . begin ( ) ; it ! = mapConfOpts . end ( ) ; + + it )
2010-03-19 00:31:15 +00:00
{
gtk_list_store_append ( treestore , & treeiter ) ; //new row
2010-07-31 00:29:49 +00:00
itval = ( hacks . _u32 & it - > second . value ) ? true : false ;
2010-10-15 09:32:41 +00:00
if ( conf . def_hacks . _u32 & it - > second . value )
{
snprintf ( descbuf , 254 , " *%s " , it - > second . desc ) ;
}
else
{
snprintf ( descbuf , 254 , " %s " , it - > second . desc ) ;
}
2010-03-19 00:31:15 +00:00
gtk_list_store_set ( treestore , & treeiter , 0 , itval , 1 , descbuf , - 1 ) ;
}
gtk_tree_view_set_model ( GTK_TREE_VIEW ( treeview ) , GTK_TREE_MODEL ( treestore ) ) ; //NB: store is cast as tree model.
2010-05-01 20:33:53 +00:00
2010-03-19 00:31:15 +00:00
g_object_unref ( treestore ) ; //allow model to be destroyed when the tree is destroyed.
2010-04-25 00:31:27 +00:00
2010-03-19 00:31:15 +00:00
//don't select/highlight rows
gtk_tree_selection_set_mode ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( treeview ) ) , GTK_SELECTION_NONE ) ;
//------treeview done -------//
2010-03-27 04:28:12 +00:00
}
2010-07-31 00:29:49 +00:00
void SaveGameHackTable ( GtkWidget * treeview , gameHacks & hacks )
2010-03-27 04:28:12 +00:00
{
GtkTreeModel * treemodel ;
GtkTreeIter treeiter ;
gboolean treeoptval ;
2010-04-25 00:31:27 +00:00
2010-03-27 04:28:12 +00:00
//------- get advanced options from the treeview model -------//
treemodel = gtk_tree_view_get_model ( GTK_TREE_VIEW ( treeview ) ) ;
gtk_tree_model_get_iter_first ( treemodel , & treeiter ) ;
2010-03-19 00:31:15 +00:00
2010-07-31 00:29:49 +00:00
hacks . _u32 = 0 ;
2010-05-01 20:33:53 +00:00
for ( map < string , confOptsStruct > : : iterator it = mapConfOpts . begin ( ) ; it ! = mapConfOpts . end ( ) ; + + it )
2010-03-27 04:28:12 +00:00
{
2010-05-01 23:34:44 +00:00
treeoptval = false ;
2010-03-27 04:28:12 +00:00
gtk_tree_model_get ( treemodel , & treeiter , 0 , & treeoptval , - 1 ) ;
2010-04-25 00:31:27 +00:00
2010-07-31 00:29:49 +00:00
if ( treeoptval ) hacks . _u32 | = it - > second . value ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
gtk_tree_model_iter_next ( treemodel , & treeiter ) ;
2010-03-27 04:28:12 +00:00
}
2010-04-25 00:31:27 +00:00
2010-03-27 04:28:12 +00:00
//---------- done getting advanced options ---------//
2010-03-19 00:31:15 +00:00
}
void OnToggle_advopts ( GtkCellRendererToggle * cell , gchar * path , gpointer user_data )
{
GtkTreeIter treeiter ;
gboolean val ;
gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( user_data ) , & treeiter , path ) ;
gtk_tree_model_get ( GTK_TREE_MODEL ( user_data ) , & treeiter , 0 , & val , - 1 ) ;
val = ! val ;
gtk_list_store_set ( GTK_LIST_STORE ( user_data ) , & treeiter , 0 , val , - 1 ) ;
}
2010-07-31 00:29:49 +00:00
void DisplayAdvancedDialog ( )
{
GtkWidget * dialog ;
GtkWidget * advanced_frame , * advanced_box ;
GtkWidget * advanced_scroll ;
GtkWidget * tree ;
dialog = gtk_dialog_new ( ) ;
gtk_window_set_title ( GTK_WINDOW ( dialog ) , " ZZOgl PG Advanced Config " ) ;
2010-12-20 19:57:50 +00:00
// A good value for the heigh will be 1000 instead of 800 but I'm afraid that some people still uses small screen...
gtk_window_set_default_size ( GTK_WINDOW ( dialog ) , 600 , 800 ) ;
2010-07-31 00:29:49 +00:00
gtk_window_set_modal ( GTK_WINDOW ( dialog ) , true ) ;
advanced_box = gtk_vbox_new ( false , 5 ) ;
advanced_frame = gtk_frame_new ( " Advanced Settings: " ) ;
gtk_container_add ( GTK_CONTAINER ( advanced_frame ) , advanced_box ) ;
tree = gtk_tree_view_new ( ) ;
CreateGameHackTable ( tree , tempHacks ) ;
advanced_scroll = gtk_scrolled_window_new ( NULL , NULL ) ;
gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( advanced_scroll ) , tree ) ;
gtk_box_pack_start ( GTK_BOX ( advanced_box ) , advanced_scroll , true , true , 2 ) ;
2010-12-24 23:58:56 +00:00
gtk_container_add ( GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ) , advanced_frame ) ;
2010-07-31 00:29:49 +00:00
gtk_widget_show_all ( dialog ) ;
gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
SaveGameHackTable ( tree , tempHacks ) ;
gtk_widget_destroy ( dialog ) ;
}
2010-03-27 04:28:12 +00:00
void DisplayDialog ( )
2010-03-19 00:31:15 +00:00
{
2010-05-01 20:33:53 +00:00
int return_value ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
GtkWidget * dialog ;
GtkWidget * main_frame , * main_box ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
GtkWidget * option_frame , * option_box ;
2010-10-15 09:32:41 +00:00
GtkWidget * log_check , * dis_hacks_check ;
2010-07-31 00:29:49 +00:00
GtkWidget * int_label , * int_box , * int_holder ;
2010-09-18 21:45:39 +00:00
GtkWidget * bilinear_label , * bilinear_box , * bilinear_holder ;
2010-07-31 00:29:49 +00:00
GtkWidget * aa_label , * aa_box , * aa_holder ;
GtkWidget * snap_label , * snap_box , * snap_holder ;
2010-10-15 09:32:41 +00:00
GtkWidget * fullscreen_label , * widescreen_check ;
2010-09-08 12:03:49 +00:00
2010-07-31 00:29:49 +00:00
GtkWidget * advanced_button ;
2010-08-19 09:21:28 +00:00
GtkWidget * separator ;
GtkWidget * skipdraw_label , * skipdraw_text , * skipdraw_holder , * warning_label ;
2010-06-19 06:23:40 +00:00
if ( ! ( conf . loaded ( ) ) ) LoadConfig ( ) ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (
" ZZOgl PG Config " ,
NULL , /* parent window*/
( GtkDialogFlags ) ( GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT ) ,
GTK_STOCK_CANCEL ,
GTK_RESPONSE_REJECT ,
GTK_STOCK_OK ,
GTK_RESPONSE_ACCEPT ,
NULL ) ;
2010-07-31 00:29:49 +00:00
log_check = gtk_check_button_new_with_label ( " Logging " ) ;
gtk_widget_set_tooltip_text ( log_check , " Used for Debugging. " ) ;
2010-05-01 20:33:53 +00:00
2010-07-31 00:29:49 +00:00
int_label = gtk_label_new ( " Interlacing: " ) ;
2010-05-01 20:33:53 +00:00
int_box = gtk_combo_box_new_text ( ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( int_box ) , " No Interlacing " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( int_box ) , " Interlace 0 " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( int_box ) , " Interlace 1 " ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( int_box ) , conf . interlace ) ;
2010-07-31 00:29:49 +00:00
gtk_widget_set_tooltip_text ( int_box , " Toggled by pressing F5 when running. " ) ;
int_holder = gtk_hbox_new ( false , 5 ) ;
gtk_box_pack_start ( GTK_BOX ( int_holder ) , int_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( int_holder ) , int_box , false , false , 2 ) ;
2010-05-01 20:33:53 +00:00
2010-09-18 21:45:39 +00:00
bilinear_label = gtk_label_new ( " Bilinear Filtering: " ) ;
bilinear_box = gtk_combo_box_new_text ( ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( bilinear_box ) , " Off " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( bilinear_box ) , " Normal " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( bilinear_box ) , " Forced " ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( bilinear_box ) , conf . bilinear ) ;
gtk_widget_set_tooltip_text ( bilinear_box , " Best quality is off. Turn on for speed. Toggled by pressing Shift + F5 when running. " ) ;
bilinear_holder = gtk_hbox_new ( false , 5 ) ;
gtk_box_pack_start ( GTK_BOX ( bilinear_holder ) , bilinear_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( bilinear_holder ) , bilinear_box , false , false , 2 ) ;
2010-07-31 00:29:49 +00:00
aa_label = gtk_label_new ( " Anti-Aliasing: " ) ;
2010-05-01 20:33:53 +00:00
aa_box = gtk_combo_box_new_text ( ) ;
2010-07-31 00:29:49 +00:00
gtk_combo_box_append_text ( GTK_COMBO_BOX ( aa_box ) , " 1X (None) " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( aa_box ) , " 2X " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( aa_box ) , " 4X " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( aa_box ) , " 8X " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( aa_box ) , " 16X " ) ;
2010-05-01 20:33:53 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( aa_box ) , conf . aa ) ;
2010-07-31 00:29:49 +00:00
gtk_widget_set_tooltip_text ( aa_box , " Toggled by pressing F6 when running. " ) ;
aa_holder = gtk_hbox_new ( false , 5 ) ;
gtk_box_pack_start ( GTK_BOX ( aa_holder ) , aa_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( aa_holder ) , aa_box , false , false , 2 ) ;
2010-05-01 20:33:53 +00:00
snap_label = gtk_label_new ( " Snapshot format: " ) ;
snap_box = gtk_combo_box_new_text ( ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( snap_box ) , " JPEG " ) ;
gtk_combo_box_append_text ( GTK_COMBO_BOX ( snap_box ) , " TIFF " ) ;
2010-06-19 08:46:40 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( snap_box ) , conf . zz_options . tga_snap ) ;
2010-07-31 00:29:49 +00:00
snap_holder = gtk_hbox_new ( false , 5 ) ;
gtk_box_pack_start ( GTK_BOX ( snap_holder ) , snap_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( snap_holder ) , snap_box , false , false , 2 ) ;
2010-05-01 20:33:53 +00:00
2010-09-08 11:16:27 +00:00
widescreen_check = gtk_check_button_new_with_label ( " Widescreen " ) ;
gtk_widget_set_tooltip_text ( widescreen_check , " Force a 4:3 ration when disabled " ) ;
2010-09-11 04:26:20 +00:00
fullscreen_label = gtk_label_new ( " Press Alt-Enter for Fullscreen. " ) ;
2010-09-08 12:03:49 +00:00
gtk_label_set_single_line_mode ( GTK_LABEL ( fullscreen_label ) , false ) ;
2010-07-31 00:29:49 +00:00
advanced_button = gtk_button_new_with_label ( " Advanced... " ) ;
2010-04-25 00:31:27 +00:00
2010-10-15 09:32:41 +00:00
dis_hacks_check = gtk_check_button_new_with_label ( " Disable Automatic Hacks " ) ;
gtk_widget_set_tooltip_text ( dis_hacks_check , " Used for testing how useful hacks that are on automatically are. " ) ;
2010-09-11 04:26:20 +00:00
# ifdef ZEROGS_DEVBUILD
2010-08-19 09:21:28 +00:00
separator = gtk_hseparator_new ( ) ;
skipdraw_label = gtk_label_new ( " Skipdraw: " ) ;
skipdraw_text = gtk_entry_new ( ) ;
warning_label = gtk_label_new ( " Experimental!! " ) ;
char buf [ 5 ] ;
sprintf ( buf , " %d " , conf . SkipDraw ) ;
gtk_entry_set_text ( GTK_ENTRY ( skipdraw_text ) , buf ) ;
skipdraw_holder = gtk_hbox_new ( false , 5 ) ;
gtk_box_pack_start ( GTK_BOX ( skipdraw_holder ) , skipdraw_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( skipdraw_holder ) , skipdraw_text , false , false , 2 ) ;
2010-09-11 04:26:20 +00:00
# endif
2010-08-19 09:21:28 +00:00
2010-05-01 20:33:53 +00:00
main_box = gtk_hbox_new ( false , 5 ) ;
main_frame = gtk_frame_new ( " ZZOgl PG Config " ) ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
gtk_container_add ( GTK_CONTAINER ( main_frame ) , main_box ) ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
option_box = gtk_vbox_new ( false , 5 ) ;
option_frame = gtk_frame_new ( " " ) ;
gtk_container_add ( GTK_CONTAINER ( option_frame ) , option_box ) ;
2010-07-31 00:29:49 +00:00
gtk_frame_set_shadow_type ( GTK_FRAME ( option_frame ) , GTK_SHADOW_NONE ) ;
2010-04-25 00:31:27 +00:00
2010-04-25 07:21:29 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , log_check , false , false , 2 ) ;
2010-09-18 21:45:39 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , bilinear_holder , false , false , 2 ) ;
2010-07-31 00:29:49 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , int_holder , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( option_box ) , aa_holder , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( option_box ) , snap_holder , false , false , 2 ) ;
2010-09-08 11:16:27 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , widescreen_check , false , false , 2 ) ;
2010-07-31 00:29:49 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , advanced_button , false , false , 2 ) ;
2010-10-15 09:32:41 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , dis_hacks_check , false , false , 2 ) ;
2010-09-11 04:26:20 +00:00
# ifdef ZEROGS_DEVBUILD
2010-08-19 09:21:28 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , separator , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( option_box ) , warning_label , false , false , 2 ) ;
gtk_box_pack_start ( GTK_BOX ( option_box ) , skipdraw_holder , false , false , 2 ) ;
2010-09-11 04:26:20 +00:00
# endif
2010-09-06 12:09:49 +00:00
gtk_box_pack_start ( GTK_BOX ( option_box ) , fullscreen_label , false , false , 2 ) ;
2010-07-31 00:29:49 +00:00
2010-03-27 04:28:12 +00:00
gtk_box_pack_start ( GTK_BOX ( main_box ) , option_frame , false , false , 2 ) ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( log_check ) , conf . log ) ;
2010-09-08 11:16:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widescreen_check ) , ( conf . widescreen ( ) ) ) ;
2010-10-15 09:32:41 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( dis_hacks_check ) , ( conf . disableHacks ) ) ;
2010-04-25 00:31:27 +00:00
2010-12-24 23:58:56 +00:00
gtk_container_add ( GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ) , main_frame ) ;
2010-07-31 00:29:49 +00:00
g_signal_connect_swapped ( GTK_OBJECT ( advanced_button ) , " clicked " , G_CALLBACK ( DisplayAdvancedDialog ) , advanced_button ) ;
2010-10-15 09:32:41 +00:00
tempHacks = conf . hacks ;
2010-05-01 20:33:53 +00:00
gtk_widget_show_all ( dialog ) ;
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
return_value = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
if ( return_value = = GTK_RESPONSE_ACCEPT )
{
2010-06-19 08:46:40 +00:00
ZZOptions fake_options ;
2010-05-01 20:33:53 +00:00
if ( gtk_combo_box_get_active ( GTK_COMBO_BOX ( int_box ) ) ! = - 1 )
2010-03-27 04:28:12 +00:00
conf . interlace = gtk_combo_box_get_active ( GTK_COMBO_BOX ( int_box ) ) ;
2010-05-01 20:33:53 +00:00
if ( gtk_combo_box_get_active ( GTK_COMBO_BOX ( aa_box ) ) ! = - 1 )
2010-03-27 04:28:12 +00:00
conf . aa = gtk_combo_box_get_active ( GTK_COMBO_BOX ( aa_box ) ) ;
2010-09-18 21:45:39 +00:00
if ( gtk_combo_box_get_active ( GTK_COMBO_BOX ( bilinear_box ) ) ! = - 1 )
conf . bilinear = gtk_combo_box_get_active ( GTK_COMBO_BOX ( bilinear_box ) ) ;
2010-04-25 00:31:27 +00:00
2010-04-25 07:21:29 +00:00
conf . log = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( log_check ) ) ;
2010-09-08 11:16:27 +00:00
fake_options . widescreen = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widescreen_check ) ) ;
2010-06-19 08:46:40 +00:00
fake_options . tga_snap = gtk_combo_box_get_active ( GTK_COMBO_BOX ( snap_box ) ) ;
2010-07-30 09:52:34 +00:00
2010-09-11 04:26:20 +00:00
# ifdef ZEROGS_DEVBUILD
2010-08-19 09:21:28 +00:00
conf . SkipDraw = atoi ( ( char * ) gtk_entry_get_text ( GTK_ENTRY ( skipdraw_text ) ) ) ;
2010-09-11 04:26:20 +00:00
# endif
2010-08-19 09:21:28 +00:00
2010-06-19 08:46:40 +00:00
conf . zz_options = fake_options ;
2010-07-31 00:29:49 +00:00
conf . hacks = tempHacks ;
2010-10-15 09:32:41 +00:00
conf . disableHacks = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( dis_hacks_check ) ) ;
2010-07-31 00:29:49 +00:00
GSsetGameCRC ( g_LastCRC , conf . hacks . _u32 ) ;
2010-05-01 20:33:53 +00:00
2010-03-27 04:28:12 +00:00
SaveConfig ( ) ;
2010-05-01 20:33:53 +00:00
}
2010-04-25 00:31:27 +00:00
2010-05-01 20:33:53 +00:00
gtk_widget_destroy ( dialog ) ;
2010-03-19 00:31:15 +00:00
}
2012-04-19 21:22:08 +00:00
EXPORT_C_ ( void ) GSconfigure ( )
2010-03-19 00:31:15 +00:00
{
2010-03-27 04:28:12 +00:00
char strcurdir [ 256 ] ;
2014-04-18 21:21:27 +00:00
if ( getcwd ( strcurdir , 256 ) = = NULL ) {
fprintf ( stderr , " Failed to get current working directory \n " ) ;
return ;
}
2010-04-25 00:31:27 +00:00
2010-06-19 06:23:40 +00:00
if ( ! ( conf . loaded ( ) ) ) LoadConfig ( ) ;
2010-04-25 00:31:27 +00:00
2010-03-27 04:28:12 +00:00
DisplayDialog ( ) ;
2010-03-19 00:31:15 +00:00
}
2010-04-02 05:53:14 +00:00
void SysMessage ( const char * fmt , . . . )
2010-03-19 00:31:15 +00:00
{
2010-05-01 20:33:53 +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 ) ;
2010-03-19 00:31:15 +00:00
}
2012-04-19 21:22:08 +00:00
EXPORT_C_ ( void ) GSabout ( )
2010-03-19 00:31:15 +00:00
{
2010-09-18 23:36:24 +00:00
SysMessage ( " ZZOgl PG: by Zeydlitz (PG version worked on by arcum42, gregory, and the pcsx2 development team). Based off of ZeroGS, by zerofrog. " ) ;
2010-03-19 00:31:15 +00:00
}
2012-04-19 21:22:08 +00:00
EXPORT_C_ ( s32 ) GStest ( )
2010-03-19 00:31:15 +00:00
{
2010-03-27 04:28:12 +00:00
return 0 ;
2010-03-19 00:31:15 +00:00
}
2010-04-25 00:31:27 +00:00
void * SysLoadLibrary ( char * lib )
2010-03-19 00:31:15 +00:00
{
return dlopen ( lib , RTLD_NOW | RTLD_GLOBAL ) ;
}
2010-04-25 00:31:27 +00:00
void * SysLoadSym ( void * lib , char * sym )
2010-03-19 00:31:15 +00:00
{
void * ret = dlsym ( lib , sym ) ;
2010-05-01 20:33:53 +00:00
2010-10-16 11:10:48 +00:00
if ( ret = = NULL ) ZZLog : : Debug_Log ( " null: %s " , sym ) ;
2010-05-01 20:33:53 +00:00
2010-03-19 00:31:15 +00:00
return dlsym ( lib , sym ) ;
}
2010-04-25 00:31:27 +00:00
char * SysLibError ( )
2010-03-19 00:31:15 +00:00
{
return dlerror ( ) ;
}
2010-04-25 00:31:27 +00:00
void SysCloseLibrary ( void * lib )
2010-03-19 00:31:15 +00:00
{
dlclose ( lib ) ;
}