当前位置: 首页>>代码示例>>Python>>正文


Python tilesetloader.TileSetLoader类代码示例

本文整理汇总了Python中horizons.util.loaders.tilesetloader.TileSetLoader的典型用法代码示例。如果您正苦于以下问题:Python TileSetLoader类的具体用法?Python TileSetLoader怎么用?Python TileSetLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TileSetLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _loadObjects

	def _loadObjects(self):
		# get fifedit objects
		self.model = self._engine.getModel()
		self.all_action_sets = ActionSetLoader.get_sets()

		TileSetLoader.load()
		ActionSetLoader.load()
		self.animationloader = SQLiteAnimationLoader()

		self._loadGroundTiles()
		self._loadBuildings()
开发者ID:acieroid,项目名称:unknown-horizons,代码行数:11,代码来源:UHObjectLoader.py

示例2: _loadObject

	def _loadObject(cls, db):
		"""Loads the ground object from the db (animations, etc)"""
		cls._fife_objects = {}
		tile_sets = TileSetLoader.get_sets()
		tile_set_data = db("SELECT set_id FROM tile_set WHERE ground_id=?", cls.id)
		for tile_set_row in tile_set_data:
			tile_set_id = str(tile_set_row[0])
			cls_name = '%d-%s' % (cls.id, cls.shape)
			cls.log.debug('Loading ground %s', cls_name)
			fife_object = None
			try:
				fife_object = horizons.globals.fife.engine.getModel().createObject(cls_name, 'ground_' + tile_set_id)
			except RuntimeError:
				cls.log.debug('Already loaded ground %d-%s', cls.id, cls.shape)
				fife_object = horizons.globals.fife.engine.getModel().getObject(cls_name, 'ground_' + tile_set_id)
				return

			fife.ObjectVisual.create(fife_object)
			visual = fife_object.get2dGfxVisual()
			for rotation, data in tile_sets[tile_set_id][cls.shape].iteritems():
				assert len(data) == 1, 'Currently only static tiles are supported'
				img = horizons.globals.fife.animationloader.load_image(data.keys()[0], tile_set_id, cls.shape, str(rotation))
				visual.addStaticImage(rotation, img.getHandle())

			# Save the object
			cls._fife_objects[tile_set_id] = fife_object
开发者ID:Antagonym,项目名称:unknown-horizons,代码行数:26,代码来源:ground.py

示例3: load_grounds

	def load_grounds(cls, db, load_now=False):
		cls.log.debug("Entities: loading grounds")
		if hasattr(cls, "grounds"):
			cls.log.debug("Entities: grounds already loaded")
			return

		from horizons.world.ground import GroundClass
		tile_sets = TileSetLoader.get_sets()
		cls.grounds = _EntitiesLazyDict()
		for (ground_id,) in db("SELECT ground_id FROM tile_set"):
			tile_set_id = db("SELECT set_id FROM tile_set WHERE ground_id=?", ground_id)[0][0]
			for shape in tile_sets[tile_set_id].iterkeys():
				cls_name = '%d-%s' % (ground_id, shape)
				cls.grounds.create_on_access(cls_name, Callback(GroundClass, db, ground_id, shape))
				if load_now:
					cls.grounds[cls_name]
		cls.grounds['-1-special'] = GroundClass(db, -1, 'special')
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:17,代码来源:entities.py

示例4: _set_cursor_image

	def _set_cursor_image(self):
		"""Replace the cursor with an image of the selected tile."""
		# FIXME the water tile is too big to use as cursor
		if self._tile_details[0] == 0:
			return

		tile = tuple(self._tile_details)
		image = TileLayingTool.tile_images.get(tile)
		if not image:
			tile_sets = TileSetLoader.get_sets()

			ground_id, action_id, rotation = tile
			set_id = horizons.globals.db.get_random_tile_set(ground_id)
			filename = tile_sets[set_id][action_id][rotation].keys()[0]

			image = horizons.globals.fife.imagemanager.load(filename)
			TileLayingTool.tile_images[tile] = image

		horizons.globals.fife.cursor.set(image)
开发者ID:ErwinJunge,项目名称:unknown-horizons,代码行数:19,代码来源:tilelayingtool.py

示例5: _loadGroundTiles

	def _loadGroundTiles(self):
		print("loading UH ground tiles...")
		tile_sets = TileSetLoader.get_sets()

		for tile_set_id in tile_sets:
			tile_set = tile_sets[tile_set_id]
			object = self.model.createObject(str(tile_set_id), util.GROUND_NAMESPACE)
			fife.ObjectVisual.create(object)

			# load animations
			for action_id in tile_sets[tile_set_id].iterkeys():
				action = object.createAction(action_id+"_"+str(tile_set_id))
				fife.ActionVisual.create(action)
				for rotation in tile_sets[tile_set_id][action_id].iterkeys():
					anim = self.animationloader.loadResource( \
						str(tile_set_id)+"+"+str(action_id)+"+"+ \
						str(rotation) + ':shift:center+0,bottom+8')
					action.get2dGfxVisual().addAnimation(int(rotation), anim)
					action.setDuration(anim.getDuration())
