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


Python ActionSetLoader.get_set方法代码示例

本文整理汇总了Python中horizons.util.loaders.actionsetloader.ActionSetLoader.get_set方法的典型用法代码示例。如果您正苦于以下问题:Python ActionSetLoader.get_set方法的具体用法?Python ActionSetLoader.get_set怎么用?Python ActionSetLoader.get_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizons.util.loaders.actionsetloader.ActionSetLoader的用法示例。


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

示例1: __init__

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
	def __init__(self, instances, show_number=True):
		self.log = logging.getLogger("gui.tabs")
		self.instances = instances
		self.widget = load_uh_widget("unit_entry_widget.xml")
		# get the icon of the first instance
		i = instances[0]
		if i.id < UNITS.DIFFERENCE_BUILDING_UNIT_ID:
			# A building. Generate dynamic thumbnail from its action set.
			imgs = ActionSetLoader.get_set(i._action_set_id).items()[0][1]
			thumbnail = imgs[45].keys()[0]
		else:
			# Units use manually created thumbnails because those need to be
			# precise and recognizable in combat situations.
			thumbnail = self.get_unit_thumbnail(i.id)
		self.widget.findChild(name="unit_button").up_image = thumbnail
		if show_number:
			self.widget.findChild(name="instance_number").text = unicode(len(self.instances))
		# only two callbacks are needed so drop unwanted changelistener inheritance
		for i in instances:
			if not i.has_remove_listener(Callback(self.on_instance_removed, i)):
				i.add_remove_listener(Callback(self.on_instance_removed, i))
			health_component = i.get_component(HealthComponent)
			if not health_component.has_damage_dealt_listener(self.draw_health):
				health_component.add_damage_dealt_listener(self.draw_health)
		self.draw_health()
开发者ID:ErwinJunge,项目名称:unknown-horizons,代码行数:27,代码来源:selectmultitab.py

示例2: on_settler_level_change

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
	def on_settler_level_change(self, message):
		assert isinstance(message, SettlerUpdate)
		setup_tax_slider(self.widget.child_finder('tax_slider'),
		                 self.widget.child_finder('tax_val_label'),
		                 self.instance.settlement,
		                 message.level)
		taxes = self.instance.settlement.tax_settings[self.instance.level]
		self.widget.child_finder('tax_val_label').text = str(taxes)
		imgs = list(ActionSetLoader.get_set(self.instance._action_set_id).items())[0][1]
		self.widget.findChild(name="building_image").image = list(imgs[45].keys())[0]
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:12,代码来源:residentialtabs.py

示例3: update_overlay

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
	def update_overlay(self, res_id, new_amount):
		"""Called when inventory amount of one resource changes.

		Looks for a fitting animation overlay based on the new inventory amount for that resource.
		If that overlay is different from the currently displayed one, removes the old overlay for
		that resource and adds a new one based on what fits *new_amount* best.
		"""
		try:
			overlay_order = self.overlays[self.action_set][self.instance._action][res_id]
		except KeyError:
			self.log.warning(
				'No overlays defined for resource `%s`, action `%s` and action set `%s`. '
				'Consider using `null` overlays for amount 0 in this action set.',
				res_id, self.instance._action, self.action_set)
			self.current_overlays[res_id] = None
			return

		# We use max(0, new_amount) restricted to what exists in overlay_order.
		# E.g. for
		#   new_amount = 3
		#   overlay_order = [[0, None],  [2, 'as_2'],  [5, 'as_full']]
		# we drop 5 (because it is defined but too large),
		# ignore 4 and 3 (because they are not defined in overlay_order),
		# and find 'as_2' as our new overlay for the amount 2.

		for (amount, overlay_name) in sorted(overlay_order, reverse=True):

			if amount > new_amount:
				# This `if` drops defined-but-too-large candidates (i.e. case `5` in above example).
				continue

			if amount == self.current_overlays[res_id]:
				# Nothing to do, continue using the same overlay
				return

			if overlay_name is None:
				# Empty overlay, only display base action set (i.e. case `0` in above example)
				self.remove_overlay(res_id)
				return

			try:
				overlay_set = ActionSetLoader.get_set(self.action_set)[overlay_name]
			except KeyError:
				self.log.warning(
					'Could not find overlay action set defined for object '
					'`%s` with id `%s` for resource `%s` and amount `%s`. '
					'Falling back to next lower overlay.',
					self.instance, self.identifier, res_id, amount)
				continue
			self.remove_overlay(res_id)
			self.add_overlay(overlay_set, z_order=res_id)
			self.current_overlays[res_id] = amount
			return
开发者ID:ErwinJunge,项目名称:unknown-horizons,代码行数:55,代码来源:inventoryoverlaycomponent.py

