Exemplo n.º 1
0
def show_new_version_hint(gui, info):
    """
	@param gui: main gui (Gui)
	@param info: UpdateInfo instance
	"""
    title = _(u"New version of Unknown Horizons")
    #xgettext:python-format
    text = _(
        u"There is a more recent release of Unknown Horizons ({new_version}) "
        u"than the one you are currently using ({old_version}).").format(
            new_version=info.version, old_version=VERSION.RELEASE_VERSION)

    dl_btn = Button(name="dl", text=_("Click to download"))
    dl_btn.position = (
        48, 138)  # i've tried, this button cannot be placed in a sane way

    def do_dl():
        webbrowser.open(info.link)
        dl_btn.text = _("A page has been opened in your browser.")
        popup.adaptLayout()

    dl_btn.capture(do_dl)

    popup = gui.build_popup(title, text)
    popup.addChild(dl_btn)

    gui.show_dialog(popup, {OkButton.DEFAULT_NAME: True}, modal=True)
Exemplo n.º 2
0
 def addTab(self, text):
     text = unicode(text)
     tab = Button(text=text)
     tab_bar = self.findChild(name='tabBar')
     tab_bar.addChild(tab)
     tab.capture(callbackWithArguments(self.showView, text))
     self.adaptLayout()
Exemplo n.º 3
0
	def prepare(self, **kwargs):
		super(VersionHint, self).prepare(**kwargs)

		dl_btn = Button(name="dl", text=T("Click to download"))
		dl_btn.position = (48, 138) # i've tried, this button cannot be placed in a sane way
		def do_dl():
			webbrowser.open(self.info.link)
			dl_btn.text = T("A page has been opened in your browser.")
			self._gui.adaptLayout()
		dl_btn.capture(do_dl)

		self._gui.addChild(dl_btn)
Exemplo n.º 4
0
	def prepare(self, **kwargs):
		super(VersionHint, self).prepare(**kwargs)

		dl_btn = Button(name="dl", text=_("Click to download"))
		dl_btn.position = (48, 138) # i've tried, this button cannot be placed in a sane way
		def do_dl():
			webbrowser.open(self.info.link)
			dl_btn.text = _("A page has been opened in your browser.")
			self._gui.adaptLayout()
		dl_btn.capture(do_dl)

		self._gui.addChild(dl_btn)
Exemplo n.º 5
0
def show_new_version_hint(gui, info):
	"""
	@param gui: main gui (Gui)
	@param info: UpdateInfo instance
	"""
	title = _(u"New version of Unknown Horizons")
	#xgettext:python-format
	text = _(u"There is a more recent release of Unknown Horizons ({new_version}) "
	         u"than the one you are currently using ({old_version}).").format(
	        new_version=info.version,
	        old_version=VERSION.RELEASE_VERSION)

	dl_btn = Button(name="dl", text=_("Click to download"))
	dl_btn.position = (48, 138) # i've tried, this button cannot be placed in a sane way
	def do_dl():
		webbrowser.open(info.link)
		dl_btn.text = _("A page has been opened in your browser.")
		popup.adaptLayout()
	dl_btn.capture(do_dl)

	popup = gui.build_popup(title, text)
	popup.addChild( dl_btn )

	gui.show_dialog(popup, {OkButton.DEFAULT_NAME : True}, modal=True)
