dashcode 1.2.5__tar.gz → 1.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dashcode-1.2.5 → dashcode-1.2.6}/PKG-INFO +1 -1
- dashcode-1.2.6/dashcode/core.py +177 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/dashcode.egg-info/PKG-INFO +1 -1
- {dashcode-1.2.5 → dashcode-1.2.6}/setup.py +1 -1
- dashcode-1.2.5/dashcode/core.py +0 -182
- {dashcode-1.2.5 → dashcode-1.2.6}/README.md +0 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/dashcode/__init__.py +0 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/dashcode.egg-info/SOURCES.txt +0 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/dashcode.egg-info/dependency_links.txt +0 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/dashcode.egg-info/top_level.txt +0 -0
- {dashcode-1.2.5 → dashcode-1.2.6}/setup.cfg +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import gzip
|
|
3
|
+
obj_string = ""
|
|
4
|
+
lvlname = ""
|
|
5
|
+
|
|
6
|
+
print("Dashcode loaded! Have fun and also join our discord server please: https://discord.gg/MXv3KTFmPE")
|
|
7
|
+
|
|
8
|
+
class Dashcode:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.objects = []
|
|
11
|
+
self.params = {
|
|
12
|
+
"NoTouch": 13,
|
|
13
|
+
"Hide": 12,
|
|
14
|
+
"Group": 57,
|
|
15
|
+
"TGroup": 51,
|
|
16
|
+
"MoveX":28,
|
|
17
|
+
"MoveY":29,
|
|
18
|
+
"LockToPX":34,
|
|
19
|
+
"LockToPY": 35,
|
|
20
|
+
"UseTarget":36,
|
|
21
|
+
"TMoveGroup":39,
|
|
22
|
+
"Duration": 10,
|
|
23
|
+
"Alpha": 11,
|
|
24
|
+
"TouchTrigger": 11,
|
|
25
|
+
"ActivateGroup": 56,
|
|
26
|
+
"ScaleX": 128,
|
|
27
|
+
"ScaleY": 129,
|
|
28
|
+
"Zoom": 107,
|
|
29
|
+
"RotateDegrees": 68,
|
|
30
|
+
"Times360": 69,
|
|
31
|
+
"LockRot": 70,
|
|
32
|
+
"Red":7,
|
|
33
|
+
"Green":8,
|
|
34
|
+
"Blue":9,
|
|
35
|
+
"Fade":10,
|
|
36
|
+
"TargetColor":23,
|
|
37
|
+
"Delay": 63,
|
|
38
|
+
"SpawnTrigger":62,
|
|
39
|
+
"MultiTrigger":87
|
|
40
|
+
}
|
|
41
|
+
self.objectids = {
|
|
42
|
+
"block": 1, "spike": 8, "yorb": 36, "coin": 1329,
|
|
43
|
+
"monster": 918, "bush": 128, "cloud": 129,
|
|
44
|
+
"alpha": 1007, "toggle": 1049, "rotate": 1346,
|
|
45
|
+
"zoom": 1913, "reverse": 1912, "move":901,
|
|
46
|
+
"checkpoint": 2063,
|
|
47
|
+
"spawn":1268,
|
|
48
|
+
"end": 3600,
|
|
49
|
+
"p_blue": 10, "p_yellow": 11, "p_green": 2926,
|
|
50
|
+
"p_cube": 12, "p_ship": 13, "p_ball": 47, "p_ufo": 111,
|
|
51
|
+
"p_wave": 660, "p_robot": 745, "p_spider": 1331, "p_swing": 1933
|
|
52
|
+
}
|
|
53
|
+
self.prefabs = {
|
|
54
|
+
"wall": {"Y":0},
|
|
55
|
+
"platform": {"X":0},
|
|
56
|
+
"square": {"SQ":0},
|
|
57
|
+
"corridor": {"X":1},
|
|
58
|
+
}
|
|
59
|
+
self.timeline = {}
|
|
60
|
+
def setobjects(self, objs:dict):
|
|
61
|
+
self.objectids = objs
|
|
62
|
+
def export_gmd(self, filedata, filename:str="Level"):
|
|
63
|
+
with open(f"{filename}.gmd", "w", encoding="utf-8") as f:
|
|
64
|
+
f.write(filedata)
|
|
65
|
+
def setparams(self, params:dict):
|
|
66
|
+
self.params = params
|
|
67
|
+
|
|
68
|
+
def format_groups(self, group_list):
|
|
69
|
+
if not group_list:
|
|
70
|
+
return ""
|
|
71
|
+
return ".".join(map(str, group_list))
|
|
72
|
+
def get_free_group(self):
|
|
73
|
+
used_groups = set()
|
|
74
|
+
for obj in self.objects:
|
|
75
|
+
if "57" in obj:
|
|
76
|
+
parsed = Dashcode().parse_object_string(obj)
|
|
77
|
+
for i2,v2 in parsed.items():
|
|
78
|
+
#print(i,v,type(i))
|
|
79
|
+
if i2 == "57":
|
|
80
|
+
for v in v2.split("."):
|
|
81
|
+
used_groups.add(int(v))
|
|
82
|
+
current_id = 1
|
|
83
|
+
while current_id in used_groups:
|
|
84
|
+
current_id += 1
|
|
85
|
+
return str(current_id)
|
|
86
|
+
|
|
87
|
+
def addobject(self, obj, params: dict):
|
|
88
|
+
if len(self.objects) <= 0:
|
|
89
|
+
self.objects.append(f"1,1,2,{-10 * 30},3,{-10 * 30},12,1,13,1")
|
|
90
|
+
extraparams = ""
|
|
91
|
+
for param, value in params.items():
|
|
92
|
+
if param in ["X", "Y", "EX", "EY"]:
|
|
93
|
+
continue
|
|
94
|
+
target_id = None
|
|
95
|
+
for i, v in self.params.items():
|
|
96
|
+
if str(param).startswith(str(i)):
|
|
97
|
+
target_id = v
|
|
98
|
+
break
|
|
99
|
+
if target_id is not None:
|
|
100
|
+
if target_id == 57 and isinstance(value, list):
|
|
101
|
+
extraparams += f",57,{self.format_groups(value)}"
|
|
102
|
+
else:
|
|
103
|
+
extraparams += f",{target_id},{value}"
|
|
104
|
+
else:
|
|
105
|
+
extraparams += f",{param},{value}"
|
|
106
|
+
oid = self.objectids.get(obj, obj)
|
|
107
|
+
pos_x = params.get('X', 0) * 30 + 15
|
|
108
|
+
pos_y = params.get('Y', 0) * 30 + 15
|
|
109
|
+
full_obj_string = f"1,{oid},2,{pos_x},3,{pos_y}{extraparams}"
|
|
110
|
+
self.objects.append(full_obj_string)
|
|
111
|
+
def parse_object_string(self,objstr):
|
|
112
|
+
data = objstr.split(',')
|
|
113
|
+
obj_dict = {}
|
|
114
|
+
for i in range(0, len(data) - 1, 2):
|
|
115
|
+
key = data[i]
|
|
116
|
+
value = data[i + 1]
|
|
117
|
+
obj_dict[key] = value
|
|
118
|
+
return obj_dict
|
|
119
|
+
|
|
120
|
+
def addprefab(self, obj: str, params: dict, prefab: str):
|
|
121
|
+
fab = self.prefabs.get(prefab)
|
|
122
|
+
if not fab:
|
|
123
|
+
return
|
|
124
|
+
ex = params.get('EX', 0)
|
|
125
|
+
ey = params.get('EY', 0)
|
|
126
|
+
base_x = params.get('X', 0)
|
|
127
|
+
base_y = params.get('Y', 0)
|
|
128
|
+
def place(x_val, y_val):
|
|
129
|
+
current_params = dict(params)
|
|
130
|
+
current_params["X"] = x_val
|
|
131
|
+
current_params["Y"] = y_val
|
|
132
|
+
self.addobject(obj, current_params)
|
|
133
|
+
if fab.get("X") == 0:
|
|
134
|
+
for i in range(ex):
|
|
135
|
+
place(base_x + i, base_y)
|
|
136
|
+
elif fab.get("Y") == 0:
|
|
137
|
+
for i in range(ey):
|
|
138
|
+
place(base_x, base_y + i)
|
|
139
|
+
elif fab.get("SQ") == 0:
|
|
140
|
+
for i in range(ex):
|
|
141
|
+
for v in range(ey):
|
|
142
|
+
place(base_x + i, base_y + v)
|
|
143
|
+
elif fab.get("X") == 1:
|
|
144
|
+
for i in range(ex):
|
|
145
|
+
place(base_x + i, base_y)
|
|
146
|
+
place(base_x + i, base_y + ey)
|
|
147
|
+
elif fab.get("Y") == 1:
|
|
148
|
+
for i in range(ey):
|
|
149
|
+
place(base_x, base_y + i)
|
|
150
|
+
place(base_x + ex, base_y + i)
|
|
151
|
+
def build_timeline(self, timeline:list):
|
|
152
|
+
cdelay = 0
|
|
153
|
+
for tlobj in timeline:
|
|
154
|
+
i = tlobj.get("Index")
|
|
155
|
+
v = tlobj.get("Value")
|
|
156
|
+
if i == "wait":
|
|
157
|
+
cdelay += v
|
|
158
|
+
elif i == "spawn":
|
|
159
|
+
self.addobject("spawn", {"X":-1, "Y":6, "Delay":str(cdelay),"TGroup":str(v)})
|
|
160
|
+
else:
|
|
161
|
+
params = {"X":-1,"Y":5}
|
|
162
|
+
for i2,v2 in v.items():
|
|
163
|
+
params[i2] = v2
|
|
164
|
+
self.addobject(i,params)
|
|
165
|
+
def create_gmd_file(self, level_name, objects_string):
|
|
166
|
+
global lvlname
|
|
167
|
+
lvlname = level_name
|
|
168
|
+
final_string_to_pack = objects_string
|
|
169
|
+
gzipped = gzip.compress(final_string_to_pack.encode('utf-8'))
|
|
170
|
+
b64_objects = base64.b64encode(gzipped).decode('utf-8').replace('/', '_').replace('+', '-')
|
|
171
|
+
return f'''<?xml version="1.0"?><plist version="1.0" gjver="2.0"><dict><k>kCEK</k><i>4</i><k>k2</k><s>{level_name}</s><k>k4</k><s>{b64_objects}</s><k>k5</k><s>Doesn't matter</s><k>k11</k><i>1091</i><k>k16</k><i>1</i><k>k80</k><i>56</i></dict></plist>'''
|
|
172
|
+
|
|
173
|
+
def decode_objects(self):
|
|
174
|
+
objects = self.objects
|
|
175
|
+
global obj_string
|
|
176
|
+
obj_string = ";".join(objects) + ";"
|
|
177
|
+
return obj_string
|
dashcode-1.2.5/dashcode/core.py
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import gzip
|
|
3
|
-
obj_string = ""
|
|
4
|
-
lvlname = ""
|
|
5
|
-
|
|
6
|
-
print("Dashcode loaded! Have fun and also join our discord server please: https://discord.gg/MXv3KTFmPE")
|
|
7
|
-
|
|
8
|
-
class Dashcode:
|
|
9
|
-
def __init__(self):
|
|
10
|
-
self.objects = []
|
|
11
|
-
self.params = {
|
|
12
|
-
"NoTouch": 13,
|
|
13
|
-
"Hide": 12,
|
|
14
|
-
"Group": 57,
|
|
15
|
-
"TGroup": 51,
|
|
16
|
-
"Duration": 10,
|
|
17
|
-
"Alpha": 11,
|
|
18
|
-
"TouchTrigger": 11,
|
|
19
|
-
"ActivateGroup": 56,
|
|
20
|
-
"ScaleX": 128,
|
|
21
|
-
"ScaleY": 129,
|
|
22
|
-
"Zoom": 107,
|
|
23
|
-
"RotateDegrees": 68,
|
|
24
|
-
"Times360": 69,
|
|
25
|
-
"LockRot": 70,
|
|
26
|
-
"Red":7,
|
|
27
|
-
"Green":8,
|
|
28
|
-
"Blue":9,
|
|
29
|
-
"Fade":10,
|
|
30
|
-
"TargetColor":23,
|
|
31
|
-
"Delay": 63,
|
|
32
|
-
"SpawnTrigger":62,
|
|
33
|
-
"MultiTrigger":87
|
|
34
|
-
}
|
|
35
|
-
self.objectids = {
|
|
36
|
-
"block": 1, "spike": 8, "yorb": 36, "coin": 1329,
|
|
37
|
-
"monster": 918, "bush": 128, "cloud": 129,
|
|
38
|
-
"alpha": 1007, "toggle": 1049, "rotate": 1346,
|
|
39
|
-
"zoom": 1913, "reverse": 1912,
|
|
40
|
-
"checkpoint": 2063,
|
|
41
|
-
"spawn":1268,
|
|
42
|
-
"end": 3600,
|
|
43
|
-
"p_blue": 10, "p_yellow": 11, "p_green": 2926,
|
|
44
|
-
"p_cube": 12, "p_ship": 13, "p_ball": 47, "p_ufo": 111,
|
|
45
|
-
"p_wave": 660, "p_robot": 745, "p_spider": 1331, "p_swing": 1933
|
|
46
|
-
}
|
|
47
|
-
self.prefabs = {
|
|
48
|
-
"wall": {"Y":0},
|
|
49
|
-
"platform": {"X":0},
|
|
50
|
-
"square": {"SQ":0},
|
|
51
|
-
"corridor": {"X":1},
|
|
52
|
-
}
|
|
53
|
-
self.timeline = {}
|
|
54
|
-
def setobjects(self, objs:dict):
|
|
55
|
-
self.objectids = objs
|
|
56
|
-
def export_gmd(self, filedata, filename:str="Level"):
|
|
57
|
-
with open(f"{filename}.gmd", "w", encoding="utf-8") as f:
|
|
58
|
-
f.write(filedata)
|
|
59
|
-
def setparams(self, params:dict):
|
|
60
|
-
self.params = params
|
|
61
|
-
|
|
62
|
-
def get_free_group(self):
|
|
63
|
-
used_groups = set()
|
|
64
|
-
for obj in self.objects:
|
|
65
|
-
if "57" in obj:
|
|
66
|
-
parsed = Dashcode().parse_object_string(obj)
|
|
67
|
-
for i,v in parsed.items():
|
|
68
|
-
#print(i,v,type(i))
|
|
69
|
-
if i == "57":
|
|
70
|
-
used_groups.add(int(v))
|
|
71
|
-
current_id = 1
|
|
72
|
-
while current_id in used_groups:
|
|
73
|
-
current_id += 1
|
|
74
|
-
return str(current_id)
|
|
75
|
-
def addobject(self, obj: str, params: dict):
|
|
76
|
-
objects = self.objects
|
|
77
|
-
if len(objects) <= 0:
|
|
78
|
-
objects.append(
|
|
79
|
-
f"1,1,2,{str(-10 * 30)},3,{str(-10 * 30)},12,1,13,1")
|
|
80
|
-
extraparams = ""
|
|
81
|
-
for param, value in params.items():
|
|
82
|
-
for i in self.params:
|
|
83
|
-
if param.startswith(i):
|
|
84
|
-
pid = self.params[param]
|
|
85
|
-
extraparams += f",{str(pid)},{value}"
|
|
86
|
-
else:
|
|
87
|
-
extraparams += f",{str(param)},{value}"
|
|
88
|
-
|
|
89
|
-
oid = self.objectids.get(obj, 1)
|
|
90
|
-
if oid:
|
|
91
|
-
objects.append(
|
|
92
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15)},3,{str(params.get('Y') * 30 + 15)}{extraparams}")
|
|
93
|
-
else:
|
|
94
|
-
objects.append(
|
|
95
|
-
f"1,{str(obj)},2,{str(params.get('X') * 30 + 15)},3,{str(params.get('Y') * 30 + 15)}{extraparams}")
|
|
96
|
-
def parse_object_string(self,objstr):
|
|
97
|
-
data = objstr.split(',')
|
|
98
|
-
|
|
99
|
-
obj_dict = {}
|
|
100
|
-
for i in range(0, len(data) - 1, 2):
|
|
101
|
-
key = data[i]
|
|
102
|
-
value = data[i + 1]
|
|
103
|
-
obj_dict[key] = value
|
|
104
|
-
|
|
105
|
-
return obj_dict
|
|
106
|
-
def addprefab(self, obj:str, params:dict, prefab:str):
|
|
107
|
-
objects = self.objects
|
|
108
|
-
extraparams = ""
|
|
109
|
-
for param, value in params.items():
|
|
110
|
-
if self.params.get(param) is not None:
|
|
111
|
-
pid = self.params[param]
|
|
112
|
-
extraparams += f",{str(pid)},{value}"
|
|
113
|
-
else:
|
|
114
|
-
extraparams += f",{str(param)},{value}"
|
|
115
|
-
|
|
116
|
-
oid = self.objectids.get(obj, 1)
|
|
117
|
-
if prefab:
|
|
118
|
-
#print("1")
|
|
119
|
-
fab = self.prefabs.get(prefab)
|
|
120
|
-
if fab:
|
|
121
|
-
#print(fab)
|
|
122
|
-
#print("2")
|
|
123
|
-
newobjs = []
|
|
124
|
-
if fab.get("X") == 0:
|
|
125
|
-
#print("3")
|
|
126
|
-
for i in range(params.get('EX')):
|
|
127
|
-
newobjs.append(
|
|
128
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + (i * 30))},3,{str(params.get('Y') * 30 + 15)}{extraparams}")
|
|
129
|
-
if fab.get("Y") == 0:
|
|
130
|
-
#print("3")
|
|
131
|
-
for i in range(params.get('EY')):
|
|
132
|
-
newobjs.append(
|
|
133
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15)},3,{str(params.get('Y') * 30 + 15 + (i * 30))}{extraparams}")
|
|
134
|
-
if fab.get("SQ") == 0:
|
|
135
|
-
for i in range(params.get('EX')):
|
|
136
|
-
newobjs.append(
|
|
137
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + (i * 30))},3,{str(params.get('Y') * 30 + 15)}{extraparams}")
|
|
138
|
-
for v in range(params.get('EY') - 1):
|
|
139
|
-
newobjs.append(
|
|
140
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + (i * 30))},3,{str(params.get('Y') * 30 + 15 + (v * 30) + 30)}{extraparams}")
|
|
141
|
-
if fab.get("X") == 1:
|
|
142
|
-
for i in range(params.get('EX')):
|
|
143
|
-
newobjs.append(
|
|
144
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + (i * 30))},3,{str(params.get('Y') * 30 + 15)}{extraparams}")
|
|
145
|
-
for i in range(params.get('EX')):
|
|
146
|
-
newobjs.append(
|
|
147
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + (i * 30))},3,{str(params.get('Y') * 30 + 15 + params.get("EY") * 30)}{extraparams}")
|
|
148
|
-
if fab.get("Y") == 1:
|
|
149
|
-
for i in range(params.get('EY')):
|
|
150
|
-
newobjs.append(
|
|
151
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15)},3,{str(params.get('Y') * 30 + 15 + (i * 30))}{extraparams}")
|
|
152
|
-
for i in range(params.get('EY')):
|
|
153
|
-
newobjs.append(
|
|
154
|
-
f"1,{str(oid)},2,{str(params.get('X') * 30 + 15 + params.get("EX") * 30)},3,{str(params.get('Y') * 30 + 15 + (i * 30))}{extraparams}")
|
|
155
|
-
objects += newobjs
|
|
156
|
-
def build_timeline(self, timeline:list):
|
|
157
|
-
cdelay = 0
|
|
158
|
-
for tlobj in timeline:
|
|
159
|
-
i = tlobj.get("Index")
|
|
160
|
-
v = tlobj.get("Value")
|
|
161
|
-
if i == "wait":
|
|
162
|
-
cdelay += v
|
|
163
|
-
elif i == "spawn":
|
|
164
|
-
self.addobject("spawn", {"X":-1, "Y":6, "Delay":str(cdelay),"TGroup":str(v)})
|
|
165
|
-
else:
|
|
166
|
-
params = {"X":-1,"Y":5}
|
|
167
|
-
for i2,v2 in v.items():
|
|
168
|
-
params[i2] = v2
|
|
169
|
-
self.addobject(i,params)
|
|
170
|
-
def create_gmd_file(self, level_name, objects_string):
|
|
171
|
-
global lvlname
|
|
172
|
-
lvlname = level_name
|
|
173
|
-
final_string_to_pack = objects_string
|
|
174
|
-
gzipped = gzip.compress(final_string_to_pack.encode('utf-8'))
|
|
175
|
-
b64_objects = base64.b64encode(gzipped).decode('utf-8').replace('/', '_').replace('+', '-')
|
|
176
|
-
return f'''<?xml version="1.0"?><plist version="1.0" gjver="2.0"><dict><k>kCEK</k><i>4</i><k>k2</k><s>{level_name}</s><k>k4</k><s>{b64_objects}</s><k>k5</k><s>Doesn't matter</s><k>k11</k><i>1091</i><k>k16</k><i>1</i><k>k80</k><i>56</i></dict></plist>'''
|
|
177
|
-
|
|
178
|
-
def decode_objects(self):
|
|
179
|
-
objects = self.objects
|
|
180
|
-
global obj_string
|
|
181
|
-
obj_string = ";".join(objects) + ";"
|
|
182
|
-
return obj_string
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|