mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-13 18:02:01 -04:00
fast trade and fast actions using ctrl+click
This commit is contained in:
parent
9e5faf53de
commit
6385447b6e
3 changed files with 147 additions and 117 deletions
|
@ -489,6 +489,14 @@ int click_map_size=0;
|
||||||
T_CLK_MAP *global_click_map=NULL;
|
T_CLK_MAP *global_click_map=NULL;
|
||||||
int global_click_map_size=0;
|
int global_click_map_size=0;
|
||||||
|
|
||||||
|
const T_CLK_MAP * find_in_click_map_entry(int x, int y,T_CLK_MAP *pt,int pocet,int evtype) {
|
||||||
|
while (pocet--) {
|
||||||
|
if (x>=pt->xlu && x<=pt->xrb && y>=pt->ylu && y<=pt->yrb && (evtype & pt->mask)) return pt;
|
||||||
|
pt++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int find_in_click_map(MS_EVENT *ms,T_CLK_MAP *pt,int pocet,int *evtype)
|
int find_in_click_map(MS_EVENT *ms,T_CLK_MAP *pt,int pocet,int *evtype)
|
||||||
{
|
{
|
||||||
int mscur=-1;
|
int mscur=-1;
|
||||||
|
|
|
@ -791,6 +791,7 @@ extern T_CLK_MAP clk_main_view[]; //clickovaci mapa pro hlavni vyhled
|
||||||
|
|
||||||
void change_click_map(T_CLK_MAP *map,int mapsize);
|
void change_click_map(T_CLK_MAP *map,int mapsize);
|
||||||
void ms_clicker(EVENT_MSG *msg,void **usr);
|
void ms_clicker(EVENT_MSG *msg,void **usr);
|
||||||
|
const T_CLK_MAP * find_in_click_map_entry(int x, int y,T_CLK_MAP *pt,int pocet,int evtype);
|
||||||
void restore_click_map(void *map,int mapsize);
|
void restore_click_map(void *map,int mapsize);
|
||||||
void save_click_map(void **map,int *mapsize);
|
void save_click_map(void **map,int *mapsize);
|
||||||
void set_game_click_map(void);
|
void set_game_click_map(void);
|
||||||
|
|
255
game/inv.c
255
game/inv.c
|
@ -812,7 +812,7 @@ T_CLK_MAP clk_inv_view[]=
|
||||||
{1,236,220,255,239,ring_place,2,-1},
|
{1,236,220,255,239,ring_place,2,-1},
|
||||||
{2,236,255,255,274,ring_place,2,-1},
|
{2,236,255,255,274,ring_place,2,-1},
|
||||||
{3,236,290,255,309,ring_place,2,-1},
|
{3,236,290,255,309,ring_place,2,-1},
|
||||||
{0,0,200,29,309,uloz_sip,MS_EVENT_MOUSE_LPRESS|MS_EVENT_MOUSE_LDBLCLK,-1},
|
{0,0,200,29,309,uloz_sip,MS_EVENT_MOUSE_LPRESS,-1},
|
||||||
{-1,37,34,225,336,human_click,2,-1},
|
{-1,37,34,225,336,human_click,2,-1},
|
||||||
{-1,45,339,212,358,inv_swap_desk,2,H_MS_DEFAULT},
|
{-1,45,339,212,358,inv_swap_desk,2,H_MS_DEFAULT},
|
||||||
{-1,54,378,497,479,start_invetory,2+8,-1},
|
{-1,54,378,497,479,start_invetory,2+8,-1},
|
||||||
|
@ -1756,54 +1756,58 @@ char vejdou_se(int pocet)
|
||||||
return pocet>0;
|
return pocet>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char uloz_sip_action(char fast_key);
|
||||||
char uloz_sip(int id,int xa,int ya,int xr,int yr)
|
char uloz_sip(int id,int xa,int ya,int xr,int yr)
|
||||||
{
|
{
|
||||||
id;xa;ya;xr;yr;
|
id;xa;ya;xr;yr;
|
||||||
|
uloz_sip_action(get_control_key_state());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char uloz_sip_action(char fast_key) {
|
||||||
if (isdemon(human_selected)) return 0;
|
if (isdemon(human_selected)) return 0;
|
||||||
if (neprezbrojit()) return 0;
|
if (neprezbrojit()) return 0;
|
||||||
if (picked_item!=NULL && picked_item[1]==0 && glob_items[picked_item[0]-1].umisteni==PL_SIP) {
|
if (picked_item!=NULL && picked_item[1]==0 && glob_items[picked_item[0]-1].umisteni==PL_SIP) {
|
||||||
char notdblclk = !(ms_last_event.event_type & MS_EVENT_MOUSE_LDBLCLK);
|
int pocet=glob_items[picked_item[0]-1].user_value;
|
||||||
if (notdblclk) {
|
if (pocet==0) pocet=1;
|
||||||
int pocet=glob_items[picked_item[0]-1].user_value;
|
if (human_selected->sipy+pocet>99) return 1;
|
||||||
if (pocet==0) pocet=1;
|
human_selected->sipy+=pocet;
|
||||||
if (human_selected->sipy+pocet>99) return 1;
|
free(picked_item);
|
||||||
human_selected->sipy+=pocet;
|
picked_item=NULL;
|
||||||
free(picked_item);
|
} else {
|
||||||
picked_item=NULL;
|
|
||||||
} else if (glob_items[picked_item[0]-1].user_value <= 1) {
|
|
||||||
int best_item = -1;
|
|
||||||
int max_arrows = 1;
|
|
||||||
for (int i = 0; i < item_count; ++i) {
|
|
||||||
if (glob_items[i].umisteni == PL_SIP
|
|
||||||
&& glob_items[i].user_value > max_arrows
|
|
||||||
&& glob_items[i].user_value <= human_selected->sipy+1) {
|
|
||||||
max_arrows = glob_items[i].user_value;
|
|
||||||
best_item = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (best_item>=0) {
|
|
||||||
picked_item[0] = best_item+1;
|
|
||||||
human_selected->sipy-=max_arrows-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
if (picked_item==NULL && human_selected->sipy)
|
if (picked_item==NULL && human_selected->sipy)
|
||||||
{
|
{
|
||||||
short x[2];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=0;i<item_count;i++) if (glob_items[i].umisteni==PL_SIP && glob_items[i].user_value==0)
|
if (fast_key) {
|
||||||
{
|
int best_item = -1;
|
||||||
x[0]=i+1;
|
int max_arrows = 1;
|
||||||
x[1]=0;
|
for (int i = 0; i < item_count; ++i) {
|
||||||
picked_item=(short *)getmem(2*sizeof(short));
|
if (glob_items[i].umisteni == PL_SIP
|
||||||
memcpy(picked_item,x,sizeof(short)*2);
|
&& glob_items[i].user_value > max_arrows
|
||||||
human_selected->sipy--;
|
&& glob_items[i].user_value <= human_selected->sipy) {
|
||||||
break;
|
max_arrows = glob_items[i].user_value;
|
||||||
}
|
best_item = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (best_item>=0) {
|
||||||
|
picked_item = (short *)getmem(2*sizeof(short));
|
||||||
|
picked_item[0] = best_item+1;
|
||||||
|
picked_item[1] = 0;
|
||||||
|
human_selected->sipy-=max_arrows;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i=0;i<item_count;i++) if (glob_items[i].umisteni==PL_SIP && glob_items[i].user_value==0)
|
||||||
|
{
|
||||||
|
picked_item=(short *)getmem(2*sizeof(short));
|
||||||
|
picked_item[0] = i+1;
|
||||||
|
picked_item[1] = 0;
|
||||||
|
human_selected->sipy--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pick_set_cursor();
|
pick_set_cursor();
|
||||||
inv_redraw();
|
inv_redraw();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1864,13 +1868,19 @@ static char MakeItemCombinations(short *itm1, short *itm2)
|
||||||
return succ;
|
return succ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char bag_action(int xr, int yr);
|
||||||
char bag_click(int id,int xa,int ya,int xr,int yr)
|
char bag_click(int id,int xa,int ya,int xr,int yr)
|
||||||
{
|
{
|
||||||
short p,*pk;
|
|
||||||
|
|
||||||
if (inv_view_mode || human_selected->stare_vls[VLS_KOUZLA] & SPL_DEMON || human_selected->vlastnosti[VLS_KOUZLA] & SPL_STONED) return vls_click(id,xa,ya,xr,yr);
|
if (inv_view_mode || human_selected->stare_vls[VLS_KOUZLA] & SPL_DEMON || human_selected->vlastnosti[VLS_KOUZLA] & SPL_STONED) return vls_click(id,xa,ya,xr,yr);
|
||||||
xa;ya;
|
xa;ya;id;
|
||||||
id=(xr/INV_XS)+6*(yr/INV_YS);
|
return bag_action(xr, yr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static char bag_action(int xr, int yr) {
|
||||||
|
int id=(xr/INV_XS)+6*(yr/INV_YS);
|
||||||
|
short p,*pk;
|
||||||
if (id>=human_selected->inv_size) return 0;
|
if (id>=human_selected->inv_size) return 0;
|
||||||
pk=picked_item;
|
pk=picked_item;
|
||||||
if (pk!=NULL)
|
if (pk!=NULL)
|
||||||
|
@ -2201,6 +2211,15 @@ char human_click(int id,int xa,int ya,int xr,int yr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void fast_inv_action(void) {
|
||||||
|
int x = ms_last_event.x;
|
||||||
|
int y = ms_last_event.y;
|
||||||
|
const T_CLK_MAP *item = find_in_click_map_entry(x, y, clk_inv_view, CLK_INV_VIEW, MS_EVENT_MOUSE_LPRESS);
|
||||||
|
if (item->proc == &uloz_sip) {
|
||||||
|
uloz_sip_action(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void inv_keyboard(EVENT_MSG *msg,void **usr)
|
void inv_keyboard(EVENT_MSG *msg,void **usr)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
@ -2211,20 +2230,15 @@ void inv_keyboard(EVENT_MSG *msg,void **usr)
|
||||||
c=quit_request_as_escape(va_arg(msg->data, int))>>8;
|
c=quit_request_as_escape(va_arg(msg->data, int))>>8;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 0x17:
|
default:break;
|
||||||
|
case 0x17: //i
|
||||||
case 1:unwire_inv_mode();
|
case 1:unwire_inv_mode();
|
||||||
wire_proc();
|
wire_proc();
|
||||||
inv_view_mode=0;
|
inv_view_mode=0;
|
||||||
break;
|
break;
|
||||||
case 28:
|
case 57:
|
||||||
case 15:
|
fast_inv_action();
|
||||||
case 50:
|
break;
|
||||||
if (GlobEvent(MAGLOB_BEFOREMAPOPEN,viewsector,viewdir))
|
|
||||||
{
|
|
||||||
unwire_inv_mode();
|
|
||||||
show_automap(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2768,14 +2782,20 @@ static void redraw_keepers_items()
|
||||||
showview(BUYBOX_X,BUYBOX_Y,w[0],w[1]);
|
showview(BUYBOX_X,BUYBOX_Y,w[0],w[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static char shop_keeper_action(int xr, int yr, char fast_trade);
|
||||||
char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
||||||
id;
|
id;
|
||||||
xa;
|
xr;
|
||||||
ya;
|
yr;
|
||||||
|
return shop_keeper_action(xa, ya, get_control_key_state());
|
||||||
|
}
|
||||||
|
static char shop_keeper_action(int xa, int ya, char fast_trade) {
|
||||||
|
int xr = (xa - BUYBOX_X - SHP_ICPLCX);
|
||||||
|
int yr = (ya - BUYBOX_Y - SHP_ICPLCY);
|
||||||
if (picked_item == NULL) {
|
if (picked_item == NULL) {
|
||||||
int i, j;
|
int i, j;
|
||||||
xr = (xa - BUYBOX_X - SHP_ICPLCX);
|
|
||||||
yr = (ya - BUYBOX_Y - SHP_ICPLCY);
|
|
||||||
if (xr < 0 || yr < 0)
|
if (xr < 0 || yr < 0)
|
||||||
return 0;
|
return 0;
|
||||||
xr /= SHP_ICSIZX;
|
xr /= SHP_ICSIZX;
|
||||||
|
@ -2792,8 +2812,7 @@ char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
||||||
redraw_keepers_items();
|
redraw_keepers_items();
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
update_mysky();
|
update_mysky();
|
||||||
if ((get_control_key_state()) && (game_extras & EX_FAST_TRADE)
|
if (fast_trade && get_sell_price(*picked_item) <= money) {
|
||||||
&& get_sell_price(*picked_item) <= money) {
|
|
||||||
play_sample_at_channel(H_SND_OBCHOD, 1, 100);
|
play_sample_at_channel(H_SND_OBCHOD, 1, 100);
|
||||||
money -= get_sell_price(*picked_item);
|
money -= get_sell_price(*picked_item);
|
||||||
sell_item(*picked_item);
|
sell_item(*picked_item);
|
||||||
|
@ -2808,31 +2827,16 @@ char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (cur_owner == -1) {
|
} else if (cur_owner == -1) {
|
||||||
char notdblclk = !(ms_last_event.event_type & MS_EVENT_MOUSE_LDBLCLK);
|
free(picked_item);
|
||||||
if (notdblclk || get_sell_price(*picked_item) > money) {
|
picked_item = NULL;
|
||||||
free(picked_item);
|
rebuild_keepers_items();
|
||||||
picked_item = NULL;
|
schovej_mysku();
|
||||||
rebuild_keepers_items();
|
pick_set_cursor();
|
||||||
schovej_mysku();
|
redraw_keepers_items();
|
||||||
pick_set_cursor();
|
ukaz_mysku();
|
||||||
redraw_keepers_items();
|
update_mysky();
|
||||||
ukaz_mysku();
|
cur_owner = 0;
|
||||||
update_mysky();
|
return 1;
|
||||||
cur_owner = 0;
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
play_sample_at_channel(H_SND_OBCHOD, 1, 100);
|
|
||||||
money -= get_sell_price(*picked_item);
|
|
||||||
sell_item(*picked_item);
|
|
||||||
if (put_item_to_inv(human_selected, picked_item)) {
|
|
||||||
picked_item = NULL;
|
|
||||||
pick_set_cursor();
|
|
||||||
}
|
|
||||||
rebuild_keepers_items();
|
|
||||||
cur_owner = picked_item != NULL;
|
|
||||||
redraw_shop();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cur_owner != -1 && picked_item != NULL) {
|
if (cur_owner != -1 && picked_item != NULL) {
|
||||||
int price, z;
|
int price, z;
|
||||||
|
@ -2892,41 +2896,44 @@ char shop_keeper_click(int id, int xa, int ya, int xr, int yr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char shop_bag_click(int id, int xa, int ya, int xr, int yr) {
|
static char shop_bag_action(int xr,int yr, char fast_trade);
|
||||||
char s[200], p;
|
char shop_bag_click(int id,int xa,int ya,int xr,int yr) {
|
||||||
int price, z;
|
id;xa;ya;
|
||||||
const TPRODUCT *pp;
|
return shop_bag_action(xr, yr, get_control_key_state());
|
||||||
if (cur_owner > -1) {
|
}
|
||||||
char notdblclk = !(ms_last_event.event_type & MS_EVENT_MOUSE_LDBLCLK);
|
static char shop_bag_action(int xr,int yr, char fast_trade)
|
||||||
if (notdblclk) {
|
{
|
||||||
id = bag_click(id, xa, ya, xr, yr);
|
char s[200],p;
|
||||||
} else {
|
int price,z;
|
||||||
id = 1;
|
const TPRODUCT *pp;
|
||||||
}
|
if (cur_owner>-1)
|
||||||
cur_owner = picked_item != NULL;
|
{
|
||||||
if (picked_item != NULL && picked_item[1] == 0 && !notdblclk) {
|
char id=bag_action(xr,yr);
|
||||||
short z;
|
cur_owner=picked_item!=NULL;
|
||||||
price = make_offer(z = picked_item[0]);
|
if (picked_item!=NULL && picked_item[1]==0 && fast_trade)
|
||||||
if (price) {
|
{
|
||||||
play_sample_at_channel(H_SND_OBCHOD, 1, 100);
|
short z;
|
||||||
buy_item(z);
|
price=make_offer(z=picked_item[0]);
|
||||||
free(picked_item);
|
if (price)
|
||||||
picked_item = NULL;
|
{
|
||||||
money += price;
|
play_sample_at_channel(H_SND_OBCHOD,1,100);
|
||||||
rebuild_keepers_items();
|
buy_item(z);
|
||||||
pick_set_cursor();
|
free(picked_item);picked_item=NULL;
|
||||||
redraw_shop();
|
money+=price;
|
||||||
}
|
rebuild_keepers_items();
|
||||||
}
|
pick_set_cursor();
|
||||||
return id;
|
redraw_shop();
|
||||||
}
|
}
|
||||||
if (picked_item == NULL) return 0;
|
}
|
||||||
z = picked_item[0];
|
return id;
|
||||||
price = get_sell_price(z);
|
}
|
||||||
pp = find_sell_product(z);
|
if (picked_item==NULL) return 0;
|
||||||
if (pp == NULL) return 0;
|
z=picked_item[0];
|
||||||
mouse_set_cursor(H_MS_DEFAULT);
|
price=get_sell_price(z);
|
||||||
if (!price) return 0;
|
pp=find_sell_product(z);
|
||||||
|
if (pp==NULL) return 0;
|
||||||
|
mouse_set_cursor(H_MS_DEFAULT);
|
||||||
|
if (!price) return 0;
|
||||||
if (price > money) {
|
if (price > money) {
|
||||||
p = message(2, 0, 0, "", texty[104], texty[230], texty[78]) + 1;
|
p = message(2, 0, 0, "", texty[104], texty[230], texty[78]) + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2954,7 +2961,7 @@ char shop_bag_click(int id, int xa, int ya, int xr, int yr) {
|
||||||
money -= price;
|
money -= price;
|
||||||
sell_item(z);
|
sell_item(z);
|
||||||
rebuild_keepers_items();
|
rebuild_keepers_items();
|
||||||
id = bag_click(id, xa, ya, xr, yr);
|
bag_action(xr, yr);
|
||||||
cur_owner = picked_item != NULL;
|
cur_owner = picked_item != NULL;
|
||||||
} else {
|
} else {
|
||||||
shop_keeper_click(0, 0, 0, 0, 0);
|
shop_keeper_click(0, 0, 0, 0, 0);
|
||||||
|
@ -2972,11 +2979,25 @@ char shop_block_click(int id, int xa, int ya,int xr,int yr)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fast_trade_click() {
|
||||||
|
int x = ms_last_event.x;
|
||||||
|
int y = ms_last_event.y;
|
||||||
|
const T_CLK_MAP *item = find_in_click_map_entry(x, y, clk_shop, CLK_SHOP, MS_EVENT_MOUSE_LPRESS);
|
||||||
|
if (item) {
|
||||||
|
if (item->proc == &shop_bag_click) {
|
||||||
|
shop_bag_action(x-item->xlu, y-item->ylu, 1);
|
||||||
|
} else if (item->proc == &shop_keeper_click) {
|
||||||
|
shop_keeper_action(x, y, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void shop_keyboard_proc(EVENT_MSG *msg, void **_) {
|
static void shop_keyboard_proc(EVENT_MSG *msg, void **_) {
|
||||||
if (msg->msg == E_KEYBOARD) {
|
if (msg->msg == E_KEYBOARD) {
|
||||||
int c = quit_request_as_escape(va_arg(msg->data,int));
|
int c = quit_request_as_escape(va_arg(msg->data,int));
|
||||||
switch(c>>8) {
|
switch(c>>8) {
|
||||||
case 1: _exit_shop(0,0,0,0,0);break;
|
case 1: _exit_shop(0,0,0,0,0);break;
|
||||||
|
case 57: fast_trade_click();break;
|
||||||
default:break;
|
default:break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue