def __init__(self):
		self.page_widgets = {}
		self.widget = load_uh_widget(self.widget_xml, center_widget=True)

		# Lists holding pickbelt ImageButtons, placed to the left/right of the book
		self.buttons = {'left': [], 'right': []}

		for i, (name, text) in enumerate(self.sections):
			self.page_widgets[i] = self.widget.findChild(name=name)

		# Create the required pickbelts
		for i, (name, text) in enumerate(self.sections):
			for side in self.buttons:
				pickbelt = ImageButton(text=text)
				pickbelt.name = name + '_' + side
				pickbelt.path = 'images/background/pickbelt_%s' % side
				pickbelt.font = "pickbelt"

				pickbelt.capture(Callback(self.update_view, i), event_name="mouseClicked")

				start_x, start_y = self.pickbelt_start_pos
				pickbelt.position = (start_x + 5*i, start_y + 70*i)

				container = self.widget.findChild(name="%s_pickbelts" % side)
				container.addChild(pickbelt)
				self.buttons[side].append(pickbelt)

		self.widget.show() # Hack to initially setup the pickbelts properly
		self.update_view()
		self.widget.hide() # Hack to initially setup the pickbelts properly
示例#2
0
    def __init__(self):
        self.page_widgets = {}
        self.widget = load_uh_widget(self.widget_xml, center_widget=True)

        # Lists holding pickbelt ImageButtons, placed to the left/right of the book
        self.buttons = {'left': [], 'right': []}

        for i, (name, text) in enumerate(self.sections):
            self.page_widgets[i] = self.widget.findChild(name=name)

        # Create the required pickbelts
        for i, (name, text) in enumerate(self.sections):
            for side in self.buttons:
                pickbelt = ImageButton(text=text)
                pickbelt.name = name + '_' + side
                pickbelt.path = 'images/background/pickbelt_%s' % side
                pickbelt.font = "pickbelt"

                pickbelt.capture(Callback(self.update_view, i),
                                 event_name="mouseClicked")

                start_x, start_y = self.pickbelt_start_pos
                pickbelt.position = (start_x + 5 * i, start_y + 70 * i)

                container = self.widget.findChild(name="%s_pickbelts" % side)
                container.addChild(pickbelt)
                self.buttons[side].append(pickbelt)

        self.widget.show()  # Hack to initially setup the pickbelts properly
        self.update_view()
        self.widget.hide()  # Hack to initially setup the pickbelts properly
示例#3
0
    def draw_widget(self):
        """
		Updates whole messagewidget (all messages): draw icons.
		Inactive messages need their icon hovered to display their text again
		"""
        button_space = self.widget.findChild(name="button_space")
        button_space.removeAllChildren()  # Remove old buttons
        for index, message in enumerate(self.active_messages):
            if index >= len(self.active_messages):
                # Only display most recent notifications
                continue
            button = ImageButton()
            button.name = str(index)
            button.path = message.path
            # show text on hover
            events = {
                button.name + "/mouseEntered": Callback(self.show_text, index),
                button.name + "/mouseExited": self.hide_text,
            }
            # init callback to something callable to improve robustness
            callback = Callback(lambda: None)
            if message.x != 0 and message.y != 0:
                # move camera to source of event on click, if there is a source
                callback = Callback.ChainedCallbacks(
                    callback,  # this makes it so the order of callback assignment doesn't matter
                    Callback(self.session.view.center, message.x, message.y),
                    Callback(self.session.ingame_gui.minimap.highlight,
                             (message.x, message.y)))
            if message.msg_type == "logbook":
                # open logbook to relevant page
                callback = Callback.ChainedCallbacks(
                    callback,  # this makes it so the order of callback assignment doesn't matter
                    Callback(self.session.ingame_gui.windows.toggle,
                             self.session.ingame_gui.logbook,
                             msg_id=message.created))
            if callback:
                events[button.name] = callback

            button.mapEvents(events)
            button_space.addChild(button)
        button_space.resizeToContent()
        self.widget.size = button_space.size
	def draw_widget(self):
		"""
		Updates whole messagewidget (all messages): draw icons.
		Inactive messages need their icon hovered to display their text again
		"""
		button_space = self.widget.findChild(name="button_space")
		button_space.removeAllChildren() # Remove old buttons
		for index, message in enumerate(self.active_messages):
			if (self.item + index) >= len(self.active_messages):
				# Only display most recent notifications
				continue
			button = ImageButton()
			button.name = str(index)
			button.path = message.path
			# show text on hover
			events = {
				button.name + "/mouseEntered": Callback(self.show_text, index),
				button.name + "/mouseExited": self.hide_text,
			}
			# init callback to something callable to improve robustness
			callback = Callback(lambda: None)
			if message.x is not None and message.y is not None:
				# move camera to source of event on click, if there is a source
				callback = Callback.ChainedCallbacks(
					   callback, # this makes it so the order of callback assignment doesn't matter
					   Callback(self.session.view.center, message.x, message.y),
					   Callback(self.session.ingame_gui.minimap.highlight, (message.x, message.y) )
				   )
			if message.type == "logbook":
				# open logbook to relevant page
				callback = Callback.ChainedCallbacks(
					   callback, # this makes it so the order of callback assignment doesn't matter
					   Callback(self.session.ingame_gui.logbook.show, message.created)
				)
			if callback:
				events[button.name] = callback

			button.mapEvents(events)
			button_space.addChild(button)
		button_space.resizeToContent()
		self.widget.size = button_space.size