def makeDMI(): dmi = DMI('state_limit.dmi') # for i in range(513): # Make a new tile img = Image.new('RGBA', (32, 32)) # Set up PIL's drawing stuff draw = ImageDraw.Draw(img) # Define a font. font = ImageFont.truetype('arial.ttf', 10) # Draw the tile number draw.text((10, 0), str(i + 1), (0, 0, 0), font=font) # Make state state_name='state {0}'.format(i+1) state=State(state_name) state.dirs=1 state.frames=1 state.icons=[img] # Add state to DMI dmi.states[state_name]=state #save dmi.save('state_limit.dmi', sort=False)
nfloors = DMI('nfloors.dmi') for tileName,tileDef in tileDefs.items(): base = floors.getFrame(tileDef['base'],directions.SOUTH,0) for color in tileDef['colors']: for arrangement in tileDef['arrangements']: arrname='' arrange=[False,False,False,False] if isinstance(arrangement,str): arrange=arrangements[arrangement] arrname=arrangement elif isinstance(arrangement,list): arrange=arrangement[1:] arrname=arrangement[0] state='{base} {color} {arrangement}'.format(base=tileDef['base'],color=color,arrangement=arrname) nstate=State(state) nstate.dirs=len(arrange) nstate.frames=1 nstate.icons=[None for _ in range(nstate.dirs)] #statedebug = DMI(state+'.dmi') nfloors.states[state]=nstate for d in range(len(arrange)): cmap = arrange[d] dirf = 0 dirn = 'SOUTH' if len(arrange) > 1: dirf = directions.IMAGE_INDICES[d] dirn = directions.getNameFromDir(dirf) print(' Generating state {0} ({1})...'.format(repr(state),dirn)) #print(repr(arrange)) img=Image.new('RGBA',(32,32)) img.paste(base)