开发者ID:acieroid,项目名称:unknown-horizons,代码行数:19,代码来源:UHObjectLoader.py

示例6: _loadObject

	def _loadObject(cls, db):
		"""Loads the ground object from the db (animations, etc)"""
		cls._fife_objects = {}
		tile_sets = TileSetLoader.get_sets()
		model = horizons.globals.fife.engine.getModel()
		load_image = horizons.globals.fife.animationloader.load_image
		tile_set_data = db("SELECT set_id FROM tile_set WHERE ground_id=?", cls.id)
		for tile_set_row in tile_set_data:
			tile_set_id = str(tile_set_row[0])
			cls_name = '{:d}-{}'.format(cls.id, cls.shape)
			cls.log.debug('Loading ground %s', cls_name)
			fife_object = None
			try:
				fife_object = model.createObject(cls_name, 'ground_' + tile_set_id)
			except fife.NameClash:
				cls.log.debug('Already loaded ground %d-%s', cls.id, cls.shape)
				fife_object = model.getObject(cls_name, 'ground_' + tile_set_id)
				return

			fife.ObjectVisual.create(fife_object)
			visual = fife_object.get2dGfxVisual()
			for rotation, data in tile_sets[tile_set_id][cls.shape].items():
				if not data:
					raise KeyError('No data found for tile set `{}` in rotation `{}`. '
						'Most likely the shape `{}` is missing.'
						.format(tile_set_id, rotation, cls.shape))
				if len(data) > 1:
					raise ValueError('Currently only static tiles are supported. '
						'Found this data for tile set `{}` in rotation `{}`: '
						'{}'.format(tile_set_id, rotation, data))
				img = load_image(list(data.keys())[0], tile_set_id, cls.shape, str(rotation))
				# make the drawing origin correspond with the center of the groundpart of the image
				# (instead of the center of the image)
				img.setYShift(int(img.getWidth() / 4 - img.getHeight() / 2))
				visual.addStaticImage(rotation, img.getHandle())

			# Save the object
			cls._fife_objects[tile_set_id] = fife_object
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:38,代码来源:ground.py

示例7: _loadObject

	def _loadObject(cls, db):
		""" Loads the ground object from the db (animations, etc)
		"""
		cls.log.debug('Loading ground %s', cls.id)
		try:
			cls._object = horizons.globals.fife.engine.getModel().createObject(str(cls.id), 'ground')
		except RuntimeError:
			cls.log.debug('Already loaded ground %s', cls.id)
			cls._object = horizons.globals.fife.engine.getModel().getObject(str(cls.id), 'ground')
			return

		fife.ObjectVisual.create(cls._object)

		tile_sets = TileSetLoader.get_sets()
		for (tile_set_id,) in db("SELECT set_id FROM tile_set WHERE ground_id=?", cls.id):
			for action_id in tile_sets[tile_set_id].iterkeys():
				action = cls._object.createAction(action_id+"_"+str(tile_set_id))
				fife.ActionVisual.create(action)
				for rotation in tile_sets[tile_set_id][action_id].iterkeys():
					anim = horizons.globals.fife.animationloader.loadResource(
						str(tile_set_id)+"+"+str(action_id)+"+"+
						str(rotation) + ':shift:center+0,bottom+8')
					action.get2dGfxVisual().addAnimation(int(rotation), anim)
					action.setDuration(anim.getDuration())
开发者ID:acieroid,项目名称:unknown-horizons,代码行数:24,代码来源:ground.py

示例8: open

					not_found = not_found + 1
					continue

				# Instead of only float value we need to hold a 'bit' more infos in all_action_sets dictionary
				animval = all_action_sets[tileset_id][action_id][rotation][file]
				del all_action_sets[tileset_id][action_id][rotation][file]
				all_action_sets[tileset_id][action_id][rotation][file_new] = [animval, \
					atlases[entry.source], entry.xpos, entry.ypos, entry.width, entry.height]

# Dump it into JSON file
import json
with open(os.path.join("development", "atlas", "actionsets.json"), mode="wb") as fjson:
	json.dump(all_action_sets, fjson, indent=1)

# Same stuff with tilesets
all_tile_sets = TileSetLoader.get_sets()
for tileset_id in all_tile_sets:
	for action_id in all_tile_sets[tileset_id]:
		for rotation in sorted(all_tile_sets[tileset_id][action_id]):
			for file in sorted(all_tile_sets[tileset_id][action_id][rotation]):

				file_new = file.replace('\\', '/')

				try:
					entry = mapping[file_new]
				except KeyError:
					print "Warning: {0} not found".format(file)
					not_found = not_found + 1
					continue

				animval = all_tile_sets[tileset_id][action_id][rotation][file]
开发者ID:acieroid,项目名称:unknown-horizons,代码行数:31,代码来源:parse_atlas.py


注:本文中的horizons.util.loaders.tilesetloader.TileSetLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。