#xc = 0 if y%2 else tw/2 rs = '' for x, tile in enumerate(ln): #if x < 200: continue #if x > 150: continue pal, row, col = tile if not ((pal == 0 and row in (1, 3)) or (pal == 1 and row in (8, 9, 10, 11, 13))): continue rs += '<div class="t%d" style="left:%dpx;top:%dpx"></div>' % ( pal * 256 + row * 16 + col, x * tw + xc, y * dh) out.write(rs) cities = reader_cty.readData(dlPath) for c in cities: name = utils.tchars(c['full_name']) x, y = c['entry_coords'] x1 = x * tw + (tw / 2 if y % 2 else 0) y1 = y * dh x2, y2 = c['exit_coords'] x2 = x2 * tw + (tw / 2 if y % 2 else 0) y2 = y2 * dh out.write('<div class="c" style="left:%dpx;top:%dpx">'\ %((x1+x2)//2-tw//2, (y1+y2)//2-th//2)) out.write("<b>%s</b><br><br>" % (name)) out.write(utils.itemStr(c).replace('\n', '<br>')) out.write('</div>') out.write('''</div> </body> </html>''')
srf.blit(pals[pal], (x*tw+xc, y*dh), (col*tw, row*th, tw, th)) fontBig = pygame.font.SysFont(fontName, 18) fontSmaller = pygame.font.SysFont(fontName, 12) fontSmallest = pygame.font.SysFont(fontName, 9) fonts = {0:fontBig, 8:fontSmaller, 13:0, 15:0, 16:0, 17:0, 18:0, 19:0, 20:0} print ('Reading cities...') cities = reader_cty.readData(dlPath) print ('Rendering names...') for i, loc in enumerate(locs): lt = loc['icon'] name = loc['name'] if lt else cities[i]['name'] name = utils.tchars(name).decode('utf-8') x, y = loc['coords'] x = x*tw + (tw/2 if y%2 else 0) y *= dh font = fonts.get(lt, fontSmallest) if not font: continue text = font.render(name, True, (255, 255, 0)) textS = font.render(name, True, (0, 0, 0, 128)) cx = x + tw//2 cy = y + dh//2 x = cx - text.get_width()//2 y = cy - text.get_height()//2 - 2*dh #print name, x, y, x1, y1, x2, y2 srf.blit(textS, (x+1, y+1)) srf.blit(text, (x, y))
of.write(''' ], locs: [ ''') print "Reading cities..." cities = format_cty.readData(dlPath) print "Reading locs..." locs = reader_loc.readData(dlPath) for i, l in enumerate(locs): x, y = l['coords'] ic = l['icon'] name = l['name'] if ic else cities[i].name name = utils.tchars(name) of.write('{icon:%d, name:"%s"},\n' % (ic, name)) #srf.fill((4, 154, 0)) of.write(''' ], locIcons: { 1:[1, 12, 0], // castle 2:[1, 12, 0], // castle 3:[1, 12, 1], // monastery 6:[1, 12, 5], // mines 8:[1, 13, 0], // village 16:[1, 12, 4], // spring 17:[1, 12, 4], // lake
<html> <head> <meta charset="utf-8"> <style type="text/css"> .ce, .cx, .l {position:absolute;width:8px;height:8px;} .ce {background-color:green;} .cx {background-color:blue;} .l {border:1px solid red;} </style> </head> <body> <div style="position:relative;border:1px solid gray;width:%dpx;height:%dpx">''' % ( divW, divH) for c in cities: name = utils.tchars(c['short_name']) x, y = c['entry_coords'] dx, dy = x - minX, y - minY print '<div class="ce" style="top:%dpx;left:%dpx" title="%s"></div>' % ( int(dy * a / 2) - 4, int(dx * a) - 4, name + ' E') x, y = c['exit_coords'] dx, dy = x - minX, y - minY print '<div class="cx" style="top:%dpx;left:%dpx" title="%s"></div>' % ( int(dy * a / 2) - 4, int(dx * a) - 4, name + ' X') locs = reader_loc.readData(dlPath) for c in locs: name = utils.tchars(c['name'] + '(' + c['str_loc_type'] + ')') x, y = c['coords'] dx, dy = x - minX, y - minY
def serArr(a): return '"' + ('","'.join([tchars(n) for n in a])) + '"'
#xc = 0 if y%2 else tw/2 rs = '' for x, tile in enumerate(ln): #if x < 200: continue #if x > 150: continue pal, row, col = tile if not ((pal == 0 and row in (1, 3)) or (pal == 1 and row in (8, 9, 10, 11, 13))): continue rs += '<div class="t%d" style="left:%dpx;top:%dpx"></div>' % ( pal * 256 + row * 16 + col, x * tw + xc, y * dh) out.write(rs) cities = format_cty.readData(dlPath) for c in cities: name = utils.tchars(c.name) x, y = c.entry_coords x1 = x * tw + (tw / 2 if y % 2 else 0) y1 = y * dh x2, y2 = c.exit_coords x2 = x2 * tw + (tw / 2 if y % 2 else 0) y2 = y2 * dh out.write('<div class="c" style="left:%dpx;top:%dpx">'\ %((x1+x2)//2-tw//2, (y1+y2)//2-th//2)) out.write("<b>%s</b><br><br>" % (name)) out.write(utils.itemStr(c).replace('\n', '<br>')) out.write('</div>') out.write('''</div> </body> </html>''')
def __str__(self): return '%s%s: %s' % (tchars(self.name), ('/' + tchars(self.short_name)) if self.name != self.short_name else '', str(self.entry_coords))