Slight delays and some renpy code


Hello!
It's been a while, once again. 
To warn you before I start rambling, this post is just me rambling and saying the update is close, which it is.

I'm writing this because I really really really wanted to push an update today, but I'm just not there yet, and unluckily I'm the type to rather delay than push out an update I'm not happy with.

As for why, there's been a lot of unlucky stuff in my life recently. Health issues, I got robbed and had to deal with court stuff, a job change... All the fun stuff. 
For sanity's sake, I put gamedev/writing on the downlow, making smaller changes and not focusing so much on the story intense parts and what not. Done notes, gotten a lot of CGs and music done (Seriously, the artists have outdone themselves and there's even some really amazing guest artist CGs coming in this update.). There's a lot of it.

Thankfully, my personal problems have been lightening up recently, which means I'm back on track.
Ok. I'm rambling. Anyway, what I wanted to say is; The update is nearly done. It'll be a literal ton of fixes and updates. UI changes, CGs, music etc. Story wise it's John's Ch3 and most likely (Don't quote me on this) most of Ch4 for both John and Mike. Charles is in the pipeline, but his chapters take a little extra energy so I'm saving him for last, meaning I'll have the most inspiration. As soon as Ch4 is done for John and Mike, he's up next for a large update.

Now; for those of you who might be into Ren'Py (the free framework I use to make DT) on your own, or those simply curious about it; I do not come empty handed. I figured I'd share my version of the choice menu (The in-game choice buttons.) for you. Maybe it'll help someone with further customization of the base ren'py functions of their own.

TL;DR for those who do not want the examples and my rambling - code is at the end.
As another disclaimer, I'm no expert. Just a hobbyist so there's probably a lot of things that are wrong or could be done better, but the code works.

To being, let's start with the standard choice screen for ren'py, and a basic menu.
Something like this.


It takes arguments from the menu and uses them to create textbuttons with said arguments. So, in the basic menu this is just the text on the button, and the action. What's after each choice, so to say.  Kind of like this example:



You can also add in simple checks and such directly into the menu itself, for example, the below example will hide/show a button depending on a set variable. It's probably the most common thing I use in DT. 
Regardless of anything else, only one version of  the Option 1 button will ever show up, which one depends on the state of the variable being True or False. Of course, this could also be a string, or an integer for example.


The above code would look like this, in the game.



Now,  I wanted little more customizability to the choice screen.

First of all, I wanted a button that was unclickable depending on certain variables.  For example is $ variable is False, I want it to be greyed out and unclickable.

As mentioned earlier, the choice menu takes arguments (kwargs) from the menu: part of the script, and plugs it into the screen and creates textbuttons with the contents. Kind of like this.



Let's take a second to talk about arguments in functions, or in this case screens. Arguments can be explained as X in a math equation. It's the X, and you decide where to plug it in. As the i (items) in the above picture.
Here's another example, to ramble.




So, since it's a choice screen and a textbutton, anything in ren'py screen language (well, Python, really but I'm not that skilled.) can be passed down. What's needed really is to pass the "sensitive" tag down to the automatically created textbutton.
Screens and Screen Language — Ren'Py Documentation (renpy.org)

So, let's add the sensitive tag from the documentation for screen language just above, to our screen, as well as a check to see if the argument is True. The format for kwargs.get would be kwargs.get(variable tag, default value)


The format for kwargs.get would be kwargs.get(variable tag, default value).
So, this will check for the argument "inactive" being "not False" (aka True), and if so, the textbutton will be"sensitive".

The usage would look something like this. Defining the kwarg inactive as True, and making it only show up if $ variable is True.
If $ variable is False, the inactive button will show up instead.

In game, it would look like this depending on if $ variable is True or False.


So, there you have it.  More arguments passed down to the choice menu screen.


Now, finally I wanted to make it so I could change the graphical image of the buttons individually on the fly, for example to signify if a choice would have more impact for John, or Mike, or for example ending a conversation.

So, adding the argument (kwarg**) "bg" with a string for an imagepath, instead of a boolean (True/False), as well as the background tag from the ren'py screenlanguage documentation.

And for usage, same as before, simply add the argument "bg" and the string for the imagepath to the menu: part in your script.



Which would look as this in the game. (Don't worry, placeholder graphics for the example.


So; here's the code. Plug it into your screens.rpy around row ~200 or so. Replace your old screen choice(items):

An then, we need a condition  for checking if we're on android, because the button size changes to 1860 (or different, depending on your setting. check your gui.choice_button_width in gui.rpy for the xsize in im.Scale.

Last of all; since this removes some of the automation it does not automatically use "choice_hover_background" for the hover image.


screen choice(items):
    style_prefix "choice"
    vbox:
        for i in items:
            $ inactive = i.kwargs.get("inactive", False)
            if renpy.android:
                $ bg = i.kwargs.get("bg", "gui/phone/button/choice_idle_background.png")
                $ bg = im.Scale(bg,1860,82)
            else:
                $ bg = i.kwargs.get("bg", "gui/button/choice_idle_background.png")
            textbutton i.caption action i.action sensitive not inactive background bg

-

Additionally, this replaces the default bg with a set string. Which removes the hover that ren'py automatically adds. I've re-added it here, as well as the functionality to add your own hover for your custom button backgrounds in your menu's by using the variable hoverbg 

screen choice(items):
    style_prefix "choice"
    vbox:
        for i in items:
            $ disabled = i.kwargs.get("disabled", False)
            if renpy.android:
                $ bg = i.kwargs.get("bg", "gui/phone/button/choice_idle_background.png")
                $ bg = im.Scale(bg,1860,82)
                $ hoverbg = i.kwargs.get("hoverbg", "gui/phone/button/choice_hover_background.png")
                $ hoverbg = im.Scale(hoverbg,1860,82)
            else:
                $ bg = i.kwargs.get("bg", "gui/button/choice_idle_background.png")
                $ hoverbg = i.kwargs.get("hoverbg", "gui/button/choice_hover_background.png")
            textbutton i.caption action i.action sensitive not disabled background bg hover_background hoverbg

Until next time, which will be the update and hopefully less... rambling.

/G

Get Distant Travels

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

I am totally on board with this project and behind you 100%

(+2)

So glad to see you're doing better my guy! Hope you enjoy the new year, and we have many more updates for the next one. :P

(+2)

Sorry for all you've been through. It's great to know you're doing better. I'm so happy these boys will be back soon!

(+1)

Good luck, dude. I can definitely be patient for something this cool, take your time.

(+1)

I am glad things are getting a bit better for you. I loved following the story so far and can't wait for more! 

(+1)

im sorry you have to deal with this stuff, i am glad to hear its lightening so i hope it gets lighter until you no longer have any problems. also take however long you need, i have several games that im still waiting on that have taught me patience is a virtue and waiting gives you some of the greatest things you could ask for. (And another thing, as perchlorate said you come before this. take care of yourself and dont overstress yourself!)

(+5)

it's so nice hearing about you, a bit sad it wasn't good news but i wish you good luck ^^

(+6)

Take all the time you need, We understand. 

Although, yourself should come before your project or your fans. Don't give in to pressure from the impatient and make time for yourself.

Wishing you the best and for a new year that will be better than the last.

-Perchlorate, halfway across the globe.