summaryrefslogtreecommitdiff
path: root/source/ui_confirm.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/ui_confirm.c')
-rw-r--r--source/ui_confirm.c123
1 files changed, 52 insertions, 71 deletions
diff --git a/source/ui_confirm.c b/source/ui_confirm.c
index 7df4e55..68078ab 100644
--- a/source/ui_confirm.c
+++ b/source/ui_confirm.c
@@ -29,62 +29,46 @@ CONFIRM MENU
=======================================================================
*/
-typedef struct m_confirmMenu_s {
+typedef struct {
menuFrameWork_t menu;
menuStatic_t text;
-
- void (*action)( qboolean yes );
-} m_confirmMenu_t;
-
-static m_confirmMenu_t m_confirm;
-
-static int ConfirmMenu_Callback( int id, int msg, int param ) {
- switch( msg ) {
- case QM_KEY:
- switch( param ) {
- case 'Y':
- case 'y':
- //UI_PopMenu();
- m_confirm.action( qtrue );
- return QMS_IN;
- case 'N':
- case 'n':
- UI_PopMenu();
- m_confirm.action( qfalse );
- return QMS_OUT;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- return QMS_NOTHANDLED;
+ confirmAction_t action;
+} confirmMenu_t;
+
+static confirmMenu_t m_confirm;
+
+static menuSound_t ConfirmKeydown( menuFrameWork_t *self, int key ) {
+ switch( key ) {
+ case 'Y':
+ case 'y':
+ m_confirm.action( qtrue );
+ // UI_PopMenu();
+ return QMS_IN;
+ case 'N':
+ case 'n':
+ m_confirm.action( qfalse );
+ UI_PopMenu();
+ return QMS_OUT;
+ default:
+ return QMS_NOTHANDLED;
+ }
}
-static void ConfirmMenu_Init( const char *text, void (*action)( qboolean yes ) ) {
+void M_Menu_Confirm( const char *text, confirmAction_t action ) {
memset( &m_confirm, 0, sizeof( m_confirm ) );
- m_confirm.menu.callback = ConfirmMenu_Callback;
- m_confirm.action = action;
+ m_confirm.menu.keydown = ConfirmKeydown;
m_confirm.text.generic.type = MTYPE_STATIC;
- m_confirm.text.generic.name = text;
- m_confirm.text.generic.x = uis.width / 2;
- m_confirm.text.generic.y = uis.height / 2;
+ m_confirm.text.generic.name = ( char * )text;
m_confirm.text.generic.uiFlags = UI_CENTER;
-
- Menu_AddItem( &m_confirm.menu, ( void * )&m_confirm.text );
-}
+ m_confirm.action = action;
+
+ Menu_AddItem( &m_confirm.menu, &m_confirm.text );
-void M_Menu_Confirm_f( const char *text, void (*action)( qboolean yes ) ) {
- if( !text || !action ) {
- Com_Error( ERR_FATAL, "M_Menu_Confirm_f: bad params" );
- }
- ConfirmMenu_Init( text, action );
UI_PushMenu( &m_confirm.menu );
+
}
/*
@@ -102,43 +86,40 @@ typedef struct m_errorMenu_s {
static m_errorMenu_t m_error;
-static int ErrorMenu_Callback( int id, int msg, int param ) {
- if( msg == QM_KEY ) {
- UI_PopMenu();
- return QMS_OUT;
- }
-
- return QMS_NOTHANDLED;
+static menuSound_t ErrorKeydown( menuFrameWork_t *self, int key ) {
+ UI_PopMenu();
+ return QMS_OUT;
}
-static void ErrorMenu_Init( comErrorType_t type, const char *text ) {
+void M_Menu_Error( comErrorType_t type, const char *text ) {
+ color_t color;
+
+ if( !text ) {
+ return;
+ }
+ switch( type ) {
+ case ERR_SILENT:
+ return;
+ case ERR_DROP:
+ *( uint32_t * )color = *( uint32_t * )colorRed;
+ break;
+ default:
+ *( uint32_t * )color = *( uint32_t * )colorYellow;
+ break;
+ }
+
memset( &m_error, 0, sizeof( m_error ) );
- m_error.menu.callback = ErrorMenu_Callback;
+ m_error.menu.keydown = ErrorKeydown;
m_error.text.generic.type = MTYPE_STATIC;
m_error.text.generic.flags = QMF_CUSTOM_COLOR;
- m_error.text.generic.name = text;
- m_error.text.generic.x = uis.width / 2;
- m_error.text.generic.y = uis.height / 2;
+ m_error.text.generic.name = ( char * )text;
m_error.text.generic.uiFlags = UI_CENTER|UI_MULTILINE;
- if( type == ERR_DROP ) {
- *( uint32_t * )m_error.text.generic.color = *( uint32_t * )colorRed;
- } else {
- *( uint32_t * )m_error.text.generic.color = *( uint32_t * )colorYellow;
- }
+ *( uint32_t * )m_error.text.generic.color = *( uint32_t * )color;
Menu_AddItem( &m_error.menu, ( void * )&m_error.text );
-}
-
-void M_Menu_Error_f( comErrorType_t type, const char *text ) {
- if( type == ERR_SILENT ) {
- return;
- }
- if( !text ) {
- return;
- }
- ErrorMenu_Init( type, text );
UI_PushMenu( &m_error.menu );
}
+