Exemplo n.º 1
0
    def _init_stats_gui(self):
        reference_icon = self.gold_gui.child_finder("balance_background")
        self.stats_gui = load_uh_widget(self.__class__.STATS_GUI_FILE)
        self.stats_gui.child_finder = PychanChildFinder(self.stats_gui)
        self.stats_gui.position = (reference_icon.x + self.gold_gui.x,
                                   reference_icon.y + self.gold_gui.y)
        self.stats_gui.mapEvents({
            'resbar_stats_container/mouseClicked/stats':
            self._toggle_stats,
        })

        # This list must correspond to `figures` in _update_stats
        images = [
            ("content/gui/images/resbar_stats/expense.png",
             T("Running costs")),
            ("content/gui/images/resbar_stats/income.png", T("Taxes")),
            ("content/gui/images/resbar_stats/buy.png", T("Buy expenses")),
            ("content/gui/images/resbar_stats/sell.png", T("Sell income")),
            ("content/gui/images/resbar_stats/scales_icon.png", T("Balance")),
        ]

        for num, (image, helptext) in enumerate(images):
            # Keep in sync with comment there until we can use that data:
            # ./content/gui/xml/ingame/hud/resource_overview_bar_stats.xml
            box = HBox(padding=0, min_size=(70, 0))
            box.name = "resbar_stats_line_{}".format(num)
            box.helptext = helptext
            #TODO Fix icon size; looks like not 16x16 a surprising amount of times.
            box.addChild(Icon(image=image))
            box.addChild(Spacer())
            box.addChild(Label(name="resbar_stats_entry_{}".format(num)))
            #TODO This label is a workaround for some fife font bug,
            # probably http://github.com/fifengine/fifengine/issues/666.
            templabel = Label(name="resbar_stats_whatever_{}".format(num))
            box.addChild(templabel)
            if num == len(images) - 1:
                # The balance line (last one) gets bold font.
                box.stylize('resource_bar')
            self.stats_gui.child_finder("entries_box").addChild(box)
	def _init_stats_gui(self):
		reference_icon = self.gold_gui.child_finder("balance_background")
		self.stats_gui = load_uh_widget(self.__class__.STATS_GUI_FILE)
		self.stats_gui.child_finder = PychanChildFinder(self.stats_gui)
		self.stats_gui.position = (reference_icon.x + self.gold_gui.x,
		                           reference_icon.y + self.gold_gui.y)
		self.stats_gui.mapEvents({
			'resbar_stats_container/mouseClicked/stats': self._toggle_stats,
		})

		# This list must correspond to `figures` in _update_stats
		images = [
			("content/gui/images/resbar_stats/expense.png",     _("Running costs")),
			("content/gui/images/resbar_stats/income.png",      _("Taxes")),
			("content/gui/images/resbar_stats/buy.png",         _("Buy expenses")),
			("content/gui/images/resbar_stats/sell.png",        _("Sell income")),
			("content/gui/images/resbar_stats/scales_icon.png", _("Balance")),
		]

		for num, (image, helptext) in enumerate(images):
			# Keep in sync with comment there until we can use that data:
			# ./content/gui/xml/ingame/hud/resource_overview_bar_stats.xml
			box = HBox(padding=0, min_size=(70, 0))
			box.name = "resbar_stats_line_%s" % num
			box.helptext = helptext
			#TODO Fix icon size; looks like not 16x16 a surprising amount of times.
			box.addChild(Icon(image=image))
			box.addSpacer(Spacer())
			box.addChild(Label(name="resbar_stats_entry_%s"%num))
			#TODO This label is a workaround for some fife font bug,
			# probably http://github.com/fifengine/fifengine/issues/666.
			templabel = Label(name="resbar_stats_whatever_%s"%num)
			box.addChild(templabel)
			if num == len(images) - 1:
				# The balance line (last one) gets bold font.
				box.stylize('resource_bar')
			self.stats_gui.child_finder("entries_box").addChild(box)