本文整理汇总了Python中horizons.gui.widgets.resourceoverviewbar.ResourceOverviewBar.set_inventory_instance方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceOverviewBar.set_inventory_instance方法的具体用法?Python ResourceOverviewBar.set_inventory_instance怎么用?Python ResourceOverviewBar.set_inventory_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.gui.widgets.resourceoverviewbar.ResourceOverviewBar
的用法示例。
在下文中一共展示了ResourceOverviewBar.set_inventory_instance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IngameGui
# 需要导入模块: from horizons.gui.widgets.resourceoverviewbar import ResourceOverviewBar [as 别名]
# 或者: from horizons.gui.widgets.resourceoverviewbar.ResourceOverviewBar import set_inventory_instance [as 别名]
#.........这里部分代码省略.........
# save reference to new "current" settlement in self.settlement
self.settlement = settlement
if settlement is None: # we want to hide the widget now (but perhaps delayed).
if old_was_player_settlement:
# After scrolling away from settlement, leave name on screen for some
# seconds. Players can still click on it to rename the settlement now.
ExtScheduler().add_new_object(self.cityinfo.hide, self,
run_in=GUI.CITYINFO_UPDATE_DELAY)
#TODO 'click to rename' tooltip of cityinfo can stay visible in
# certain cases if cityinfo gets hidden in tooltip delay buffer.
else:
# hovered settlement of other player, simply hide the widget
self.cityinfo.hide()
else:# do not hide if settlement is hovered and a hide was previously scheduled
ExtScheduler().rem_call(self, self.cityinfo.hide)
self.update_settlement() # calls show()
settlement.add_change_listener(self.update_settlement)
def _on_settler_inhabitant_change(self, message):
assert isinstance(message, SettlerInhabitantsChanged)
foundlabel = self.cityinfo.child_finder('city_inhabitants')
old_amount = int(foundlabel.text) if foundlabel.text else 0
foundlabel.text = u' {amount:>4d}'.format(amount=old_amount+message.change)
foundlabel.resizeToContent()
def update_settlement(self):
city_name_label = self.cityinfo.child_finder('city_name')
if self.settlement.owner.is_local_player: # allow name changes
# Update settlement on the resource overview to make sure it
# is setup correctly for the coming calculations
self.resource_overview.set_inventory_instance(self.settlement)
cb = Callback(self.show_change_name_dialog, self.settlement)
helptext = _("Click to change the name of your settlement")
city_name_label.enable_cursor_change_on_hover()
else: # no name changes
cb = lambda : AmbientSoundComponent.play_special('error')
helptext = u""
city_name_label.disable_cursor_change_on_hover()
self.cityinfo.mapEvents({
'city_name': cb
})
city_name_label.helptext = helptext
foundlabel = self.cityinfo.child_finder('owner_emblem')
foundlabel.image = 'content/gui/images/tabwidget/emblems/emblem_%s.png' % (self.settlement.owner.color.name)
foundlabel.helptext = self.settlement.owner.name
foundlabel = self.cityinfo.child_finder('city_name')
foundlabel.text = self.settlement.get_component(SettlementNameComponent).name
foundlabel.resizeToContent()
foundlabel = self.cityinfo.child_finder('city_inhabitants')
foundlabel.text = u' {amount:>4d}'.format(amount=self.settlement.inhabitants)
foundlabel.resizeToContent()
self._update_cityinfo_position()
def _update_cityinfo_position(self):
""" Places cityinfo widget depending on resource bar dimensions.
For a normal-sized resource bar and reasonably large resolution:
* determine resource bar length (includes gold)
* determine empty horizontal space between resbar end and minimap start