grid with imagebuttons not updating on cell size change

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
tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

grid with imagebuttons not updating on cell size change

#1 Post by tornsoul »

3*3 grid with a 2x2 center of "something"

Something being either "screen cell1"(just a solid) or "screen cell2" (an imagebutton)

Using the up/down textbuttons to resize the grid works great for cell1 (solids) but not at all for cell2 (imagebutton)
To make it even stranger - The style inspector actually reports that the imagebuttons have increased in size (after hitting the up button a ton)

Anyone have any clue what's going on - and importantly how to fix it....

The idea is to end up with a board game where the user can increase/decrease the tile size - Hence the need for clickable imagebuttons in the grid

code: line 32/33 - switch between cell1 and cell2

Code: Select all

screen heading(val = None):
    if val == None:
        null
    else:
        text val

screen cell(arc):
    add Solid("F00", xysize=(arc.size, arc.size))

screen cell2(arc2):
    imagebutton:
        idle Solid("F00", xysize=(arc2.size, arc2.size))
        action NullAction()
        at transform:
             xsize arc2.size
             ysize arc2.size

screen test_grid(arc):
    vbox:
        textbutton "up" action Function(arc.increase_size, 8)
        textbutton "down" action Function(arc.decrease_size, 8)

        grid 3 3:
            spacing 5
            use heading(None)
            use heading("x0")
            use heading("x1")

            for y, row in enumerate(arc.thear):
                use heading("y" + str(y))
                for x, val in enumerate(row):
                    use cell(arc)
                    #use cell2(arc)

label start:
    $ ac = Arclass()
    show screen test_grid(ac)
    "testing"
    return


init python:
    class Arclass:
        def __init__(self):
            self.thear = [[1,2],[3,4]]
            self.size = 64

        def increase_size(self, num):
            self.size = self.size + num

        def decrease_size(self, num):
            self.size = self.size - num
I've used a clean sandbox - renpy 7.4.4

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: grid with imagebuttons not updating on cell size change

#2 Post by Alex »

tornsoul wrote: Thu Jun 24, 2021 8:18 am ...The idea is to end up with a board game where the user can increase/decrease the tile size - Hence the need for clickable imagebuttons in the grid...
Try to zoom the whole game instead of buttons in the grid.
Couple of samples^
viewtopic.php?f=8&t=53959&p=505886&hilit=zoom#p505886
viewtopic.php?f=8&t=55947&p=514658&hili ... te#p514658

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: grid with imagebuttons not updating on cell size change

#3 Post by tornsoul »

For what I had in mind scaling the whole thing won't look all that good - so won't really work.

I've got the usual small/medium/large tiles.
The size difference is substantial (5x*5 grid to 50*50 - and maybe double that - depending on a few other things)
This means that the artwork simply won't scale - and needs to be custom for each size (or the large set will look very ugly - or the small one ineligible) - it's a very small tile set, so not that much of an issue to make three sets (game quality/look and feel is more important)

But thanks for the suggestion - I'll keep it in mind for other use cases where it might be more applicable.

So - Unfortunately still looking for a solution/workaround/whatever for my issue.

Post Reply

Who is online

Users browsing this forum: simple_human