Example #1
0
    def _add_generic_line_to_gui(self, id, line_prefix, people, tax, costs):
        inhabitants = widgets.Label(name='inhabitants_%d' % id)
        inhabitants.text = unicode(people)
        inhabitants.min_size = inhabitants.max_size = (110, 20)

        taxes = widgets.Label(name='taxes_%d' % id)
        taxes.text = unicode(tax)
        taxes.min_size = taxes.max_size = (50, 20)

        running_costs = widgets.Label(name='running_costs_%d' % id)
        running_costs.text = unicode(costs)
        running_costs.min_size = running_costs.max_size = (100, 20)

        balance = widgets.Label(name='balance_%d' % id)
        balance.text = unicode(tax - costs)
        balance.min_size = balance.max_size = (60, 20)

        hbox = widgets.HBox()
        for widget in line_prefix:
            hbox.addChild(widget)
        hbox.addChild(inhabitants)
        hbox.addChild(taxes)
        hbox.addChild(running_costs)
        hbox.addChild(balance)
        self._content_vbox.addChild(hbox)
Example #2
0
    def _add_line_to_gui(self, player):
        stats = player.get_latest_stats()

        emblem = widgets.Label(name='emblem_{:d}'.format(player.worldid),
                               text="   ")
        emblem.background_color = player.color
        emblem.min_size = (12, 20)

        name = widgets.Label(name='player_{:d}'.format(player.worldid))
        name.text = player.name
        name.min_size = (108, 20)

        money_score = widgets.Label(
            name='money_score_{:d}'.format(player.worldid))
        money_score.text = str(stats.money_score)
        money_score.min_size = (60, 20)

        land_score = widgets.Label(
            name='land_score_{:d}'.format(player.worldid))
        land_score.text = str(stats.land_score)
        land_score.min_size = (50, 20)

        resource_score = widgets.Label(
            name='resource_score_{:d}'.format(player.worldid))
        resource_score.text = str(stats.resource_score)
        resource_score.min_size = (90, 20)

        building_score = widgets.Label(
            name='building_score_{:d}'.format(player.worldid))
        building_score.text = str(stats.building_score)
        building_score.min_size = (70, 20)

        settler_score = widgets.Label(
            name='settler_score_{:d}'.format(player.worldid))
        settler_score.text = str(stats.settler_score)
        settler_score.min_size = (60, 20)

        unit_score = widgets.Label(
            name='unit_score_{:d}'.format(player.worldid))
        unit_score.text = str(stats.unit_score)
        unit_score.min_size = (50, 20)

        total_score = widgets.Label(
            name='total_score_{:d}'.format(player.worldid))
        total_score.text = str(stats.total_score)
        total_score.min_size = (70, 20)

        hbox = widgets.HBox()
        hbox.addChild(emblem)
        hbox.addChild(name)
        hbox.addChild(money_score)
        hbox.addChild(land_score)
        hbox.addChild(resource_score)
        hbox.addChild(building_score)
        hbox.addChild(settler_score)
        hbox.addChild(unit_score)
        hbox.addChild(total_score)
        self._content_vbox.addChild(hbox)
Example #3
0
    def _init_gui(self):
        """Initial init of gui."""
        self._gui = load_xml_translated("configure_route.xml")
        self.listbox = self._gui.findChild(name="branch_office_list")
        self.listbox._setItems(list(self.branch_offices))

        vbox = self._gui.findChild(name="left_vbox")
        for entry in self.instance.route.waypoints:
            hbox = widgets.HBox()
            label = widgets.Label()
            label.text = unicode(entry['branch_office'].settlement.name)
            hbox.addChild(label)
            vbox.addChild(hbox)

        # we want escape key to close the widget, what needs to be fixed here?
        self._gui.on_escape = self.hide
        # needs to check the current state and set the button state afterwards
        #		self._gui.findChild(name='start_route').set_inactive()
        self._gui.mapEvents({
            'cancelButton':
            self.hide,
            'add_bo/mouseClicked':
            self.append_bo,
            'start_route/mouseClicked':
            self.instance.route.enable,
            #		  'start_route/mouseClicked' : self.toggle_route
        })
        center_widget(self._gui)
