예제 #1
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def toggle_fullscreen(self):
     """
     Swith between fullscreen or windowed mode.
     @return: if available and successfull, will return True, else return False.
     @rtype: Boolean
     """
     pygame.display.toggle_fullscreen()
     debugger.info("toggling fullscreen mode")
예제 #2
0
파일: engine.py 프로젝트: ialad/pyscumm
 def __update(self):
     for list_pos, x in enumerate(self.__dragging):
         if self.__dragging[list_pos]:
             if ( self.clock.time - self.__dragging[list_pos] ) >= self.mouse.drag_time:
                 event_dict = { "type":DRAG_START, "btn":"NotImplementedError", "obj":self._get_picked(), "pos":self.mouse.position  }
                 debugger.info("DRAG_START event launched %s" % event_dict)
                 self.room.on_event( event_dict )
                 self.__dragging[list_pos] = 0
예제 #3
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def toggle_fullscreen(self):
     """
     Swith between fullscreen or windowed mode.
     @return: if available and successfull, will return True, else return False.
     @rtype: Boolean
     """
     pygame.display.toggle_fullscreen()
     debugger.info("toggling fullscreen mode")
예제 #4
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def close(self):
     """
     Close que display window.
     @return None
     """
     if not self._opened:
         return
     pygame.display.quit()
     debugger.info("display closed")
예제 #5
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def close(self):
     """
     Close que display window.
     @return None
     """
     if not self._opened:
         return
     pygame.display.quit()
     debugger.info("display closed")
예제 #6
0
파일: engine.py 프로젝트: ialad/pyscumm
 def __process_mouse_button_up(self, event):
     if self.__dragging[event.button-1]:
         event_dict = { "type":SINGLE_CLICK, "btn":event.button, "obj":self._get_picked(), "pos":self.mouse.position  }
         debugger.info("SINGLE_CLICK event launched %s" % event_dict)
         self.room.on_event( event_dict )
         self.__dragging[event.button-1] = 0
     else:
         event_dict = { "type":DRAG_END, "btn":event.button, "obj":self._get_picked(), "pos":self.mouse.position  }
         debugger.info("DRAG_END event launched %s" % event_dict)
         self.room.on_event( event_dict )
예제 #7
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def open(self):
     """
     Open the display window with the setted size.
     @return: None
     """
     self._opened = True
     pygame.init()
     pygame.mouse.set_visible(False)
     pygame.display.init()
     self._set_title(self._title)
     self._set_size(self._size)
     debugger.info("display openned")
예제 #8
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def _set_size(self, size):
     """
     Set a new display size.
     @param size: The new size of the display (X,Y,*).
     @type size: pygame.base.Vector3D
     @return: None
     """
     self._size = size
     if not self._opened: return
     screen = pygame.display.set_mode(self._size, pygame.HWSURFACE)
     screen.set_clip(pygame.Rect((0, 0), self._size))
     debugger.info("display size setted [%s]" % (str(self._size)))
예제 #9
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def open(self):
     """
     Open the display window with the setted size.
     @return: None
     """
     self._opened = True
     pygame.init()
     pygame.mouse.set_visible(False)
     pygame.display.init()
     self._set_title(self._title)
     self._set_size(self._size)
     debugger.info("display openned")
예제 #10
0
파일: engine.py 프로젝트: ialad/pyscumm
 def __process_mouse_button_down(self, event):
     if event.button not in [1,2,3]:
         return
     # Check if DOUBLE_CLICK
     if self.clock.time - self.__button_time[event.button-1] < self.mouse.doubleclick_time:
         event_dict = { "type":DOUBLE_CLICK, "btn":event.button, "obj":self._get_picked(), "pos":self.mouse.position  }
         debugger.info("DOUBLE_CLICK event launched %s" % event_dict)
         self.room.on_event(event_dict)
         self.__dragging[event.button-1] = 0
     else:
         self.__button_time[event.button-1] = self.clock.time
     # Prepare a possible a DRAG_START
         self.__dragging[event.button-1] = self.clock.time
