/*! Sets the active state of the button. If active == False then the button's visible state is set to False. \return None \author jfpatry \date Created: 2000-09-18 \date Modified: 2000-09-18 */ void button_set_active( button_t *button, bool_t active ) { check_assertion( button != NULL, "button is NULL" ); if ( !button->active && active ) { ui_add_mouse_motion_callback( button, button_mouse_motion_cb ); ui_add_mouse_down_callback( button, button_mouse_down_cb ); ui_add_mouse_up_callback( button, button_mouse_up_cb ); ui_set_dirty(); } else if ( button->active && !active ) { ui_delete_mouse_motion_callback( button ); ui_delete_mouse_down_callback( button ); ui_delete_mouse_up_callback( button ); ui_set_dirty(); } button->active = active; if ( !active ) { button_set_visible( button, False ); } }
/*! Callback invoked when mouse up event is received. \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ static void button_mouse_up_cb( void *widget, winsys_mouse_button_t which_button, int x, int y ) { button_t *button = (button_t*) widget; check_assertion( button != NULL, "button is NULL" ); if ( which_button != WS_LEFT_BUTTON ) { return; } if ( ! button->enabled ) { return; } if ( !in_bbox( button, x, y ) ) { if ( button->clicked ) { print_debug( DEBUG_UI, "Button is up (not clicked)" ); button->clicked = False; ui_set_dirty(); } return; } if ( button->clicked ) { button->clicked = False; print_debug( DEBUG_UI, "Button was clicked" ); button_perform_click_action( button ); ui_set_dirty(); } }
static void save_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); cur_sound = listbox_get_current_item( sound_listbox ); int snd = *((int*) get_list_elem_data( cur_sound )); cur_video = listbox_get_current_item( video_listbox ); int vid = *((int*) get_list_elem_data( cur_video )); setparam_sound_enabled(snd); if (getparam_music_enabled() == 1 && snd == 0) stopMusic(); setparam_music_enabled (snd); saveparamSoundEnabled(snd); setparam_video_quality (vid); set_video_quality(vid); saveparamVideoQuality(vid); set_game_mode( GAME_TYPE_SELECT ); ui_set_dirty(); }
/*! Callback called when one of the arrow buttons is pressed \return None \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ static void listbox_arrow_click_cb( button_t *button, void* userdata ) { listbox_t *listbox = (listbox_t*)userdata; check_assertion( listbox != NULL, "listbox is NULL" ); if ( button == listbox->up_button ) { listbox->cur_item = get_prev_list_elem( listbox->item_list, listbox->cur_item ); } else if ( button == listbox->down_button ) { listbox->cur_item = get_next_list_elem( listbox->item_list, listbox->cur_item ); } else { check_assertion( 0, "listbox arrow click callback called with " "unknown button" ); } if ( listbox->item_change_cb != NULL ) { listbox->item_change_cb( listbox, listbox->item_change_cb_userdata ); } update_button_enabled_states( listbox ); ui_set_dirty(); }
/*! Callback invoked when mouse down event is received. \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ static void button_mouse_down_cb( void *widget, winsys_mouse_button_t which_button, int x, int y ) { button_t *button = (button_t*) widget; check_assertion( button != NULL, "button is NULL" ); if ( which_button != WS_LEFT_BUTTON ) { return; } if ( !in_bbox( button, x, y ) ) { return; } if ( ! button->enabled ) { return; } if ( button->clicked == False ) { print_debug( DEBUG_UI, "Button is down" ); button->clicked = True; ui_set_dirty(); } }
/*! Highlight button \author ehall \date Created: 2000-09-30 \date Modified: 2000-09-30 */ void button_set_highlight( button_t *button, bool_t highlight ) { check_assertion( button != NULL, "button is NULL" ); if (!(button->focused == highlight)) { ui_set_dirty(); } button->focused = highlight; }
void help_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); set_game_mode( HELP ); ui_set_dirty(); }
void preference_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); set_game_mode( PREFERENCE ); ui_set_dirty(); }
void credits_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); set_game_mode( CREDITS ); ui_set_dirty(); }
static void chancel_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); set_game_mode( GAME_TYPE_SELECT ); ui_set_dirty(); }
/*! Callback called when race listbox item changes \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ static void race_listbox_item_change_cb( listbox_t *listbox, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); cur_elem = listbox_get_current_item( listbox ); if ( g_game.practicing ) { open_course_data_t *data; data = (open_course_data_t*) get_list_elem_data( cur_elem ); textarea_set_text( desc_ta, data->description ); ui_set_dirty(); } else { race_data_t *data; data = (race_data_t*) get_list_elem_data( cur_elem ); textarea_set_text( desc_ta, data->description ); if ( cup_complete && conditions_ssbtn && wind_ssbtn && snow_ssbtn && mirror_ssbtn ) { ssbutton_set_state( conditions_ssbtn, (int) data->conditions ); ssbutton_set_state( wind_ssbtn, (int) data->windy ); ssbutton_set_state( snow_ssbtn, (int) data->snowing ); ssbutton_set_state( mirror_ssbtn, (int) data->mirrored ); } update_button_enabled_states(); ui_set_dirty(); } update_race_data(); }
/*! Sets the visibility of the listbox. Also sets the active state to the value of \c visible. \return None \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ void listbox_set_visible( listbox_t *listbox, bool_t visible ) { check_assertion( listbox != NULL, "listbox is NULL" ); /* This check is necessary to prevent infinite mutual recursion */ if ( listbox->active != visible ) { listbox_set_active( listbox, visible ); } if ( !listbox->visible && visible ) { ui_add_widget_draw_callback( listbox, listbox_draw_cb ); ui_set_dirty(); } else if ( listbox->visible && !visible ) { ui_delete_widget_draw_callback( listbox ); ui_set_dirty(); } listbox->visible = visible; }
/*! Callback called when back button is clicked \author jfpatry \date Created: 2000-09-24 \date Modified: 2000-09-24 */ static void back_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); if ( g_game.practicing ) { set_game_mode( GAME_TYPE_SELECT ); } else { set_game_mode( EVENT_SELECT ); } ui_set_dirty(); }
/*! Sets the visibility of the specified button. Also sets the active state of the button to match the visible state. \return None \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ void button_set_visible( button_t *button, bool_t visible ) { check_assertion( button != NULL, "button is NULL" ); /* This check is necessary to prevent infinite mutual recursion */ if ( button->active != visible ) { button_set_active( button, visible ); } if ( !button->visible && visible ) { ui_add_widget_draw_callback( button, button_draw_cb ); ui_set_dirty(); } else if ( button->visible && !visible ) { ui_delete_widget_draw_callback( button ); ui_set_dirty(); } button->visible = visible; }
void enter_event_click_cb( button_t* button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); g_game.current_event = NULL; g_game.current_cup = NULL; g_game.current_race = -1; g_game.practicing = False; set_game_mode( EVENT_SELECT ); ui_set_dirty(); }
/*! Sets the item list for the listbox \author jfpatry \date Created: 2000-09-23 \date Modified: 2000-09-23 */ void listbox_set_item_list( listbox_t *listbox, list_t item_list, listbox_list_elem_to_string_fptr_t func ) { check_assertion( listbox != NULL, "listbox is NULL" ); listbox->item_list = item_list; listbox->cur_item = get_list_head(item_list); listbox->label_gen_func = func; update_button_enabled_states( listbox ); ui_set_dirty(); }
/*! Callback invoked when mouse motion event is received. \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ static void button_mouse_motion_cb( void *widget, int x, int y ) { button_t *button = (button_t*) widget; check_assertion( button != NULL, "button is NULL" ); if ( ! button->enabled ) { return; } if ( in_bbox( button, x, y ) ) { if ( button->focused == False ) { print_debug( DEBUG_UI, "Mouse entered button" ); button->focused = True; ui_set_dirty(); } } else { if ( button->focused == True ) { print_debug( DEBUG_UI, "Mouse left button" ); button->focused = False; ui_set_dirty(); } } }
//wich is in this version the "world challenge click callback void practice_click_cb( button_t *button, void *userdata ) { check_assertion( userdata == NULL, "userdata is not null" ); g_game.current_event = NULL; g_game.current_cup = NULL; g_game.current_race = -1; g_game.practicing = True; #ifdef __APPLE__ //usefull for score saving g_game.race.name=NULL; #endif set_game_mode( RACE_SELECT ); ui_set_dirty(); }
/*! Sets the enabled state of the button \return None \author jfpatry \date Created: 2000-09-17 \date Modified: 2000-09-17 */ void button_set_enabled( button_t *button, bool_t enabled ) { check_assertion( button != NULL, "button is NULL" ); if ( button->enabled != enabled ) { ui_set_dirty(); } button->enabled = enabled; if ( !enabled ) { button->clicked = False; button->focused = False; } }
static void back() { if ( g_game.practicing ) { #ifdef SPEED_MODE set_game_mode( RACING_MODE_SELECT ); #else set_game_mode( GAME_TYPE_SELECT ); #endif } else { set_game_mode( GAME_TYPE_SELECT ); } winsys_reset_js_bindings(); ui_set_dirty(); }
static void continue_click_cb( button_t *button, void *userdata ) { cup_data_t *cup_data; player_data_t *plyr = get_player_data( local_player() ); check_assertion( userdata == NULL, "userdata is not null" ); cur_event = listbox_get_current_item( event_listbox ); event_data = (event_data_t*) get_list_elem_data( cur_event ); cur_cup = listbox_get_current_item( cup_listbox ); cup_data = (cup_data_t*) get_list_elem_data( cur_cup ); g_game.current_event = get_event_name( event_data ); g_game.current_cup = get_cup_name( cup_data ); plyr->lives = INIT_NUM_LIVES; set_game_mode( RACE_SELECT ); ui_set_dirty(); }
static void event_listbox_item_change_cb( listbox_t *listbox, void *userdata ) { list_elem_t cur_event; list_t cup_list; check_assertion( userdata == NULL, "userdata is not null" ); cur_event = listbox_get_current_item( listbox ); event_data = (event_data_t*) get_list_elem_data( cur_event ); cup_list = get_event_cup_list( event_data ); listbox_set_item_list( cup_listbox, cup_list, cup_list_elem_to_string_func ); set_cur_cup_to_first_incomplete( event_data, cup_list ); listbox_set_current_item( cup_listbox, cur_cup ); update_button_enabled_states(); ui_set_dirty(); }
/*! callback for mouse motion events \return None \author jfpatry \date Created: 2000-09-16 \date Modified: 2000-09-16 */ void ui_event_motion_func( int x, int y ) { point2d_t old_pos; if ( is_mode_change_pending() ) { /* Don't process events until mode change occurs */ return; } /* Reverse y coordinate */ y = getparam_y_resolution() - y; trigger_mouse_motion_cbs( mouse_motion_cbs, x, y ); old_pos = cursor_pos; cursor_pos = make_point2d( x, y ); if ( old_pos.x != x || old_pos.y != y ) { /* Update UI snow */ if ( getparam_ui_snow() ) { if ( right_mouse_button_down ) { make_ui_snow( cursor_pos ); reset_ui_snow_cursor_pos( cursor_pos ); } else if ( middle_mouse_button_down ) { make_ui_snow( cursor_pos ); push_ui_snow( cursor_pos ); } else { push_ui_snow( cursor_pos ); } } /* Need to redraw cursor */ ui_set_dirty(); ui_check_dirty(); } }