Пример #1
0
 def genDMIH(self):
     o = '\r\nstate "%s" {' % self.name
     o += self.genDMIHLine('hotspot', self.hotspot, '')
     o += self.genDMIHLine('frames', self.frames, -1)
     tdirs = 'ONE'
     if self.dirs == 4:
         tdirs = 'CARDINAL'
     elif self.dirs == 8:
         tdirs = 'ALL'
     o += self.genDMIHLine('dirs', tdirs, '')
     o += self.genDMIHLine('movement', self.movement, 0)
     o += self.genDMIHLine('loop', self.loop, 0)
     o += self.genDMIHLine('rewind', self.rewind, 0)
     o += self.genDMIHLine('delay', self.delay, [])
     
     o += '\n\timport pngs {' 
     for vdir in range(self.dirs):
         _dir = directions.IMAGE_INDICES[vdir]
         o += '\n\t\tdirection "%s" {' % directions.getNameFromDir(_dir)
         for f in range(self.frames):
             o += '\n\t\t\t"%s"' % self.getFrame(_dir, f)
         o += '\n\t\t}'
     o += '\n\t}'
     o += "\n}"
     return o
Пример #2
0
floors = DMI(sys.argv[1])
floors.loadAll()
basedir = 'floor_quads'
if os.path.isdir('floor_quads'):
    shutil.rmtree(basedir)
os.makedirs('floor_quads')
for icon_state in extract:
    if icon_state not in floors.states:
        print('Can\'t find state {0}!'.format(icon_state))
        continue
    for d in range(floors.states[icon_state].dirs):
        dirf = 0
        dirn = 'SOUTH'
        if floors.states[icon_state].dirs > 1:
            dirf = directions.IMAGE_INDICES[d]
            dirn = directions.getNameFromDir(dirf)
        print('{0} {1} {2}'.format(icon_state, dirn, floors.states[icon_state].dirs))
        img = floors.getFrame(icon_state, dirf, 0)
        for i in range(len(quadDefs)):
            quad = img.crop(quadDefs[i])
            if isKnownQuad(i, quad, icon_state):
                print('  Skipping quad #{}'.format(i + 1))
                continue
            color = icon_state
            if color.endswith('full'):
                color = color[:-4]
            qpath = os.path.join(basedir, str(i))
            qfile = os.path.join(qpath, '{0}.png'.format(color))
            if not os.path.isdir(qpath):
                os.makedirs(qpath)
            quad.save(qfile, 'PNG')