Reworked gtk_MessageDialog to have icons, center

the window, etc.
This commit is contained in:
Clinton Freeman 2012-05-09 20:51:27 -04:00
parent a6c7474450
commit 24b3efb6ec
5 changed files with 1570 additions and 780 deletions

View file

@ -1,4 +1,3 @@
textures/common/areaportal
{
qer_trans 0.50
@ -14,7 +13,7 @@ textures/common/areaportal
textures/common/caulk
{
surfaceparm nodraw
surfaceparm nolightmap
surfaceparm nolightmap
surfaceparm nomarks
}
@ -62,7 +61,6 @@ textures/common/donotenter
surfaceparm donotenter
}
// never used
//
//textures/common/energypad
@ -78,14 +76,14 @@ textures/common/donotenter
// }
//}
textures/common/full_clip // silly shader, use weapclip instead
textures/common/full_clip // silly shader, use weapclip instead
{
qer_trans 0.40
surfaceparm nodraw
surfaceparm playerclip
}
textures/common/hint // should NOT use surfaceparm hint.. strange but true
textures/common/hint // should NOT use surfaceparm hint... strange but true
{
qer_nocarve
qer_trans 0.30
@ -97,15 +95,28 @@ textures/common/hint // should NOT use surfaceparm hint.. strange but true
surfaceparm hint // ydnar: yes it should.
}
textures/common/invisible // solid, transparent polygons, casts shadows
// Obsidian: Local hint works like normal hint but doesn't create portals beyond local structural brushes. Experimental, use with caution.
textures/common/hintlocal
{
surfaceparm nolightmap
{
map textures/common/invisible.tga
alphaFunc GE128
qer_nocarve
qer_trans 0.30
qer_editorImage textures/common/hintlocal.tga
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm structural
surfaceparm trans
surfaceparm noimpact
}
textures/common/invisible // solid, transparent polygons, casts shadows
{
surfaceparm nolightmap
{
map textures/common/invisible.tga
alphaFunc GE128
depthWrite
rgbGen vertex
}
}
}
textures/common/mirror1
@ -113,15 +124,11 @@ textures/common/mirror1
qer_editorimage textures/common/mirror1.tga
surfaceparm nolightmap
portal
{
map textures/common/mirror1.tga
blendfunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
depthWrite
}
}
textures/common/mirror2
@ -134,11 +141,10 @@ textures/common/mirror2
blendfunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
depthWrite
}
{
map textures/sfx/mirror.tga
blendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
}
{
map textures/sfx/mirror.tga
blendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
}
}
textures/common/missileclip
@ -180,7 +186,6 @@ textures/common/nodrop
surfaceparm nodrop
}
textures/common/noimpact
{
qer_editorimage textures/common/nolightmap.tga
@ -212,7 +217,6 @@ textures/common/portal
tcMod turb 0 0.25 0 0.05
blendfunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
depthWrite
}
}
@ -230,7 +234,7 @@ textures/common/terrain
{
q3map_terrain
surfaceparm nodraw
surfaceparm nolightmap
surfaceparm nolightmap
surfaceparm nomarks
}
@ -268,7 +272,7 @@ textures/common/weapclip
{
qer_trans 0.40
surfaceparm nodraw
surfaceparm nolightmap
surfaceparm nolightmap
surfaceparm trans
surfaceparm nomarks
}
@ -298,14 +302,12 @@ textures/common/botclip
surfaceparm botclip
}
//
// ydnar q3map lightgrid bounds
//
// the min/max bounds of brushes with this shader in a map
// will define the bounds of the map's lightgrid (model lighting)
// note: make it as small as possible around player space
// to minimize bsp size and compile time
//
textures/common/lightgrid
{
@ -319,3 +321,142 @@ textures/common/lightgrid
surfaceparm lightgrid
}
//******************************************************************************
// Obsidian 2007-08-24 (update 2010-12-03)
// Q3Map2 "common" shaders
//******************************************************************************
// ydnar: antiportal works like hint, but supresses portals
// add this to your common.shader file
textures/common/antiportal
{
qer_nocarve
qer_trans 0.30
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm structural
surfaceparm trans
surfaceparm noimpact
surfaceparm antiportal
}
// ydnar: skip works like quake 2 hint: it doesn't generate bsp splits
// use on sides of hint brushes where you don't want bsp splits or portals
// add this to your common.shader file
textures/common/skip
{
qer_nocarve
qer_trans 0.30
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm structural
surfaceparm trans
surfaceparm noimpact
surfaceparm skip
}
// Obsidian: same as skip but name changed to allow Radiant to filter both hint and skip
textures/common/hintskip
{
qer_nocarve
qer_trans 0.30
qer_editorImage textures/common/skip.tga
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm structural
surfaceparm trans
surfaceparm noimpact
surfaceparm skip
}
// Obsidian: 2 usages for watercaulk depending on water brush complexity
// SIMPLE WATER BRUSHES - use watercaulk on faces between water brushes
// COMPLEX WATER BRUSHES - overlap complex water brushes with watercaulk.
// Water shader should be nodraw, nonsolid, trans, *sans-water*
textures/common/watercaulk
{
qer_trans 0.5
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
surfaceparm water
}
textures/common/slimecaulk
{
qer_trans 0.5
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
surfaceparm slime
}
textures/common/lavacaulk
{
qer_trans 0.5
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
surfaceparm lava
}
// alpha fade shaders
// (c) 2004 randy reddig
// http://www.shaderlab.com
// distribution, in part or in whole, in any medium, permitted
textures/common/alpha_100
{
qer_trans 0.5
q3map_alphaMod volume
q3map_alphaMod scale 1.0
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
}
textures/common/alpha_75
{
qer_trans 0.5
q3map_alphaMod volume
q3map_alphaMod scale 0.75
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
}
textures/common/alpha_50
{
qer_trans 0.5
q3map_alphaMod volume
q3map_alphaMod scale 0.5
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
}
textures/common/alpha_25
{
qer_trans 0.5
q3map_alphaMod volume
q3map_alphaMod scale 0.25
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
}
textures/common/alpha_0
{
qer_trans 0.5
q3map_alphaMod volume
q3map_alphaMod scale 0
surfaceparm nodraw
surfaceparm nonsolid
surfaceparm trans
}