예제 #11
0
파일: driver.py 프로젝트: jrodrigog/pyscumm
 def _set_size(self, size):
     """
     Set a new display size.
     @param size: The new size of the display (X,Y,*).
     @type size: pygame.base.Vector3D
     @return: None
     """
     self._size = size
     if not self._opened:
         return
     screen = pygame.display.set_mode(self._size, pygame.HWSURFACE)
     screen.set_clip(pygame.Rect((0, 0), self._size))
     debugger.info("display size setted [%s]" % (str(self._size)))
예제 #12
0
파일: engine.py 프로젝트: jrodrigog/pyscumm
 def __update(self):
     for list_pos, x in enumerate(self.__dragging):
         if self.__dragging[list_pos]:
             if (self.clock.time -
                     self.__dragging[list_pos]) >= self.mouse.drag_time:
                 event_dict = {
                     "type": DRAG_START,
                     "btn": "NotImplementedError",
                     "obj": self._get_picked(),
                     "pos": self.mouse.position
                 }
                 debugger.info("DRAG_START event launched %s" % event_dict)
                 self.room.on_event(event_dict)
                 self.__dragging[list_pos] = 0
예제 #13
0
파일: engine.py 프로젝트: jrodrigog/pyscumm
 def __process_mouse_button_down(self, event):
     if event.button not in [1, 2, 3]:
         return
     # Check if DOUBLE_CLICK
     if self.clock.time - self.__button_time[
             event.button - 1] < self.mouse.doubleclick_time:
         event_dict = {
             "type": DOUBLE_CLICK,
             "btn": event.button,
             "obj": self._get_picked(),
             "pos": self.mouse.position
         }
         debugger.info("DOUBLE_CLICK event launched %s" % event_dict)
         self.room.on_event(event_dict)
         self.__dragging[event.button - 1] = 0
     else:
         self.__button_time[event.button - 1] = self.clock.time
         # Prepare a possible a DRAG_START
         self.__dragging[event.button - 1] = self.clock.time
예제 #14
0
파일: engine.py 프로젝트: jrodrigog/pyscumm
 def __process_mouse_button_up(self, event):
     if self.__dragging[event.button - 1]:
         event_dict = {
             "type": SINGLE_CLICK,
             "btn": event.button,
             "obj": self._get_picked(),
             "pos": self.mouse.position
         }
         debugger.info("SINGLE_CLICK event launched %s" % event_dict)
         self.room.on_event(event_dict)
         self.__dragging[event.button - 1] = 0
     else:
         event_dict = {
             "type": DRAG_END,
             "btn": event.button,
             "obj": self._get_picked(),
             "pos": self.mouse.position
         }
         debugger.info("DRAG_END event launched %s" % event_dict)
         self.room.on_event(event_dict)
