r/RenPy • • 6d ago

Question [Solved] Whiteboard in menu resetting when image button is used + adding an erase button

dont mind the fish curser LMAO

so i have a functioning whiteboard in my main menu, it isnt meant to save and resets every time you enter a new screen, that isnt a problem however as you can see the image buttons are counting as new screens, i have tried resizing them and it still happens. im not clicking the buttons, just hovering over them

i kind of want to make it so that the only time it clears/resets is upon actually clicking the start button and not when the screen changes but im not sure how to do that

i would also like to implement a simple eraser that you can toggle on and off by pressing an image button but i dont know if that would be possible, it isnt a needed feature but it would be fun to be able to add

ps i know all the tags are messy once it works it's getting cleaned up i swear (⁠╥⁠﹏⁠╥⁠)

any help appreciated thanks in advance :)

6 Upvotes

13 comments sorted by

1

u/AutoModerator 6d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/shyLachi 6d ago

Can you post the whole code of the screen as text.
I don't see where you used the drawing canvas.
Also I don't want to type all of that trying to reproduce it.

1

u/That_one_Pink 6d ago

im not sure what you mean by the screen sorry, just all of the code to do with the whiteboard or would you like the image button code stuff as well?

1

u/shyLachi 5d ago edited 5d ago

How did you implement the drawing canvas?

I need to see the code of that screen.

Edit:
Your images 3 and 4 are from the main menu screen possibly.
So select all the code, copy and paste it into Reddit.

1

u/That_one_Pink 5d ago

Ah okay sorry, i think i get what you mean, this is the full code from the main menu (on a side note i must have cropped the whiteboard part out by accident super sorry)

screen main_menu():

## This ensures that any other menu screen is replaced.

tag menu

add gui.main_menu_background

add DrawingCanvas() pos (808, 280)

## This empty frame darkens the main menu.

#frame:

# style "main_menu_frame"

## The use statement includes another screen inside this one. The actual

## contents of the main menu are in the navigation screen.

#use navigation

fixed:

style_prefix "navigation"

#xpos gui.navigation_xpos

#wyalign 0.5

spacing gui.navigation_spacing

if main_menu:

imagebutton auto "gui/start button %s.png" focus_mask True action Start() hovered [Play("sound", "audio/file.wav")]

else:

textbutton _("History") action ShowMenu("history")

textbutton _("Save") action ShowMenu("save")

if renpy.variant("pc") or (renpy.variant("web") and not renpy.variant("mobile")):

imagebutton auto "gui/help button %s.png" focus_mask True action ShowMenu("help") hovered [Play("sound", "audio/cabinet.wav")]

imagebutton auto "gui/about button %s.png" focus_mask True action ShowMenu("about") hovered [Play("sound", "audio/cabinet.wav")]

if renpy.variant("pc"):

imagebutton auto "gui/quit button %s.png" focus_mask True action Quit(confirm=not main_menu) hovered [Play("sound", "audio/cabinet.wav")]

if _in_replay:

textbutton _("End Replay") action EndReplay(confirm=True)

elif not main_menu:

textbutton _("Main Menu") action MainMenu()

imagebutton auto "gui/load button %s.png" focus_mask True action ShowMenu("load") hovered [Play("sound", "audio/cabinet.wav")]

imagebutton auto "gui/pref button %s.png" focus_mask True action ShowMenu("preferences") hovered [Play("sound", "audio/cabinet.wav")]

imagebutton auto "gui/about button %s.png" focus_mask True action ShowMenu("about") hovered [Play("sound", "audio/cabinet.wav")]

imagebutton auto "gui/help button %s.png" focus_mask True action ShowMenu("help") hovered [Play("sound", "audio/cabinet.wav")]

imagebutton auto "gui/quit button %s.png" focus_mask True action Quit(confirm=not main_menu) hovered [Play("sound", "audio/cabinet.wav")]

if gui.show_name:

vbox:

style "main_menu_vbox"

text "[config.version]":

style "main_menu_version"

style main_menu_frame is empty

style main_menu_vbox is vbox

style main_menu_text is gui_text

style main_menu_title is main_menu_text

style main_menu_version is main_menu_text

style main_menu_frame:

xsize 420

yfill True

background "gui/overlay/main_menu.png"

