static int display_accept_buddy(char *name) { window_info *win = NULL; int label_id = 101, yes_button = 102, no_button = 103; char string[250] = {0}; int current_window; for(current_window = 0; current_window < MAX_ACCEPT_BUDDY_WINDOWS; current_window++) { /* Find a free slot in the array */ if(accept_windows[current_window].window_id == -1) { break; } } if (current_window >= MAX_ACCEPT_BUDDY_WINDOWS) { // uh oh, no free window return -1; } safe_snprintf(accept_windows[current_window].name, sizeof (accept_windows[current_window].name), "%s", name); accept_windows[current_window].window_id = create_window(buddy_accept_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, (ELW_USE_UISCALE|ELW_WIN_DEFAULT) ^ ELW_CLOSE_BOX); set_window_handler(accept_windows[current_window].window_id, ELW_HANDLER_DISPLAY, &display_accept_buddy_handler); set_window_handler(accept_windows[current_window].window_id, ELW_HANDLER_UI_SCALE, &ui_scale_accept_handler ); if (accept_windows[current_window].window_id <=0 || accept_windows[current_window].window_id >= windows_list.num_windows) return -1; win = &windows_list.window[accept_windows[current_window].window_id]; /* Add text */ safe_snprintf(string, sizeof(string), buddy_wants_to_add_str, accept_windows[current_window].name); accept_windows[current_window].text = malloc((strlen(string)+5)*sizeof(*accept_windows[current_window].text)); /* Add checkbox if we don't have him/her in our list. */ if(!is_in_buddylist(accept_windows[current_window].name)) { accept_windows[current_window].checkbox = checkbox_add(win->window_id, NULL, 0, 0, win->small_font_len_y, win->small_font_len_y, NULL); label_id = label_add_extended(win->window_id, label_id, NULL, 0, 0, 0, win->current_scale * DEFAULT_SMALL_RATIO, -1, -1, -1, buddy_add_to_list_str); widget_set_OnClick(win->window_id, label_id, click_accept_checkbox_label); } /* Add buttons */ yes_button = button_add_extended(win->window_id, yes_button, NULL, 0, 0, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, yes_str); no_button = button_add_extended(win->window_id, no_button, NULL, 0, 0, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, no_str); widget_set_OnClick(win->window_id, yes_button, click_accept_yes); widget_set_OnClick(win->window_id, no_button, click_accept_no); ui_scale_accept_handler(win); return win->window_id; }
static __inline__ void draw_actor_points(float zoom_multip, float px, float py) { float size_x = float_minimap_size / (tile_map_size_x * 6); float size_y = float_minimap_size / (tile_map_size_y * 6); actor *a; int i; float x, y; glPushMatrix(); glDisable(GL_TEXTURE_2D); //display the actors glEnable( GL_POINT_SMOOTH ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glPointSize(8); rotate_actor_points(zoom_multip,px,py); glBegin(GL_POINTS); for (i = 0; i < max_actors; i++) { if (actors_list[i]) { a = actors_list[i]; if (a->attached_actor != -1 && a->actor_id == -1) continue; x = a->x_tile_pos * size_x; y = float_minimap_size - (a->y_tile_pos * size_y); glColor3f(0.0f,0.0f,0.0f); glVertex2f(x+2*zoom_multip, y+2*zoom_multip); if (a->kind_of_actor == NPC) elglColourN("minimap.npc"); else if(a->actor_id == yourself) elglColourN("minimap.yourself"); else if(a->is_enhanced_model && (a->kind_of_actor == PKABLE_HUMAN || a->kind_of_actor == PKABLE_COMPUTER_CONTROLLED)) elglColourN("minimap.pkable"); else if(a->is_enhanced_model && is_in_buddylist(a->actor_name)) elglColourN("minimap.buddy"); else if (is_color ((unsigned char)a->actor_name[0])) { if(a->is_enhanced_model && is_in_buddylist(a->actor_name)) elglColourN("minimap.buddy"); else { // Use the colour of their name. This gives purple bots, green demigods, etc. int color = from_color_char (a->actor_name[0]); glColor3ub (colors_list[color].r1, colors_list[color].g1, colors_list[color].b1); } } else if(!a->is_enhanced_model) { if (a->dead) elglColourN("minimap.deadcreature"); else // alive elglColourN("minimap.creature"); } else elglColourN("minimap.otherplayer"); // Draw it! glVertex2f(x, y); } } // mines for (i = 0; i < NUM_MINES; i++) { mine *m = &mine_list[i]; if (m->obj_3d_id != -1) { x = m->x * size_x; y = float_minimap_size - (m->y * size_y); if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { elglColourN("minimap.mine"); glVertex2f(x, y); } } } glEnd();//GL_POINTS glDisable(GL_BLEND); glDisable(GL_POINT_SMOOTH); glPopMatrix(); if (pf_follow_path) { x = pf_dst_tile->x * size_x; y = float_minimap_size - (pf_dst_tile->y * size_y); if (x != px || y != py) { float diff = 6.0f*zoom_multip; if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { glPushMatrix(); glDisable(GL_TEXTURE_2D); rotate_actor_points(zoom_multip,px,py); glBegin(GL_LINES); glColor3f(1.0f,0.0f,1.0f); //purple glVertex2f(x-diff, y-diff); glVertex2f(x+diff, y+diff); glVertex2f(x-diff, y+diff); glVertex2f(x+diff, y-diff); glEnd();//GL_LINES glPopMatrix(); } } } //draw map markings for(i=0;i<max_mark;i++){ if(!marks[i].server_side) continue; x= marks[i].x*size_x; y= float_minimap_size-(marks[i].y*size_y); if (x != px || y != py) { float diff = 4.0f*zoom_multip; if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { glPushMatrix(); glDisable(GL_TEXTURE_2D); rotate_actor_points(zoom_multip,px,py); glBegin(GL_LINES); elglColourN("minimap.servermark"); glVertex2f(x-diff, y-diff); glVertex2f(x+diff, y+diff); glVertex2f(x-diff, y+diff); glVertex2f(x+diff, y-diff); glEnd();//GL_LINES glPopMatrix(); } } } glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_TEXTURE_2D); }