Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Here's the code for the phone!
- define nvl_mode = "phone" ##Allow the NVL mode to become a phone conversation
- default MC_Name = name ##The name of the main character, used to place them on the screen
- init -1 python:
- phone_position_x = 0.15 # 0.3
- phone_position_y = 0.8 # 0.5
- def Phone_ReceiveSound(event, interact=True, **kwargs):
- if event == "show_done":
- renpy.sound.play("audio/sfx/ReceiveText.ogg")
- def Phone_SendSound(event, interact=True, **kwargs):
- if event == "show_done":
- renpy.sound.play("audio/sfx/SendText.ogg")
- def print_bonjour():
- print("bonjour")
- transform phone_transform(pXalign=0.5, pYalign=0.5):
- xcenter pXalign
- yalign pYalign
- transform phone_appear(pXalign=0.5, pYalign=0.5): #Used only when the dialogue have one element
- xcenter pXalign
- yalign pYalign
- on show:
- yoffset 1080
- easein_back 1.0 yoffset 0
- transform message_appear(pDirection):
- alpha 0.0
- xoffset 50 * pDirection
- parallel:
- ease 0.5 alpha 1.0
- parallel:
- easein_back 0.5 xoffset 0
- transform message_appear_icon():
- zoom 0.0
- easein_back 0.5 zoom 1.0
- transform message_narrator:
- alpha 0.0
- yoffset -50
- parallel:
- ease 0.5 alpha 1.0
- parallel:
- easein_back 0.5 yoffset 0
- # Creating a transform to add the selected phone background as the UI bg
- transform phone_bg_zoom:
- crop (650, 0, 620, 1080)
- zoom 0.85926
- screen PhoneDialogue(dialogue, items=None):
- style_prefix "phoneFrame"
- frame at phone_transform(phone_position_x, phone_position_y):
- if len(dialogue) == 1:
- at phone_appear(phone_position_x, phone_position_y)
- viewport:
- draggable True
- mousewheel True
- yinitial 1.0
- vbox:
- null height 20
- use nvl_phonetext(dialogue)
- null height 100
- # If there is a choice menu, move the messages up so the latest can still be seen
- if len(items) > 0:
- null height len(items) * 100
- # Adding in choice menu
- if len(items) > 0:
- frame:
- yalign 0.9
- xalign 0.5
- ysize len(items) * 115
- xsize 480
- background None #Solid("#00000080")
- foreground None
- vbox:
- yalign 0.9
- for i in items: #For each choice, add its button
- button:
- action i.action
- xalign 0.5
- frame:
- idle_background Solid(gui.idle_color)
- hover_background Solid(gui.hover_color)
- foreground None
- xysize (450,90)
- text i.caption:
- align (0.5,0.5)
- text_align 0.5
- size 26
- screen nvl_phonetext(dialogue, items = None):
- if MC_Name != name:
- $ MC_Name = name
- style_prefix None
- $ previous_d_who = None
- for id_d, d in enumerate(dialogue):
- if d.who == None: # Narrator
- frame:
- background Solid("#808b9680")
- #background None
- foreground None
- xysize (500,40)
- text d.what:
- xpos -335
- ypos 0.0
- xsize 350
- text_align 0.5
- #italic True
- size 28
- slow_cps False
- id d.what_id
- if d.current and not items:
- at message_narrator
- else:
- if d.who == MC_Name:
- $ message_frame = "phone_send_frame.png"
- else:
- $ message_frame = "phone_received_frame.png"
- hbox:
- spacing 10
- if d.who == MC_Name:
- box_reverse True
- #If this is the first message of the character, show an icon
- if previous_d_who != d.who:
- if d.who == MC_Name:
- $ message_icon = "phone_send_icon.png"
- elif d.who == friend:
- $ message_icon = "phone_send_icon_bff.png"
- else:
- #$ message_icon = "phone_received_icon.png"
- $ message_icon = "phone_send_icon_"+d.who+".png"
- add message_icon:
- if d.current and not items:
- at message_appear_icon()
- else:
- null width 107
- vbox:
- yalign 1.0
- if d.who != MC_Name and previous_d_who != d.who:
- text d.who outlines [ (gui.outline, "#000000A0", 0, 0) ]
- frame:
- padding (20,20)
- background Frame(message_frame, 23,23,23,23)
- xsize 350
- if d.current and not items:
- if d.who == MC_Name:
- at message_appear(1)
- else:
- at message_appear(-1)
- text d.what:
- pos (0,0)
- xsize 350
- slow_cps False
- if d.who == MC_Name :
- color "#FFF"
- text_align 1.0
- xpos -580
- else:
- # Changing colour from black to white to better work with text outline option
- color "#fff"
- id d.what_id
- $ previous_d_who = d.who
- style phoneFrame is default
- style phoneFrame_frame:
- # Adding custom bg
- #background Transform("phone_background.png", xcenter=0.5,yalign=0.5)
- background Transform("[phone_background]", crop=(650, 0, 620, 1050), zoom=0.81, xcenter=0.5,yalign=0.5)
- foreground Transform("phone_foreground.png", xcenter=0.5,yalign=0.5)
- ysize 815
- xsize 495
- style phoneFrame_viewport:
- yfill True
- xfill True
- yoffset -20
- style phoneFrame_vbox:
- spacing 10
- xfill True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement