Most basic of basic GUI customization

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
brohanu
Newbie
Posts: 9
Joined: Wed Dec 18, 2013 7:56 pm
Contact:

Most basic of basic GUI customization

#1 Post by brohanu »

So, my intention here is to make a little window on the side that lists the player's current stats: STR, DEX, CON, INT, WIS, CHA.
I have not had much luck parsing the many tutorials on GUI floating around here, perhaps because they're doing things that look good and seem fairly more ambitious, or perhaps they're jumping over the very basics which I'm missing out on. After all, I used this engine for about a week a year ago and only started again yesterday.

So, I just need a step by step here, if someone would be so kind.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Most basic of basic GUI customization

#2 Post by SundownKid »

That would probably be best served by using "bars". So for example

Code: Select all

screen stats:
    vbox:
        xysize (300,400)
        xalign 1.0
        yalign 0.0
        text "STR: [str]" 
        bar value str range 100
        text "DEX: [dex]" 
        bar value dex range 100
        text "INT: [int]" 
        bar value int range 100

label start:
    $ str = 0
    $ dex = 0
    $ int = 0

    show screen stats
    e "Now you can see your stats."
    $ str += 1
    e "Strength was boosted by 1"

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Most basic of basic GUI customization

#3 Post by trooper6 »

You don't even need bars. You can just have the numbers:

Code: Select all

screen stats:
    vbox:
        xysize (300,500)
        xalign 1.0
        yalign 0.0
        text "STR: [str]" 
        text "DEX: [dex]" 
        text "INT: [int]" 

label start:
    $ str = 0
    $ dex = 0
    $ int = 0

    show screen stats
    e "Now you can see your stats."
    $ str += 1
    e "Strength was boosted by 1"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

brohanu
Newbie
Posts: 9
Joined: Wed Dec 18, 2013 7:56 pm
Contact:

Re: Most basic of basic GUI customization

#4 Post by brohanu »

Thanks a bunch! Sorry for not being as prompt as you all were.
How would I add a background to the window so it isn't just disembodied text though?

I also used to have a guide on hand for a button to show and hide a menu, but can't relocate it at the moment.

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Most basic of basic GUI customization

#5 Post by Onishion »

You can change the bits that say "vbox" to:

Code: Select all

frame:
    #the size and shape information
    has vbox
        #whatever else they had up there
and then the rest of it. The frame part puts a border. Alternately you could slap an image behind there.

One problem I had with using numbers for stats once is that the numbers did not always update in realtime, they would wait until I did somethign else before updating.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Most basic of basic GUI customization

#6 Post by trooper6 »

Frames can have backgrounds, so use a frame (read up on all of this in the Screen Language section of the documentation)
As for making a button that hides or shows your screen...again this is all in the documentation:
Screen Language (look up buttons): http://www.renpy.org/doc/html/screens.html
And the actions you can give the buttons: http://www.renpy.org/doc/html/screen_actions.html

But this code gives you a screen with a frame and a button that brings up that screen or hides it if it is already visible:

Code: Select all

default stren = 0
default dex = 0
default int = 0

screen control():
    textbutton "Stats" action If(renpy.get_screen("stats"), Hide("stats"), Show("stats")):
        xalign 1.0 yalign 0.7

screen stats():
    frame:
        #background "images/frame_image.png"
        background "#000000"
        xalign 1.0
        yalign 0.0 
        xysize (150,150)
        vbox:
            xalign 0.5
            yalign 0.5
            text "STR: [stren]" 
            text "DEX: [dex]" 
            text "INT: [int]" 
        
# The game starts here.
label start:
    scene bg underpassn
    show screen control()
    "If you want to see your stats push the stats button."
    "Now you can see your stats."
    $ stren += 1
    "Strength was boosted by 1"
    "Press the stats button to hide your stats screen."
As you can see above, you can use the keyword background to add an image for your background (the commented out line), or just give it a color (the line that is not commented out).
There shouldn't be any problem with updating the stats either, at least I haven't encountered any.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

brohanu
Newbie
Posts: 9
Joined: Wed Dec 18, 2013 7:56 pm
Contact:

Re: Most basic of basic GUI customization

#7 Post by brohanu »

Thanks a ton for your in-depth contributions. This community seems over-the-top helpful.
I've been combing the documentation regularly, but apparently I'm not very good at it :P thanks for spelling it out anyway.
What I'm attempting to do now is a basic inventory display screen. I just have the variable "inventory" that contains a blank list, and new items are appended to it, uses "in" checks, all that good stuff. All I want to do for the player is give them a displayable list of all the items they have. What I've been weaseling around is using a "for" statement to cycle through the items and display all of them (and hope they don't fall off the screen) (is it possible to add scroll bars?), but I can't get the python-only "for" statement to work together with the renpy "text" statement. I'm not well versed in how the two scripts interact.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Most basic of basic GUI customization

#8 Post by trooper6 »

My inventory thread has an example of a screen that shows your inventory list with for:
http://lemmasoft.renai.us/forums/viewto ... =8&t=30788

in Short:

Code: Select all

screen inventory_screen():
    vbox:
        align (0.9, 0.0)
        text "Inventory:"
        for item in backpack:
            text ("[item]")
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: No registered users