本文整理汇总了Python中horizons.messaging.AddStatusIcon.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python AddStatusIcon.subscribe方法的具体用法?Python AddStatusIcon.subscribe怎么用?Python AddStatusIcon.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.messaging.AddStatusIcon
的用法示例。
在下文中一共展示了AddStatusIcon.subscribe方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def __init__(self, session):
self.session = session
# {instance: [list of icons]}
self.icons = {}
# Renderer used to render the icons
self.renderer = self.session.view.renderer['GenericRenderer']
AddStatusIcon.subscribe(self.on_add_icon_message)
RemoveStatusIcon.subscribe(self.on_remove_icon_message)
WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
示例2: test_decommissioned
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def test_decommissioned(session, player):
settlement, island = settle(session)
lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)
cb = mock.Mock()
AddStatusIcon.subscribe(cb)
assert not cb.called
ToggleActive(lj.get_component(Producer))(player)
assert_called_with_icon(cb, DecommissionedStatus)
示例3: __init__
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def __init__(self, session):
self.session = session
# {instance: [list of icons]}
self.icons = {}
# Renderer used to render the icons
self.renderer = self.session.view.renderer['GenericRenderer']
self.tooltip_instance = None # no weakref:
# we need to remove the tooltip always anyway, and along with it the entry here
self.tooltip_icon = Icon(position=(1,1)) # 0, 0 is currently not supported by tooltips
AddStatusIcon.subscribe(self.on_add_icon_message)
HoverInstancesChanged.subscribe(self.on_hover_instances_changed)
RemoveStatusIcon.subscribe(self.on_remove_icon_message)
WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
示例4: test_productivity_low
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def test_productivity_low(session, player):
settlement, island = settle(session)
Build(BUILDINGS.CHARCOAL_BURNER, 30, 30, island, settlement=settlement)(player)
cb = mock.Mock()
AddStatusIcon.subscribe(cb)
# Not yet low
assert not cb.called
session.run(seconds=60)
# Now low
assert_called_with_icon(cb, ProductivityLowStatus)
示例5: test_settler_unhappy
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def test_settler_unhappy(session, player):
settlement, island = settle(session)
cb = mock.Mock()
AddStatusIcon.subscribe(cb)
settler = Build(BUILDINGS.RESIDENTIAL, 30, 30, island, settlement=settlement)(player)
# certainly not unhappy
assert settler.happiness > 0.45
assert not cb.called
# make it unhappy
settler.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, -settler.happiness)
assert settler.happiness < 0.1
assert_called_with_icon(cb, SettlerUnhappyStatus)
示例6: test_inventory_full
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def test_inventory_full(session, player):
settlement, island = settle(session)
lj = Build(BUILDINGS.LUMBERJACK, 30, 30, island, settlement=settlement)(player)
cb = mock.Mock()
AddStatusIcon.subscribe(cb)
# Not full
assert not cb.called
inv = lj.get_component(StorageComponent).inventory
res = RES.BOARDS
inv.alter(res, inv.get_free_space_for(res))
session.run(seconds=1)
# Full
assert_called_with_icon(cb, InventoryFullStatus)
示例7: __init__
# 需要导入模块: from horizons.messaging import AddStatusIcon [as 别名]
# 或者: from horizons.messaging.AddStatusIcon import subscribe [as 别名]
def __init__(self, renderer, layer):
"""
@param renderer: Renderer used to render the icons
@param layer: map layer, needed to place icon
"""
self.layer = layer
self.renderer = renderer
# {instance: [list of icons]}
self.icons = {}
self.tooltip_instance = None # no weakref:
# we need to remove the tooltip always anyway, and along with it the entry here
self.tooltip_icon = Icon(position=(1, 1)) # 0, 0 is currently not supported by tooltips
AddStatusIcon.subscribe(self.on_add_icon_message)
HoverInstancesChanged.subscribe(self.on_hover_instances_changed)
RemoveStatusIcon.subscribe(self.on_remove_icon_message)
WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)