Esempio n. 1
0
    def show_build_menu(self, update=False):
        """
		@param update: set when build possibilities change (e.g. after inhabitant tier upgrade)
		"""
        # check if build menu is already shown
        if hasattr(self.get_cur_menu(), 'name') and self.get_cur_menu(
        ).name == "build_menu_tab_widget":
            self.hide_menu()

            if not update:  # this was only a toggle call, don't reshow
                return

        self.set_cursor()  # set default cursor for build menu
        self.deselect_all()

        if not any(settlement.owner.is_local_player
                   for settlement in self.session.world.settlements):
            # player has not built any settlements yet. Accessing the build menu at such a point
            # indicates a mistake in the mental model of the user. Display a hint.
            tab = TabWidget(
                self, tabs=[TabInterface(widget="buildtab_no_settlement.xml")])
        else:
            btabs = BuildTab.create_tabs(self.session, self._build)
            tab = TabWidget(self,
                            tabs=btabs,
                            name="build_menu_tab_widget",
                            active_tab=BuildTab.last_active_build_tab)
        self.show_menu(tab)
Esempio n. 2
0
    def show_menu(self, jump_to_tabclass=None):
        """Shows tabwidget tabs of this instance.

		Opens the first such tab unless jump_to_tabclass specifies otherwise.
		@param jump_to_tabclass: open the first tab that is a subclass to this parameter
		"""
        from horizons.gui.tabs import TabWidget
        tablist = None
        if self.instance.owner is not None and self.instance.owner.is_local_player:
            tablist = self.tabs
        else:  # this is an enemy instance with respect to the local player
            tablist = self.enemy_tabs

        if not tablist:
            return

        tabclasses = [
            tabclass for tabclass in tablist
            if tabclass.shown_for(self.instance)
        ]
        try:
            active_tab_index = tabclasses.index(self.active_tab)
        except ValueError:
            active_tab_index = None
        tabs = [tabclass(self.instance) for tabclass in tabclasses]
        tabwidget = TabWidget(self.session.ingame_gui,
                              tabs=tabs,
                              active_tab=active_tab_index)

        if jump_to_tabclass:
            for i, tab in enumerate(tabs):
                if isinstance(tab, jump_to_tabclass):
                    tabwidget.show_tab(i)
                    break
        self.session.ingame_gui.show_menu(tabwidget)
    def show_menu(self, jump_to_tabclass=None):
        """Shows tabs from self.__class__.tabs, if there are any.
		@param jump_to_tabclass: open the first tab that is a subclass to this parameter
		"""
        from horizons.gui.tabs import TabWidget
        tablist = None
        if self.instance.owner is not None and self.instance.owner.is_local_player:
            tablist = self.tabs
        else:  # this is an enemy instance with respect to the local player
            tablist = self.enemy_tabs

        if tablist:
            tabs = [
                tabclass(self.instance) for tabclass in tablist
                if tabclass.shown_for(self.instance)
            ]
            tabwidget = TabWidget(self.session.ingame_gui, tabs=tabs)

            if jump_to_tabclass:
                for i, tab in enumerate(tabs):
                    if isinstance(tab, jump_to_tabclass):
                        tabwidget._show_tab(i)
                        break

            self.session.ingame_gui.show_menu(tabwidget)
    def show_menu(self):
        """Shows tabs from self.__class__.tabs, if there are any"""
        # this local import prevents circular imports
        from horizons.gui.tabs import TabWidget
        tablist = []
        if self.owner == self.session.world.player:
            tablist = self.tabs
        else:  # this is an enemy instance with respect to the local player
            tablist = self.enemy_tabs

        if tablist:
            tabs = [tabclass(self) for tabclass in tablist]
            self.session.ingame_gui.show_menu(TabWidget(self.session.ingame_gui, \
                                                        tabs=tabs))
Esempio n. 5
0
	def show_build_menu(self):
		# check if build menu is already shown
		if hasattr(self.get_cur_menu(), 'name'):
			if self.get_cur_menu().name == "build_menu_tab_widget":
				self.hide_menu()
				return

		self.session.cursor = SelectionTool(self.session) # set cursor for build menu
		self.deselect_all()
		lvl = self.session.world.player.settler_level
		btabs = [BuildTab(i, self.callbacks_build[i]) for i in range(0, lvl+1)]
		tab = TabWidget(self, tabs=btabs, name="build_menu_tab_widget", \
								    active_tab=BuildTab.last_active_build_tab)
		self.show_menu(tab)
Esempio n. 6
0
 def show_multi_select_tab(self, instances):
     tab = TabWidget(self,
                     tabs=[SelectMultiTab(instances)],
                     name='select_multi')
     self.show_menu(tab)
Esempio n. 7
0
 def setup(self):
     """Called after the world editor was initialized."""
     self._settings_tab = TabWidget(
         self, tabs=[SettingsTab(self.session.world_editor, self)])
     self._settings_tab.show()
Esempio n. 8
0
 def show_multi_select_tab(self):
     tab = TabWidget(self,
                     tabs=[SelectMultiTab(self.session)],
                     name='select_multi')
     self.show_menu(tab)
Esempio n. 9
0
 def _show_settings(self):
     """Display settings widget to change brush size and select tiles."""
     tab = TabWidget(self._ingame_gui,
                     tabs=[SettingsTab(self._world_editor, self._session)])
     self._ingame_gui.show_menu(tab)