示例4: init_widget

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
	def init_widget(self):
		super().init_widget()
		name = self.instance.settlement.get_component(NamedComponent).name
		self.widget.findChild(name="headline").text = name
		setup_tax_slider(self.widget.child_finder('tax_slider'),
		                 self.widget.child_finder('tax_val_label'),
		                 self.instance.settlement,
		                 self.instance.level)

		taxes = self.instance.settlement.tax_settings[self.instance.level]
		self.widget.child_finder('tax_val_label').text = str(taxes)
		action_set = ActionSetLoader.get_set(self.instance._action_set_id)
		action_gfx = list(action_set.items())[0][1]
		image = list(action_gfx[45].keys())[0]
		self.widget.findChild(name="building_image").image = image
开发者ID:MarkusHackspacher,项目名称:unknown-horizons,代码行数:17,代码来源:residentialtabs.py

示例5: getInstance

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
	def getInstance(cls, session, x, y, action='idle', level=0, rotation=45, action_set_id=None, world_id=""):
		"""Get a Fife instance
		@param x, y: The coordinates
		@param action: The action, defaults to 'idle'
		@param level: object level. Relevant for choosing an action set
		@param rotation: rotation of the object. Any of [ 45 + 90*i for i in xrange(0, 4) ]
		@param action_set_id: can be set if the action set is already known. If set, level isn't considered.
		@return: tuple (fife_instance, action_set_id)
		"""
		assert isinstance(x, int)
		assert isinstance(y, int)
		#rotation = cls.check_build_rotation(session, rotation, x, y)
		# TODO: replace this with new buildable api
		# IDEA: save rotation in savegame
		facing_loc = fife.Location(session.view.layers[cls.layer])
		instance_coords = list((x, y, 0))
		layer_coords = list((x, y, 0))
		width, length = cls.size

		# NOTE:
		# nobody actually knows how the code below works.
		# it's for adapting the facing location and instance coords in
		# different rotations, and works with all quadratic buildings (tested up to 4x4)
		# for the first unquadratic building (2x4), a hack fix was put into it.
		# the plan for fixing this code in general is to wait until there are more
		# unquadratic buildings, and figure out a pattern of the placement error,
		# then fix that generally.

		if rotation == 45:
			layer_coords[0] = x + width + 3

			if width == 2 and length == 4:
				# HACK: fix for 4x2 buildings
				instance_coords[0] -= 1
				instance_coords[1] += 1

		elif rotation == 135:
			instance_coords[1] = y + length - 1
			layer_coords[1] = y - length - 3

			if width == 2 and length == 4:
				# HACK: fix for 4x2 buildings
				instance_coords[0] += 1
				instance_coords[1] -= 1

		elif rotation == 225:
			instance_coords = list(( x + width - 1, y + length - 1, 0))
			layer_coords[0] = x - width - 3

			if width == 2 and length == 4:
				# HACK: fix for 4x2 buildings
				instance_coords[0] += 1
				instance_coords[1] -= 1

		elif rotation == 315:
			instance_coords[0] = x + width - 1
			layer_coords[1] = y + length + 3

			if width == 2 and length == 4:
				# HACK: fix for 4x2 buildings
				instance_coords[0] += 1
				instance_coords[1] -= 1

		else:
			return None
		instance = session.view.layers[cls.layer].createInstance(
			cls._fife_object,
			fife.ModelCoordinate(*instance_coords),
			world_id)
		facing_loc.setLayerCoordinates(fife.ModelCoordinate(*layer_coords))

		if action_set_id is None:
			action_set_id = cls.get_random_action_set(level=level)
		fife.InstanceVisual.create(instance)

		action_set = ActionSetLoader.get_set(action_set_id)
		if not action in action_set:
			if 'idle' in action_set:
				action = 'idle'
			elif 'idle_full' in action_set:
				action = 'idle_full'
			else:
				# set first action
				action = action_set.keys()[0]

		if (Fife.getVersion() >= (0, 3, 6)):
			instance.actRepeat(action+"_"+str(action_set_id), facing_loc)
		else:
			instance.act(action+"_"+str(action_set_id), facing_loc, True)
		return (instance, action_set_id)
开发者ID:squiddy,项目名称:unknown-horizons,代码行数:92,代码来源:building.py

示例6: init_widget

# 需要导入模块: from horizons.util.loaders.actionsetloader import ActionSetLoader [as 别名]
# 或者: from horizons.util.loaders.actionsetloader.ActionSetLoader import get_set [as 别名]
 def init_widget(self):
     super(SignalFireOverviewTab, self).init_widget()
     action_set = ActionSetLoader.get_set(self.instance._action_set_id)
     action_gfx = action_set.items()[0][1]
     image = action_gfx[45].keys()[0]
     self.widget.findChild(name="building_image").image = image
开发者ID:squiddy,项目名称:unknown-horizons,代码行数:8,代码来源:buildingtabs.py


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