def _add_line_to_gui(self, ship, sequence_number): sequence_number_label = Label( name='sequence_number_{:d}'.format(ship.worldid)) sequence_number_label.text = str(sequence_number) sequence_number_label.min_size = sequence_number_label.max_size = (15, 20) ship_name = Label(name='ship_name_{:d}'.format(ship.worldid)) ship_name.text = ship.get_component(NamedComponent).name ship_name.min_size = ship_name.max_size = (100, 20) from horizons.engine.pychan_util import RenameImageButton rename_icon = RenameImageButton( name='rename_{:d}'.format(ship.worldid)) rename_icon.path = "images/background/rename_feather_20" rename_icon.helptext = T("Click to change the name of this ship") rename_icon.max_size = (20, 20) # (width, height) ship_type = Label(name='ship_type_{:d}'.format(ship.worldid)) ship_type.text = ship.classname ship_type.min_size = ship_type.max_size = (60, 20) weapons = Label(name='weapons_{:d}'.format(ship.worldid)) if isinstance(ship, FightingShip): weapon_list = [] for weapon_id, amount in sorted( ship.get_weapon_storage().itercontents()): weapon_list.append('{:d} {}'.format( amount, self.session.db.get_res_name(weapon_id))) if weapon_list: weapons.text = ', '.join(weapon_list) else: #i18n There are no weapons equipped at the moment. weapons.text = T('None') else: weapons.text = T('N/A') weapons.min_size = weapons.max_size = (60, 20) health = Label(name='health_{:d}'.format(ship.worldid)) health_component = ship.get_component(HealthComponent) health.text = '{:.1f}/{:.1f}'.format(health_component.health, health_component.max_health) health.min_size = health.max_size = (65, 20) status = Label(name='status_{:d}'.format(ship.worldid)) status.text, status_position = ship.get_status() status.min_size = status.max_size = (320, 20) hbox = HBox() hbox.addChild(sequence_number_label) hbox.addChild(ship_name) hbox.addChild(rename_icon) hbox.addChild(ship_type) hbox.addChild(weapons) hbox.addChild(health) hbox.addChild(status) self._content_vbox.addChild(hbox) return (ship_name, rename_icon, status, status_position)
def _add_line_to_gui(self, ship, sequence_number): sequence_number_label = Label(name='sequence_number_%d' % ship.worldid) sequence_number_label.text = unicode(sequence_number) sequence_number_label.min_size = sequence_number_label.max_size = (15, 20) ship_name = Label(name='ship_name_%d' % ship.worldid) ship_name.text = ship.get_component(NamedComponent).name ship_name.min_size = ship_name.max_size = (100, 20) from horizons.engine.pychan_util import RenameImageButton rename_icon = RenameImageButton(name='rename_%d' % ship.worldid) rename_icon.up_image = "content/gui/images/background/rename_feather_20.png" rename_icon.hover_image = "content/gui/images/background/rename_feather_20_h.png" rename_icon.helptext = _("Click to change the name of this ship") rename_icon.max_size = (20, 20) # (width, height) ship_type = Label(name='ship_type_%d' % ship.worldid) ship_type.text = ship.classname ship_type.min_size = ship_type.max_size = (60, 20) weapons = Label(name='weapons_%d' % ship.worldid) if isinstance(ship, FightingShip): weapon_list = [] for weapon_id, amount in sorted(ship.get_weapon_storage().itercontents()): weapon_list.append('%d %s' % (amount, self.session.db.get_res_name(weapon_id))) if weapon_list: weapons.text = u', '.join(weapon_list) else: #i18n There are no weapons equipped at the moment. weapons.text = _('None') else: weapons.text = _('N/A') weapons.min_size = weapons.max_size = (60, 20) health = Label(name='health_%d' % ship.worldid) health_component = ship.get_component(HealthComponent) health.text = u'%d/%d' % (health_component.health, health_component.max_health) health.min_size = health.max_size = (65, 20) status = Label(name='status_%d' % ship.worldid) status.text, status_position = ship.get_status() status.min_size = status.max_size = (320, 20) hbox = HBox() hbox.addChild(sequence_number_label) hbox.addChild(ship_name) hbox.addChild(rename_icon) hbox.addChild(ship_type) hbox.addChild(weapons) hbox.addChild(health) hbox.addChild(status) self._content_vbox.addChild(hbox) return (ship_name, rename_icon, status, status_position)
def _add_line_to_gui(self, settlement, sequence_number): sequence_number_label = widgets.Label(name='sequence_number_%d' % settlement.worldid) sequence_number_label.text = unicode(sequence_number) sequence_number_label.min_size = sequence_number_label.max_size = (15, 20) name = widgets.Label(name='name_%d' % settlement.worldid) name.text = settlement.get_component(NamedComponent).name name.min_size = name.max_size = (175, 20) from horizons.engine.pychan_util import RenameImageButton rename_icon = RenameImageButton(name='rename_%d' % settlement.worldid) rename_icon.path = "images/background/rename_feather_20" rename_icon.helptext = _("Click to change the name of your settlement") rename_icon.max_size = (20, 20) # (width, height) self._add_generic_line_to_gui(settlement.worldid, [sequence_number_label, name, rename_icon], settlement.inhabitants, settlement.cumulative_taxes, settlement.cumulative_running_costs) return name, rename_icon
def _add_line_to_gui(self, settlement, sequence_number): sequence_number_label = widgets.Label(name='sequence_number_{:d}'.format(settlement.worldid)) sequence_number_label.text = str(sequence_number) sequence_number_label.min_size = sequence_number_label.max_size = (15, 20) name = widgets.Label(name='name_{:d}'.format(settlement.worldid)) name.text = settlement.get_component(NamedComponent).name name.min_size = name.max_size = (175, 20) from horizons.engine.pychan_util import RenameImageButton rename_icon = RenameImageButton(name='rename_{:d}'.format(settlement.worldid)) rename_icon.path = "images/background/rename_feather_20" rename_icon.helptext = T("Click to change the name of your settlement") rename_icon.max_size = (20, 20) # (width, height) self._add_generic_line_to_gui(settlement.worldid, [sequence_number_label, name, rename_icon], settlement.inhabitants, settlement.cumulative_taxes, settlement.cumulative_running_costs) return name, rename_icon