def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) # communicate via stdout. Sometimes the process seems to print more information, therefore # we add markers around our data so it's easier for the caller to get to the data. args = (location, world, Minimap.COLORS['island'], Minimap.COLORS['water']) data = [(x, y, r, g, b) for (x, y), (r, g, b) in iter_minimap_points(*args)] print('DATA', json.dumps(data), 'ENDDATA')
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) # communicate via stdout. Sometimes the process seems to print more information, therefore # we add markers around our data so it's easier for the caller to get to the data. args = (location, world, Minimap.COLORS['island'], Minimap.COLORS['water']) data = [(x, y, r, g, b) for (x, y), (r, g, b) in iter_minimap_points_colors(*args)] print('DATA', json.dumps(data), 'ENDDATA')
def _update_map_preview(self, map_file): if self._map_preview: self._map_preview.end() world = load_raw_world(map_file) self._map_preview = Minimap( self._gui.findChild(name='map_preview_minimap'), session=None, view=None, world=world, targetrenderer=horizons.globals.fife.targetrenderer, imagemanager=horizons.globals.fife.imagemanager, cam_border=False, use_rotation=False, tooltip=None, on_click=None, preview=True) self._map_preview.draw()
def _update_map_preview(self, map_file): if self._map_preview: self._map_preview.end() world = load_raw_world(map_file) self._map_preview = Minimap( self._gui.findChild(name='map_preview_minimap'), session=None, view=None, world=world, targetrenderer=horizons.globals.fife.targetrenderer, imagemanager=horizons.globals.fife.imagemanager, cam_border=False, use_rotation=False, tooltip=None, on_click=None, preview=True) self._map_preview.draw()
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.ext.dummy import Dummy from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) minimap = Minimap( location, session=None, view=None, world=world, targetrenderer=Dummy(), imagemanager=Dummy(), cam_border=False, use_rotation=False, preview=True) # communicate via stdout print minimap.dump_data()
def generate_random_minimap(size, parameters): """Called as subprocess, calculates minimap data and passes it via string via stdout""" # called as standalone basically, so init everything we need from horizons.entities import Entities from horizons.ext.dummy import Dummy from horizons.main import _create_main_db if not VERSION.IS_DEV_VERSION: # Hack enable atlases. # Usually the minimap generator uses single tile files, but in release # mode these are not available. Therefor we have to hackenable atlases # for the minimap generation in this case. This forces the game to use # the correct imageloader # In normal dev mode + enabled atlases we ignore this and just continue # to use single tile files instead of atlases for the minimap generation. # These are always available in dev checkouts PATHS.DB_FILES = PATHS.DB_FILES + (PATHS.ATLAS_DB_PATH, ) db = _create_main_db() horizons.globals.db = db horizons.globals.fife.init_animation_loader(not VERSION.IS_DEV_VERSION) Entities.load_grounds(db, load_now=False) # create all references map_file = generate_random_map(*parameters) world = load_raw_world(map_file) location = Rect.init_from_topleft_and_size_tuples((0, 0), size) minimap = Minimap( location, session=None, view=None, world=world, targetrenderer=Dummy(), imagemanager=Dummy(), cam_border=False, use_rotation=False, preview=True) # communicate via stdout print minimap.dump_data()