How to deal with drags taking random position on screen after interaction which change drag lists content?
May be there are way to flush their positions to locate them as they spawn on game start.
Or method to solve it in another way.
Video demostrating problem: In develop - LotR LCG desktop player.
Drag group:
Code: Select all
draggroup:
for index,card in enumerate(p.current().hand):
$x,y,h = calculate_hand_card_position(index)
if len(p.current().hand) <= 8:
drag:
dragged card_dragged_handler
drag_name "Hand %s"%(index)
drag_handle (0, 0, 1.0, 1.0)
droppable False
xpos x
ypos y
use handcard(card=card,x=x,y=y)
else:
drag:
dragged card_dragged_handler
drag_name "Hand %s"%(index)
drag_handle (0, 0, 1.0, 1.0)
droppable False
xpos x
ypos y
use handcard(card=card,x=x,y=y,h=h)
for index, key in enumerate(drag_drop_tokens):
drag:
drag_name key
dragged token_dragged_handler
xpos (30 + side_bar_width + 100*index)
ypos 630
droppable False
use icon(img = drag_drop_tokens[key][0],frame=drag_drop_tokens[key][1],mask=drag_drop_tokens[key][2],size=int(stat_icon_size*1.5))
for index,card in enumerate(p.current().heroes):
$x,y = calculate_field_hero_card_position(index)
drag:
dragged card_dragged_handler
drag_name "field_hero %s"%(index)
drag_handle (0, 0, 1.0, 1.0)
xpos x
ypos y
use fieldcard(card=card,x=x,y=y)
Code: Select all
def card_dragged_handler(drags, drop):
renpy.hide_screen('fieldcard_info')
# debug(drags[0].__dict__)
notify("%s - %s"%(drags[0].last_x,drags[0].last_y))
data = drags[0].drag_name.split()
if data[0] == 'Hand':
if drags[0].last_x > side_bar_width + 100:
index = int(data[1])
card = p.current().hand[index]
p.current().hand.remove(card)
p.current().heroes.append(card)
if data[0] == 'field_hero':
if drags[0].last_x < side_bar_width:
index = int(data[1])
card = p.current().heroes[index]
p.current().heroes.remove(card)
p.current().hand.append(card)