I have a draggroup with few drags forming a grid. Drags are droppables and draggables, like inventory system, so the item can be dropped on the placeholder.
I want to make a generic re-usable screen that just accepts the list and then draws the drag elements grid, but I have a problem when I'm using multiple draggroups.
Example of the code just to show the issue I'm addressing:
Code: Select all
init python:
def get_pos_coords(
column_index,
row_index,
cell_width,
cell_height,
x_offset=0,
y_offset=0,
x_margin=0,
y_margin=0,
):
return (
column_index * cell_width + x_offset + column_index * x_margin,
row_index * cell_height + y_offset + row_index * y_margin,
)
screen lemmasoft_question_drags_grid_transclude(x, y, is_droppable=False, is_draggable=False):
drag:
xpos x
ypos y
droppable is_droppable
draggable is_draggable
frame:
xsize 100
ysize 100
transclude
screen lemmasoft_question_drags_grid(some_items, x_offset, y_offset):
for i in range(4):
for j in range(2):
$ index = i + j * 4
python:
x, y = store.get_pos_coords(
i, j,
cell_width=100, cell_height=100,
x_offset=x_offset, y_offset=y_offset,
x_margin=5, y_margin=5,
)
use lemmasoft_question_drags_grid_transclude(x, y, is_droppable=True):
text "placeholder"
if len(some_items) > index:
use lemmasoft_question_drags_grid_transclude(x, y, is_draggable=True):
text "item " + some_items[index]
screen lemmasoft_question():
draggroup:
use lemmasoft_question_drags_grid(['A1', 'A2', 'A3'], x_offset=0, y_offset=0)
draggroup:
use lemmasoft_question_drags_grid(['B1', 'B2', 'B3'], x_offset=300, y_offset=300)
label start:
call screen lemmasoft_question()