-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
238 lines (223 loc) · 7.95 KB
/
main.py
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
import glob
import os.path
import pathlib
import generation.converts as converts
import generation.copyright as gencopy
import generation.dump_py as dumpy
release_year = 2023
repo = "https://github.com/yoimerdr/gallerynpy"
def generate_dumpy_renpy():
"""
Generate some empty renpy classes and functions to correct lint errors in the IDE.
All the src/gallerynpy/store package is generated with this.
"""
args = [dumpy.PyParameter("*args"), dumpy.PyParameter("**kwargs")]
display_pck = dumpy.PyPackage(
name="display",
variables=[
dumpy.PyVariable("core", value="displayable", has_value=True)
],
files=[
dumpy.PyFile(
name="im",
imports=[
dumpy.PyImport(
dumpy.Nameable("displayable"),
imports=[dumpy.Nameable("Displayable")],
relative=True
)
],
classes=[
dumpy.PyClass(name="Surfer", methods=[
dumpy.PyFunction("get_size", simple_return="1920, 1080"),
]),
dumpy.PyClass(
name="Image",
parent=dumpy.Nameable("Displayable"),
methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("path"),
]),
dumpy.PyFunction(name="load", simple_return="Surfer()")
]
),
dumpy.PyClass(
name="Scale",
parent=dumpy.Nameable("Displayable"),
methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("path"),
dumpy.PyParameter("width"),
dumpy.PyParameter("height"),
*args
])
]
)
]
),
dumpy.PyFile(
name="transform",
classes=[dumpy.PyClass("ATLTransform")]
),
dumpy.PyFile(
name="displayable",
classes=[dumpy.PyClass("Displayable")]
)
],
import_all=True
)
renpy_pck = dumpy.PyPackage(
name="renpy",
files=[
dumpy.PyFile(
name="config",
variables=[
dumpy.PyVariable(name="basedir", value="'/'")
]
)
],
functions=[
dumpy.PyFunction(
name="loadable",
params=[dumpy.PyParameter("path")],
simple_return="True"
),
dumpy.PyFunction(
name="get_registered_image",
params=[dumpy.PyParameter("name")],
simple_return="Image(name)"
),
dumpy.PyFunction(name="restart_interaction")
],
packages=[
display_pck
],
import_all=True
)
store_pck = dumpy.PyPackage(
"store",
imports=[
dumpy.PyImport(
dumpy.Nameable("renpy.display"),
relative=True,
import_all=True
)
],
variables=[
dumpy.PyVariable(name="dissolve")
],
classes=[
dumpy.PyClass(
name="Action",
methods=[
dumpy.PyFunction(name="get_sensitive", simple_return="True"),
dumpy.PyFunction(name="get_selected", simple_return="False"),
dumpy.PyFunction(name="__call__", params=[
dumpy.PyParameter(name="*args"),
dumpy.PyParameter(name="**kwargs")
])
]
),
dumpy.PyClass(
name="Solid",
parent=dumpy.Nameable("Displayable"),
methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("color")
])
]),
dumpy.PyClass(
name="Composite",
methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("size", ),
dumpy.PyParameter("positions"),
dumpy.PyParameter("displayable")
])
]
),
dumpy.PyClass(name="Button", methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter(name="action")
])
]),
dumpy.PyClass(name="Function", methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("callable", ),
*args
])
]),
dumpy.PyClass(name="Call", methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("label", ),
*args
])
]),
dumpy.PyClass(name="Play", methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("canal", ),
dumpy.PyParameter("resource", )
])
]),
dumpy.PyClass(name="Stop", methods=[
dumpy.PyFunction(name="__init__", params=[
dumpy.PyParameter("canal", ),
])
]),
dumpy.PyClass(name="Null"),
dumpy.PyClass(name="NullAction", parent=dumpy.Nameable(name="Action")),
dumpy.PyClass(name="Return"),
dumpy.PyClass(name="Gallery", methods=[
dumpy.PyFunction(name="image", params=[
dumpy.PyParameter(name="displayable"),
*args
]),
dumpy.PyFunction(name="condition", params=[
dumpy.PyParameter(name="condition"),
*args
]),
dumpy.PyFunction(name="button", params=[
dumpy.PyParameter(name="name"),
*args
]),
dumpy.PyFunction(name="make_button", params=[
dumpy.PyParameter("name"),
dumpy.PyParameter("disp"),
*args
], return_type="Button")
])
],
packages=[
renpy_pck
],
files=[
dumpy.PyFile(name="ui", functions=[
dumpy.PyFunction(name="adjustment")
]),
dumpy.PyFile(name="persistent", variables=[
dumpy.PyVariable(name="gallerynpy_with_speed"),
dumpy.PyVariable(name="gallerynpy_animation_speed")
]),
dumpy.PyFile(name="config", variables=[
dumpy.PyVariable(name="screen_width", value=1920),
dumpy.PyVariable(name="screen_height", value=1080)
])
],
import_all=False
)
store_pck.create()
def add_copyright():
files = glob.glob("gallerynpy/**/*.py", recursive=True)
gencopy.remove_from(files, release_year, "Yoimer Davila", repo)
gencopy.add_to(files, release_year, "Yoimer Davila", repo)
def generate_rpy():
"""
Copy the contents of the _ren.py files and pass them to an .rpy file according to the renpy instruction present in it.
"""
files = glob.glob("gallerynpy/**/*.py", recursive=True)
out = pathlib.Path(os.path.abspath("dist"))
converts.to_rpyf(files, out_folder=str(out))
gencopy.add_to(out.glob("**/*.rpy"), release_year, "Yoimer Davila", repo)
# generate_dumpy_renpy()
# add_copyright()
generate_rpy()