Exemplo n.º 6
0
	def __update_game_details(self, game=None):
		"""Set map name and other misc data in a widget. Only possible in certain states"""
		if game is None:
			game = self.__get_selected_game()
			if game is None:
				return
		#xgettext:python-format
		self.current.findChild(name="game_map").text = _("Map: {map_name}").format(map_name=game.get_map_name())
		self.current.findChild(name="game_name").text = _("Name: {game_name}").format(game_name=game.get_name())
		self.current.findChild(name="game_creator").text = _("Creator: {game_creator}").format(game_creator=game.get_creator())
		#xgettext:python-format
		self.current.findChild(name="game_playersnum").text = _("Players: {player_amount}/{player_limit}").format(
		                           player_amount=game.get_player_count(),
		                           player_limit=game.get_player_limit())
		vbox_inner = self.current.findChild(name="game_info")
		if game.is_savegame(): # work around limitations of current systems via messages
			path = SavegameManager.get_multiplayersave_map(game.mapname)
			btn_name = "save_missing_help_button"
			btn = vbox_inner.findChild(name=btn_name)
			if SavegameAccessor.get_hash(path) != game.get_map_hash():
				text = ""
				if btn is None:
					btn = Button(name=btn_name)
					btn.text = _("This savegame is missing (click here)")
					last_elem = vbox_inner.findChild(name="game_info_last")
					if last_elem is None: # no last elem -> we are last
						vbox_inner.addChild( btn )
					else:
						vbox_inner.insertChildBefore( btn, last_elem )
				btn_text = _(u"For multiplayer load, it is necessary for you to have the correct savegame file.") + u"\n"
				btn_text += _(u"The file will be downloaded when the game starts.")
				btn.btn_text = btn_text
				def show():
					self.show_popup(_("Help"), btn_text, size=1)
				btn.capture(show)

			else:
				text = _(u"This is a savegame.")
				if btn is not None:
					btn.hide()

			if text:
				self.current.findChild(name="game_isloaded").text = text

		self.__update_players_box(game)

		vbox_inner.adaptLayout() # inner vbox always exists
		vbox = self.current.findChild(name="gamedetailsbox")
		if vbox is not None:
			vbox.adaptLayout()
	def _create_button(self, action, index):
		"""Important! The button name is set to index so that when a button is pressed, we know its index"""
		button = Button()
		button.name = str(index)
		button.max_size = button.min_size = (100, 18)
		return button
Exemplo n.º 8
0
	def _create_button(self, action, index):
		"""Important! The button name is set to index so that when a button is pressed, we know its index"""
		button = Button()
		button.name = str(index)
		button.max_size = button.min_size = (100, 18)
		return button
    def __update_game_details(self, game=None):
        """Set map name and other misc data in a widget. Only possible in certain states"""
        if game is None:
            game = self.__get_selected_game()
            if game is None:
                return
        #xgettext:python-format
        self.current.findChild(
            name="game_map").text = _("Map: {map_name}").format(
                map_name=game.get_map_name())
        self.current.findChild(
            name="game_name").text = _("Name: {game_name}").format(
                game_name=game.get_name())
        self.current.findChild(
            name="game_creator").text = _("Creator: {game_creator}").format(
                game_creator=game.get_creator())
        #xgettext:python-format
        self.current.findChild(name="game_playersnum").text = _(
            "Players: {player_amount}/{player_limit}").format(
                player_amount=game.get_player_count(),
                player_limit=game.get_player_limit())
        vbox_inner = self.current.findChild(name="game_info")
        if game.is_savegame(
        ):  # work around limitations of current systems via messages
            path = SavegameManager.get_multiplayersave_map(game.mapname)
            btn_name = "save_missing_help_button"
            btn = vbox_inner.findChild(name=btn_name)
            if SavegameAccessor.get_hash(path) != game.get_map_hash():
                text = ""
                if btn is None:
                    btn = Button(name=btn_name)
                    btn.text = _("This savegame is missing (click here)")
                    last_elem = vbox_inner.findChild(name="game_info_last")
                    if last_elem is None:  # no last elem -> we are last
                        vbox_inner.addChild(btn)
                    else:
                        vbox_inner.insertChildBefore(btn, last_elem)
                btn_text = _(
                    u"For multiplayer load, it is necessary for you to have the correct savegame file."
                ) + u"\n"
                btn_text += _(
                    u"The file will be downloaded when the game starts.")
                btn.btn_text = btn_text

                def show():
                    self.show_popup(_("Help"), btn_text, size=1)

                btn.capture(show)

            else:
                text = _(u"This is a savegame.")
                if btn is not None:
                    btn.hide()

            if text:
                self.current.findChild(name="game_isloaded").text = text

        self.__update_players_box(game)

        vbox_inner.adaptLayout()  # inner vbox always exists
        vbox = self.current.findChild(name="gamedetailsbox")
        if vbox is not None:
            vbox.adaptLayout()