예제 #15
0
파일: engine.py 프로젝트: ialad/pyscumm
    def run(self, room):
        pygame.init()
        debugger.info("turning ON engine...")
        try:
            import psyco
            psyco.full()
            debugger.info("python-psyco module found, performance acelerarion enabled")
        except ImportError:
            debugger.warn("python-psyco module not found, performance aceleration unavaliable")

        self.display.open()
        self.room = room()
        leave = False
        while not leave:
            try:
                self.clock.tick()
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        raise StopEngine()
                    elif event.type == pygame.MOUSEMOTION:
                        event_dict = { "type":MOUSE_MOTION, "pos":self.mouse.position, "obj":self._get_picked()  }
                        debugger.info("MOUSE_MOTION event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.MOUSEBUTTONDOWN:
                        self.__process_mouse_button_down( event )
                    elif event.type == pygame.MOUSEBUTTONUP:
                        self.__process_mouse_button_up( event )
                        #self.room.on_event(event)
                    elif event.type == pygame.KEYDOWN:
                        event_dict = { "type":KEY_DOWN, "key":event.key, "mod":"NotImplemented" }
                        debugger.info("KEY_DOWN event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.KEYUP:
                        event_dict = { "type":KEY_UP, "key":event.key, "mod":"NotImplemented" }
                        debugger.info("KEY_UP event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                self.__update()
                # Sort the container list by Z axis.
                #self.room.container.sort(key=lambda d: d.position.z)
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info("ChangeRoom exception raised, changing room to %s" % e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
예제 #16
0
파일: engine.py 프로젝트: jrodrigog/pyscumm
    def run(self, room):
        pygame.init()
        debugger.info("turning ON engine...")
        try:
            import psyco
            psyco.full()
            debugger.info(
                "python-psyco module found, performance acelerarion enabled")
        except ImportError:
            debugger.warn(
                "python-psyco module not found, performance aceleration unavaliable"
            )

        self.display.open()
        self.room = room()
        leave = False
        while not leave:
            try:
                self.clock.tick()
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        raise StopEngine()
                    elif event.type == pygame.MOUSEMOTION:
                        event_dict = {
                            "type": MOUSE_MOTION,
                            "pos": self.mouse.position,
                            "obj": self._get_picked()
                        }
                        debugger.info("MOUSE_MOTION event launched %s" %
                                      event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.MOUSEBUTTONDOWN:
                        self.__process_mouse_button_down(event)
                    elif event.type == pygame.MOUSEBUTTONUP:
                        self.__process_mouse_button_up(event)
                        #self.room.on_event(event)
                    elif event.type == pygame.KEYDOWN:
                        event_dict = {
                            "type": KEY_DOWN,
                            "key": event.key,
                            "mod": "NotImplemented"
                        }
                        debugger.info("KEY_DOWN event launched %s" %
                                      event_dict)
                        self.room.on_event(event_dict)
                    elif event.type == pygame.KEYUP:
                        event_dict = {
                            "type": KEY_UP,
                            "key": event.key,
                            "mod": "NotImplemented"
                        }
                        debugger.info("KEY_UP event launched %s" % event_dict)
                        self.room.on_event(event_dict)
                self.__update()
                # Sort the container list by Z axis.
                #self.room.container.sort(key=lambda d: d.position.z)
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info(
                    "ChangeRoom exception raised, changing room to %s" %
                    e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
예제 #17
0
파일: engine.py 프로젝트: ialad/pyscumm
                # Sort the container list by Z axis.
                #self.room.container.sort(key=lambda d: d.position.z)
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info("ChangeRoom exception raised, changing room to %s" % e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
        self.display.close()
        debugger.info("engine totally stopped, exiting")

    def __process_mouse_button_down(self, event):
        if event.button not in [1,2,3]:
            return
        # Check if DOUBLE_CLICK
        if self.clock.time - self.__button_time[event.button-1] < self.mouse.doubleclick_time:
            event_dict = { "type":DOUBLE_CLICK, "btn":event.button, "obj":self._get_picked(), "pos":self.mouse.position  }
            debugger.info("DOUBLE_CLICK event launched %s" % event_dict)
            self.room.on_event(event_dict)
            self.__dragging[event.button-1] = 0
        else:
            self.__button_time[event.button-1] = self.clock.time
        # Prepare a possible a DRAG_START
            self.__dragging[event.button-1] = self.clock.time
예제 #18
0
파일: engine.py 프로젝트: jrodrigog/pyscumm
                # Call update the room
                self.room.update()
                self.room.draw()
                self.mouse.update()
                self.mouse.draw()
                self.display.flip()
            except ChangeRoom, e:
                debugger.info(
                    "ChangeRoom exception raised, changing room to %s" %
                    e.__class__.__name__)
                self.room = e
            except StopEngine:
                debugger.info("stopping Engine...")
                leave = True
        self.display.close()
        debugger.info("engine totally stopped, exiting")

    def __process_mouse_button_down(self, event):
        if event.button not in [1, 2, 3]:
            return
        # Check if DOUBLE_CLICK
        if self.clock.time - self.__button_time[
                event.button - 1] < self.mouse.doubleclick_time:
            event_dict = {
                "type": DOUBLE_CLICK,
                "btn": event.button,
                "obj": self._get_picked(),
                "pos": self.mouse.position
            }
            debugger.info("DOUBLE_CLICK event launched %s" % event_dict)
            self.room.on_event(event_dict)