File diff suppressed because it is too large Load diff

View file

@ -849,6 +849,207 @@ gint dialog_url_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
return TRUE;
}
int WINAPI gtk_MessageBoxNew( void *parent, const char *message,
const char *caption, const guint32 flags,
const char *URL ) {
int loop = TRUE, ret = IDCANCEL;
// create dialog window
GtkWidget *dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
gtk_window_set_title( GTK_WINDOW( dlg ), caption );
gtk_window_set_policy( GTK_WINDOW( dlg ), FALSE, FALSE, TRUE );
gtk_container_border_width( GTK_CONTAINER( dlg ), 10 ); // TODO: magic number
g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
gtk_widget_realize( dlg );
if( parent ) {
gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) );
gtk_window_set_position( GTK_WINDOW( dlg ), GTK_WIN_POS_CENTER_ON_PARENT );
}
GtkAccelGroup *accel = gtk_accel_group_new();
gtk_window_add_accel_group( GTK_WINDOW( dlg ), accel );
// begin layout
GtkWidget *outer_vbox = gtk_vbox_new( FALSE, 10 ); // TODO: magic number
gtk_container_add( GTK_CONTAINER( dlg ), outer_vbox );
gtk_widget_show( outer_vbox );
// add icon
GtkWidget *dlg_icon;
//! @note kaz 05/09/2012 only support commonly used icons, fill out others as needed
switch( flags & MB_ICONMASK ) {
case MB_ICONHAND: {
dlg_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG );
break;
}
case MB_ICONQUESTION: {
dlg_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG );
break;
}
case MB_ICONEXCLAMATION: {
dlg_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG );
break;
}
case MB_ICONINFORMATION:
default: {
dlg_icon = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG );
break;
}
#if(WINVER >= 0x0400)
case MB_USERICON: {
//dlg_icon = gtk_image_new_from_stock( ?????, GTK_ICON_SIZE_DIALOG );
break;
}
#endif
}
GtkWidget *icon_text_hbox = gtk_hbox_new( FALSE, 10 ); // TODO: magic number
gtk_box_pack_start( GTK_BOX( outer_vbox ), icon_text_hbox, FALSE, FALSE, 2 ); // TODO: magic number
gtk_widget_show( icon_text_hbox );
gtk_box_pack_start( GTK_BOX( icon_text_hbox ), dlg_icon, FALSE, FALSE, 2 ); // TODO: magic number
gtk_widget_show( dlg_icon );
// add message
GtkWidget *dlg_msg = gtk_label_new( message );
gtk_box_pack_start( GTK_BOX( icon_text_hbox ), dlg_msg, FALSE, FALSE, 2 ); // TODO: magic number
gtk_label_set_justify( GTK_LABEL( dlg_msg ), GTK_JUSTIFY_LEFT );
gtk_widget_show( dlg_msg );
// add buttons
GtkWidget *hsep = gtk_hseparator_new();
gtk_box_pack_start( GTK_BOX( outer_vbox ), hsep, FALSE, FALSE, 2 ); // TODO: magic number
gtk_widget_show( hsep );
GtkWidget *buttons_hbox = gtk_hbox_new( FALSE, 10 ); // TODO: magic number
gtk_box_pack_start( GTK_BOX( outer_vbox ), buttons_hbox, FALSE, FALSE, 2 ); // TODO: magic number
gtk_widget_show( buttons_hbox );
//! @note kaz 05/09/2012 only support commonly used icons, fill out others as needed
switch( flags & MB_TYPEMASK ) {
case MB_OK:
default: {
GtkWidget *btn_ok = gtk_button_new_with_label( _( "Ok" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_ok, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_ok ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
gtk_widget_add_accelerator( btn_ok, "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
gtk_widget_add_accelerator( btn_ok, "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
GTK_WIDGET_SET_FLAGS( btn_ok, GTK_CAN_DEFAULT );
gtk_widget_grab_default( btn_ok );
gtk_widget_show( btn_ok );
ret = IDOK;
break;
}
case MB_OKCANCEL: {
GtkWidget *btn_ok = gtk_button_new_with_label( _( "Ok" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_ok, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_ok ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
gtk_widget_add_accelerator( btn_ok, "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
GTK_WIDGET_SET_FLAGS( btn_ok, GTK_CAN_DEFAULT );
gtk_widget_grab_default( btn_ok );
gtk_widget_show( btn_ok );
GtkWidget *btn_cancel = gtk_button_new_with_label( _( "Cancel" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_cancel, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_cancel ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
gtk_widget_add_accelerator( btn_cancel, "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
gtk_widget_show( btn_cancel );
ret = IDCANCEL;
break;
}
case MB_ABORTRETRYIGNORE: {
//! @todo fill out
break;
}
case MB_YESNOCANCEL: {
GtkWidget *btn_yes = gtk_button_new_with_label( _( "Yes" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_yes, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_yes ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
GTK_WIDGET_SET_FLAGS( btn_yes, GTK_CAN_DEFAULT );
gtk_widget_grab_default( btn_yes );
gtk_widget_show( btn_yes );
GtkWidget *btn_no = gtk_button_new_with_label( _( "No" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_no, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_no ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
gtk_widget_show( btn_no );
GtkWidget *btn_cancel = gtk_button_new_with_label( _( "Cancel" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_cancel, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_cancel ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
gtk_widget_show( btn_cancel );
ret = IDCANCEL;
break;
}
case MB_YESNO: {
GtkWidget *btn_yes = gtk_button_new_with_label( _( "Yes" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_yes, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_yes ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
GTK_WIDGET_SET_FLAGS( btn_yes, GTK_CAN_DEFAULT );
gtk_widget_grab_default( btn_yes );
gtk_widget_show( btn_yes );
GtkWidget *btn_no = gtk_button_new_with_label( _( "No" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_no, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_no ), "clicked",
GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
gtk_widget_show( btn_no );
ret = IDNO;
break;
}
case MB_RETRYCANCEL: {
//! @todo fill out
break;
}
#if(WINVER >= 0x0500)
case MB_CANCELTRYCONTINUE: {
//! @todo fill out
break;
}
#endif
}
// optionally add URL
if( URL ) {
GtkWidget *btn_url = gtk_button_new_with_label( _( "Go to URL" ) );
gtk_box_pack_start( GTK_BOX( buttons_hbox ), btn_url, TRUE, TRUE, 0 ); // TODO: magic number
gtk_signal_connect( GTK_OBJECT( btn_url ), "clicked",
GTK_SIGNAL_FUNC( dialog_url_callback ), NULL );
g_object_set_data( G_OBJECT( btn_url ), "URL", (void *)URL );
GTK_WIDGET_SET_FLAGS( btn_url, GTK_CAN_DEFAULT );
gtk_widget_grab_default( btn_url );
gtk_widget_show( btn_url );
}
// show it
gtk_widget_show( dlg );
gtk_grab_add( dlg );
while( loop )
gtk_main_iteration();
gtk_grab_remove( dlg );
gtk_widget_destroy( dlg );
return ret;
}
int WINAPI gtk_MessageBox( void *parent, const char* lpText, const char* lpCaption, guint32 uType, const char* URL ){
GtkWidget *window, *w, *vbox, *hbox;
GtkAccelGroup *accel;

View file

@ -76,6 +76,9 @@ GtkWidget* create_menu_in_menu_with_mnemonic( GtkWidget *menu, const gchar *mnem
do various message boxes, IDOK .. IDNO
URL adds an optional 'go to URL' button
*/
int WINAPI gtk_MessageBoxNew( void *parent, const char *message,
const char *caption = "Radiant", const guint32 flags = MB_OK,
const char *URL = NULL );
int WINAPI gtk_MessageBox( void *parent, const char* lpText, const char* lpCaption = "Radiant", guint32 uType = MB_OK, const char* URL = NULL );
// NOTE: the returned filename is allocated with g_malloc and MUST be freed with g_free (both for win32 and Gtk dialogs)
// GtkWidget *parent

View file

@ -1401,9 +1401,11 @@ qboolean ConfirmModified(){
return true;
}
if ( gtk_MessageBox( g_pParentWnd->m_pWidget, "This will lose changes to the map", "warning", MB_OKCANCEL ) == IDCANCEL ) {
if ( gtk_MessageBoxNew( g_pParentWnd->m_pWidget, "The current map has changed since it was last saved.\n"
"Would you like to save before continuing?", "Exit Radiant", MB_YESNOCANCEL | MB_ICONQUESTION ) == IDCANCEL ) {
return false;
}
return true;
}