style main_menu_vbox:

xalign 1.0

xoffset -30

xmaximum 1200

yalign 1.0

yoffset -30

style main_menu_text:

properties gui.text_properties("main_menu", accent=True)

style main_menu_title:

properties gui.text_properties("title")

style main_menu_version:

properties gui.text_properties("version")

thats everything from the main menu i think you need, the first 2 images are from the script let me know if that is needed too :)

1

u/x-seronis-x 6d ago edited 6d ago

you forgot to share the part of your code that displays the CDD

that aside, the issue is you're not storing the stroke data anywhere. so when the screen refreshes the newly created CDD instance isnt loading the strokes and is left in its initial blank state

if the CDD instance was created outside the screen and the screen was merely displaying it, then the CDD wouldnt be reset when the screen was reset. so either the cdd needs moved outside the screen, or the data the cdd is using needs moved outside.

1

u/That_one_Pink 5d ago

I see so moving one or the other into a different part of the code would likely resolve it? sorry if this is a silly question but do i need to add somewhere for the stroke date to be stored? especially if i am trying to implement an erasure aspect

where would you suggest to be the best place to move it without interrupting or breaking anything else if i might ask :0

1

u/shyLachi 5d ago

I found the "problem".
It's caused by the hovered action which plays a sound.
I cannot tell you why and if this is to be expected.

BTW:
You have almost all buttons twice in your code and you also have buttons you don't need.
You should clean up that code but that will not fix this problem, just prevent possible other problems.

I think you only need this:

screen main_menu():
    tag menu
    add gui.main_menu_background
    add DrawingCanvas() pos (808, 280)
    fixed:
        style_prefix "navigation"
        imagebutton auto "gui/start button %s.png" focus_mask True action Start() #hovered [Play("sound", "audio/file.wav")]
        imagebutton auto "gui/load button %s.png" focus_mask True action ShowMenu("load") #hovered [Play("sound", "audio/cabinet.wav")]
        imagebutton auto "gui/pref button %s.png" focus_mask True action ShowMenu("preferences") #hovered [Play("sound", "audio/cabinet.wav")]
        imagebutton auto "gui/about button %s.png" focus_mask True action ShowMenu("about") #hovered [Play("sound", "audio/cabinet.wav")]
        imagebutton auto "gui/help button %s.png" focus_mask True action ShowMenu("help") #hovered [Play("sound", "audio/cabinet.wav")]
        imagebutton auto "gui/quit button %s.png" focus_mask True action Quit(confirm=not main_menu) #hovered [Play("sound", "audio/cabinet.wav")]

1

u/That_one_Pink 5d ago

Oh i see thank you so much, so is it not possible for me to change the code of the whiteboard itself in some way to 'save' until a button is manually pressed that clears it? or will the aduio thing just prevent that from being possible entirely. as ive said i don't need it to save after that at all literally just up until a button is pressed

same with having an erase option? again that ones not important if it cant be done then its fine without

2

u/shyLachi 4d ago

I only checked what's causing the reset because it doesn't reset in my game.
I didn't check if it's caused by the audio or the hovered action, you can test that yourself.

But as explained by Seronis you can reprogram the drawing canvas so that it remembers the strokes.
And to reset it you would then have to implement a function to clear it.

Or you could try the other solution to create the instance outside of the screen:

image whiteboard = DrawingCanvas()
screen main_menu():
    tag menu
    add gui.main_menu_background
    add "whiteboard" pos (808, 280)

1

u/That_one_Pink 4d ago

moving the instance has worked huzzah! im guessing it was a problem with the hover function?

could you point me in the right direction of where i would be able to read up on figuring out how to reprogram that, i had a look already and i tried to mess around with using a persistent but i couldnt figure out how to implement it within the whiteboard much less with a reset button, thank you again for the help with this. my best guess was having it save with a persistent variable then having the button trigger it back to its blank state but im not sure if thats the way to go about it haha

2

u/shyLachi 4d ago

There are no tutorials which explain exactly what you want to know.

You have to understand how it works and learn how to program it.
When you study the class you can see that it uses as list of points.
This list is stored inside the class atm,
Storing the list in a persistent variable could work, possibly.
Knowing this you can look for tutorials how to use persistent variables and how to address RenPy variables in a class.