Ren'Py Hiding all screens (and showing one)

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
Hey, guys. Me again with my noobish questions.
Is there a way to hide all screens to show another? And then to close it + return those that were shown back.

Like... :FacePalm:


I'm trying to do some "Journal" thingy. And since I completely suck at producing a decent UI, I just roll with defaults.
I want to hide every other text-button and image-button (they're both from the same "screen") to show portraits and, later, a description of what the player needs to do.
I don't have variables for what room you are in, so if I hide room interactions, I don't know how to turn them back on (if the player decides to open the Journal in different rooms)...

Plus, ideally, I'd like to hide everything and show only the Journal, and then have a separate button there to return back screens that were hidden.
Is there a simple way to do what I want?
Thanks.
 

Erogrey

New Member
May 20, 2019
8
6
Hi. It's just a simple concept:

Try create an "list" (variable) of currently showed screens (where are your textbutton's/hotspot's/etc.). If important screen is showed, then add a variable (name) to that "list":

Python:
label bruh:
    show screen portrait_screen
    $ MarkScreenAction("portrait_screen")
And add functions to hide/show ALL possible showed screens with FOR steatment (use list of marked screens), like:

Python:
define currentScreensList = [ ]

init python:

    def HideThemAll(currentScreensList):
        for item in currentScreensList:
            renpy.hide_screen(item)

    def AbortAbort(currentScreensList):
        for item in currentScreensList:
            renpy.show_screen(item)

    def MarkScreenAction(item):
        currentScreensList.append(item)
Then, use it:

Python:
label journal_thingy:
    show screen journal_screen
    $ HideThemAll(currentScreensList) ## Or another list
 
Last edited:

Erogrey

New Member
May 20, 2019
8
6
And Ren'Py has a "tag" system for screens ( ):
Code:
tag
Parsed as a name, not an expression. This specifies a tag associated with this screen. Showing a screen replaces other screens with the same tag. This can be used to ensure that only one screen of a menu is shown at a time, in the same context.
For example, you can replace target screens (that has same tag) with empty screens... But i think it not that useful.
 
  • Like
Reactions: AdventAnyx

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
Is there a way to hide all screens to show another? And then to close it + return those that were shown back.
Not natively. You have to create your own code for this
Python:
init python:

    def hideAllShowOne( toDisplay=None ):
        # Reset the list of hidden screens.
        store.hiddenScreens = []
        # For each existing screen... 
        for s in renpy.display.screen.screens_by_name:
            # if it is shown...
            if renpy.get_screen(s) :
                # add it to the list of hidden screens...
                hiddenScreens.append( s )
                # then hide it.
                renpy.hide_screen( s )
        #  And finally show the wanted screen, it there's
        # one passed to the function.
        if not toDisplay is None:
            renpy.show_screen( toDisplay )

    def unhideAll( toHide=None ):
        #  If there's a screen passed to the function,
        # starts by hidding it.
        if not toHide is None:
            renpy.hide_screen( toHide )
        # Then show all the screens previously hidden.
        for s in hiddenScreens:
            renpy.show_screen( s )
        # And reset the list of hidden screens.
        store.hiddenScreens = []

# Ensure that the list will be savable.
default hiddenScreens = []


label whatever:
    [...]
    $ hideAllShowOne( "myScreen" )
    [...]
    $ unhideAll( 'myScreen" )
But be careful, you can only know what screen is displayed, but not what where the arguments used. And also you can have to discriminate between screens used by Ren'py and screens used by your game. All this implying that there's possible issues with such code.


This being said, is it really what you want to do ?

From what I get, you want to hide the screens because there's buttons on them, and the player shouldn't be allowed the right to click on them when a particular screen in displayed. Therefore, what you want is not effectively hide the screens, but just to invalidate their buttons.
And this can be achieved really easily, by using the screen property :
Code:
screen journal():
    modal True
    [...]
And it's done. Each time the screen "journal" will be shown on the screen, the player will only be able to click on the buttons defined in it. Every other buttons defined in another shown screen will be unclickable. Then, once the "journal" screen will be hidden, those buttons will be clickable again.
 
  • Like
Reactions: AdventAnyx

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
Thanks, guys. Never created lists before. And never used "for". I...need to figure out how to write them and how they work.

The way I do this now is using that "tag" thing. Every top image-button is in the screen "hud", and I use ToggleScreen, so that player can open separate stats screens and view them in any order:


And that's why at first I wanted the "Journal" to act the same.
Probably the easier solution is gonna be creating huge non-transparent background and showing portraits on it...
It's kinda lame.
Or maybe I do need to store the room that player's in to use something like:
action [ToggleScreen("Lewdness"), ToggleScreen("room_actions")] for each imagebutton

But...Then if the player clicks those buttons one by one, the room screen will toggle back and forth...Fuck...
Can I somehow put "if" statement into the action [SomeThing(), SomeOtherThing()] ?

But anyway, thanks for your reply.

Edit: wait! I'm an idiot, right? I can add the same tag to the room interaction screen? Just need to figure out how to show it back once other screens are closed.
Is there a way to check if none of the same-tag screens are shown?

Edit2: how the standard text-box does this?
I use "call screen" like this, once player enters the room-label:
Code:
call screen sam_room1
    if _return == "work1":
        if es_brain < 150:
            $ es_brain += renpy.random.randint(0,1)
        if gloria_plot >= 22:
            jump work3
        elif gloria_plot >= 10:
            jump work2
        else:
            jump work1
    elif _return == "es_office1":
        jump es_office1
    elif _return == "laptop1":
        call laptop1
        jump sam_room_new_day
and if there's a label with text in it, the room interaction screen hides itself without my help. So the default text-box must be doing something I'd like to do, right?

 
Last edited:

Erogrey

New Member
May 20, 2019
8
6
Edit2: how the standard text-box does this?
If I understand correctly, you want keep screen "sam_room1" after jumping from label to label (after say screen)? Well, in this case try using quick menu as reference:
Python:
init python:
    config.overlay_screens.append("quick_menu")
    config.overlay_screens.append("sam_room1")
    [other annoying screens like "helpers"/"reminders"]

default sam_room1 = False

screen sam_room1():
    if sam_room1: ## When it need to be shown, it will be there even if you jumping between labels
And hide those screens manualy if needed:
Python:
label work1:
    $ sam_room1 = False ## Do this before "scene" or before "jump"
    [some code with pause]
    $ sam_room1 = True ## Bringing back overlay buttons right before "return" to free roam (jumping to main label)
If that screen need to be changed, do not forget hide/show it like usual.

Although all this can be a "crutch"... And it "just works".

Is there a way to check if none of the same-tag screens are shown?
Only one (the last) should be shown. Other screens with same tag supposed to be hidden automatically when you've call on of the "same tagged" screens. Currently I've no using this feature, so not much to say.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
The way I do this now is using that "tag" thing. Every top image-button is in the screen "hud", and I use ToggleScreen, so that player can open separate stats screens and view them in any order:


And that's why at first I wanted the "Journal" to act the same.
What prevent you to do the same for the "Journal" ?

There's no need to hide screens to do what you shown. You open the "Journal" then circle through it by using an identical tag for each pages, and you prevent the player to mess with the game by using the property, as I said in my previous answer.

So, yes, what prevent you to do this ?


Or maybe I do need to store the room that player's in to use something like:
But once again, why do you want to hide something ? What is the purpose or reason that force you to hide something when the journal is opened ?


Can I somehow put "if" statement into the action [SomeThing(), SomeOtherThing()] ?
Yes, the screen action. But it will not solve your problem, just over complicate the solution.


Edit: wait! I'm an idiot, right? I can add the same tag to the room interaction screen?
But why ? Why should you do that ?
This screen is not part of the journal, it should absolutely not have the same tag than it.


Is there a way to check if none of the same-tag screens are shown?
If you know the name of those screens, yes. But once again why ?

What are you effectively trying to achieve ? And no, the answer isn't "hide all the screens, then show them again". That's the solution you tried to apply, not the problem you are trying to solve.


So the default text-box must be doing something I'd like to do, right?
Surely... But in fact it's impossible to effectively tell because, as said above, it's really hard to understand what you effectively want.

I mean, at no time the "default text-box" (as I understand the meaning of those words) hide a single screen ; it just pop-up on top of everything, without caring a single time what screen is, or not, visible. So, what you want to do is not to hide all the screens then show them again...

And until you finally say what problem you want to solve, no one will be able to give you the right answer.
Yet I guess that I already did it twice...


Side note : The tooltip box that appear and disappear is really annoying. If it were placed somewhere else, it would works, but you placed it as extension of the HUD part, and it lead to a really bad effect. You should either place it somewhere else, or keep its box zone permanently showing.
 
  • Like
Reactions: AdventAnyx

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
Yeah, I worded that poorly.
Woke up today and decided it's not worth the hassle, honestly.



The reason I was trying to hide room interactions is that the player can click through the Journal (and any other stat-video) screen. Also to clear the space a lil bit for the pop-up screen, since those text buttons are ugly.

Making it modal made it worse, since now you can't interact with the main "hud" screen until you close the Journal screen. The super goofy solution could probably be placing invisible image-buttons (or maybe hot-spots...I didn't use hot-spots yet once) over every top button to mimic the same ToggleScreen action...But I decided to just roll with another ugly self-made huge box.

Anyway, thanks for your attempt to educate me. o_O
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
The reason I was trying to hide room interactions is that the player can click through the Journal (and any other stat-video) screen.
And therefore, hiding the screens wasn't your problem, just your solution.


Making it modal made it worse, since now you can't interact with the main "hud" screen until you close the Journal screen.
Python:
screen journal():
    modal True

    # Display the HUD on top of the journal screen
    use nameOfTheHUDscreen

    [content of the journal screen]
Problem solved.

Python:
screen journal():
    imagebutton:
        # A totally transparent image...
        idle Solid( "#00000000" )
        # that start right bellow the HUD...
        xpos 0 ypos 50
        # cover all the rest of the screen...
        xsize config.screen_width ysize config.screen_height - 50
        # and do nothing when clicked.
        action NullAction()

    [content of the journal screen]
Problem solved a second time.
 
  • Red Heart
Reactions: AdventAnyx

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
And therefore, hiding the screens wasn't your problem, just your solution.




Python:
screen journal():
    modal True

    # Display the HUD on top of the journal screen
    use nameOfTheHUDscreen

    [content of the journal screen]
Problem solved.

Python:
screen journal():
    imagebutton:
        # A totally transparent image...
        idle Solid( "#00000000" )
        # that start right bellow the HUD...
        xpos 0 ypos 50
        # cover all the rest of the screen...
        xsize config.screen_width ysize config.screen_height - 50
        # and do nothing when clicked.
        action NullAction()

    [content of the journal screen]
Problem solved a second time.
Absolutely amazing! The second option is right what I needed.
Guess next time I should find better words to describe what I want instead of what I'm trying to do (since I invent problems that shouldn't even exist).

The first one is cool too. I didn't know about that "use" thingy. Unfortunately, it creates a of the "hud" screen and the whole thing gets darker. Doesn't matter, the 2nd one is perfect.

Thank you! :love:
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,355
15,269
Guess next time I should find better words to describe what I want instead of what I'm trying to do (since I invent problems that shouldn't even exist).
It's, alas, a common problem (known as ) that is far to be limited to codding.
In codding, it mostly concern people who are new to it. Because of their still limited knowledge, and because they sometimes tend to see all they do as magic, they have more difficulties to put words on what block them. It's both a bit too specialized and a bit to global, but , can worth being read.
And don't worry, I've been in your shoes when I started. I know that I insisted more than a bit in my answer, but it wasn't mean in a harsh way. It was more to help you understand what you did "wrong" (relatively speaking) than anything else.


The first one is cool too. I didn't know about that "use" thingy. Unfortunately, it creates a of the "hud" screen and the whole thing gets darker.
Yeah, it's a problem when, among other things, you use some transparency. Ideally, the first solution is to use more globally. you never directly display the HUD, but include it (through use in all your screens. Therefore it's only shown once, which solve the problem.


Thank you! :love:
You're welcome.