/* mouse over slots - show tool tips */ static int mouseover_manufacture_slot_handler(window_info *win, int mx, int my) { int pos; int check_for_eye = 0; int help_line = 0; /* See if we're over a message - and offer clear help if so */ if (show_help_text && *inventory_item_string && (my > manufacture_menu_y_len-85) && my < (manufacture_menu_y_len-37)) { show_help((disable_double_click)?click_clear_str :double_click_clear_str, 0, win->len_y + 10 + SMALL_FONT_Y_LEN*help_line++); } /* see if we're over an item in the main category */ pos=get_mouse_pos_in_grid(mx, my, 12, 3, 0, 0, SLOT_SIZE, SLOT_SIZE); if (pos >= 0 && manufacture_list[pos].quantity > 0){ if (show_help_text) show_help(manu_add_str, 0, win->len_y + 10 + SMALL_FONT_Y_LEN*help_line++); check_for_eye = 1; } /* see if we're over an item from the "production pipe" */ pos=get_mouse_pos_in_grid(mx, my, NUM_MIX_SLOTS, 1, 5, manufacture_menu_y_len-37, SLOT_SIZE, SLOT_SIZE); if (pos >= 0) { if (manufacture_list[MIX_SLOT_OFFSET+pos].quantity > 0){ if (show_help_text) show_help(manu_remove_str, 0, win->len_y + 10 + SMALL_FONT_Y_LEN*help_line++); check_for_eye = 1; } else show_help(recipe_show_hide_str, 0, win->len_y + 10 + SMALL_FONT_Y_LEN*help_line++); } /*check recipe controls*/ if (pos<0 && show_help_text) recipe_controls_mouseover_handler(win, mx,my,&help_line); // show the recipe search help if (show_help_text && !recipes_shown && !disable_manuwin_keypress) show_help(recipe_find_str, 0, win->len_y + 10 + SMALL_FONT_Y_LEN*help_line++); /* if we're over an occupied slot and the eye cursor function is active, show the eye cursor */ if (check_for_eye){ if (action_mode == ACTION_LOOK){ elwin_mouse = CURSOR_EYE; return 1; } } return 0; }
/* mouse over slots - show tool tips */ int mouseover_manufacture_slot_handler(window_info *win, int mx, int my) { int pos; int check_for_eye = 0; /* See if we're over a message - and offer clear help if so */ if (show_help_text && *inventory_item_string && (my > manufacture_menu_y_len-85) && my < (manufacture_menu_y_len-37)) { show_help((disable_double_click)?click_clear_str :double_click_clear_str, 0, win->len_y+10); } /* see if we clicked on any item in the main category */ pos=get_mouse_pos_in_grid(mx, my, 12, 3, 0, 0, 33, 33); if (pos >= 0 && manufacture_list[pos].quantity > 0){ if (show_help_text) show_help(manu_add_str, 0, manufacture_menu_y_len+10); check_for_eye = 1; } /* see if we clicked on any item from the "production pipe" */ pos=get_mouse_pos_in_grid(mx, my, 6, 1, 5, manufacture_menu_y_len-37, 33, 33); if (pos >= 0 && manufacture_list[36+pos].quantity > 0){ if (show_help_text) show_help(manu_remove_str, 0, manufacture_menu_y_len+10); check_for_eye = 1; } /*check recipe controls*/ if (show_help_text) recipe_controls_mouseover_handler(mx,my); /* if we're over an occupied slot and the eye cursor function is active, show the eye cursor */ if (check_for_eye){ if (action_mode == ACTION_LOOK){ elwin_mouse = CURSOR_EYE; return 1; } } return 0; }
int mouseover_ground_items_handler(window_info *win, int mx, int my) { int yoffset = get_window_scroll_pos(win->window_id); int pos = (yoffset>my) ?-1 :get_mouse_pos_in_grid(mx, my+1, ground_items_grid_cols, ground_items_grid_rows, 0, 0, GRIDSIZE, GRIDSIZE); if(pos!=-1 && pos<ITEMS_PER_BAG && ground_item_list[pos].quantity) { if(item_action_mode==ACTION_LOOK) { elwin_mouse=CURSOR_EYE; } else { elwin_mouse=CURSOR_PICK; } return 1; } return 0; }
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; }
static int click_manufacture_handler(window_info *win, int mx, int my, Uint32 flags) { int pos; Uint8 str[100]; int quantitytomove=1; if ((flags & ELW_CTRL) || (flags & ELW_SHIFT) || (flags & ELW_ALT)) quantitytomove = 10; /* if the eye cursor is active and we right click, change to standard walk */ if(action_mode==ACTION_LOOK && (flags&ELW_RIGHT_MOUSE)) action_mode = ACTION_WALK; //see if we clicked on any item in the main category pos=get_mouse_pos_in_grid(mx, my, GRID_COLS, GRID_ROWS, 0, 0, SLOT_SIZE, SLOT_SIZE); if (pos >= 0 && manufacture_list[pos].quantity > 0) { if(action_mode==ACTION_LOOK || (flags&ELW_RIGHT_MOUSE)) { str[0]=LOOK_AT_INVENTORY_ITEM; str[1]=manufacture_list[pos].pos; my_tcp_send(my_socket,str,2); return 1; } else { int j; last_changed_slot=-1; for(j=MIX_SLOT_OFFSET;j<MIX_SLOT_OFFSET+NUM_MIX_SLOTS;j++) if(manufacture_list[j].pos==manufacture_list[pos].pos && manufacture_list[j].quantity > 0){ //found an empty space in the "production pipe" if (flags & ELW_WHEEL_UP) { if (manufacture_list[j].quantity < quantitytomove) quantitytomove = -manufacture_list[j].quantity; else quantitytomove*=-1; } else if (manufacture_list[pos].quantity < quantitytomove) quantitytomove = manufacture_list[pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[pos].pos; manufacture_list[j].image_id=manufacture_list[pos].image_id; manufacture_list[j].id=manufacture_list[pos].id; manufacture_list[pos].quantity -= quantitytomove; copy_recipe_from_manu_list(manu_recipe.items); do_click_sound(); return 1; } for(j=MIX_SLOT_OFFSET;j<MIX_SLOT_OFFSET+NUM_MIX_SLOTS;j++) if(manufacture_list[j].quantity <= 0){ //found an empty space in the "production pipe" if (flags & ELW_WHEEL_UP) return 1; //quantity already 0 in production pipeline if (manufacture_list[pos].quantity < quantitytomove) quantitytomove = manufacture_list[pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[pos].pos; manufacture_list[j].image_id=manufacture_list[pos].image_id; manufacture_list[j].id=manufacture_list[pos].id; manufacture_list[pos].quantity -= quantitytomove; copy_recipe_from_manu_list(manu_recipe.items); do_click_sound(); return 1; } } } else if (pos>=0) last_changed_slot=-1; //see if we clicked on any item from the "production pipe" pos=get_mouse_pos_in_grid(mx, my, NUM_MIX_SLOTS, 1, pipeline_x, manufacture_menu_y_len-recipe_y_offset, SLOT_SIZE, SLOT_SIZE); if (pos >= 0 && manufacture_list[MIX_SLOT_OFFSET+pos].quantity > 0) { if(action_mode==ACTION_LOOK || (flags&ELW_RIGHT_MOUSE)){ str[0]=LOOK_AT_INVENTORY_ITEM; str[1]=manufacture_list[MIX_SLOT_OFFSET+pos].pos; my_tcp_send(my_socket,str,2); return 1; } else { int j; last_changed_slot=pos; for(j=0;j<MIX_SLOT_OFFSET;j++) if(manufacture_list[j].quantity && manufacture_list[j].pos==manufacture_list[MIX_SLOT_OFFSET+pos].pos){ //found item in ingredients slot, move from "production pipe" back to this slot if (flags & ELW_WHEEL_DOWN) { if (manufacture_list[MIX_SLOT_OFFSET+pos].quantity < quantitytomove) quantitytomove = -manufacture_list[MIX_SLOT_OFFSET+pos].quantity; else quantitytomove*=-1; } else if (manufacture_list[MIX_SLOT_OFFSET+pos].quantity < quantitytomove) quantitytomove = manufacture_list[MIX_SLOT_OFFSET+pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[MIX_SLOT_OFFSET+pos].pos; manufacture_list[j].image_id=manufacture_list[MIX_SLOT_OFFSET+pos].image_id; manufacture_list[j].id=manufacture_list[MIX_SLOT_OFFSET+pos].id; manufacture_list[MIX_SLOT_OFFSET+pos].quantity -= quantitytomove; copy_recipe_from_manu_list(manu_recipe.items); do_click_sound(); return 1; } for(j=0;j<MIX_SLOT_OFFSET;j++) if(!manufacture_list[j].quantity){ //found item in ingredients slot, move from "production pipe" back to this slot if (manufacture_list[MIX_SLOT_OFFSET+pos].quantity < quantitytomove) quantitytomove = manufacture_list[MIX_SLOT_OFFSET+pos].quantity; //handles mouse wheel if (flags & ELW_WHEEL_DOWN) return 1; //No more items to put in production pipe manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[MIX_SLOT_OFFSET+pos].pos; manufacture_list[j].image_id=manufacture_list[MIX_SLOT_OFFSET+pos].image_id; manufacture_list[j].id=manufacture_list[MIX_SLOT_OFFSET+pos].id; manufacture_list[MIX_SLOT_OFFSET+pos].quantity -= quantitytomove; copy_recipe_from_manu_list(manu_recipe.items); do_click_sound(); return 1; } } } else if (pos>=0) { //click on an empty slot //handle the mouse wheel if (recipes_loaded && (pos!=last_changed_slot)) { if (((flags&ELW_WHEEL_UP)||(flags&ELW_WHEEL_DOWN)) && recipe_win >= 0 && recipe_win < windows_list.num_windows) { //simulate a click on the dropdown last_changed_slot=-1; recipe_dropdown_click_handler(&windows_list.window[recipe_win],0,0,flags); use_recipe(cur_recipe); build_manufacture_list(); } else { toggle_recipe_window(); } do_click_sound(); return 0; } } else last_changed_slot=-1; //see if we clicked on the recipe handler recipe_controls_click_handler(win,mx,my,flags); // clear the message area if double-clicked if ((my > manufacture_menu_y_len-text_y_offset) && my < (manufacture_menu_y_len-recipe_y_offset)) { static Uint32 last_click = 0; if (safe_button_click(&last_click)) { set_shown_string(0,""); return 1; } } return 0; }
/* mouse over slots - show tool tips */ static int mouseover_manufacture_slot_handler(window_info *win, int mx, int my) { int pos; int check_for_eye = 0; int help_line = 0; const char *descp_str = NULL; /* Do nothing when mouse over title bar */ if (my<0) return 0; /* See if we're over a message - and offer clear help if so */ if (show_help_text && *inventory_item_string && (my > manufacture_menu_y_len-text_y_offset) && my < (manufacture_menu_y_len-recipe_y_offset)) { show_help((disable_double_click) ?click_clear_str :double_click_clear_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); } /* see if we're over an item in the main category */ pos=get_mouse_pos_in_grid(mx, my, GRID_COLS, GRID_ROWS, 0, 0, SLOT_SIZE, SLOT_SIZE); if (pos >= 0 && manufacture_list[pos].quantity > 0){ if (show_help_text) show_help(manu_add_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); if (show_item_desc_text && item_info_available() && (get_item_count(manufacture_list[pos].id, manufacture_list[pos].image_id) == 1)) descp_str = get_item_description(manufacture_list[pos].id, manufacture_list[pos].image_id); check_for_eye = 1; mouse_over_main_pos = pos; } /* see if we're over an item from the "production pipe" */ pos=get_mouse_pos_in_grid(mx, my, NUM_MIX_SLOTS, 1, pipeline_x, manufacture_menu_y_len-recipe_y_offset, SLOT_SIZE, SLOT_SIZE); if (pos >= 0) { if (manufacture_list[MIX_SLOT_OFFSET+pos].quantity > 0){ if (show_help_text) show_help(manu_remove_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); check_for_eye = 1; mouse_over_pipe_pos = pos; } else if (pos != last_changed_slot) show_help(recipe_show_hide_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); } /*check recipe controls*/ if (pos<0 && show_help_text) recipe_controls_mouseover_handler(win, mx,my,&help_line); // show the recipe search help if (show_help_text && !recipes_shown && !disable_manuwin_keypress) show_help(recipe_find_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); /* if set, show the description last */ if (descp_str != NULL) show_help(descp_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); /* if we're over an occupied slot and the eye cursor function is active, show the eye cursor */ if (check_for_eye){ if (action_mode == ACTION_LOOK){ elwin_mouse = CURSOR_EYE; return 1; } } return 0; }
int click_manufacture_handler(window_info *win, int mx, int my, Uint32 flags) { int pos; static int last_slot=-1; Uint8 str[100]; int quantitytomove=1; if ((flags & ELW_CTRL) || (flags & ELW_SHIFT) || (flags & ELW_ALT)) quantitytomove = 10; /* if the eye cursor is active and we right click, change to standard walk */ if(action_mode==ACTION_LOOK && (flags&ELW_RIGHT_MOUSE)) action_mode = ACTION_WALK; //see if we clicked on any item in the main category pos=get_mouse_pos_in_grid(mx, my, 12, 3, 0, 0, 33, 33); if (pos >= 0 && manufacture_list[pos].quantity > 0) { if(action_mode==ACTION_LOOK || (flags&ELW_RIGHT_MOUSE)) { str[0]=LOOK_AT_INVENTORY_ITEM; str[1]=manufacture_list[pos].pos; my_tcp_send(my_socket,str,2); return 1; } else { int j; last_slot=-1; for(j=36;j<36+6;j++) if(manufacture_list[j].pos==manufacture_list[pos].pos && manufacture_list[j].quantity > 0){ //found an empty space in the "production pipe" if (flags & ELW_WHEEL_UP) { if (manufacture_list[j].quantity < quantitytomove) quantitytomove = -manufacture_list[j].quantity; else quantitytomove*=-1; } else if (manufacture_list[pos].quantity < quantitytomove) quantitytomove = manufacture_list[pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[pos].pos; manufacture_list[j].image_id=manufacture_list[pos].image_id; manufacture_list[pos].quantity -= quantitytomove; copy_recipe(); return 1; } for(j=36;j<36+6;j++) if(!manufacture_list[j].quantity > 0){ //found an empty space in the "production pipe" if (flags & ELW_WHEEL_UP) return 1; //quantity already 0 in production pipeline if (manufacture_list[pos].quantity < quantitytomove) quantitytomove = manufacture_list[pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[pos].pos; manufacture_list[j].image_id=manufacture_list[pos].image_id; manufacture_list[pos].quantity -= quantitytomove; copy_recipe(); return 1; } } } else if (pos>=0) last_slot=-1; //see if we clicked on any item from the "production pipe" pos=get_mouse_pos_in_grid(mx, my, 6, 1, 5, manufacture_menu_y_len-37, 33, 33); if (pos >= 0 && manufacture_list[36+pos].quantity > 0) { if(action_mode==ACTION_LOOK || (flags&ELW_RIGHT_MOUSE)){ str[0]=LOOK_AT_INVENTORY_ITEM; str[1]=manufacture_list[36+pos].pos; my_tcp_send(my_socket,str,2); return 1; } else { int j; last_slot=pos; for(j=0;j<36;j++) if(manufacture_list[j].quantity && manufacture_list[j].pos==manufacture_list[36+pos].pos){ //found item in ingredients slot, move from "production pipe" back to this slot if (flags & ELW_WHEEL_DOWN) { if (manufacture_list[36+pos].quantity < quantitytomove) quantitytomove = -manufacture_list[36+pos].quantity; else quantitytomove*=-1; } else if (manufacture_list[36+pos].quantity < quantitytomove) quantitytomove = manufacture_list[36+pos].quantity; manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[36+pos].pos; manufacture_list[j].image_id=manufacture_list[36+pos].image_id; manufacture_list[36+pos].quantity -= quantitytomove; copy_recipe(); return 1; } for(j=0;j<36;j++) if(!manufacture_list[j].quantity){ //found item in ingredients slot, move from "production pipe" back to this slot if (manufacture_list[36+pos].quantity < quantitytomove) quantitytomove = manufacture_list[36+pos].quantity; //handles mouse wheel if (flags & ELW_WHEEL_DOWN) return 1; //No more items to put in production pipe manufacture_list[j].quantity += quantitytomove; manufacture_list[j].pos=manufacture_list[36+pos].pos; manufacture_list[j].image_id=manufacture_list[36+pos].image_id; manufacture_list[36+pos].quantity -= quantitytomove; copy_recipe(); return 1; } } } else if (pos>=0) { //click on an empty slot //handle the mouse wheel if (pos!=last_slot && ((flags&ELW_WHEEL_UP)||(flags&ELW_WHEEL_DOWN))) { //simulate a click on the dropdown last_slot=-1; recipe_dropdown_click_handler(win,0,0,flags); use_recipe(cur_recipe); build_manufacture_list(); return 0; } } else last_slot=-1; //see if we clicked on the recipe handler recipe_controls_click_handler(mx,my,flags); // clear the message area if double-clicked if ((my > manufacture_menu_y_len-85) && my < (manufacture_menu_y_len-37)) { static Uint32 last_click = 0; if (safe_button_click(&last_click)) { set_shown_string(0,""); return 1; } } return 0; }
int click_ground_items_handler(window_info *win, int mx, int my, Uint32 flags) { int pos; Uint8 str[10]; int right_click = flags & ELW_RIGHT_MOUSE; int ctrl_on = flags & ELW_CTRL; int yoffset = get_window_scroll_pos(win->window_id); // only handle mouse button clicks, not scroll wheels moves if ( (flags & ELW_MOUSE_BUTTON) == 0) { return 0; } if(right_click) { if(item_dragged != -1) { item_dragged = -1; } else if(item_action_mode == ACTION_LOOK) { item_action_mode = ACTION_WALK; } else { item_action_mode = ACTION_LOOK; } return 1; } // see if we clicked on the "Get All" box if(mx>(win->len_x-GRIDSIZE) && mx<win->len_x && my>ELW_BOX_SIZE && my<GRIDSIZE+ELW_BOX_SIZE){ pick_up_all_items(); do_get_item_sound(); return 1; } pos = (my<0) ?-1 :get_mouse_pos_in_grid(mx,my+yoffset+1,ground_items_grid_cols,ground_items_grid_rows,0,0,GRIDSIZE,GRIDSIZE); if(pos==-1 || pos>=ITEMS_PER_BAG){ } else if(!ground_item_list[pos].quantity) { if (item_dragged != -1){ str[0] = DROP_ITEM; str[1] = item_dragged; *((Uint32 *) (str + 2)) = SDL_SwapLE32(item_quantity); my_tcp_send(my_socket, str, 6); do_drop_item_sound(); } } else if(item_action_mode==ACTION_LOOK) { str[0]= LOOK_AT_GROUND_ITEM; str[1]= ground_item_list[pos].pos; my_tcp_send(my_socket,str,2); } else { int quantity; quantity= ground_item_list[pos].quantity; if(quantity > item_quantity && !ctrl_on) quantity= item_quantity; str[0]= PICK_UP_ITEM; str[1]= ground_item_list[pos].pos; *((Uint32 *)(str+2))= SDL_SwapLE32(quantity); my_tcp_send(my_socket,str,6); do_get_item_sound(); } return 1; }