예제 #1
0
	def keyPressed(self, evt):
		if evt.isConsumed():
			return

		action = KeyConfig().translate(evt)
		_Actions = KeyConfig._Actions

		if action == _Actions.ESCAPE:
			self.gui.on_escape()
			evt.consume()
		elif action == _Actions.CONSOLE:
			horizons.main.fife.console.toggleShowHide()
			evt.consume()
		elif action == _Actions.HELP:
			self.gui.on_help()
		elif action == _Actions.SCREENSHOT:
			screenshotfilename = os.path.join(PATHS.SCREENSHOT_DIR,
			            string.replace(datetime.datetime.now().isoformat('.') + ".png", ":", "-"))

			''' the filename is changed into a string, cause it looks like FIFE can't handle unicode strings yet
			it's only a workaround to prevent a crash ...
			this should be changed later to unicode(string.replace(datetime... '''

			screenshotfilename = str(screenshotfilename)
			horizons.main.fife.engine.getRenderBackend().captureScreen(screenshotfilename)
			if self.gui.session is not None:
				# ingame message if there is a session
				self.gui.session.ingame_gui.message_widget.add(None, None, 'SCREENSHOT', \
																													{'file': screenshotfilename})
		elif action == _Actions.QUICKLOAD:
			from horizons.main import _load_last_quicksave
			_load_last_quicksave()
예제 #2
0
    def keyPressed(self, evt):
        if evt.isConsumed():
            return
        keyval = evt.getKey().getValue()
        keystr = evt.getKey().getAsString().lower()
        if keyval == fife.Key.ESCAPE:
            self.gui.on_escape()
            evt.consume()
        elif keyval == fife.Key.F10:
            horizons.main.fife.console.toggleShowHide()
            evt.consume()
        elif keyval == fife.Key.F1:
            self.gui.on_help()
        elif keystr == 's':
            screenshotfilename = os.path.join(
                PATHS.SCREENSHOT_DIR,
                string.replace(datetime.datetime.now().isoformat('.') + ".png",
                               ":", "-"))
            ''' the filename is changed into a string, cause it looks like FIFE can't handle unicode strings yet
			it's only a workaround to prevent a crash ...
			this should be changed later to unicode(string.replace(datetime... '''

            screenshotfilename = str(screenshotfilename)
            horizons.main.fife.engine.getRenderBackend().captureScreen(
                screenshotfilename)
            if self.gui.session is not None:
                # ingame message if there is a session
                self.gui.session.ingame_gui.message_widget.add(None, None, 'SCREENSHOT', \
                                         {'file': screenshotfilename})
        elif keyval == fife.Key.F9:
            from horizons.main import _load_last_quicksave
            _load_last_quicksave()
예제 #3
0
	def keyPressed(self, evt):
		if evt.isConsumed():
			return
		keyval = evt.getKey().getValue()
		keystr = evt.getKey().getAsString().lower()
		if keyval == fife.Key.ESCAPE:
			self.gui.on_escape()
			evt.consume()
		elif keyval == fife.Key.F10:
			horizons.main.fife.console.toggleShowHide()
			evt.consume()
		elif keyval == fife.Key.F1:
			self.gui.on_help()
		elif keystr == 's':
			screenshotfilename = os.path.join(PATHS.SCREENSHOT_DIR,
			            string.replace(datetime.datetime.now().isoformat('.') + ".png", ":", "-"))

			''' the filename is changed into a string, cause it looks like FIFE can't handle unicode strings yet
			it's only a workaround to prevent a crash ...
			this should be changed later to unicode(string.replace(datetime... '''

			screenshotfilename = str(screenshotfilename)
			horizons.main.fife.engine.getRenderBackend().captureScreen(screenshotfilename)
			if self.gui.session is not None:
				# ingame message if there is a session
				self.gui.session.ingame_gui.message_widget.add(None, None, 'SCREENSHOT', \
																													{'file': screenshotfilename})
		elif keyval == fife.Key.F9:
			from horizons.main import _load_last_quicksave
			_load_last_quicksave()
예제 #4
0
    def keyPressed(self, evt):
        if evt.isConsumed():
            return

        action = KeyConfig().translate(evt)
        _Actions = KeyConfig._Actions

        key_event_handled = True

        if action == _Actions.ESCAPE:
            self.gui.on_escape()
        elif action == _Actions.CONSOLE:
            horizons.globals.fife.console.toggleShowHide()
        elif action == _Actions.HELP:
            self.gui.on_help()
        elif action == _Actions.SCREENSHOT:
            # save the screenshot into a temporary file because fife doesn't support unicode paths
            temp_handle, temp_path = tempfile.mkstemp()
            os.close(temp_handle)
            horizons.globals.fife.engine.getRenderBackend().captureScreen(
                temp_path)

            # move the screenshot into the final location
            filename = datetime.datetime.now().isoformat('.').replace(
                ":", "-") + ".png"
            final_path = os.path.join(PATHS.SCREENSHOT_DIR, filename)
            shutil.move(temp_path, final_path)

            # ingame message if there is a session
            if self.gui.session is not None:
                self.gui.session.ingame_gui.message_widget.add(
                    point=None,
                    string_id='SCREENSHOT',
                    message_dict={'file': final_path})
        elif action == _Actions.QUICKLOAD:
            from horizons.main import _load_last_quicksave
            _load_last_quicksave(self.gui.session)
        else:
            key_event_handled = False  # nope, nothing triggered

        if key_event_handled:
            evt.consume()  # prevent other listeners from being called
	def keyPressed(self, evt):
		if evt.isConsumed():
			return

		action = KeyConfig().translate(evt)
		_Actions = KeyConfig._Actions

		key_event_handled = True

		if action == _Actions.ESCAPE:
			self.gui.on_escape()
		elif action == _Actions.CONSOLE:
			self.gui.fps_display.toggle()
		elif action == _Actions.HELP:
			self.gui.on_help()
		elif action == _Actions.SCREENSHOT:
			# save the screenshot into a temporary file because fife doesn't support unicode paths
			temp_handle, temp_path = tempfile.mkstemp()
			os.close(temp_handle)
			horizons.globals.fife.engine.getRenderBackend().captureScreen(temp_path)

			# move the screenshot into the final location
			filename = datetime.datetime.now().isoformat('.').replace(":", "-") + ".png"
			final_path = os.path.join(PATHS.SCREENSHOT_DIR, filename)
			shutil.move(temp_path, final_path)

			# ingame message if there is a session
			if self.gui.session is not None:
				self.gui.session.ingame_gui.message_widget.add(point=None, string_id='SCREENSHOT',
				                                               message_dict={'file': final_path})
		elif action == _Actions.QUICKLOAD:
			from horizons.main import _load_last_quicksave
			_load_last_quicksave(self.gui.session)
		else:
			key_event_handled = False # nope, nothing triggered

		if key_event_handled:
			evt.consume() # prevent other listeners from being called