Esempio n. 1
0
def main(cursor):
	build		= int(common.get_val('build', 0))
	region_name	= common.get_val('region', '').lower()
	
	the_map = mapper.Map_maker()
	
	if build != 0:# Remote mode
		the_map.icon_path = 'images/teamIcons/'
	
	onclick_js = """
	var map_x = parseInt(document.getElementById('labelHideX').innerHTML);
	var map_y = parseInt(document.getElementById('labelHideY').innerHTML);
	use_map_xy(map_x, map_y);"""
	
	source_dict = region_data.get_source_dict(the_map, region_name, build)
	source_dict["build"]		= build
	source_dict["onclick_js"]	= onclick_js
	source_dict["output"]		= the_map.map_grid(cursor)
	
	return mapper.map_source(source_dict)
Esempio n. 2
0
def output_map(options, the_world=None, skip_upload=False):
	from classes import mapper
	from rules import region_data
	
	if the_world != None:
		cursor = the_world.cursor
	else:
		cursor = database.get_cursor()
	files = {}
	
	#	Map Selector
	#------------------------
	from pages.map import map_select
	f = open('%s/map/index.html' % common.data['woa_folder'], 'w')
	f.write(map_select.make_map_select(cursor))
	f.write(padding)
	f.close()
	
	files['index.html'] = '%s/map/index.html' % common.data['woa_folder']
	
	#	Big map
	#------------------------
	the_map = mapper.Map_maker()
	the_map.icon_path = 'images/teamIcons/'
	source_dict = {
		"build":				1,
		"output":				the_map.map_grid(cursor),
	}
	
	map_source = mapper.map_source(source_dict)
	
	f = open('%s/map/latest.html' % common.data['woa_folder'], 'w')
	f.write(map_source)
	f.write(padding)
	
	f = open('%s/map/turn_%d_normal.html' % (common.data['woa_folder'], common.current_turn()), 'w')
	f.write(map_source)
	f.write(padding)
	
	f.close()
	
	files['latest.html'] = '%s/map/latest.html' % common.data['woa_folder']
	files['turn_%d_normal.html' % common.current_turn()] = '%s/map/turn_%d_normal.html' % (common.data['woa_folder'], common.current_turn())
	
	# Now to make all the region maps
	# for r in region_data.region_list:
	for r in progressbar(region_data.region_list, "Creating Maps: ", 60, True):
		the_map = mapper.Map_maker()
		the_map.icon_path = 'images/teamIcons/'
		
		source_dict = region_data.get_source_dict(the_map, r.name)
		source_dict["output"] = the_map.map_grid(cursor)
		source_dict["build"] = 1
		
		map_source = mapper.map_source(source_dict)
		
		f = open('%s/map/latest_%s.html' % (common.data['woa_folder'], r.name.lower()), 'w')
		f.write(map_source)
		f.write(padding)
		f.close()
		
		f = open('%s/map/turn_%s_%s.html' % (common.data['woa_folder'], common.current_turn(), r.name.lower()), 'w')
		f.write(map_source)
		f.write(padding)
		f.close()
		
		files['latest_%s.html' % r.name.lower()] = '%s/map/latest_%s.html' % (common.data['woa_folder'], r.name.lower())
		files['turn_%s_%s.html' % (common.current_turn(), r.name.lower())] = '%s/map/turn_%s_%s.html' % (common.data['woa_folder'], common.current_turn(), r.name.lower())
	
	if not skip_upload:
		upload("ftp.woarl.com", "*****@*****.**", ftp_pass['map'], files, options.delay, options.verbose)
		print(database.shell_text('[g]Map uploaded[/g]'))
Esempio n. 3
0
def main(cursor):
	grid_size	= int(common.get_val('grid_size', 0))
	region		= common.get_val('region', 'rayti')
	
	if grid_size not in [10, 20, 30, 40, 60, 80, 100]:
		grid_size = 10
	
	the_map = terrain_mapper.Terrain_mapper()
	the_map.mouseover = 0
	the_map.grid_size = grid_size
	region_source_dict = region_data.get_source_dict(the_map, region, build_mode=0)
	
	if common.get_val('mode') == "terrain_map":
		map_output = the_map.map_terrain(cursor, colour_mode=True)
	else:
		map_output = the_map.map_terrain(cursor)
	
	terrain_select_list = []
	for t in map_data.terrain:
		terrain_select_list.append("<option value='%s'>%s</option>" % (t, t))
	
	terrain_select = "".join(terrain_select_list)
	
	source_dict = {
		"onclick_js":			"",
		"pgrid_size":			int(grid_size*2.5),
		"output":				map_output,
		"map_legend":			"",
		
		"header":				"""<div style="background-image: url('%(media_path)simages/grid_%(pgrid_size)s.png'); position: absolute; top:0px; left:0px; width:%(map_width)spx; height:%(map_height)spx;" onclick="alert('The background recieved an onclick, this is probably not meant to happen.');"></div>""" % {
			"pgrid_size":	int(grid_size*2.5),
			"map_width":	(the_map.right - the_map.left)*2.5,
			"map_height":	(the_map.bottom - the_map.top)*2.5,
			"media_path":	common.data['media_path'],
		},
		
		"footer":				"""<div style="position:absolute;top:%(map_height)spx;width:%(map_width)spx;height:30px;background-color:#ACF;">
			<select name="terrain" id="terrain">
				%(terrain_select)s
			</select>
			&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=10%(region)s">Minute</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=20%(region)s">Tiny</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=30%(region)s">Small</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=40%(region)s">Normal</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=60%(region)s">Big</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=80%(region)s">Large</a>&nbsp;&nbsp;&nbsp;
			<a href="web.py?mode=edit_map&amp;grid_size=100%(region)s">Huge</a>&nbsp;&nbsp;&nbsp;
		</div>""" % {
			"map_width":		(the_map.right - the_map.left)*2.5,
			"map_height":		(the_map.bottom - the_map.top)*2.5,
			"region":			"&amp;region=%s" % region,
			"terrain_select":	terrain_select,
		}
	}
	
	for k, v in region_source_dict.items():
		source_dict[k] = v
	
	output = terrain_mapper.map_source(source_dict)
	return output