Example #4
0
	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
Example #5
0
	def _add_summary_line_to_gui(self):
		people = 0
		tax = 0
		costs = 0
		for settlement in self.session.world.settlements:
			if settlement.owner is self.session.world.player:
				people += settlement.inhabitants
				tax += settlement.cumulative_taxes
				costs += settlement.cumulative_running_costs

		sequence_number_label = widgets.Label(name='sequence_number_total')
		sequence_number_label.min_size = sequence_number_label.max_size = (15, 20)

		name = widgets.Label(name='name_total')
		name.text = T('Total')
		name.min_size = name.max_size = (200, 20)

		self._add_generic_line_to_gui(0, [sequence_number_label, name], people, tax, costs)
	def _check_no_entries_label(self):
		"""Update hint informing about how to add waypoints. Only visible when there are none."""
		name = "no_entries_hint"
		if not self.instance.route.waypoints:
			lbl = widgets.Label(name=name, text=T("Click on a settlement to add a waypoint!"))
			self._gui.findChild(name="left_vbox").addChild(lbl)
		else:
			lbl = self._gui.findChild(name=name)
			if lbl:
				self._gui.findChild(name="left_vbox").removeChild(lbl)
Example #7
0
    def __init__(self, text=u"", panel_size=25, *args, **kwargs):
        super(StatusBar, self).__init__(*args, **kwargs)
        self.min_size = (panel_size, panel_size)

        self._tooltip = None
        self._label = widgets.Label(text=text)
        self.addChild(self._label)

        self._text = u""
        self._tooltipDisplayed = False
Example #8
0
    def _add_line_to_gui(self, container, resource_id, amount):
        res_name = self.db.get_res_name(resource_id)

        icon = create_resource_icon(resource_id, self.db)
        icon.name = 'icon_%s' % resource_id
        icon.max_size = icon.min_size = icon.size = (20, 20)

        label = widgets.Label(name='resource_%s' % resource_id)
        label.text = res_name
        label.min_size = (100, 20)

        amount_label = widgets.Label(name='produced_sum_%s' % resource_id)
        amount_label.text = unicode(amount)

        hbox = widgets.HBox()
        hbox.addChild(icon)
        hbox.addChild(label)
        hbox.addChild(amount_label)
        container.addChild(hbox)
Example #9
0
    def _add_line_to_gui(self, resource_id, amount):
        displayed = self.db.get_res_inventory_display(resource_id)
        if not displayed:
            return
        res_name = self.db.get_res_name(resource_id)

        icon = create_resource_icon(resource_id, self.db)
        icon.name = 'icon_%s' % resource_id
        icon.max_size = icon.min_size = icon.size = (20, 20)

        label = widgets.Label(name='resource_%s' % resource_id)
        label.text = res_name
        label.min_size = (100, 20)

        amount_label = widgets.Label(name='produced_sum_%s' % resource_id)
        amount_label.text = unicode(amount)

        hbox = widgets.HBox()
        hbox.addChild(icon)
        hbox.addChild(label)
        hbox.addChild(amount_label)
        self._content_vbox.addChild(hbox)
Example #10
0
    def append_bo(self):
        selected = self.listbox._getSelectedItem()
        if selected == None:
            return
        vbox = self._gui.findChild(name="left_vbox")

        hbox = widgets.HBox()
        label = widgets.Label()
        label.text = selected
        hbox.addChild(label)

        self.instance.route.append(self.branch_offices[selected], {4: -1})

        vbox.addChild(hbox)
        self.hide()
        self.show()
	def __init__(self,callback,**kwargs):
		super(ObjectIcon,self).__init__(**kwargs)

		self.callback = callback

		self.capture(self._mouseEntered, "mouseEntered")
		self.capture(self._mouseExited, "mouseExited")
		self.capture(self._mouseClicked, "mouseClicked")

		vbox = widgets.VBox(padding=3)

		# Icon
		self.icon = widgets.Icon(**kwargs)
		self.addChild(self.icon)

		# Label
		hbox = widgets.HBox(padding=1)
		self.addChild(hbox)
		self.label = widgets.Label(**kwargs)
		hbox.addChild(self.label)