Ren'Py Ren'Py SMS interface

baloneysammich

Active Member
Jun 3, 2017
993
1,516
In a couple games I've played recently that feature an in-game smartphone, the text messaging interface behaves kinda weird IMO. Clicking anywhere on the phone itself doesn't progress the messages. It's necessary to click somewhere away from the phone.

I'm wondering if there's a possible workaround for this. I know this isn't very informative, so please let me know how I can elaborate. One of the games in question is Crimson High, FWIW.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,204
RenPy doesn't have a SMS interface.

Any SMS interface you see has been written by a developer of a game (or copy/pasted from another game or the ).
It'll be a or a couple of screens. Each written to look like a phone interface.

I've had a quick look at Crimson High.
It's a new phone system to me (and I've seen 3 or 4 in the past).

In this case, it is some custom code that has reused part of RenPy's NVL mode as a phone screen.

You say "one of the games in question". Which imply other games using this same code? I wonder if those are also games by the same developer. If not, it could be two separate issues you're seeing.

In this specific game, the issue is that the developer has made it so that the phone screen is draggable (you can use the mouse to drag the text window up and down). But this means it needs to reserve the left mouse button within that window to watch out for it being used to drag - and so doesn't respond to mouse clicks to advance the story.

You can edit phone.rpy, Line 81:

Python:
        viewport:
            # draggable True
            mousewheel True

I just commented out the line. Though you could also change it to draggable False.

If you were unaware you could edit the source code, I suggest you look into UnRen.
 
Last edited:
  • Red Heart
Reactions: baloneysammich

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
I'm wondering if there's a possible workaround for this.
As usual with Ren'Py, there's many possible workaround.

The easiest one come from the screen featuring the smartphone:
Python:
screen smartphone():
    # The smartphone image.
    add "images/smartphone.jpg"

    # Process all message.
    for i in messages:
        # displaying their content.
        text "[i.text]":
            # In either 'incoming" style or "outgoing" one.
            style i.style

    # Add a full transparent image button on top of everything.
    imagebutton:
        idle Solid( "#00000000" )
        xpos 0 ypos 0
        xsize config.screen_width ysize config.screen_height
        action [Whatever action expected]

Another other, more complicated, but possibly easier to deal with when you works on the game, is to rely on . You need to redefine the "say" screen to something that should more or less looks like this (wrote on the fly):
Python:
# Define the new needed style:

style namebox_incoming   # Author of the incoming message
style say_incoming   # Content of the incoming message
style namebox_outgoing   # Author of the outgoing message
style say_outgoing   # Content of the outgoing message

# Dictionary where the discussions and their messages will be stored.
default allSMS = {}

#  A new parameter added, /SMS/. It will be either *None*, when it's a regular
# dialog line, or it will be the name of the discussion.
screen say(who, what, SMS=None):

    style_prefix 'say'

    # The default behavior
    if not SMS:
        window:
            id 'window'
            has vbox

            if who is not None:
                window:
                    id 'namebox'
                    style "namebox"
                    text who id 'who'

            text what:
                id 'what'
                style_suffix 'dialogue'

            if not renpy.variant("small"):
                add SideImage() xalign 0.0 yalign 1.0

    # The behavior when it's a SMS
    if SMS:

        # Put them all on a viewport
        viewport:
            yinitial 1.0
            # Style it

            # display all the SMS for this discussion
            for  author, txt in allSMS[SMS]:
                vbox:
                    text author:
                        #  Assuming that /MC_name/ is where the name of the
                        # MC is.
                        if from == MC_name:
                            style "namebox_outgoing"
                        else:
                            style "namebox_incoming"
                    text txt:
                        if from == MC_name:
                            style "say_outgoing"
                        else:
                            style "say_incoming"
       
            # Then display the last message.
            vbox:
                text who id "who":
                    if who == MC_name:
                        style "namebox_outgoing"
                    else:
                        style "namebox_incoming"
                text what id "what":
                    if who == MC_name:
                        style "say_outgoing"
                    else:
                        style "say_incoming"

        # Finally add the message, and it's author, into the discussion.
        allSMS[SMS].append( ( who, what ) )
If I haven't messed too much, it should be used this way:
Code:
label discussionWithMom:
    mom "Hey honey, can you buy some butter when you come home from school ?" ( SMS="momPrivate" )
    MC "Ok mom, but you'll have to suck my dick goodnight."( SMS="momPrivate" )
    mom "Just that ? No problem, I was ready to give you my ass, but since you just want a BJ"( SMS="momPrivate" )
[...]

label discussionWithGirls:
    sister "So, [sisBFF.name], still ready for tonight ?"( SMS="threesomePlaning" )
    sisBFF "Ready ? I'm so ready that I already have to change my panties three times." ( SMS="threesomePlaning" )
    sister "Slut !  ;)" ( SMS="threesomePlaning" )
    sisBFF "It's why I'm your best friend :D" ( SMS="threesomePlaning" )
    sister "You know me so well. No one eat my cunt like you bitch." ( SMS="threesomePlaning" )
    MC "Er... Is this still a threesome, or have you forgot me ?" ( SMS="threesomePlaning" )
[...]
In the first label, you'll have a discussion between two persons. Incoming messages will come from the mother, outgoing from the MC.
In the second label, it will be a discussion with three persons. Both the sister and her best friend will be incoming messages, while MC ones will be outgoing.

And, if I haven't messed the screen too much, all this like if you where writing a regular scene with regular dialogs.


Edit: Added the only mandatory property for the viewport. It wasn't necessarily as obvious as I could have thought at first.
 
Last edited:

baloneysammich

Active Member
Jun 3, 2017
993
1,516
79flavors

Sorry for the confusion. I know the interface isn't a standard feature, the title was just shorthand.

I had actually looked at the code and noticed that this implementation used NVL. But I have just enough understanding of Ren'Py to be dangerous, so I didn't want to make assumptions and turn this into an XY problem.

The other game where I've seen this issue is not from the same dev. But it's in a messy development state so I didn't want to bring it into the discussion. I really only mentioned it because I wanted to indicate I didn't think this issue was merely a bug.

Anyway... thanks a lot for the workaround! It's just what I was looking for.

anne O'nymous

Thanks for all your input. The solution from 79flavors is ideal in this case, but I'll remember this for other situations.
 
  • Like
Reactions: anne O'nymous