-
Notifications
You must be signed in to change notification settings - Fork 1
/
EE_main.rpy
387 lines (319 loc) · 16.6 KB
/
EE_main.rpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#######VERSION: 2.4
#
#DON'T TOUCH:
#Code needed to capture the input text everytime the page changes.
init -2 python:
class GetText(Action):
def __init__(self,screen_name,input_id):
self.screen_name=screen_name
self.input_id=input_id
def __call__(self):
if renpy.get_widget(self.screen_name,self.input_id):
return str(renpy.get_widget(self.screen_name,self.input_id).content)
###################################################################################################
###################################################################################################
#
#screens
#
###################################################################################################
###################################################################################################
#screen to start a new event.
screen new_tutorial_menu:
vbox:
xalign 0.5
yalign 0.5
textbutton _("New Project: simple") action [SetVariable("project_kind","simple"),Jump("new_project")]
null height 50
textbutton _("New Project: with branches") action [SetVariable("project_kind","map"),Jump("new_project")]
null height 50
textbutton _("Tutorial") action Jump("EE_tutorial")
#
#This is the main screen of the Event Editor. The one you will see all the time while editing.
#
screen event_window:
imagemap:
ground BG_temp
#yanchor -config.screen_height
#xalign 0.5
if char_onscreen_temp0!="":
add char_onscreen_temp0 xanchor 0.5 xpos position_temp_char0 yalign 1.0
if char_onscreen_temp1!="":
add char_onscreen_temp1 xanchor 0.5 xpos position_temp_char1 yalign 1.0
if char_onscreen_temp2!="":
add char_onscreen_temp2 xanchor 0.5 xpos position_temp_char2 yalign 1.0
if project_kind=="map":
textbutton _("MAP") action [GetText("event_window","input"),SetVariable('sel_act',"out")] xalign 1.0
else:
textbutton _("Event Menu") action [GetText("event_window","input"),ShowMenu("project_main_menu")] xalign 1.0
vbox:
hbox:
textbutton _("Speaker") action Show('speaker_selection') xminimum 120
textbutton _("Base BG") action Show('BG_base_selection') xminimum 120
textbutton _("BG") action Show('BG_selection') xminimum 120
textbutton _("EV") action Show ('EV_bg_selection') xminimum 120
textbutton _("Characters") action Show ('character_selection') xminimum 120
textbutton _("Comments") action ShowMenu ('comments_screen') xminimum 120
hbox:
text _("page [page]/[minievent_temp.totalpages]") min_width 120 text_align 0.5
textbutton _("<-1<") action If(page>1,[GetText("event_window","input"),SetVariable("pagechange",-1)]) xminimum 80
textbutton _(">+1>") action [GetText("event_window","input"),SetVariable("pagechange",1),If(page==minievent_temp.totalpages,SetVariable('sel_act',"addpage2"))] xminimum 80
textbutton _("<-10<") action If(page-10>0,[GetText("event_window","input"),SetVariable("pagechange",-10)]) xmaximum 80
textbutton _(">+10>") action If(page+10<=minievent_temp.totalpages,[GetText("event_window","input"),SetVariable("pagechange",10)]) xmaximum 80
textbutton _("AddPage") action [GetText("event_window","input"),SetVariable('sel_act',"addpage1")] xminimum 120
textbutton _("RemovePage") action [GetText("event_window","input"),SetVariable('sel_act',"removepage")] xminimum 120
window:
has vbox
python:
try:
ui.text(eval(speaker_temp).name,color=eval(speaker_temp).who_args["color"])
except:
ui.text(speaker_temp)
input id "input" default minievent_temp.page_text[page]
screen comments_screen:
imagemap:
ground "images/bgs/start/editor.png"
vbox:
yfill True
viewport:
ymaximum 400
scrollbars "vertical"
draggable True
mousewheel True
vbox:
spacing 10
for ii in range(1,minievent_temp.totalpages+1):
if minievent_temp.comments[ii]!='':
$ ui.text ("PAGE "+str(ii)+" : "+minievent_temp.comments[ii])
hbox:
xalign 0.5
yalign 0.5
textbutton _('delete comment') action If(minievent_temp.comments[page]!='',Jump('delete_comment')) xminimum 200
textbutton _('change comment') action ui.callsinnewcontext('change_comment') xminimum 200
null width 50
textbutton _('return') action Return() xminimum 200
window:
text minievent_temp.comments[page]
###################################################################################################
###################################################################################################
#
#labels
#
###################################################################################################
###################################################################################################
#
#
#The label you need to point to start the event editor.
#
label EE_start:
developer "This is an Event Editor, have fun!"
call screen new_tutorial_menu
return
#
#
#When you start to write a new event:
#
label new_project:
$ modname = ""
menu:
"New Project For:"
"Main Game Plot":
pass
"Mod":
$modname = renpy.input("Write a name of mod","mod")
$_modn = modname + "_"
$ project_name = "EEout_" + _modn + renpy.input("Write a name for the event","test")
if project_name == "EEout_" + _modn:
developer "You must write a name for the event"
jump new_project
elif project_kind == "map":
jump EE_map
else:
$ minievent_list[project_name]=minievent(project_name,project_name,False)
$ minievent_temp=minievent_list[project_name]
$ page=1
$ pagechange = 0
$ sel_act=""
$ BG_temp = "black"
$ speaker_temp='narrator'
$ c_position="0"
$ char_expressions=[""]
$ char_onscreen_temp0=""
$ char_onscreen_temp1=""
$ char_onscreen_temp2=""
$ char_nu_temp = 0
$ position_temp_char0= 0
$ position_temp_char1= 0
$ position_temp_char2= 0
jump event_editor
return
label insert_pos_manually:
if char_nu_temp == 0:
$ position_temp_char0 = float(renpy.input("Write the xpos (remember it must be a float number):",allow=",.0123456789"))
if char_nu_temp == 1:
$ position_temp_char1 = float(renpy.input("Write the xpos (remember it must be a float number):",allow=",.0123456789"))
if char_nu_temp == 2:
$ position_temp_char2 = float(renpy.input("Write the xpos (remember it must be a float number):",allow=",.0123456789"))
return
label insert_speaker_manually:
$ speaker_temp = "\""+renpy.input("Write who is speaking:")+"\""
return
label change_comment:
$ minievent_temp.comments[page] = renpy.input("Change the comment:",default=minievent_temp.comments[page])
return
label delete_comment:
$ minievent_temp.comments[page] = ''
return
label change_project_name:
$ project_name=renpy.input("Write a name for the event",default=project_name)
if project_name=="EEout_":
"You must write a name for the event"
jump change_project_name
return
#
#This code is looped every time you change page while editing.
#It is needed to save all the variable modified and to update them for the new page.
#
label event_editor:
label event_editor_repeat:
$ minievent_temp.page_text[page]=renpy.call_screen("event_window")
if sel_act=="addpage1":
$ sel_act=""
$ minievent_temp.totalpages +=1
$ minievent_temp.page_text.insert(page,"")
$ minievent_temp.speaker.insert(page,'narrator')
$ minievent_temp.char_onscreen.insert(page,["","",""])
$ minievent_temp.char_position.insert(page,[0,0,0])
$ BG_temp=minievent_temp.BG[page]
$ minievent_temp.BG.insert(page,"black")
$ minievent_temp.comments.insert(page,"")
elif sel_act=="addpage2":
$ sel_act=""
$ minievent_temp.totalpages +=1
$ minievent_temp.page_text.append("")
$ minievent_temp.speaker.append('narrator')
$ minievent_temp.BG.append(BG_temp)
$ minievent_temp.char_onscreen.append([char_onscreen_temp0,char_onscreen_temp1,char_onscreen_temp2])
$ minievent_temp.char_position.append([position_temp_char0,position_temp_char1,position_temp_char2])
$ minievent_temp.comments.append("")
elif sel_act=="removepage":
menu:
"Are you sure you want to delete this page?"
"YES":
$ sel_act=""
$ minievent_temp.totalpages -=1
$ minievent_temp.page_text.pop(page)
$ minievent_temp.speaker.pop(page)
$ minievent_temp.BG.pop(page)
$ minievent_temp.char_onscreen.pop(page)
$ minievent_temp.char_position.pop(page)
$ minievent_temp.comments.pop(page)
if page>minievent_temp.totalpages:
$ page -= 1
$ BG_temp=minievent_temp.BG[page]
$ speaker_temp=minievent_temp.speaker[page]
$ [char_onscreen_temp0,char_onscreen_temp1,char_onscreen_temp2] = minievent_temp.char_onscreen[page]
$ [position_temp_char0,position_temp_char1,position_temp_char2] = minievent_temp.char_position[page]
"NO":
$ sel_act=""
$ minievent_temp.char_onscreen[page]=[char_onscreen_temp0,char_onscreen_temp1,char_onscreen_temp2]
$ minievent_temp.char_position[page]=[position_temp_char0,position_temp_char1,position_temp_char2]
$ minievent_temp.BG[page]=BG_temp
$ minievent_temp.speaker[page]=speaker_temp
$ page += pagechange
$ BG_temp=minievent_temp.BG[page]
$ speaker_temp=minievent_temp.speaker[page]
$ [char_onscreen_temp0,char_onscreen_temp1,char_onscreen_temp2] = minievent_temp.char_onscreen[page]
$ [position_temp_char0,position_temp_char1,position_temp_char2] = minievent_temp.char_position[page]
$ pagechange = 0
if sel_act=='out':
$ sel_act=""
scene
hide screen sc
hide screen event_main_menu
if project_kind=="map":
jump EE_map_repeat
jump event_editor_repeat
label exporting_project:
if project_name in EE__label_list:
menu:
debug "Warning!\n
Event with name [project_name] is already existing.\n
if you don't change event name it will over write existing one.\n
Do you want to overwrite?"
"Change Event name":
jump change_project_name
"Overwrite":
pass
python:
expath = "events/"
if modname != "":
expath = "mods/" + modname + "/" + expath
target = renpy.loader.transfn(expath)
target = open(target + project_name + ".rpy",'w+')
ind=''
n_ind=1
ind=indentation(n_ind)
target.write("label "+project_name+":\n")
if project_kind=="map":
export(minievent_list['beginning'],n_ind)
else:
export(minievent_list[project_name],n_ind)
target.write(" return")
target.close()
return
init python:
def export_scene(minievent_temp,ind):
for xx in range(1,minievent_temp.totalpages+1):
if minievent_temp.BG[xx-1]!=minievent_temp.BG[xx]:
target.write(ind+"scene "+minievent_temp.BG[xx]+"\n")
for yy in range(3):
if minievent_temp.char_onscreen[xx][yy]!=minievent_temp.char_onscreen[xx-1][yy] or (minievent_temp.char_position[xx][yy]!=minievent_temp.char_position[xx-1][yy] and minievent_temp.char_onscreen[xx][yy]!=""):
if minievent_temp.char_onscreen[xx][yy]=="":
target.write(ind+"hide "+minievent_temp.char_onscreen[xx-1][yy]+"\n")
else:
target.write(ind+"show "+minievent_temp.char_onscreen[xx][yy]+" at Position(xanchor=0.5,xpos=%f) \n" % minievent_temp.char_position[xx][yy])
if minievent_temp.speaker[xx]=='narrator':
target.write(ind+ "\""+minievent_temp.page_text[xx]+"\"\n")
else:
target.write(ind+minievent_temp.speaker[xx])
target.write(" \""+minievent_temp.page_text[xx]+"\"\n")
if minievent_temp.comments[xx]!='':
target.write(ind+" # "+minievent_temp.comments[xx])
target.write("\n")
return
def export(minievent_temp,n_ind):
ind=indentation(n_ind)
if minievent_temp.type=='normal':
export_scene(minievent_temp,ind)
if minievent_temp.branch!=False:
export(minievent_list[minievent_temp.branch[0]],n_ind)
elif minievent_temp.type=='branch':
target.write(ind+'menu:\n')
n_ind+=2
for ii in range(len(minievent_temp.branch)):
target.write(' '+ind+'"'+minievent_temp.branching_text[ii]+'":\n')
export(minievent_list[minievent_temp.branch[ii]],n_ind)
n_ind-=2
if minievent_temp.branch_end!=False:
export(minievent_list[minievent_temp.branch_end[0]],n_ind)
return
def indentation(n_ind):
ind=''
for ii in range(n_ind):
ind+=' '
return ind
label EE_tutorial:
scene bg start code
'In the Event Editor each "page" correspond to "one click" in game.'
'VERY IMPORTANT: The editor does not notice that you have modified a page until you "change page". So when you are going to EXPORT or SAVE the event, you should change page before doing so, this way you can be sure that your modifications are remembered.'
'TEXT' 'When you start the Event Editor you will have the possibility to write the text that you want to show in this window you are reading now. You can input the text in this very same window. It can be both dialogue or narration text. There are just a a couple thing you have to remember.'
'TEXT' 'You cannot write on a newline in the Event Editor. To do that you have to write "\\ n" (without the space in the middle) : when the event is shown in game, the text after "\\ n" will be shown on a new line. \nAlso remember that there is no need of space after the n: "Hi. \\ nHow are you?". No space between "\\ n" and "How".'
'SPEAKER' 'Select this button in the top-left part of the screen to choose wich name will be shown as the "speaker" of dialogue line. Select "none" if you are going to write a narration text.\nAnd there is also a "WRITE NEW" option to let you use a name that is not in the premade list.'
'CHARACTER' 'Select this to show some character on the screen. You can manage a max of three character on the screen at the same time. They will be "char1", "char2" and "char3". Use the bar or the numbered buttons to decide the character\'s horizontal position. You can also press the button under the bar, on the left, to input the position yourself (it must be a number between 0 and 1)'
'CHARACTER' 'Under the position bar you will see some buttons with names on them. Choose wich character you want to display on the screen. On the right there will be other buttons with numbers: each number corrispond to a different face expression, body position or dress for the selected character.'
'BACKGROUND' 'Select the BG button and you will have the list of background options.'
'COMMENTS' 'This open a new screen. In this screen you can add a comment for the page you were working on (you can also delete it). The comment will also be present in the EXPORTED code, after a \# so that anyone can see that comment when working on the code.\nAlso from this screen you can see all the comments of the current event.Use this option to remind yourself something or to give some info to anyone that will work on the exported code.'
'MENU' 'This button is in the top-right part of the screen. In this menu there are other option to modify your event.'
'EXPORT EVENT' 'Very easy to use. Just push the button. Then, in the same folder as the .exe, you will find a file named <project_name>.rpy. \nThat is the code for your event.'
'SAVE&LOAD' 'If you want to save your work, you can do so with the normal SAVE system. Just press "ESC", you will enter the game main menu and here you can save as if you were simply playing the game. To LOAD and contiue modifing your event just use the LOAD option.'
return