/* Body of rbverse_verse_update after GVL is given up. */ static VALUE rbverse_verse_update_body( void *ptr ) { uint32 *microseconds = (uint32 *)ptr; DEBUGMSG( " calling verse_callback_update( %d ).", *microseconds ); verse_callback_update( *microseconds ); return Qtrue; }
int main(void) { /* Register callbacks for interesting commands. */ verse_callback_set(verse_send_connect_accept, callback_accept_connect, NULL); verse_callback_set(verse_send_node_create, callback_node_create, NULL); /* Kick off program by connecting to Verse host on local machine. */ verse_send_connect("list-nodes", "<secret>", "localhost", NULL); while(TRUE) verse_callback_update(10000); /* Listen to network, get callbacks. */ return EXIT_SUCCESS; /* This is never reached. */ }
void deceive_intro_handler(BInputState *input, void *application_handler_func) { static boolean active = FALSE, init = FALSE; static char connect_type_in[48]; if(init == FALSE) { d_init_master(); deceive_load_bookmarks(NULL); init = TRUE; } connect_type_in[0] = 0; if(e_vc_check_connected() && e_vc_check_accepted_slot(0)) { betray_set_action_func(application_handler_func, NULL); return; } if(input->mode == BAM_MAIN) { verse_callback_update(3000); return; } if(input->mode == BAM_DRAW) { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPopMatrix(); glPopMatrix(); glPushMatrix(); glClearColor(1, 1, 1, 1); glTranslatef(0, 0, -1); glDisable(GL_DEPTH_TEST); if(deceive_draw_func != NULL) deceive_draw_func(deceive_user_pointer); } if((input->mouse_button[0] == FALSE && input->last_mouse_button[0] == TRUE) || (input->mouse_button[1] == FALSE && input->last_mouse_button[1] == TRUE) || (input->mouse_button[2] == FALSE && input->last_mouse_button[2] == TRUE)) active = TRUE; /* if(active) { if(e_vc_check_connected_slot(0)) { if(input->mode == BAM_DRAW) sui_draw_text(sui_compute_text_length(0.02, 2, "CONNECTING...") * -0.5, -0.3, 0.02, 2, "CONNECTING...", 0, 0, 0); if(sw_text_button(input, sui_compute_text_length(SUI_T_SIZE, SUI_T_SPACE, "Cancel") * -0.5, -0.35, 0, SUI_T_SIZE, SUI_T_SPACE, "Cancel", co_line_color[0], co_line_color[1], co_line_color[2], color)) { e_vc_disconnect(0); } } else { static boolean text_init = FALSE; static boolean list = FALSE; static char address[64] = {0}, name[64] = {0}, pass[64] = {0}, hidden[64] = {0}; static float scroll = 0; float color = 0; if(list) color = 0.9; else scroll = 0; if(!text_init) { char *t; uint i; t = sui_get_setting_text("address", "localhost"); for(i = 0; i < 64 && t[i] != 0 ; i++) address[i] = t[i]; address[i] = 0; t = sui_get_setting_text("name", "name"); for(i = 0; i < 64 && t[i] != 0 ; i++) name[i] = t[i]; name[i] = 0; t = sui_get_setting_text("pass", "pass"); for(i = 0; i < 64 && t[i] != 0 ; i++) pass[i] = t[i]; pass[i] = 0; text_init = TRUE; } if(input->mouse_button[0] == TRUE && input->last_mouse_button[0] == FALSE) if(sui_box_click_test(-0.2, -0.2 - SUI_T_SIZE, 0.4, SUI_T_SIZE * 3.0)) list = TRUE; if(input->mouse_button[0] == FALSE && input->last_mouse_button[0] == FALSE) list = FALSE; if(input->mode == BAM_DRAW) sui_draw_text(sui_compute_text_length(0.02, 2, "CONNECT") * -0.5, 0.35, 0.02, 2, "CONNECT", color, color, color); if(sw_text_button(input, -0.2, 0.25 - 2 * 0.02, 0, 0.02, 0.3, "Localhost", color, color, color)) e_vc_connect("localhost", "anonymous", "nopass", NULL); if(sw_text_button(input, 0.2, 0.25 - 2 * 0.02, 1, 0.02, 0.3, "Exit", color, color, color)) exit(0); if(address[0] != 0) { for(i = 0; i < d_login_list_length; i++) { for(j = 0; d_login_list[i].address[j] == address[j] && d_login_list[i].address[j] != 0; j++); if(j > 0 && address[j] == 0) link = &d_login_list[i]; } } if(link != NULL) sui_draw_text(-0.2, -0.2, SUI_T_SIZE, SUI_T_SPACE, link->address, 0.8, 0.8, 0.8); sui_type_in(input, -0.2, -0.2, 0.4, SUI_T_SIZE, address, 64, NULL, NULL, color, color, color); sui_draw_2d_line_gl(-0.2, -0.2, 0.2, -0.2, color, color, color, 0); sui_type_in(input, -0.2, -0.25, 0.4, SUI_T_SIZE, name, 64, NULL, NULL, color, color, color); sui_draw_2d_line_gl(-0.2, -0.25, 0.2, -0.25, color, color, color, 0); hidden_type_in(input, -0.2, -0.3, 0.4, SUI_T_SIZE, pass, 64, color, color, color); sui_draw_2d_line_gl(-0.2, -0.3, 0.2, -0.3, color, color, color, 0); if(sw_text_button(input, -0.2, -0.325 - 2 * 0.02, 0, 0.02, 0.3, "OK", color, color, color)) { e_vc_connect(address, name, pass, NULL); deceive_save_bookmarks(NULL); } if(sw_text_button(input, 0.2, -0.325 - 2 * 0.02, 1, 0.02, 0.3, "Clear", color, color, color)) { address[0] = 0; name[0] = 0; pass[0] = 0; } if(list == TRUE) { if(input->pointer_y > 0.45) scroll -= 0.4 * betray_get_delta_time(); if(input->pointer_y < -0.45) scroll += 0.4 * betray_get_delta_time(); if(scroll < 0) scroll = 0; if(scroll > d_login_list_length * 0.05 - 0.05) scroll = d_login_list_length * 0.05 - 0.05; if(input->mode == BAM_DRAW) { for(i = 0; i < d_login_list_length; i++) { sui_draw_text(-0.2, scroll - 0.2 + (float)i * -0.05, SUI_T_SIZE, SUI_T_SPACE, d_login_list[i].address, 0, 0, 0); deceive_draw_symb_close(0.2, scroll - 0.19 + (float)i * -0.05); } }else if(input->mouse_button[0] == FALSE && input->last_mouse_button[0] == TRUE) { i = -(input->pointer_y + 0.175 - scroll) / 0.05; if(i < d_login_list_length) { if(input->pointer_x > 0.19 && input->pointer_x < 0.21) d_login_list[i] = d_login_list[--d_login_list_length]; else { for(j = 0; j < 47; j++) address[j] = d_login_list[i].address[j]; for(j = 0; j < 47; j++) name[j] = d_login_list[i].name[j]; for(j = 0; j < 47; j++) pass[j] = d_login_list[i].pass[j]; } } } } } }*/ if(input->mode == BAM_DRAW) { float border[16] = {-1, 10, 1, 10, 1, 0.45, -1, 0.45, -1, -10, 1, -10, 1, -0.45, -1, -0.45}; sui_draw_gl(GL_QUADS, border, 8, 2, 0, 0, 0, 1); } if(active) d_draw_login(input); if(input->mode == BAM_DRAW) { glEnable(GL_DEPTH_TEST); glPopMatrix(); glPushMatrix(); glPushMatrix(); } }