Add type checking for ui_create_dialog
This commit is contained in:
parent
77c0b58591
commit
be041a9cfc
|
@ -239,7 +239,25 @@ typedef cstring_tie<10> ui_messagebox_tie;
|
|||
int ui_messagebox( short xc, short yc, const char * text, const ui_messagebox_tie &Button );
|
||||
#define ui_messagebox(X,Y,N,T,...) ((ui_messagebox)((X),(Y),(T), ui_messagebox_tie(__VA_ARGS__)))
|
||||
|
||||
extern UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, int (*callback)(UI_DIALOG *, struct d_event *, void *), void *userdata );
|
||||
template <typename T>
|
||||
class ui_subfunction_t
|
||||
{
|
||||
public:
|
||||
typedef int (*type)(UI_DIALOG *, d_event *, T *);
|
||||
};
|
||||
|
||||
class unused_ui_userdata_t;
|
||||
static unused_ui_userdata_t *const unused_ui_userdata = NULL;
|
||||
|
||||
template <typename T>
|
||||
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, typename ui_subfunction_t<T>::type callback, T *userdata )
|
||||
{
|
||||
return ui_create_dialog(x, y, w, h, flags, (ui_subfunction_t<void>::type) callback, (void *)userdata);
|
||||
}
|
||||
|
||||
template <>
|
||||
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, typename ui_subfunction_t<void>::type callback, void *userdata );
|
||||
|
||||
extern struct window *ui_dialog_get_window(UI_DIALOG *dlg);
|
||||
extern void ui_dialog_set_current_canvas(UI_DIALOG *dlg);
|
||||
extern void ui_close_dialog( UI_DIALOG * dlg );
|
||||
|
|
|
@ -220,7 +220,8 @@ static int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
|
|||
return rval;
|
||||
}
|
||||
|
||||
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, int (*callback)(UI_DIALOG *, d_event *, void *), void *userdata )
|
||||
template <>
|
||||
UI_DIALOG * ui_create_dialog( short x, short y, short w, short h, enum dialog_flags flags, ui_subfunction_t<void>::type callback, void *userdata )
|
||||
{
|
||||
UI_DIALOG *dlg;
|
||||
int sw, sh, req_w, req_h;
|
||||
|
|
|
@ -306,7 +306,7 @@ int ui_get_filename( char * filename, const char * filespec, const char * messag
|
|||
b->spaces[i] = ' ';
|
||||
b->spaces[34] = 0;
|
||||
|
||||
dlg = ui_create_dialog( 200, 100, 400, 370, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), (int (*)(UI_DIALOG *, d_event *, void *))browser_handler, b );
|
||||
dlg = ui_create_dialog( 200, 100, 400, 370, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), browser_handler, b );
|
||||
|
||||
b->user_file = ui_add_gadget_inputbox( dlg, 60, 30, PATH_MAX, 40, InputText );
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ int MenuX( int x, int y, int NumButtons, const char *const text[] )
|
|||
y = h - height;
|
||||
}
|
||||
|
||||
dlg = ui_create_dialog( x, y, width, height, static_cast<dialog_flags>(DF_FILLED | DF_SAVE_BG | DF_MODAL), (int (*)(UI_DIALOG *, d_event *, void *))menu_handler, m );
|
||||
dlg = ui_create_dialog( x, y, width, height, static_cast<dialog_flags>(DF_FILLED | DF_SAVE_BG | DF_MODAL), menu_handler, m );
|
||||
|
||||
x = MENU_BORDER+3;
|
||||
y = MENU_BORDER+3;
|
||||
|
|
|
@ -173,7 +173,7 @@ int (ui_messagebox)( short xc, short yc, const char * text, const ui_messagebox_
|
|||
y = h - height;
|
||||
}
|
||||
|
||||
dlg = ui_create_dialog( x, y, width, height, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), (int (*)(UI_DIALOG *, d_event *, void *))messagebox_handler, m );
|
||||
dlg = ui_create_dialog( x, y, width, height, static_cast<dialog_flags>(DF_DIALOG | DF_MODAL), messagebox_handler, m );
|
||||
|
||||
//ui_draw_line_in( MESSAGEBOX_BORDER, MESSAGEBOX_BORDER, width-MESSAGEBOX_BORDER, height-MESSAGEBOX_BORDER );
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ int do_hostage_dialog()
|
|||
SelectClosestHostage();
|
||||
|
||||
// Open a window with a quit button
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+10, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))hostage_dialog_handler, h );
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+10, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, hostage_dialog_handler, h );
|
||||
h->quitButton = ui_add_gadget_button( MainWindow, 20, 222, 48, 40, "Done", NULL );
|
||||
|
||||
h->hostageText = ui_add_gadget_inputbox( MainWindow, 10, 50, HOSTAGE_MESSAGE_LEN, HOSTAGE_MESSAGE_LEN, HostageMessage );
|
||||
|
|
|
@ -86,10 +86,10 @@ int do_centers_dialog()
|
|||
|
||||
// Open a window with a quit button
|
||||
#if defined(DXX_BUILD_DESCENT_I)
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))centers_dialog_handler, c );
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, centers_dialog_handler, c );
|
||||
i = 80;
|
||||
#elif defined(DXX_BUILD_DESCENT_II)
|
||||
MainWindow = ui_create_dialog( 20, TMAPBOX_Y+20, 740, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))centers_dialog_handler, c );
|
||||
MainWindow = ui_create_dialog( 20, TMAPBOX_Y+20, 740, 545-TMAPBOX_Y, DF_DIALOG, centers_dialog_handler, c );
|
||||
i = 40;
|
||||
#endif
|
||||
c->quitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );
|
||||
|
|
|
@ -312,7 +312,7 @@ int do_trigger_dialog()
|
|||
hostage_close_window();
|
||||
|
||||
// Open a window with a quit button
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))trigger_dialog_handler, t );
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, trigger_dialog_handler, t );
|
||||
|
||||
// These are the checkboxes for each door flag.
|
||||
i = 44;
|
||||
|
|
|
@ -305,7 +305,7 @@ static int padnum=0;
|
|||
|
||||
static void init_editor_screen();
|
||||
static void gamestate_restore_check();
|
||||
static int editor_handler(UI_DIALOG *dlg, d_event *event, void *data);
|
||||
static int editor_handler(UI_DIALOG *dlg, d_event *event, unused_ui_userdata_t *data);
|
||||
|
||||
void init_editor()
|
||||
{
|
||||
|
@ -745,7 +745,7 @@ void init_editor_screen()
|
|||
gr_set_curfont(editor_font);
|
||||
gr_set_fontcolor( CBLACK, CWHITE );
|
||||
|
||||
EditorWindow = ui_create_dialog( 0 , 0, ED_SCREEN_W, ED_SCREEN_H, DF_FILLED, editor_handler, NULL );
|
||||
EditorWindow = ui_create_dialog( 0 , 0, ED_SCREEN_W, ED_SCREEN_H, DF_FILLED, editor_handler, unused_ui_userdata );
|
||||
|
||||
LargeViewBox = ui_add_gadget_userbox( EditorWindow,LVIEW_X,LVIEW_Y,LVIEW_W,LVIEW_H);
|
||||
#if ORTHO_VIEWS
|
||||
|
@ -1002,7 +1002,7 @@ int RestoreGameState() {
|
|||
}
|
||||
|
||||
// Handler for the main editor dialog
|
||||
int editor_handler(UI_DIALOG *dlg, d_event *event, void *data)
|
||||
int editor_handler(UI_DIALOG *dlg, d_event *event, unused_ui_userdata_t *)
|
||||
{
|
||||
editor_view *new_cv;
|
||||
int keypress = 0;
|
||||
|
|
|
@ -469,7 +469,7 @@ int do_robot_dialog()
|
|||
memset(&r->goody_angles, 0, sizeof(vms_angvec));
|
||||
|
||||
// Open a window with a quit button
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))robot_dialog_handler, r );
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, robot_dialog_handler, r );
|
||||
r->quitButton = ui_add_gadget_button( MainWindow, 20, 286, 40, 32, "Done", NULL );
|
||||
|
||||
ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType );
|
||||
|
@ -758,7 +758,7 @@ int do_object_dialog()
|
|||
Cur_goody_count = 0;
|
||||
|
||||
// Open a window with a quit button
|
||||
MattWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))object_dialog_handler, o );
|
||||
MattWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, object_dialog_handler, o );
|
||||
o->quitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );
|
||||
|
||||
o->quitButton->hotkey = KEY_ENTER;
|
||||
|
|
|
@ -366,7 +366,7 @@ int do_wall_dialog()
|
|||
close_all_windows();
|
||||
|
||||
// Open a window with a quit button
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))wall_dialog_handler, wd );
|
||||
MainWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, wall_dialog_handler, wd );
|
||||
wd->quitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );
|
||||
|
||||
// These are the checkboxes for each door flag.
|
||||
|
|
Loading…
Reference in a new issue