Advertisement
Guest User

Untitled

a guest
Nov 29th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  1. # Here's the code for the phone!
  2.  
  3. define nvl_mode = "phone" ##Allow the NVL mode to become a phone conversation
  4. default MC_Name = name ##The name of the main character, used to place them on the screen
  5.  
  6. init -1 python:
  7. phone_position_x = 0.15 # 0.3
  8. phone_position_y = 0.8 # 0.5
  9.  
  10. def Phone_ReceiveSound(event, interact=True, **kwargs):
  11. if event == "show_done":
  12. renpy.sound.play("audio/sfx/ReceiveText.ogg")
  13. def Phone_SendSound(event, interact=True, **kwargs):
  14. if event == "show_done":
  15. renpy.sound.play("audio/sfx/SendText.ogg")
  16. def print_bonjour():
  17. print("bonjour")
  18.  
  19.  
  20. transform phone_transform(pXalign=0.5, pYalign=0.5):
  21. xcenter pXalign
  22. yalign pYalign
  23.  
  24. transform phone_appear(pXalign=0.5, pYalign=0.5): #Used only when the dialogue have one element
  25. xcenter pXalign
  26. yalign pYalign
  27.  
  28. on show:
  29. yoffset 1080
  30. easein_back 1.0 yoffset 0
  31.  
  32.  
  33. transform message_appear(pDirection):
  34. alpha 0.0
  35. xoffset 50 * pDirection
  36. parallel:
  37. ease 0.5 alpha 1.0
  38. parallel:
  39. easein_back 0.5 xoffset 0
  40.  
  41. transform message_appear_icon():
  42. zoom 0.0
  43. easein_back 0.5 zoom 1.0
  44.  
  45.  
  46. transform message_narrator:
  47. alpha 0.0
  48. yoffset -50
  49.  
  50. parallel:
  51. ease 0.5 alpha 1.0
  52. parallel:
  53. easein_back 0.5 yoffset 0
  54.  
  55. # Creating a transform to add the selected phone background as the UI bg
  56.  
  57. transform phone_bg_zoom:
  58. crop (650, 0, 620, 1080)
  59. zoom 0.85926
  60.  
  61.  
  62. screen PhoneDialogue(dialogue, items=None):
  63.  
  64. style_prefix "phoneFrame"
  65. frame at phone_transform(phone_position_x, phone_position_y):
  66. if len(dialogue) == 1:
  67. at phone_appear(phone_position_x, phone_position_y)
  68.  
  69. viewport:
  70. draggable True
  71. mousewheel True
  72. yinitial 1.0
  73. vbox:
  74. null height 20
  75. use nvl_phonetext(dialogue)
  76. null height 100
  77.  
  78. # If there is a choice menu, move the messages up so the latest can still be seen
  79. if len(items) > 0:
  80. null height len(items) * 100
  81.  
  82.  
  83.  
  84. # Adding in choice menu
  85. if len(items) > 0:
  86. frame:
  87. yalign 0.9
  88. xalign 0.5
  89. ysize len(items) * 115
  90. xsize 480
  91. background None #Solid("#00000080")
  92. foreground None
  93.  
  94. vbox:
  95. yalign 0.9
  96. for i in items: #For each choice, add its button
  97. button:
  98. action i.action
  99. xalign 0.5
  100. frame:
  101. idle_background Solid(gui.idle_color)
  102. hover_background Solid(gui.hover_color)
  103. foreground None
  104. xysize (450,90)
  105.  
  106. text i.caption:
  107. align (0.5,0.5)
  108. text_align 0.5
  109. size 26
  110.  
  111. screen nvl_phonetext(dialogue, items = None):
  112.  
  113. if MC_Name != name:
  114. $ MC_Name = name
  115.  
  116. style_prefix None
  117.  
  118. $ previous_d_who = None
  119. for id_d, d in enumerate(dialogue):
  120. if d.who == None: # Narrator
  121. frame:
  122. background Solid("#808b9680")
  123. #background None
  124. foreground None
  125. xysize (500,40)
  126.  
  127. text d.what:
  128. xpos -335
  129. ypos 0.0
  130. xsize 350
  131. text_align 0.5
  132. #italic True
  133. size 28
  134. slow_cps False
  135. id d.what_id
  136. if d.current and not items:
  137. at message_narrator
  138. else:
  139. if d.who == MC_Name:
  140. $ message_frame = "phone_send_frame.png"
  141. else:
  142. $ message_frame = "phone_received_frame.png"
  143.  
  144. hbox:
  145. spacing 10
  146. if d.who == MC_Name:
  147. box_reverse True
  148.  
  149. #If this is the first message of the character, show an icon
  150. if previous_d_who != d.who:
  151. if d.who == MC_Name:
  152. $ message_icon = "phone_send_icon.png"
  153. elif d.who == friend:
  154. $ message_icon = "phone_send_icon_bff.png"
  155. else:
  156. #$ message_icon = "phone_received_icon.png"
  157. $ message_icon = "phone_send_icon_"+d.who+".png"
  158.  
  159. add message_icon:
  160. if d.current and not items:
  161. at message_appear_icon()
  162.  
  163. else:
  164. null width 107
  165.  
  166. vbox:
  167. yalign 1.0
  168. if d.who != MC_Name and previous_d_who != d.who:
  169. text d.who outlines [ (gui.outline, "#000000A0", 0, 0) ]
  170.  
  171. frame:
  172. padding (20,20)
  173.  
  174.  
  175. background Frame(message_frame, 23,23,23,23)
  176. xsize 350
  177.  
  178. if d.current and not items:
  179. if d.who == MC_Name:
  180. at message_appear(1)
  181. else:
  182. at message_appear(-1)
  183.  
  184. text d.what:
  185. pos (0,0)
  186. xsize 350
  187. slow_cps False
  188.  
  189.  
  190. if d.who == MC_Name :
  191. color "#FFF"
  192. text_align 1.0
  193. xpos -580
  194. else:
  195. # Changing colour from black to white to better work with text outline option
  196. color "#fff"
  197.  
  198.  
  199. id d.what_id
  200. $ previous_d_who = d.who
  201.  
  202. style phoneFrame is default
  203.  
  204. style phoneFrame_frame:
  205. # Adding custom bg
  206. #background Transform("phone_background.png", xcenter=0.5,yalign=0.5)
  207.  
  208. background Transform("[phone_background]", crop=(650, 0, 620, 1050), zoom=0.81, xcenter=0.5,yalign=0.5)
  209. foreground Transform("phone_foreground.png", xcenter=0.5,yalign=0.5)
  210.  
  211. ysize 815
  212. xsize 495
  213.  
  214. style phoneFrame_viewport:
  215. yfill True
  216. xfill True
  217.  
  218. yoffset -20
  219.  
  220. style phoneFrame_vbox:
  221. spacing 10
  222. xfill True
  223.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement