Ejemplo n.º 1
0
	def on_chime(self):
		"""
		Called chime action. Displaying call for help on artists and game design,
		introduces information for SoC applicants (if valid).
		"""
		AmbientSoundComponent.play_special("message")
		self.show_dialog(self.widgets['call_for_support'], {'okButton' : True}, onPressEscape = True)
Ejemplo n.º 2
0
    def move_entry(self, entry, direction):
        """
		moves an entry up or down
		"""
        position = self.widgets.index(entry)
        if position == len(self.widgets) and direction is "down" or position == 0 and direction is "up":
            AmbientSoundComponent.play_special("error")
            return

        if direction is "up":
            new_pos = position - 1
        elif direction is "down":
            new_pos = position + 1
        else:
            return

        vbox = self._gui.findChild(name="left_vbox")

        vbox.removeChildren(self.widgets)
        self.widgets.insert(new_pos, self.widgets.pop(position))
        self._route_cmd("move_waypoint", position, direction)
        vbox.addChildren(self.widgets)

        self._gui.adaptLayout()
        self._resource_selection_area_layout_hack_fix()
Ejemplo n.º 3
0
	def move_entry(self, entry, direction):
		"""
		moves an entry up or down
		"""
		position = self.widgets.index(entry)
		if position == len(self.widgets) and direction is 'down' or \
		   position == 0 and direction is 'up':
			AmbientSoundComponent.play_special('error')
			return

		if direction is 'up':
			new_pos = position - 1
		elif direction is 'down':
			new_pos = position + 1
		else:
			return

		vbox = self._gui.findChild(name="left_vbox")
		enabled = self.instance.route.enabled
		self.instance.route.disable()

		vbox.removeChildren(self.widgets)
		self.widgets.insert(new_pos,self.widgets.pop(position))
		self.instance.route.move_waypoint(position, direction)
		vbox.addChildren(self.widgets)

		if enabled:
			self.instance.route.enable()

		self._gui.adaptLayout()
		self._resource_selection_area_layout_hack_fix()
Ejemplo n.º 4
0
 def __join_game(self, game=None):
     """Joins a multiplayer game. Displays lobby for that specific game"""
     if game == None:
         game = self.__get_selected_game()
     if (
         game.load is not None
         and SavegameAccessor.get_hash(SavegameManager.get_multiplayersave_map(game.mapname)) != game.load
     ):
         self.show_popup(_("Error"), self.current.findChild(name="save_missing_help_button").btn_text, size=1)
         return
     if game.get_uuid() == -1:  # -1 signals no game
         AmbientSoundComponent.play_special("error")
         return
     if game.get_version() != NetworkInterface().get_clientversion():
         self.show_popup(
             _("Wrong version"),
             # xgettext:python-format
             _(
                 "The game's version differs from your version. Every player in a multiplayer game must use the same version. This can be fixed by every player updating to the latest version. Game version: {game_version} Your version: {own_version}"
             ).format(game_version=game.get_version(), own_version=NetworkInterface().get_clientversion()),
         )
         return
         # actual join
     join_worked = NetworkInterface().joingame(game.get_uuid())
     if not join_worked:
         return
     self.__apply_new_nickname()
     self.__show_gamelobby()
Ejemplo n.º 5
0
    def __call__(self, issuer):
        """Execute the command
		@param issuer: the issuer of the command
		"""
        if self.position is None:
            AmbientSoundComponent.play_special(self.sound)
        else:
            AmbientSoundComponent.play_special(self.sound, Point(self.position[0], self.position[1]))
Ejemplo n.º 6
0
	def speed_down(self):
		if self.speed_is_paused():
			AmbientSoundComponent.play_special('error')
			return
		if self.timer.ticks_per_second in GAME_SPEED.TICK_RATES:
			i = GAME_SPEED.TICK_RATES.index(self.timer.ticks_per_second)
			if i > 0:
				self.speed_set(GAME_SPEED.TICK_RATES[i - 1])
		else:
			self.speed_set(GAME_SPEED.TICK_RATES[0])
Ejemplo n.º 7
0
	def _scroll(self, direction):
		"""Scroll back or forth one message.
		@param direction: -1 or 1"""
		if len(self._widgets) == 0:
			return
		new_cur = self._cur_entry + direction
		if new_cur < 0 or new_cur >= len(self._widgets):
			return # invalid scroll
		self._cur_entry = new_cur
		AmbientSoundComponent.play_special('flippage')
		self._redraw_captainslog()
Ejemplo n.º 8
0
	def _make_configuration_default(self, reset=False):
		"""Saves current resources as default via game settings"""
		if reset:
			config = [] # meaning invalid
		else:
			config = json.dumps(self._get_current_resources())
		horizons.main.fife.set_uh_setting("ResourceOverviewBarConfiguration", config)
		horizons.main.fife.save_settings()
		self._update_default_configuration()
		AmbientSoundComponent.play_special("success")
		if reset: # in the other case, it's already set
			self.redraw()
Ejemplo n.º 9
0
	def mousePressed(self,  evt):
		if evt.getButton() == fife.MouseEvent.LEFT:
			obj = self._get_object(evt)
			if obj and self._is_buildable(obj.id):
				self.session.set_cursor('building', Entities.buildings[obj.id])
			elif obj: # object that is not buildable
				AmbientSoundComponent.play_special('error')
				self.on_escape()
			else:
				self.on_escape()
			evt.consume()
		elif evt.getButton() == fife.MouseEvent.RIGHT:
			self.on_escape()
			evt.consume()
		else:
			super(PipetteTool,  self).mouseClicked(evt)
Ejemplo n.º 10
0
    def append_warehouse(self, warehouse):
        """Add a warehouse to the list on the left side.
		@param warehouse: Set to add a specific one, else the selected one gets added.
		"""
        if len(self.widgets) >= self.MAX_ENTRIES:
            # reached max entries the gui can hold
            AmbientSoundComponent.play_special("error")
            return

        self._route_cmd("append", warehouse.worldid)
        self.add_gui_entry(warehouse)
        if self.resource_menu_shown:
            self.hide_resource_menu()

        self._check_no_entries_label()

        self._gui.adaptLayout()
Ejemplo n.º 11
0
	def _add_message(self, message, sound=None):
		"""Internal function for adding messages. Do not call directly.
		@param message: Message instance
		@param sound: path to soundfile"""
		self.active_messages.insert(0, message)
		if len(self.active_messages) > self.MAX_MESSAGES:
			self.active_messages.remove(self.active_messages[self.MAX_MESSAGES])

		if sound:
			horizons.main.fife.play_sound('speech', sound)
		else:
			# play default msg sound
			AmbientSoundComponent.play_special('message')

		if message.x is not None and message.y is not None:
			self.session.ingame_gui.minimap.highlight( (message.x, message.y) )

		self.draw_widget()
		self.show_text(0)
		ExtScheduler().add_new_object(self.hide_text, self, self.SHOW_NEW_MESSAGE_TEXT)
Ejemplo n.º 12
0
	def set_active(self, production=None, active=True):
		super(MineProducer, self).set_active(production, active)
		# check if the user set it to waiting_for_res (which doesn't do anything)
		if active and self._get_current_state() == PRODUCTION.STATES.waiting_for_res:
			super(MineProducer, self).set_active(production, active=False)
			AmbientSoundComponent.play_special('error')