/*
- Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Overview
========
- This plugin allows the user to rebuild the "wad" key pair in the worldspawn
- so that it has a list of all the .wad files in use.
Version History
===============
v0.1 - 28/May/2002
- Initial version.
- v1.0 - 10/March/2003
- - Added more console output
- - Removed some old test code
- - Tweaked dialog box.
- - Fixed up for Radiant 1.3.5
-
ToDo
====
- Nothing...
+ * Code it ? :)
*/
_QERFileSystemTable g_FileSystemTable;
_QEREntityTable g_EntityTable;
+// cast to GtkWidget*
+void *g_pMainWnd;
+
+// =============================================================================
+// Ripped from TexTool.cpp
+
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
+ int *loop, *ret;
+
+ auto parent = widget.window();
+ loop = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "loop" );
+ ret = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "ret" );
+
+ *loop = 0;
+ *ret = gpointer_to_int( data );
+}
+
+static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
+ int *loop;
+
+ gtk_widget_hide( widget );
+ loop = (int*)gtk_object_get_data( GTK_OBJECT( widget ), "loop" );
+ *loop = 0;
+
+ return TRUE;
+}
+
+int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){
+ GtkWidget *w, *hbox;
+ int mode = ( uType & MB_TYPEMASK ), ret, loop = 1;
+
+ auto window = ui::Window( ui::window_type::TOP );
+ window.connect( "delete_event",
+ G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy",
+ G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_title( window, lpCaption );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop );
+ gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret );
+ gtk_widget_realize( window );
+
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
+
+ w = ui::Label( lpText );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
+ w.show();
+
+ w = gtk_hseparator_new();
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
+
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
+
+ if ( mode == MB_OK ) {
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
+ gtk_widget_grab_default( w );
+ w.show();
+ ret = IDOK;
+ }
+ else if ( mode == MB_OKCANCEL ) {
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
+ gtk_widget_grab_default( w );
+ w.show();
+
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
+ ret = IDCANCEL;
+ }
+ else if ( mode == MB_YESNOCANCEL ) {
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
+ gtk_widget_grab_default( w );
+ w.show();
+
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
+
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
+ ret = IDCANCEL;
+ }
+ else /* if (mode == MB_YESNO) */
+ {
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
+ gtk_widget_grab_default( w );
+ w.show();
+
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
+ ret = IDNO;
+ }
+
+ window.show();
+ gtk_grab_add( window );
+
+ while ( loop )
+ gtk_main_iteration();
+
+ gtk_grab_remove( window );
+ window.destroy();
+
+ return ret;
+}
+
+// End of rip from TexTool.cpp
// =============================================================================
// Ripped from cmdlib.cpp
Extract file parts
====================
*/
-void HYDRA_ExtractFilePath( const char *path, char *dest ){
+void ExtractFilePath( const char *path, char *dest ){
const char *src;
src = path + strlen( path ) - 1;
dest[src - path] = 0;
}
-void HYDRA_ExtractFileName( const char *path, char *dest ){
+void ExtractFileName( const char *path, char *dest ){
const char *src;
src = path + strlen( path ) - 1;
*dest = 0;
}
-void HYDRA_ConvertDOSToUnixName( char *dst, const char *src ){
+void ConvertDOSToUnixName( char *dst, const char *src ){
while ( *src )
{
if ( *src == '\\' ) {
if ( strcmp( shadername,"color" ) == 0 ) {
return wadlist;
}
- HYDRA_ExtractFilePath( shadername,tmpstr );
+ ExtractFilePath( shadername,tmpstr );
// Sys_Printf("checking: %s\n",shadername);
int l = strlen( tmpstr ) - 1;
}
else
{
- Sys_Printf( "HydraToolz: WARNING: Unknown wad file for shader %s\n",shadername );
+ Sys_Printf( "WARNING: Unknown wad file for shader %s\n",shadername );
return wadlist;
}
- HYDRA_ExtractFileName( tmpstr,tmpstr );
+ ExtractFileName( tmpstr,tmpstr );
wadname = (char *)malloc( strlen( tmpstr ) + 5 );
sprintf( wadname,"%s.wad",tmpstr );
for ( GSList *l = wadlist; l != NULL ; l = l->next )
{
- if ( !stricmp( (char *)l->data,wadname ) ) {
+ if ( string_equal_nocase( (char *)l->data,wadname ) ) {
free( wadname );
return wadlist;
}
}
- Sys_Printf( "HydraToolz: Adding Wad File to WAD list: %s (reason: ",wadname );
+ Sys_Printf( "Adding Wad File to WAD list: %s (reason: ",wadname );
if ( shadername ) {
Sys_Printf( "see shader \"%s\")\n", shadername );
}
int i,nb;
char wads[2048]; // change to CString usage ?
- *wads = 0;
+ wads[0] = 0;
char *p1,*p2;
entity_t *pEntity;
epair_t *pEpair;
face_t *f;
brush_t *b;
char cleanwadname[QER_MAX_NAMELEN];
- char *actualwad;
+ const char *actualwad;
pEntity = (entity_t *)g_FuncTable.m_pfnGetEntityHandle( 0 ); // get the worldspawn ent
- Sys_Printf( "HydraToolz: Searching for in-use wad files...\n" );
+ Sys_Printf( "Searching for in-use wad files...\n" );
for ( pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next )
{
- if ( stricmp( pEpair->key,"wad" ) == 0 ) {
+ if ( string_equal_nocase( pEpair->key,"wad" ) ) {
strcpy( wads,pEpair->value );
- HYDRA_ConvertDOSToUnixName( wads,wads );
-
- Sys_Printf( "HydraToolz: Current wad key is \"%s\"!\n",wads );
+ ConvertDOSToUnixName( wads,wads );
// ok, we got the list of ; delimited wads, now split it into a GSList that contains
// just the wad names themselves.
}
if ( strchr( p1,'/' ) || strchr( p1,'\\' ) ) {
- HYDRA_ExtractFileName( p1,cleanwadname );
+ ExtractFileName( p1,cleanwadname );
wadlist = AddToWadList( wadlist, NULL, cleanwadname );
}
else
}
}
- if ( !*wads ) {
- Sys_Printf( "HydraToolz: No \"wad\" keypair wound in worldspawn\n" );
- }
-
-
nb = g_FuncTable.m_pfnAllocateActiveBrushHandles();
for ( i = 0; i < nb; i++ )
{
}
g_FuncTable.m_pfnReleaseSelectedBrushHandles();
- Sys_Printf( "HydraToolz: Rebuilding worldspawn's \"wad\" key-pair...\n" );
// Now we have a complete list of wadnames (without paths) so we just have to turn this
// back to a ; delimited list.
- *wads = 0;
+ wads[0] = 0;
while ( wadlist )
{
- // skip wad files if they start with "common-"
- if ( strnicmp( (char *)wadlist->data,"common-",7 ) == 0 ) {
- Sys_Printf( "HydraToolz: Skipping radiant/user-supplied wad file %s\n",(char *)wadlist->data );
+ if ( string_equal_nocase( (char *)wadlist->data,"common-hydra.wad" ) ) {
+ Sys_Printf( "Skipping radiant-supplied wad file %s\n",(char *)wadlist->data );
}
else
{
strcat( wads,";" );
}
- actualwad = vfsGetFullPath( (char *)wadlist->data, 0, 0 );
+ actualwad = vfsGetFullPath( (char *)wadlist->data );
if ( actualwad ) {
strcat( wads, actualwad );
}
else
{
- Sys_Printf( "HydraToolz: WARNING: could not locate wad file %s\n",(char *)wadlist->data );
+ Sys_Printf( "WARNING: could not locate wad file %s\n",(char *)wadlist->data );
strcat( wads, (char *)wadlist->data );
}
}
}
// store the wad list back in the worldspawn.
- if ( *wads ) {
+ if ( wads[0] ) {
//free(pEpair->value);
//pEpair->value = strdup(wads);
SetKeyValue( pEntity, "wad", wads );
- Sys_Printf( "HydraToolz: Setting worldspawn \"wad\" key value to \"%s\"\n",wads );
-
}
- Sys_Printf( "HydraToolz: Finished rebuilding wad keypair!\n" );
-
}
// =============================================================================
// PLUGIN INTERFACE STUFF
// plugin name
-const char *PLUGIN_NAME = "HydraToolz";
+const char *PLUGIN_NAME = "Q3 Texture Tools";
// commands in the menu
const char *PLUGIN_COMMANDS = "About...;Create/Update WAD keypair";
-const char *PLUGIN_ABOUT = "HydraToolz v1.0 for GTKRadiant\n\n"
+const char *PLUGIN_ABOUT = "HydraToolz for GTKRadiant\n\n"
"By Hydra!";
extern "C" void* WINAPI QERPlug_GetFuncTable(){
}
const char* QERPlug_Init( void* hApp, void *pWidget ){
+ GtkWidget* pMainWidget = static_cast<GtkWidget*>( pWidget );
+
+ g_pMainWnd = pMainWidget;
+ memset( &g_FuncTable, 0, sizeof( _QERFuncTable_1 ) );
+ g_FuncTable.m_nSize = sizeof( _QERFuncTable_1 );
return "HydraToolz for GTKRadiant"; // do we need this ? hmmm
}
UpdateWadKeyPair();
}
else if ( !strcmp( p, "About..." ) ) {
- g_FuncTable.m_pfnMessageBox( NULL, PLUGIN_ABOUT, "About", MB_OK, NULL );
+ g_FuncTable.m_pfnMessageBox( (GtkWidget*)NULL, PLUGIN_ABOUT, "About", eMB_OK );
}
}
CSynapseServer* g_pSynapseServer = NULL;
CSynapseClientHydraToolz g_SynapseClient;
-#if __GNUC__ >= 4
-#pragma GCC visibility push(default)
-#endif
-extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
-#if __GNUC__ >= 4
-#pragma GCC visibility pop
-#endif
+extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ){
if ( strcmp( version, SYNAPSE_VERSION ) ) {
Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
return NULL;