All pastes #22635 Raw Edit

Anonymous

public c v1 · immutable
#22635 ·published 2005-09-11 10:59 UTC
rendered paste body
int	click_quickbar_handler(window_info *win, int mx, int my, Uint32 flags){	int i,y;	int x_screen,y_screen;	Uint8 str[100];	int trigger=ELW_LEFT_MOUSE|ELW_CTRL|ELW_SHIFT;//flags we'll use for the quickbar relocation handling	int right_click = flags & ELW_RIGHT_MOUSE;	// only handle mouse button clicks, not scroll wheels moves	if ( (flags & ELW_MOUSE_BUTTON) == 0) return 0;	/*if(right_click) {		switch(qb_action_mode) {		case ACTION_WALK:			qb_action_mode=ACTION_LOOK;			break;		case ACTION_LOOK:			qb_action_mode=ACTION_USE;			break;		case ACTION_USE:			qb_action_mode=ACTION_USE_WITEM;			break;		case ACTION_USE_WITEM:			if(use_item!=-1)				use_item=-1;			else				qb_action_mode=ACTION_WALK;			break;		default:			use_item=-1;			qb_action_mode=ACTION_WALK;		}		return 1;	}*/	/*qb_action_mode = ACTION_WALK;	if(qb_action_mode==ACTION_USE_WITEM)	action_mode=ACTION_USE_WITEM;	if(qb_action_mode==ACTION_USE)		action_mode=ACTION_USE;*/	// no in window check needed, already done	//see if we clicked on any item in the main category	for(y=0;y<6;y++)		{			if(quickbar_dir==VERTICAL)				{					x_screen=0;					y_screen=y*30;				}			else				{					x_screen=y*30;					y_screen=0;				}			if(mx>x_screen && mx<x_screen+30 && my>y_screen && my<y_screen+30)				{					//see if there is an empty space to drop this item over.					if(item_dragged!=-1)//we have to drop this item						{					//		int any_item=0;							for(i=0;i<6;i++)								{									//if(item_list[i].quantity && item_list[i].pos==y)									if (item_list[item_dragged].image_id == quickbar_items[i].image_id)										{									//		any_item=1;									//		if(item_dragged==i)//drop the item only over itself									//			item_dragged=-1;									//		return 1;										 /* We're dragging something we                                       already have in our QB, pretend that's it*/                                   	item_dragged = quickbar_items[i].pos;                                   	break;										}								}//							if(!any_item)							}                           if (item_dragged == quickbar_items[y].pos)                           { /* It's already in that slot */                               item_dragged = -1;                               return 1;                           }                           else                           {                               for (i = 0; i < 6; i++)								{									if (quickbar_items[i].pos == item_dragged)                                   {                                       quickbar_items[i].image_id = quickbar_items[y].image_id;                                       quickbar_items[i].pos = quickbar_items[y].pos;                                       break;                                   }								}                           }                           quickbar_items[y].pos = item_dragged;                           quickbar_items[y].image_id = item_list[item_dragged].image_id;                           item_dragged = -1;                           save_quickbar();                           return 1;						}					if(quickbar_relocatable>0)						{							if((flags&trigger)==(ELW_LEFT_MOUSE|ELW_CTRL))							{								//toggle draggable								Uint32 flags = get_flags(quickbar_win);																if (!quickbar_draggable)								{									flags &= ~ELW_SHOW_LAST;									flags |= ELW_DRAGGABLE | ELW_TITLE_BAR;									change_flags (quickbar_win, flags);									quickbar_draggable = 1;								}								else 								{									flags |= ELW_SHOW_LAST;									flags &= ~(ELW_DRAGGABLE | ELW_TITLE_BAR);									change_flags (quickbar_win, flags);									quickbar_draggable = 0;									quickbar_x = window_width - windows_list.window[quickbar_win].cur_x;									quickbar_y = windows_list.window[quickbar_win].cur_y;								}							}							else if ( (flags & trigger)== (ELW_LEFT_MOUSE | ELW_SHIFT) && (get_flags (quickbar_win) & (ELW_TITLE_BAR | ELW_DRAGGABLE)) == (ELW_TITLE_BAR | ELW_DRAGGABLE) )							{								//toggle vertical/horisontal								flip_quickbar();							}							else if (((flags&trigger)==trigger))								{									//reset									reset_quickbar();								}						}					//see if there is any item there					//for(i=0;i<6;i++)								   i = quickbar_items[y].pos;                   //should we get the info for it?                   if(item_list[i].quantity)					{                           if(ctrl_on){                               str[0]=DROP_ITEM;                               str[1]=item_list[i].pos;                               *((Uint16 *)(str+2))=item_list[i].quantity;                               my_tcp_send(my_socket, str, 4);                               return 1;                           } else if(action_mode==ACTION_LOOK)                               {                                   click_time=cur_time;                                   str[0]=LOOK_AT_INVENTORY_ITEM;                                   str[1]=item_list[i].pos;                                   my_tcp_send(my_socket,str,2);                               }                           else if(action_mode==ACTION_USE || right_click)                               {                                   if(i != -1 && item_list[i].use_with_inventory                                       && item_list[i].quantity)										{										    str[0]=USE_INVENTORY_ITEM;											str[1]=item_list[i].pos;											my_tcp_send(my_socket,str,2);										}											return 1;										}                                   return 1;                               }                           else if(action_mode==ACTION_USE_WITEM) {                               if(use_item!=-1) {                                   str[0]=ITEM_ON_ITEM;                                   str[1]=item_list[use_item].pos;                                   str[2]=item_list[i].pos;                                   my_tcp_send(my_socket,str,3);                                   use_item=-1;                               }                               else                                   use_item=i;                               return 1;                           }                           else//we might test for other things first, like use or drop                               {								   if(item_dragged==-1)//we have to drag this item																		{													item_dragged=i;									}	                           return 1;		                       }        		               else if ((i == -1 || item_list[i].quantity < 1) && right_click)                       {                           switch(action_mode)                           {                               case ACTION_WALK:                                   action_mode=ACTION_LOOK;                                   break;                               case ACTION_LOOK:                                   action_mode=ACTION_USE;                                   break;                               case ACTION_USE:                                   action_mode=ACTION_USE_WITEM;                                   break;                               case ACTION_USE_WITEM:                                   if(use_item!=-1)                                       use_item=-1;                                   else                                       action_mode=ACTION_WALK;                                   break;                               default:                                   use_item=-1;                                   action_mode=ACTION_WALK;								}						}				}		}	return 1;}