diff options
Diffstat (limited to '')
-rw-r--r-- | src/exporter.py | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/src/exporter.py b/src/exporter.py index bd28221..3e91e9f 100644 --- a/src/exporter.py +++ b/src/exporter.py @@ -177,6 +177,7 @@ class KPMapExporter: requiredFixUps = [] stringsToAdd = set() textures = set() + texInfo = set() tilesets = set() offsets = {None: 0xFFFFFFFF} @@ -250,6 +251,8 @@ class KPMapExporter: w, h = doodad.size data += struct.pack('>fffffii', x, y, w, h, doodad.angle, 0, len(doodad.animations)) + + texInfo.add((doodad.source[0], doodad.source[1].height() * doodad.source[1].width() * 2)) texture = doodad.source[1] textures.add(texture) requiredFixUps.append((len(data) - 8, texture)) @@ -296,35 +299,34 @@ class KPMapExporter: current = len(data) data += struct.pack('>hhiiiiii', x+12, y+12, 0, 0, 0, 0, 0, 0) - # figure out the exits by direction - exits = [None, None, None, None] - left, right, up, down = 0, 1, 2, 3 + # this varies + if node.isStop(): + # figure out the exits by direction + leftExit, rightExit, upExit, downExit = None, None, None, None - for exit in node.exits: - start, end = exit._startNodeRef(), exit._endNodeRef() - opposite = end if (start == node) else start + for exit in node.exits: + start, end = exit._startNodeRef(), exit._endNodeRef() + opposite = end if (start == node) else start - oX, oY = opposite.position - deltaX, deltaY = oX-x, oY-y - angle = math.degrees(math.atan2(deltaX, deltaY)) % 360 - print "Here: %d,%d Opposite %d,%d Delta: %d,%d Angle: %d" % (x,y,oX,oY,deltaX,deltaY,angle) + oX, oY = opposite.position + deltaX, deltaY = oX-x, oY-y + angle = math.degrees(math.atan2(deltaX, deltaY)) % 360 - # Left = 270, Right = 90, Up = 180, Down = 0 - if angle >= 225 and angle <= 315: - direction = left - elif angle >= 45 and angle <= 135: - direction = right - elif angle > 135 and angle < 225: - direction = up - elif angle > 315 or angle < 45: - direction = down + # Left = 270, Right = 90, Up = 180, Down = 0 + if angle >= 225 and angle <= 315: + leftExit = exit + elif angle >= 45 and angle <= 135: + rightExit = exit + elif angle > 135 and angle < 225: + upExit = exit + elif angle > 315 or angle < 45: + downExit = exit - if exits[direction]: - print "Conflicting directions!" - while exits[direction]: - direction = (direction + 1) % 4 + exits = [leftExit, rightExit, upExit, downExit] - exits[direction] = exit + else: + # not a stop, so just dump them in + exits = node.exits + [None,None,None,None] requiredFixUps.append((current+4, exits[0])) requiredFixUps.append((current+8, exits[1])) @@ -394,6 +396,20 @@ class KPMapExporter: data += '\0' # textures + texA = sorted(texInfo, key=lambda x: x[1]) + + s = 0 + d = 0 + for texItem in texA: + print texItem[1]/1000, "kb:", texItem[0] + s += texItem[1] + d += 1 + if d == 10: + d = 0 + print "So far:", s/1000, "kb" + + print "Total:", s/1000, "kb" + texPadding = ((len(data) + 0x1F) & ~0x1F) - len(data) data += ('\0' * texPadding) |