-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.py
104 lines (94 loc) · 3.64 KB
/
map.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
import PIL
from PIL import ImageTk, Image
class myMap:
def __init__(self, name, initValues_instance):
self.initValues = initValues_instance
self.name = name
self.map = []
self.exportMap = []
self.exportMap2 = []
self.clipboardElementMemo = 0
self.pythonImageObjectMemory = []
def add(self, x, pythonImgAbsPath):
self.map.append(x)
self.pythonImageObjectMemory.append(pythonImgAbsPath)
# print("New element added to the current map also created image: " + self.name)
def prepareForSave(self):
for (element,pythonImageObjectMemo) in zip(self.map, self.pythonImageObjectMemory):
if hasattr(element, 'text'):
# print("DETECTED TEXT LABEL")
myObject = {
"x": str(element.x),
"y": str(element.y),
"text": str(element.text),
"textColor": str(element.textColor),
"textSize": element.textSize,
"pythonImgPath": pythonImageObjectMemo
}
else:
myObject = { "x": str(element.x),
"y": str(element.y),
"w": str(element.w),
"h": str(element.h),
"tex": element.texture,
"tiles":
{
"tilesX": str(element.tilesX),
"tilesY": str(element.tilesY)
},
"pythonImgPath": pythonImageObjectMemo
}
if hasattr(element, 'colectionLabel'):
myObject["colectionLabel"] = element.colectionLabel
myObject["points"] = element.points
# print("It is a collection item ...")
if hasattr(element, 'enemyLabel'):
myObject["enemyLabel"] = element.enemyLabel
myObject["enemyOptions"] = element.enemyOptions
# print("It is a enemy item ...")
self.exportMap.append(myObject)
def prepareForExport(self):
self.exportMap2.clear()
for element in self.map:
if hasattr(element, 'text'):
# print("DETECTED TEXT LABEL")
myObject = {
"x": str(element.x),
"y": str(element.y),
"text": str(element.text),
"textColor": str(element.textColor),
"textSize": element.textSize
}
else:
myObject = { "x": element.x * self.initValues.exportScale,
"y": element.y * self.initValues.exportScale,
"w": element.w * self.initValues.exportScale,
"h": element.h * self.initValues.exportScale,
"tex": element.texture,
"tiles":
{
"tilesX": element.tilesX,
"tilesY": element.tilesY
}
}
if hasattr(element, 'colectionLabel'):
myObject["colectionLabel"] = element.colectionLabel
myObject["points"] = element.points
print("It is a collection item ...")
if hasattr(element, 'enemyLabel'):
myObject["enemyLabel"] = element.enemyLabel
myObject["enemyOptions"] = element.enemyOptions
print("It is a enemy item ...")
self.exportMap2.append(myObject)
def clear(self):
self.map.clear()
self.pythonImageObjectMemory.clear()
self.exportMap.clear()
self.exportMap2.clear()
def removeLast(self):
self.clipboardElementMemo = self.map.pop()
self.pythonImageObjectMemory.pop()
if len(self.exportMap) != 0:
self.exportMap.pop()
if len(self.exportMap2) != 0:
self.exportMap2.pop()