int display_session_handler(window_info *win) { int i, x, y, timediff; char buffer[128]; x = 10; y = 21; timediff = 0; glColor3f(1.0f, 1.0f, 1.0f); safe_snprintf(buffer, sizeof(buffer), "%-20s%-17s%-17s%-17s", "Skill", "Total Exp", "Max Exp", "Last Exp" ); draw_string_small(x, y, (unsigned char*)buffer, 1); glDisable(GL_TEXTURE_2D); glColor3f(newcol_r, newcol_g, newcol_b); glBegin(GL_LINES); glVertex3i(0, 37, 0); glVertex3i(win->len_x, 37, 0); glEnd(); glEnable(GL_TEXTURE_2D); glColor3f(1.0f, 1.0f, 1.0f); y = 55; for (i=0; i<NUM_SKILLS; i++) { if ((last_mouse_click_y >= y) && (last_mouse_click_y < y+16)) elglColourN("global.mouseselected"); else if ((last_mouse_over_y >= y) && (last_mouse_over_y < y+16)) elglColourN("global.mousehighlight"); else glColor3f(1.0f, 1.0f, 1.0f); safe_snprintf(buffer, sizeof(buffer), "%-20s%-17u%-17u%-17u", statsinfo[i].skillnames->name, *(statsinfo[i].exp) - session_exp[i], max_exp[i], last_exp[i]); draw_string_small(x, y, (unsigned char*)buffer, 1); y += 16; } y += 16; glColor3f(1.0f, 1.0f, 1.0f); draw_string_small(x, y, (unsigned char*)"Session Time", 1); timediff = cur_time - session_start_time; safe_snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", timediff/3600000, (timediff/60000)%60, (timediff/1000)%60); draw_string_small(x + 200, y, (unsigned char*)buffer, 1); y += 16; draw_string_small(x, y, (unsigned char*)"Exp/Min", 1); if(timediff<=0){ timediff=1; } safe_snprintf(buffer, sizeof(buffer), "%2.2f", (float)(*(statsinfo[SI_ALL].exp) - session_exp[SI_ALL])/((float)timediff/60000.0f)); draw_string_small(x + 200, y, (unsigned char*)buffer, 1); if (show_reset_help) { show_help(session_reset_help, 0, win->len_y+10); show_reset_help = 0; } #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
int display_session_handler(window_info *win) { int i; Uint32 timediff; char buffer[128]; float oa_exp; int y_step = (int)(0.5 + win->current_scale * 16); int extra_x_offset = (int)(0.5 + win->current_scale * 200); int start_y_offset = (int)(0.5 + win->current_scale * 55); int start_line_y_offset = (int)(0.5 + win->current_scale * 37); int x = (int)(0.5 + win->current_scale * 10); int y = (int)(0.5 + win->current_scale * 21); timediff = 0; oa_exp = 0.0f; glColor3f(1.0f, 1.0f, 1.0f); safe_snprintf(buffer, sizeof(buffer), "%-20s%-17s%-17s%-17s", "Skill", "Total Exp", "Max Exp", "Last Exp" ); draw_string_small_zoomed(x, y, (unsigned char*)buffer, 1, win->current_scale); glDisable(GL_TEXTURE_2D); glColor3f(0.77f, 0.57f, 0.39f); glBegin(GL_LINES); glVertex3i(0, start_line_y_offset, 0); glVertex3i(win->len_x, start_line_y_offset, 0); glEnd(); glEnable(GL_TEXTURE_2D); glColor3f(1.0f, 1.0f, 1.0f); y = start_y_offset; for (i=0; i<NUM_SKILLS; i++) { if ((last_mouse_click_y >= y) && (last_mouse_click_y < y+16)) elglColourN("global.mouseselected"); else if ((last_mouse_over_y >= y) && (last_mouse_over_y < y+16)) elglColourN("global.mousehighlight"); else glColor3f(1.0f, 1.0f, 1.0f); safe_snprintf(buffer, sizeof(buffer), "%-20s%-17u%-17u%-17u", statsinfo[i].skillnames->name, *(statsinfo[i].exp) - session_exp[i], max_exp[i], last_exp[i]); draw_string_small_zoomed(x, y, (unsigned char*)buffer, 1, win->current_scale); y += y_step; if(i < NUM_SKILLS-1) oa_exp += *(statsinfo[i].exp) - session_exp[i]; } y += y_step; glColor3f(1.0f, 1.0f, 1.0f); draw_string_small_zoomed(x, y, (unsigned char*)"Session Time", 1, win->current_scale); timediff = cur_time - session_start_time; safe_snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", timediff/3600000, (timediff/60000)%60, (timediff/1000)%60); draw_string_small_zoomed(x + extra_x_offset, y, (unsigned char*)buffer, 1, win->current_scale); y += y_step; draw_string_small_zoomed(x, y, (unsigned char*)"Exp/Min", 1, win->current_scale); if(timediff<=0){ timediff=1; } safe_snprintf(buffer, sizeof(buffer), "%2.2f", oa_exp/((float)timediff/60000.0f)); draw_string_small_zoomed(x + extra_x_offset, y, (unsigned char*)buffer, 1, win->current_scale); y += y_step; draw_string_small_zoomed(x, y, (unsigned char*)"Distance", 1, win->current_scale); safe_snprintf(buffer, sizeof(buffer), "%d", (distance_moved<0) ?0: distance_moved); draw_string_small_zoomed(x + extra_x_offset, y, (unsigned char*)buffer, 1, win->current_scale); if (show_reset_help) { show_help(session_reset_help, -TAB_MARGIN, win->len_y+10+TAB_MARGIN, win->current_scale); show_reset_help = 0; } #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
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); }
int display_knowledge_handler(window_info *win) { size_t i; int x = text_border; int y = text_border; int scroll = vscrollbar_get_pos (win->window_id, knowledge_scroll_id); char points_string[16]; char *research_string; int points_pos; float font_ratio = win->small_font_len_x/12.0; float max_name_x = (win->len_x - win->box_size - 2*x)/2; int is_researching = 1; int text_width = win->len_x - 2 * text_border; char knowledge_text_buf[TEXTBUFSIZE]; if(your_info.research_total && (your_info.research_completed==your_info.research_total)) safe_snprintf(points_string, sizeof(points_string), "%s", completed_research); else safe_snprintf(points_string, sizeof(points_string), "%i/%i",your_info.research_completed,your_info.research_total); if(your_info.researching < knowledge_count) { research_string = knowledge_list[your_info.researching].name; } else if (your_info.researching < sizeof(knowledge_list)) { research_string = unknown_book_short_str; } else { research_string = not_researching_anything; points_string[0] = '\0'; is_researching = 0; } points_pos = (progress_right_x - progress_left_x - strlen(points_string) * win->small_font_len_x) / 2; glDisable(GL_TEXTURE_2D); glColor3f(0.77f,0.57f,0.39f); glBegin(GL_LINES); // window separators glVertex3i(0,booklist_y_len,0); glVertex3i(win->len_x,booklist_y_len,0); glVertex3i(0,progressbox_y_len,0); glVertex3i(win->len_x,progressbox_y_len,0); //progress bar glVertex3i(progress_left_x,progress_top_y,0); glVertex3i(progress_right_x,progress_top_y,0); glVertex3i(progress_left_x,progress_bot_y,0); glVertex3i(progress_right_x,progress_bot_y,0); glVertex3i(progress_left_x,progress_top_y,0); glVertex3i(progress_left_x,progress_bot_y,0); glVertex3i(progress_right_x,progress_top_y,0); glVertex3i(progress_right_x,progress_bot_y,0); glEnd(); //progress bar if (is_researching) { int progress = (progress_right_x - progress_left_x - 1) * get_research_fraction(); glBegin(GL_QUADS); glColor3f(0.40f,0.40f,1.00f); glVertex3i(progress_left_x+1+gx_adjust,progress_top_y+gy_adjust,0); glVertex3i(progress_left_x+1+progress+gx_adjust,progress_top_y+gy_adjust,0); glColor3f(0.10f,0.10f,0.80f); glVertex3i(progress_left_x+1+progress+gx_adjust,progress_bot_y-1+gy_adjust,0); glVertex3i(progress_left_x+1+gx_adjust,progress_bot_y-1+gy_adjust,0); glColor3f(0.77f,0.57f,0.39f); glEnd(); } glEnable(GL_TEXTURE_2D); //draw text if (selected_book >= 0 && knowledge_list[selected_book].present && knowledge_list[selected_book].has_book) text_width = book_start_x - 2 * text_border; put_small_text_in_box_zoomed((unsigned char *)raw_knowledge_string, strlen((char *)raw_knowledge_string), text_width, (char *)knowledge_text_buf, win->current_scale); draw_string_small_zoomed(text_border,booklist_y_len + text_border,(unsigned char*)knowledge_text_buf, info_lines, win->current_scale); glColor3f(1.0f,1.0f,1.0f); draw_string_small_zoomed(text_border,progress_top_y+3+gy_adjust,(unsigned char*)researching_str,1, win->current_scale); draw_string_small_zoomed(text_border+(strlen(researching_str)+1)*win->small_font_len_x,progress_top_y+3+gy_adjust,(unsigned char*)research_string,1, win->current_scale); draw_string_small_zoomed(progress_left_x+points_pos+gx_adjust,progress_top_y+3+gy_adjust,(unsigned char*)points_string,1, win->current_scale); if (is_researching && mouse_over_progress_bar) { char eta_string[20]; int eta_pos; get_research_eta_str(eta_string, sizeof(eta_string)); eta_pos = (int)(progress_right_x - progress_left_x - strlen(eta_string)*win->small_font_len_x) / 2; draw_string_small_zoomed(progress_left_x + eta_pos, progress_top_y - win->small_font_len_y + 2, (unsigned char*)eta_string, 1, win->current_scale); mouse_over_progress_bar=0; } // Draw knowledges for(i = 2*scroll; y < (booklist_y_len - booklist_y_step); i++) { int highlight = 0; float colour_brightness = (knowledge_list[i].present) ?1.0 : 0.6; if (*highlight_string && (strlen(knowledge_list[i].name) > 0) && (get_string_occurance(highlight_string, knowledge_list[i].name, strlen(knowledge_list[i].name), 1) != -1)) highlight = 1; if (!highlight && (i == selected_book)) { GLfloat cols[3]; elglGetColour3v("global.mouseselected", cols); glColor3f (cols[0]*colour_brightness, cols[1]*colour_brightness, cols[2]*colour_brightness); } else if (knowledge_list[i].mouse_over) elglColourN("global.mousehighlight"); else if (highlight) glColor3f (1.0f*colour_brightness, 0.6f*colour_brightness, 0.0f*colour_brightness); else glColor3f (1.0f*colour_brightness, 1.0f*colour_brightness, 1.0f*colour_brightness); /* truncate the string if it is too long */ if ((get_string_width((unsigned char*)knowledge_list[i].name) * font_ratio) > max_name_x) { const char *append_str = "... "; size_t dest_max_len = strlen(knowledge_list[i].name)+strlen(append_str)+1; char *used_name = (char *)malloc(dest_max_len); truncated_string(used_name, knowledge_list[i].name, dest_max_len, append_str, max_name_x, font_ratio); draw_string_zoomed(x, y, (unsigned char*)used_name,1,font_ratio); /* if the mouse is over this line and its truncated, tooltip to full name */ if (knowledge_list[i].mouse_over) { show_help(knowledge_list[i].name, -TAB_MARGIN, win->len_y+10+TAB_MARGIN, win->current_scale); know_show_win_help = 0; } free(used_name); } else draw_string_zoomed(x,y,(unsigned char*)knowledge_list[i].name,1,font_ratio); x += (win->len_x-win->box_size-2*text_border)/2; if (i % 2 == 1) { y += booklist_y_step; x = text_border; } } if (know_show_win_help) { show_help(cm_help_options_str, -TAB_MARGIN, win->len_y+10+TAB_MARGIN, win->current_scale); know_show_win_help = 0; } #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }