int click_help_handler(window_info *win, int mx, int my, Uint32 flags) { _Text *t=Page[helppage].T.Next; if(flags&ELW_WHEEL_UP) { vscrollbar_scroll_up(help_win, help_menu_scroll_id); } else if(flags&ELW_WHEEL_DOWN) { vscrollbar_scroll_down(help_win, help_menu_scroll_id); } else { int j = vscrollbar_get_pos(help_win, help_menu_scroll_id); while(t) { int xlen=strlen(t->text)*((t->size)?11:8),ylen=(t->size)?18:15; if(t->ref && mx>(t->x) && mx<(t->x+xlen) && my>(t->y-j) && my<(t->y+ylen-j)) { //changing page int i; for(i=0; i<numpage+1; i++) { if(!xmlStrcasecmp((xmlChar*)Page[i].Name,(xmlChar*)t->ref)) { helppage=i; vscrollbar_set_pos(help_win, help_menu_scroll_id, 0); vscrollbar_set_bar_len(help_win, help_menu_scroll_id, Page[helppage].max_y); break; } } break; } t=t->Next; } } return 1; }
// selectively grey recipe context options static void context_recipe_pre_show_handler(window_info *win, int widget_id, int mx, int my, window_info *cm_win) { int first_shown = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id); cm_grey_line(cm_recipewin, CMRIC_ADD, (wanted_num_recipe_entries >= max_num_recipe_entries)); cm_grey_line(cm_recipewin, CMRIC_CLEAR, (cur_recipe < first_shown) || (cur_recipe >= first_shown + num_displayed_recipes)); cm_grey_line(cm_recipewin, CMRIC_DELETE, (cur_recipe < first_shown) || (cur_recipe >= first_shown + num_displayed_recipes)); }
int display_buddy_handler(window_info *win) { int i=0,x=2,y=2; glEnable(GL_TEXTURE_2D); // Draw budies qsort(buddy_list,MAX_BUDDY,sizeof(_buddy),compare2); for(i=vscrollbar_get_pos(buddy_win,12);i<(vscrollbar_get_pos(buddy_win,12)+19);i++){ switch(buddy_list[i].type){ case 0:glColor3f(1.0,1.0,1.0);break; case 1:glColor3f(1.0,0,0);break; case 2:glColor3f(0,1.0,0);break; case 3:glColor3f(0,0,1.0);break; case 4:glColor3f(1.0,1.0,0);break; } draw_string_zoomed(x,y,buddy_list[i].name,1,0.7); y+=10; } return 1; }
int display_emotes_handler(window_info *win){ int i,pos; actor *act = get_actor_ptr_from_id(yourself); static int last_pos=0; //check if vbar has been moved pos=vscrollbar_get_pos(emotes_win, EMOTES_SCROLLBAR_ITEMS); if(pos!=last_pos){ last_pos=pos; update_selectables(); } //draw texts glEnable(GL_TEXTURE_2D); SET_COLOR(c_orange1); draw_string_small(20, 15, (unsigned char*)"Categories",1); draw_string_small(20, emotes_rect_y+30+5, (unsigned char*)"Emotes",1); for(i=0;i<EMOTES_CATEGORIES;i++){ if(cur_cat==i) SET_COLOR(c_blue2); else glColor3f(1.0f, 1.0f, 1.0f); draw_string_small(23, 32+13*i, (unsigned char*)emote_cats[i],1); } for(i=0;i<EMOTES_SHOWN;i++){ if(emote_sel[cur_cat]==selectables[i]) SET_COLOR(c_blue2); else glColor3f(1.0f, 1.0f, 1.0f); if(cur_cat&&act&&selectables[i]==act->poses[cur_cat-1]) SET_COLOR(c_green1); if(selectables[i]) draw_string_small(23, 30+emotes_rect_y+20+1+13*i, (unsigned char*)selectables[i]->name,1); } glColor3f(0.77f, 0.57f, 0.39f); //do grids glDisable(GL_TEXTURE_2D); rendergrid(1, 1, 20, 30, emotes_rect_x, emotes_rect_y); rendergrid(1, 1, 20, 30+emotes_rect_y+20, emotes_rect_x2, emotes_rect_y2); glEnable(GL_TEXTURE_2D); //draw description if(emote_sel[cur_cat]){ draw_string_small(20, emotes_menu_y_len-36, emote_str1,2); draw_string_small(20, emotes_menu_y_len-36+16, emote_str2,1); } #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
int mouseover_storage_handler(window_info *win, int mx, int my) { static int last_pos; int last_category; cur_item_over=-1; if (my < 0) mouse_over_titlebar = 1; else mouse_over_storage = 1; if(my>10 && my<202){ if(mx>10 && mx<130){ int i; int pos=last_pos=(my-20)/13; int p; for(i=p=vscrollbar_get_pos(storage_win,STORAGE_SCROLLBAR_CATEGORIES);i<no_storage_categories;i++){ if(i==selected_category) { } else if(i!=p+pos) { storage_categories[i].name[0] = to_color_char (c_orange1); } else { storage_categories[i].name[0] = to_color_char (c_green2); } } return 0; } else if (mx>150 && mx<352){ cur_item_over = get_mouse_pos_in_grid(mx, my, 6, 6, 160, 10, 32, 32)+vscrollbar_get_pos(storage_win, STORAGE_SCROLLBAR_ITEMS)*6; if(cur_item_over>=no_storage||cur_item_over<0||!storage_items[cur_item_over].quantity) cur_item_over=-1; } } last_category = last_pos+vscrollbar_get_pos(storage_win,STORAGE_SCROLLBAR_CATEGORIES); if(last_pos>=0 && last_pos<13 && last_category != selected_category) { storage_categories[last_category].name[0] = to_color_char (c_orange1); last_pos=-1; } return 0; }
void update_selectables(){ int pos,i; hash_entry *he; i=0; pos=vscrollbar_get_pos(emotes_win, EMOTES_SCROLLBAR_ITEMS); memset(selectables,0,sizeof(emote_data*)*EMOTES_SHOWN); hash_start_iterator(emotes); while((he=hash_get_next(emotes))&&i<EMOTES_SHOWN){ emote_data *emote; emote=((emote_data *)he->item); if(!cur_cat&&emote->pose>EMOTE_STANDING) { //emotes pos--; if(pos>=0) continue; selectables[i]=emote; i++; } else if(cur_cat&&emote->pose==(cur_cat-1)){ //poses pos--; if(pos>=0) continue; selectables[i]=emote; i++; } } emote_str1[1]=emote_str2[0]=emote_str2[1]=0; if(emote_sel[cur_cat]){ emote_dict *emd; emote_str1[0]=127+c_orange2; safe_strcat((char*)emote_str1,(char*)emote_sel[cur_cat]->desc,/*sizeof(emote_str1)*/23); hash_start_iterator(emote_cmds); while((he=hash_get_next(emote_cmds))){ emd = (emote_dict*)he->item; if (emd->emote==emote_sel[cur_cat]){ int ll; //draw command if(!emote_str2[0]) { emote_str2[0]=127+c_grey1; safe_strcat((char*)emote_str2,"Trigger:",10); } ll=strlen((char*)emote_str2); emote_str2[ll]=127+c_green3; emote_str2[ll+1]=emote_str2[ll+2]=' '; emote_str2[ll+3]=0; safe_strcat((char*)emote_str2,emd->command,/*sizeof(emote_str2)*/23); break; //just one command } } } }
// Move the names list to make the select list visible // void List_Window::make_active_visable(void) { const size_t top_entry = vscrollbar_get_pos (win_id, names_scroll_id); int new_pos = top_entry; if (Vars::lists()->get_active()<top_entry) new_pos = Vars::lists()->get_active(); else if (Vars::lists()->get_active()>=(top_entry+num_show_names_list)) new_pos = Vars::lists()->get_active() - (num_show_names_list - 1); else return; vscrollbar_set_pos(win_id, names_scroll_id, new_pos); }
int click_buddy_handler(window_info *win, int mx, int my, Uint32 flags) { int x=mx,y=my; if(x>win->len_x-20) return 0; // clicked on a buddies name, start apm to them y/= 10; y+= vscrollbar_get_pos(buddy_win,12); sprintf(input_text_line,"/%s ",buddy_list[y].name); input_text_lenght= strlen(input_text_line); return 1; }
static int display_buddy_handler(window_info *win) { int i = 0; int y = buddy_border_space; int offset = 0; glEnable(GL_TEXTURE_2D); // Draw buddies qsort(buddy_list,MAX_BUDDY,sizeof(_buddy),buddy_list_name_cmp); offset = vscrollbar_get_pos (win->window_id, buddy_scroll_id); if (offset >= 0) { for (i = offset; i < offset + num_displayed_buddies; i++) { switch(buddy_list[i].type){ case 0:glColor3f(1.0,1.0,1.0);break; case 1:glColor3f(1.0,0,0);break; case 2:glColor3f(0,1.0,0);break; case 3:glColor3f(0.25,0.5,1.0);break; case 4:glColor3f(1.0,1.0,0);break; case 0xFE:glColor3f(0.5,0.55,0.60);break; default:glColor3f(1.0,1.0,1.0);//invalid number? make it white } draw_string_small_zoomed(buddy_border_space, y, (unsigned char*)buddy_list[i].name, 1, win->current_scale); y += buddy_name_step_y; } } //Draw a button for the requests if(!queue_isempty(buddy_request_queue)) { glDisable(GL_TEXTURE_2D); //glColor3f(0.77f, 0.59f, 0.77f); glColor3f(0.3, 1, 0.3); glBegin(GL_LINE_LOOP); glVertex2i(request_box_start_x - win->small_font_len_x, 0); glVertex2i(request_box_start_x, win->small_font_len_y + 1); glVertex2i(win->len_x - win->box_size - 1, win->small_font_len_y + 1); glVertex2i(win->len_x - win->box_size - 1, 0); glEnd(); glEnable(GL_TEXTURE_2D); draw_string_small_zoomed(request_box_start_x + win->small_font_len_x + gx_adjust, 2 + gy_adjust, (unsigned char*)buddy_request_str, 1, win->current_scale); } glColor3f(newcol_r, newcol_g, newcol_b); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
// The mouse is over the window // int List_Window::mouseover(window_info *win, int mx, int my) { if ((my < 0) || (cm_window_shown()!=CM_INIT_VALUE)) return 0; if (Vars::lists()->valid_active_list() && mx>=0 && mx<(get_grid_size()*6) && my>=0 && my<(get_grid_size()*num_grid_rows)) { size_t item_number = get_item_number(mx, my); if (item_number < Vars::lists()->get_list().get_num_items()) { Uint16 item_id = Vars::lists()->get_list().get_item_id(item_number); int image_id = Vars::lists()->get_list().get_image_id(item_number); if (show_item_desc_text && item_info_available() && (get_item_count(item_id, image_id) == 1)) desc_str = get_item_description(item_id, image_id); help_str.push_back(item_list_pickup_help_str); help_str.push_back(item_list_use_help_str); help_str.push_back(item_list_edit_help_str); } if ((storage_item_dragged != -1) || (item_dragged != -1)) help_str.push_back(item_list_add_help_str); else help_str.push_back(item_list_drag_help_str); } // check if over the add list button if (my>add_button_y && my<(add_button_y+2*DEFAULT_FONT_Y_LEN) && mx>add_button_x && mx<win->len_x) { help_str.push_back(item_list_create_help_str); mouse_over_add_button = true; } // check if over the list names and get which name int start_names = get_grid_size()*num_grid_rows; if ((my > start_names) && (my < (start_names+get_names_size_y()))) name_under_mouse = vscrollbar_get_pos (win_id, names_scroll_id) + static_cast<int>((my - start_names - get_list_gap()/2) / (get_list_gap() + names_list_height)); // name list context help if ((my > start_names) && (my < (start_names+get_names_size_y()))) { help_str.push_back(cm_help_options_str); if (!strlen(filter)) help_str.push_back(item_list_find_help_str); } return 0; }
/* key presses in the window used for a recipe name search string */ static int keypress_recipe_handler(window_info *win, int mx, int my, Uint32 key, Uint32 unikey) { char keychar = tolower(key_to_char(unikey)); last_recipe_key_time = SDL_GetTicks(); if ((keychar == SDLK_RETURN) && (key & ELW_CTRL)) { select_recipe(cur_recipe); return 1; } if ((keychar == '`') || (key & ELW_CTRL) || (key & ELW_ALT)) return 0; if (keychar == SDLK_ESCAPE) { clear_recipe_filter(); return 1; } if (string_input(recipe_name_filter, sizeof(recipe_name_filter), keychar) || (keychar == SDLK_RETURN)) { if (strlen(recipe_name_filter)) { size_t i; for (i=cur_recipe+1; i<cur_recipe+num_recipe_entries; i++) { size_t check = i % num_recipe_entries; if (recipes_store[check].name != NULL && safe_strcasestr(recipes_store[check].name, strlen(recipes_store[check].name), recipe_name_filter, strlen(recipe_name_filter)) != NULL) { /* have matching name so set as the current and make sure visible */ int first_displayed_recipe = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id); int new_pos = first_displayed_recipe; cur_recipe = check; if (cur_recipe < first_displayed_recipe) new_pos = cur_recipe; else if (cur_recipe >= (first_displayed_recipe+num_displayed_recipes)) new_pos = cur_recipe - (num_displayed_recipes - 1); else break; vscrollbar_set_pos(win->window_id, recipe_win_scroll_id, new_pos); break; } } } return 1; } return 0; }
static void scroll_to_note_button(int nr) { int pos = vscrollbar_get_pos (main_note_tab_id, note_button_scroll_id); int max_nr_rows = note_button_scroll_height / (note_button_height + note_button_y_space); int row = nr / 2; if (row < pos) { vscrollbar_set_pos (main_note_tab_id, note_button_scroll_id, row); note_button_scroll_handler (); } else if (row >= pos + max_nr_rows) { vscrollbar_set_pos (main_note_tab_id, note_button_scroll_id, row - max_nr_rows + 1); note_button_scroll_handler (); } }
int click_knowledge_handler(window_info *win, int mx, int my, Uint32 flags) { int x,y,idx; Uint8 str[3]; x= mx; y= my; if(x > win->len_x-win->box_size) return 0; if(y > booklist_y_len) return 0; if(flags&ELW_WHEEL_UP) { vscrollbar_scroll_up(win->window_id, knowledge_scroll_id); return 1; } else if(flags&ELW_WHEEL_DOWN) { vscrollbar_scroll_down(win->window_id, knowledge_scroll_id); return 1; } else { selected_book = -1; x = (x < (win->len_x-win->box_size)/2) ?0 :1; y/=booklist_y_step; idx = x + 2 *(y + vscrollbar_get_pos (win->window_id, knowledge_scroll_id)); if(idx < knowledge_count) { str[0] = GET_KNOWLEDGE_INFO; *(Uint16 *)(str+1) = SDL_SwapLE16((short)idx); my_tcp_send(my_socket,str,3); raw_knowledge_string[0] = '\0'; // Check if we display the book image and label knowledge_book_id = idx; if (knowledge_list[idx].present && knowledge_list[idx].has_book) { widget_unset_flags (win->window_id, knowledge_book_image_id, WIDGET_DISABLED); widget_unset_flags (win->window_id, knowledge_book_label_id, WIDGET_DISABLED); } else { widget_set_flags(win->window_id, knowledge_book_image_id, WIDGET_DISABLED); widget_set_flags(win->window_id, knowledge_book_label_id, WIDGET_DISABLED); } selected_book = idx; } do_click_sound(); } return 1; }
void note_button_set_pos (int id) { int scroll_pos = vscrollbar_get_pos (main_note_tab_id, note_button_scroll_id); int max_nr_rows = note_button_scroll_height / (note_button_height + note_button_y_space); int row = id / 2 - scroll_pos; if (row < 0 || row >= max_nr_rows) { widget_set_flags (main_note_tab_id, note_list[id].button_id, WIDGET_INVISIBLE); } else { int x = 5 + (id % 2) * (note_button_width + note_button_x_space); int y = 50 + (note_button_height + note_button_y_space) * row; widget_unset_flags (main_note_tab_id, note_list[id].button_id, WIDGET_INVISIBLE); widget_move (main_note_tab_id, note_list[id].button_id, x, y); } }
/* act on scroll wheel in the main window or clicking a URL */ static int click_url_handler(window_info *win, int mx, int my, Uint32 flags) { static size_t cm_id = CM_INIT_VALUE; if (flags & ELW_WHEEL_UP) vscrollbar_scroll_up(url_win, url_scroll_id); else if (flags & ELW_WHEEL_DOWN) vscrollbar_scroll_down(url_win, url_scroll_id); else if (have_url_count && url_win_hover_url != NULL) { if (flags & ELW_CTRL) { delete_current_url(url_win_hover_url); do_window_close_sound(); } else if (flags & ELW_RIGHT_MOUSE) { cm_url = url_win_hover_url; /* create first time needed */ if (!cm_valid(cm_id)) { cm_id = cm_create(cm_url_menu_str, context_url_handler); cm_set_pre_show_handler(cm_id, context_url_pre_show_handler); } cm_show_direct(cm_id, -1, -1); } else { /* open the URL but block double clicks */ Uint32 currentclicktime = SDL_GetTicks(); if (currentclicktime < url_win_clicktime) url_win_clicktime = 0; /* just in case we're running for 49 days :) */ if ((currentclicktime - url_win_clicktime > 1000) || (url_win_clicked_url != url_win_hover_url)) { do_click_sound(); open_current_url(url_win_hover_url); } } } url_win_top_line = vscrollbar_get_pos(url_win, url_scroll_id); return 0; }
int mouseover_knowledge_handler(window_info *win, int mx, int my) { int i; if (mx>=progress_left_x && mx<progress_right_x && my>progress_top_y && my<progress_bot_y) mouse_over_progress_bar=1; if (cm_window_shown()!=CM_INIT_VALUE) return 0; for(i=0;i<knowledge_count;i++)knowledge_list[i].mouse_over=0; if (my>0) know_show_win_help = 1; if(mx>win->len_x-win->box_size) return 0; if(my>booklist_y_len) return 0; mx = (mx < (win->len_x-win->box_size)/2) ?0 :1; my/=booklist_y_step; knowledge_list[mx+2*(my+vscrollbar_get_pos (win->window_id, knowledge_scroll_id))].mouse_over=1; return 0; }
int click_encyclopedia_handler(window_info *win, int mx, int my, Uint32 flags) { _Text *t=Page[currentpage].T.Next; if(flags&ELW_WHEEL_UP) { vscrollbar_scroll_up(encyclopedia_win, encyclopedia_scroll_id); } else if(flags&ELW_WHEEL_DOWN) { vscrollbar_scroll_down(encyclopedia_win, encyclopedia_scroll_id); } else { int j = vscrollbar_get_pos(encyclopedia_win, encyclopedia_scroll_id); while(t){ int xlen=strlen(t->text)*((t->size)?11:8),ylen=(t->size)?18:15; if(t->ref && mx>(t->x) && mx<(t->x+xlen) && my>(t->y-j) && my<(t->y+ylen-j)){ // check if its a webpage if (!strncasecmp(t->ref, "http://", 7)) { open_web_link(t->ref); } else { //changing page int i; for(i=0;i<numpage+1;i++){ if(!xmlStrcasecmp((xmlChar*)Page[i].Name,(xmlChar*)t->ref)){ currentpage=i; vscrollbar_set_pos(encyclopedia_win, encyclopedia_scroll_id, 0); vscrollbar_set_bar_len(encyclopedia_win, encyclopedia_scroll_id, Page[currentpage].max_y); break; } } } break; } t=t->Next; } } return 1; }
//CLICK HANDLERS static int recipe_dropdown_click_handler(window_info *win, int mx, int my, Uint32 flags){ static int last_clicked=0; static int last_recipe=0; int first_displayed_recipe = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id); int rel_curr; if (flags & ELW_WHEEL_UP) { cur_recipe=(cur_recipe-1+num_recipe_entries)%num_recipe_entries; rel_curr = cur_recipe - first_displayed_recipe; if ((rel_curr < 0) || (rel_curr >= num_displayed_recipes)) vscrollbar_set_pos(win->window_id, recipe_win_scroll_id, cur_recipe); } else if (flags & ELW_WHEEL_DOWN) { cur_recipe=(cur_recipe+1)%num_recipe_entries; rel_curr = cur_recipe - first_displayed_recipe; if ((rel_curr < 0) || (rel_curr >= num_displayed_recipes)) { first_displayed_recipe = cur_recipe; if (cur_recipe > 0) first_displayed_recipe -= num_displayed_recipes - 1; vscrollbar_set_pos(win->window_id, recipe_win_scroll_id, first_displayed_recipe); } } else { //normal click select_window(recipe_win); cur_recipe=first_displayed_recipe + my/(SLOT_SIZE+1); //double click on the same recipe to select it and close the dropdown if ( ((SDL_GetTicks() - last_clicked) < 400)&& last_recipe==cur_recipe) select_recipe(cur_recipe); last_clicked = SDL_GetTicks(); do_click_sound(); } last_recipe = cur_recipe; return 1; }
/* draw the recipes - finishing any resize to snap to a reasonable size */ static int recipe_dropdown_draw(window_info *win){ static int resizing = 0; size_t i; int first_displayed_recipe = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id); int relative_cur = cur_recipe - first_displayed_recipe; int help_line = 0; int find_active = 0; /* if resizing wait until we stop */ if (win->resized) resizing = 1; /* once we stop, snap the window size to fit nicely */ else if (resizing) { resizing = 0; num_displayed_recipes = (int)(win->len_y / SLOT_SIZE); if (num_displayed_recipes > num_recipe_entries) num_displayed_recipes = num_recipe_entries; resize_window(win->window_id, recipe_win_width, num_displayed_recipes*SLOT_SIZE); } /* draw all the shown recipes */ for (i=0; i<num_displayed_recipes && i<num_recipe_entries; i++) draw_production_pipe(win,0,SLOT_SIZE*i,i+first_displayed_recipe); /* if shown, the current (highlighted in red) recipe needs drawing again and its name displayed */ if ((relative_cur >= 0) && (relative_cur < num_displayed_recipes)) { draw_production_pipe(win,0,SLOT_SIZE*relative_cur,cur_recipe); if ((cur_recipe < num_recipe_entries) && (recipes_store[cur_recipe].name != NULL)) show_help(recipes_store[cur_recipe].name, win->len_x+5, SLOT_SIZE*relative_cur+(SLOT_SIZE-win->small_font_len_y)/2, win->current_scale); } /* display any name search text */ if (strlen(recipe_name_filter)) { if (SDL_GetTicks() > (last_recipe_key_time+5000)) clear_recipe_filter(); else { static char tmp[30]; safe_snprintf(tmp, sizeof(tmp), "%s[%s]", item_list_find_str, recipe_name_filter); show_help(tmp, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); find_active = 1; } } /* display the name of the recipe with the mouse over, plus general help */ if (mouse_over_recipe != -1) { size_t actual_recipe = mouse_over_recipe + first_displayed_recipe; if ((actual_recipe != cur_recipe) && (actual_recipe < num_recipe_entries) && (recipes_store[actual_recipe].name != NULL)) show_help(recipes_store[actual_recipe].name, win->len_x+5, SLOT_SIZE*mouse_over_recipe+(SLOT_SIZE-win->small_font_len_y)/2, win->current_scale); if (show_help_text) { show_help(cm_help_options_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(recipe_select_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(recipe_load_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(find_active?recipe_during_find_str:recipe_find_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); } } mouse_over_recipe = -1; return 1; }
static int click_buddy_handler (window_info *win, int mx, int my, Uint32 flags) { int x = mx; int y = my - buddy_border_space; char str[50]; // scroll the winow with the mouse wheel if(flags & ELW_WHEEL_UP) { vscrollbar_scroll_up(buddy_win,buddy_scroll_id); return 1; } else if(flags & ELW_WHEEL_DOWN) { vscrollbar_scroll_down(buddy_win,buddy_scroll_id); return 1; } // only handle mouse button clicks, not scroll wheels moves if ( (flags & ELW_MOUSE_BUTTON) == 0) return 0; if(x > (win->len_x - win->box_size)) { //Clicked on the scrollbar. Let it fall through. return 0; } else if(!queue_isempty(buddy_request_queue) && mx > (request_box_start_x - win->small_font_len_x) && y < (win->small_font_len_y + 1)) { //Clicked on the requests button while(!queue_isempty(buddy_request_queue)) { char *name = queue_pop(buddy_request_queue); select_window(display_accept_buddy(name)); free(name); } return 1; } // clicked on a buddy's name y /= buddy_name_step_y; if (y >= num_displayed_buddies) return 0; y += vscrollbar_get_pos(buddy_win,buddy_scroll_id); if((strlen(buddy_list[y].name) == 0)||(buddy_list[y].type > 0xFE)) { //There's no name. Fall through. return 0; } if(flags&ELW_RIGHT_MOUSE) { if(flags&ELW_CTRL) { //CTRL + right click, delete buddy. safe_snprintf(str, sizeof(str), "%c#del_buddy %s", RAW_TEXT, buddy_list[y].name); my_tcp_send(my_socket, (Uint8*)str, strlen(str+1)+1); } else { //Right click, open edit window display_buddy_change(&buddy_list[y]); } } else if (buddy_list[y].type < 0xFE) { //start a pm to them // clear the buffer clear_input_line(); // insert the person's name safe_snprintf (str, sizeof(str),"/%s ", buddy_list[y].name); //put_string_in_buffer (&input_text_line, str, 0); //We'll just reuse the paste function here paste_in_input_field((unsigned char*)str); } return 1; }
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; }
void get_storage_items (const Uint8 *in_data, int len) { int i; int cat, pos; int idx; int plen; if (item_uid_enabled) plen=10; else plen=8; if (in_data[0] == 255) { // It's just an update - make sure we're in the right category idx = 2; active_storage_item = SDL_SwapLE16(*((Uint16*)(&in_data[idx+6]))); for (i = 0; i < STORAGE_ITEMS_SIZE; i++) { if ((storage_items[i].pos == SDL_SwapLE16(*((Uint16*)(&in_data[idx+6])))) && (storage_items[i].quantity > 0)) { storage_items[i].image_id = SDL_SwapLE16(*((Uint16*)(&in_data[idx]))); storage_items[i].quantity = SDL_SwapLE32(*((Uint32*)(&in_data[idx+2]))); if (item_uid_enabled) storage_items[i].id = SDL_SwapLE16(*((Uint16*)(&in_data[idx+8]))); else storage_items[i].id = unset_item_uid; return; } } for (i = 0; i < STORAGE_ITEMS_SIZE; i++) { if (storage_items[i].quantity == 0) { if (item_uid_enabled) storage_items[i].id = SDL_SwapLE16(*((Uint16*)(&in_data[idx+8]))); else storage_items[i].id = unset_item_uid; storage_items[i].pos = SDL_SwapLE16(*((Uint16*)(&in_data[idx+6]))); storage_items[i].image_id = SDL_SwapLE16(*((Uint16*)(&in_data[idx]))); storage_items[i].quantity = SDL_SwapLE32(*((Uint32*)(&in_data[idx+2]))); no_storage++; return; } } } no_storage = (len - 2) / plen; cat = find_category(in_data[1]); if (cat >= 0) { storage_categories[cat].name[0] = to_color_char (c_red3); if (selected_category != -1 && cat != selected_category) storage_categories[selected_category].name[0] = to_color_char (c_orange1); set_window_name(" - ", storage_categories[cat].name+1); selected_category = cat; } idx = 2; for (i = 0; i < no_storage && i < STORAGE_ITEMS_SIZE; i++, idx += plen) { storage_items[i].image_id = SDL_SwapLE16(*((Uint16*)(&in_data[idx]))); storage_items[i].quantity = SDL_SwapLE32(*((Uint32*)(&in_data[idx+2]))); storage_items[i].pos = SDL_SwapLE16(*((Uint16*)(&in_data[idx+6]))); if (item_uid_enabled) storage_items[i].id = SDL_SwapLE16(*((Uint16*)(&in_data[idx+8]))); else storage_items[i].id = unset_item_uid; } for ( ; i < STORAGE_ITEMS_SIZE; i++) { storage_items[i].quantity=0; } vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_ITEMS, 0); pos = vscrollbar_get_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES); if (cat < pos) { vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES, cat); } else if (cat >= pos + STORAGE_CATEGORIES_DISPLAY) { vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES, cat - STORAGE_CATEGORIES_DISPLAY + 1); } if (selected_category != -1) category_updated(); }
int display_storage_handler(window_info * win) { int i; int n=0; int pos; have_storage_list = 0; //We visited storage, so we may have changed something glColor3f(0.77f, 0.57f, 0.39f); glEnable(GL_TEXTURE_2D); for(i=pos=vscrollbar_get_pos(storage_win,STORAGE_SCROLLBAR_CATEGORIES); i<no_storage_categories && storage_categories[i].id!=-1 && i<pos+STORAGE_CATEGORIES_DISPLAY; i++,n++){ draw_string_small(20, 20+n*13, (unsigned char*)storage_categories[i].name,1); } if(storage_text[0]){ if (strcmp(storage_text, last_storage_text) != 0) { safe_strncpy(last_storage_text, storage_text, sizeof(last_storage_text)); put_small_text_in_box ((Uint8 *)storage_text, strlen(storage_text), win->len_x - 18*2, wrapped_storage_text); } draw_string_small(18, 220, (unsigned char*)wrapped_storage_text, 2); } glColor3f(1.0f,1.0f,1.0f); for(i=pos=6*vscrollbar_get_pos(storage_win, STORAGE_SCROLLBAR_ITEMS); i<pos+36 && i<no_storage;i++){ GLfloat u_start, v_start, u_end, v_end; int x_start, x_end, y_start, y_end; int cur_item; GLuint this_texture; if(!storage_items[i].quantity)continue; cur_item=storage_items[i].image_id%25; #ifdef NEW_TEXTURES get_item_uv(cur_item, &u_start, &v_start, &u_end, &v_end); #else /* NEW_TEXTURES */ u_start=0.2f*(cur_item%5); u_end=u_start+(float)50/255; v_start=(1.0f+((float)50/255)/255.0f)-((float)50/255*(cur_item/5)); v_end=v_start-(float)50/255; #endif /* NEW_TEXTURES */ this_texture=get_items_texture(storage_items[i].image_id/25); #ifdef NEW_TEXTURES if (this_texture != -1) { bind_texture(this_texture); } #else /* NEW_TEXTURES */ if(this_texture!=-1) get_and_set_texture_id(this_texture); #endif /* NEW_TEXTURES */ x_start=(i%6)*32+161; x_end=x_start+31; y_start=((i-pos)/6)*32+10; y_end=y_start+31; glBegin(GL_QUADS); draw_2d_thing(u_start,v_start,u_end,v_end,x_start,y_start,x_end,y_end); glEnd(); } if(cur_item_over!=-1 && mouse_in_window(win->window_id, mouse_x, mouse_y) == 1){ char str[20]; Uint16 item_id = storage_items[cur_item_over].id; int image_id = storage_items[cur_item_over].image_id; if (show_item_desc_text && item_info_available() && (get_item_count(item_id, image_id) == 1)) show_help(get_item_description(item_id, image_id), 0, win->len_y + 10); if (active_storage_item!=storage_items[cur_item_over].pos) { safe_snprintf(str, sizeof(str), "%d",storage_items[cur_item_over].quantity); show_help(str,mouse_x-win->pos_x-(strlen(str)/2)*8,mouse_y-win->pos_y-14); } } // Render the grid *after* the images. It seems impossible to code // it such that images are rendered exactly within the boxes on all // cards glDisable(GL_TEXTURE_2D); glColor3f(0.77f, 0.57f, 0.39f); glBegin(GL_LINE_LOOP); glVertex2i(10, 10); glVertex2i(10, 202); glVertex2i(130, 202); glVertex2i(130, 10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2i(10, 212); glVertex2i(10, 262); glVertex2i(392, 262); glVertex2i(392, 212); glEnd(); if (view_only_storage) { Uint32 currentticktime = SDL_GetTicks(); if (currentticktime < drop_fail_time) drop_fail_time = 0; /* trap wrap */ if ((currentticktime - drop_fail_time) < 250) glColor3f(0.8f,0.2f,0.2f); /* flash red if tried to drop into */ else glColor3f(0.37f, 0.37f, 0.39f); /* otherwise draw greyed out */ } rendergrid(6, 6, 160, 10, 32, 32); glEnable(GL_TEXTURE_2D); glColor3f(1.0f,1.0f,1.0f); if(active_storage_item >= 0) { /* Draw the active item's quantity on top of everything else. */ for(i = pos = 6*vscrollbar_get_pos(storage_win, STORAGE_SCROLLBAR_ITEMS); i < pos+36 && i < no_storage; i++) { if(storage_items[i].pos == active_storage_item) { if (storage_items[i].quantity) { char str[20]; int x = (i%6)*32+161; safe_snprintf(str, sizeof(str), "%d", storage_items[i].quantity); if(x > 353) { x = 321; } show_help(str, x, ((i-pos)/6)*32+18); } break; } } } #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
static int url_win_scroll_click(widget_list *widget, int mx, int my, Uint32 flags) { url_win_top_line = vscrollbar_get_pos(url_win, url_scroll_id); return 1; }
// Draw the item list window // int List_Window::draw(window_info *win) { Vars::lists()->check_and_timed_save(false); // if resizing wait until we stop if (win->resized) resizing = true; // once we stop, snap the window size to fix nicely else if (resizing) { calc_num_show_names(win->len_y); resizing = false; resize_window (win->window_id, get_size_x(), get_size_y()); } // check if we need to change the number of grid rows shown int new_num_grid_rows = min_grid_rows(); if (Vars::lists()->valid_active_list()) new_num_grid_rows = std::max(static_cast<size_t>(new_num_grid_rows), (Vars::lists()->get_list().get_num_items() +5) / 6); if (num_grid_rows != new_num_grid_rows) { num_grid_rows = new_num_grid_rows; resized_name_panel(win); } glEnable(GL_TEXTURE_2D); // draw the images if (Vars::lists()->valid_active_list()) { glColor3f(1.0f,1.0f,1.0f); for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++) { int x_start, y_start; x_start = get_grid_size() * (i%6) + 1; y_start = get_grid_size() * (i/6); draw_item(Vars::lists()->get_list().get_image_id(i), x_start, y_start, get_grid_size()); } } size_t help_lines_shown = 0; // Display any name search text if (strlen(filter)) { if (SDL_GetTicks() > (last_key_time+5000)) { filter[0] = '\0'; last_key_time = 0; } else { std::string tmp = std::string(item_list_find_str) + std::string("[") + std::string(filter) + std::string("]"); show_help(tmp.c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++)); } } // draw mouse over window help text if (show_help_text) { if (!resizing) for (size_t i=0; i<help_str.size(); ++i) show_help(help_str[i], 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown++)); help_str.clear(); } glDisable(GL_TEXTURE_2D); // draw the item grid glColor3f(0.77f,0.57f,0.39f); rendergrid(6, num_grid_rows, 0, 0, get_grid_size(), get_grid_size()); // if an object is selected, draw a green grid around it if (Vars::lists()->valid_active_list() && (quantities.selected == ITEM_EDIT_QUANT) && (selected_item_number < Vars::lists()->get_list().get_num_items())) { int x_start = selected_item_number%6 * get_grid_size(); int y_start = static_cast<int>(selected_item_number/6) * get_grid_size(); if ((SDL_GetTicks() - il_pickup_fail_time) < 250) glColor3f(0.8f,0.2f,0.2f); else glColor3f(0.0f, 1.0f, 0.3f); rendergrid(1, 1, x_start, y_start, get_grid_size(), get_grid_size()); rendergrid(1, 1, x_start-1, y_start-1, get_grid_size()+2, get_grid_size()+2); } glEnable(GL_TEXTURE_2D); // draw the quantities over everything else so they always show if (Vars::lists()->valid_active_list()) { glColor3f(1.0f,1.0f,1.0f); char str[80]; for(size_t i=0; i<Vars::lists()->get_list().get_num_items() && i<static_cast<size_t>(6*num_grid_rows); i++) { int x_start, y_start, y_end; x_start = get_grid_size() * (i%6) + 1; y_start = get_grid_size() * (i/6); y_end = y_start + get_grid_size() - 1; safe_snprintf(str, sizeof(str), "%i", Vars::lists()->get_list().get_quantity(i)); draw_string_small_shadowed(x_start, (i&1)?(y_end-15):(y_end-27), (unsigned char*)str, 1,1.0f,1.0f,1.0f, 0.0f, 0.0f, 0.0f); } } // Drawn the new list button (+) with highlight when mouse over if (mouse_over_add_button) glColor3f(0.99f,0.77f,0.55f); else glColor3f(0.77f,0.57f,0.39f); draw_string_zoomed(add_button_x, add_button_y, (unsigned const char*)"+", 1, 2.0); // draw the item list names glColor3f(1.0f,1.0f,1.0f); int pos_y = get_grid_size()*num_grid_rows + get_list_gap(); int num_shown = 0; const int top_entry = vscrollbar_get_pos (win_id, names_scroll_id); const std::vector<List> lists = Vars::lists()->get_lists(); const int hl_width = static_cast<int>(win->len_x-ELW_BOX_SIZE-3); const int hl_height = static_cast<int>(names_list_height + get_list_gap()); const size_t disp_chars = static_cast<size_t>((win->len_x-ELW_BOX_SIZE-2*get_list_gap()) / SMALL_FONT_X_LEN); for (size_t i = top_entry; i<lists.size() && num_shown<num_show_names_list; ++i) { if (i==Vars::lists()->get_active()) draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 1); else if (i==name_under_mouse) draw_highlight(1, static_cast<int>(pos_y-get_list_gap()/2), hl_width, hl_height, 0); glColor3f(1.0f,1.0f,1.0f); if (lists[i].get_name().size() > disp_chars) { std::string todisp = lists[i].get_name().substr(0,disp_chars); draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(todisp.c_str()), 1); if (i==name_under_mouse) show_help(lists[i].get_name().c_str(), 0, static_cast<int>(0.5 + win->len_y + 10 + SMALL_FONT_Y_LEN * help_lines_shown)); } else draw_string_small(get_list_gap(), pos_y, reinterpret_cast<const unsigned char*>(lists[i].get_name().c_str()), 1); pos_y += static_cast<int>(names_list_height + get_list_gap()); num_shown++; } if (clicked && (name_under_mouse < lists.size())) { do_click_sound(); Vars::lists()->set_active(name_under_mouse); } if (clicked && mouse_over_add_button) { do_click_sound(); new_or_rename_list(true); } name_under_mouse = static_cast<size_t>(-1); mouse_over_add_button = clicked = false; #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
int display_encyclopedia_handler(window_info *win) { _Text *t=Page[currentpage].T.Next; _Image *i=Page[currentpage].I.Next; int j; j=vscrollbar_get_pos(encyclopedia_win, encyclopedia_scroll_id); while(t) { int ylen=(t->size)?18:15; int xlen=strlen(t->text)*((t->size)?11:8); // Bounds Check the Text if((t->y-j > 0) && (t->y-j < encyclopedia_menu_y_len-20 )) { if(t->ref) { //draw a line glColor3f(0.5,0.5,0.5); glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); glVertex3i(t->x+4,t->y+ylen-j,0); glVertex3i(t->x+4+xlen-8,t->y+ylen-j,0); glEnd(); glEnable(GL_TEXTURE_2D); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE } if(t->size) { if(t->ref && mouse_x>(t->x+win->cur_x) && mouse_x<(t->x+xlen+win->cur_x) && mouse_y>(t->y+win->cur_y-j) && mouse_y<(t->y+ylen+win->cur_y-j)) glColor3f(0.3,0.6,1.0); else glColor3f(t->r,t->g,t->b); draw_string(t->x,t->y-j,(unsigned char*)t->text,1); } else { if(t->ref && mouse_x>(t->x+win->cur_x) && mouse_x<(t->x+xlen+win->cur_x) && mouse_y>(t->y+win->cur_y-j) && mouse_y<(t->y+ylen+win->cur_y-j)) glColor3f(0.3,0.6,1.0); else glColor3f(t->r,t->g,t->b); draw_string_small(t->x,t->y-j,(unsigned char*)t->text,1); } } // No next line? if(!t->Next) break; t=t->Next; } glColor3f(1.0f,1.0f,1.0f); while(i){ // Bounds Check the Text if((i->y-j > 0) && (i->yend-j < encyclopedia_menu_y_len-40 )) { if(i->mouseover==1) { i=i->Next; continue; } if(mouse_x>(i->x+win->cur_x) && mouse_x<(win->cur_x+i->xend) && mouse_y>(i->y+win->cur_y-j) && mouse_y<(win->cur_y-j+i->yend)) { if(i->Next!=NULL) { if(i->Next->mouseover==1) i=i->Next; } } #ifdef NEW_TEXTURES bind_texture(i->id); #else /* NEW_TEXTURES */ get_and_set_texture_id(i->id); #endif /* NEW_TEXTURES */ glBegin(GL_QUADS); draw_2d_thing(i->u, i->v, i->uend, i->vend,i->x, i->y-j,i->xend,i->yend-j); glEnd(); } i=i->Next; } #ifdef ENCYCL_NAVIGATION if (repeat_search && last_search != NULL) { find_page(last_search, NULL); repeat_search = 0; } if (show_cm_help) { show_help(cm_encycl_help_str, 0, win->len_y+10); show_cm_help = 0; } #endif return 1; }
int display_help_handler(window_info *win) { _Text *t=Page[helppage].T.Next; _Image *i=Page[helppage].I.Next; int j; j=vscrollbar_get_pos(help_win,0); while(t) { int ylen=(t->size)?18:15; int xlen=strlen(t->text)*((t->size)?11:8); if((t->y-j > 0) && (t->y-j < help_menu_y_len-20 )) { if(t->ref) { //draw a line glColor3f(0.5,0.5,0.5); glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); glVertex3i(t->x+4,t->y+ylen-j,0); glVertex3i(t->x+4+xlen-8,t->y+ylen-j,0); glEnd(); glEnable(GL_TEXTURE_2D); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE } if(t->size) { if(t->ref && mouse_x>(t->x+win->cur_x) && mouse_x<(t->x+xlen+win->cur_x) && mouse_y>(t->y+win->cur_y-j) && mouse_y<(t->y+ylen+win->cur_y-j)) glColor3f(0.3,0.6,1.0); else glColor3f(t->r,t->g,t->b); draw_string(t->x,t->y-j,(unsigned char*)t->text,1); } else { if(t->ref && mouse_x>(t->x+win->cur_x) && mouse_x<(t->x+xlen+win->cur_x) && mouse_y>(t->y+win->cur_y-j) && mouse_y<(t->y+ylen+win->cur_y-j)) glColor3f(0.3,0.6,1.0); else glColor3f(t->r,t->g,t->b); draw_string_small(t->x,t->y-j,(unsigned char*)t->text,1); } } t=t->Next; } glColor3f(1.0f,1.0f,1.0f); while(i) { if((i->y-j > 0) && (i->yend-j < help_menu_y_len-40 )) { if(i->mouseover==1) { i=i->Next; continue; } if(mouse_x>(i->x+win->cur_x) && mouse_x<(win->cur_x+i->xend) && mouse_y>(i->y+win->cur_y-j) && mouse_y<(win->cur_y+i->yend-j)) { if(i->Next!=NULL) { if(i->Next->mouseover==1) i=i->Next; } } #ifdef NEW_TEXTURES bind_texture(i->id); #else /* NEW_TEXTURES */ get_and_set_texture_id(i->id); #endif /* NEW_TEXTURES */ glBegin(GL_QUADS); draw_2d_thing(i->u, i->v, i->uend, i->vend,i->x, i->y-j,i->xend,i->yend-j); glEnd(); } i=i->Next; } return 1; }
int click_storage_handler(window_info * win, int mx, int my, Uint32 flags) { if(flags&ELW_WHEEL_UP) { if(mx>10 && mx<130) { vscrollbar_scroll_up(storage_win, STORAGE_SCROLLBAR_CATEGORIES); } else if(mx>150 && mx<352){ vscrollbar_scroll_up(storage_win, STORAGE_SCROLLBAR_ITEMS); } } else if(flags&ELW_WHEEL_DOWN) { if(mx>10 && mx<130) { vscrollbar_scroll_down(storage_win, STORAGE_SCROLLBAR_CATEGORIES); } else if(mx>150 && mx<352){ vscrollbar_scroll_down(storage_win, STORAGE_SCROLLBAR_ITEMS); } } else if ( (flags & ELW_MOUSE_BUTTON) == 0) { return 0; } else { if(my>10 && my<202){ if(mx>10 && mx<130){ int cat=-1; cat=(my-20)/13 + vscrollbar_get_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES); move_to_category(cat); do_click_sound(); } else if(mx>150 && mx<352){ if(view_only_storage && item_dragged!=-1 && left_click){ drop_fail_time = SDL_GetTicks(); do_alert1_sound(); } else if(!view_only_storage && item_dragged!=-1 && left_click){ Uint8 str[6]; str[0]=DEPOSITE_ITEM; str[1]=item_list[item_dragged].pos; *((Uint32*)(str+2))=SDL_SwapLE32(item_quantity); my_tcp_send(my_socket, str, 6); do_drop_item_sound(); if(item_list[item_dragged].quantity<=item_quantity) item_dragged=-1;//Stop dragging this item... } else if(right_click || (view_only_storage && left_click)){ storage_item_dragged=-1; item_dragged=-1; if(cur_item_over!=-1) { Uint8 str[3]; str[0]=LOOK_AT_STORAGE_ITEM; *((Uint16*)(str+1))=SDL_SwapLE16(storage_items[cur_item_over].pos); my_tcp_send(my_socket, str, 3); active_storage_item=storage_items[cur_item_over].pos; do_click_sound(); } } else if(!view_only_storage && cur_item_over!=-1){ storage_item_dragged=cur_item_over; active_storage_item=storage_items[cur_item_over].pos; do_drag_item_sound(); } } } } return 1; }