Display drag above of other draggroup elements during dragging

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
bob_54321
Newbie
Posts: 2
Joined: Sat Nov 04, 2017 4:06 pm
Contact:

Display drag above of other draggroup elements during dragging

#1 Post by bob_54321 »

Hi. I would appreciate an advice on wether this can be implemented.
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()
Two draggroups should represent different category of items that should not interfere. It will work if all drags located inside of one draggroup, with a callback checking item category on drop, but I wonder, is it possible to also make it work with separate draggroups?
example.png

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Display drag above of other draggroup elements during dragging

#2 Post by Remix »

I think you will have to go with the single draggroup and conditional drop check option with drag_raise set to True for each draggable item.
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]