Ejemplo n.º 1
0
    def __init__(self, appClass, resolution=DEFAULT_RESOLUTION,
            debugWindowSize=None, fakeFullscreen=False):

        resolution = Point2D(resolution)
        testMode = not 'AVG_DEPLOY' in os.environ

        if testMode and debugWindowSize is not None:
            debugWindowSize = Point2D(debugWindowSize)
        else:
            debugWindowSize = Point2D(0, 0)

        if fakeFullscreen:
            if os.name != 'nt':
                raise RuntimeError('Fakefullscreen is supported only on windows')
            elif not testMode:
                self.__enableFakeFullscreen()

            fullscreen = False
        else:
            fullscreen = not testMode

        player.enableMouse(not 'AVG_DISABLE_MOUSE' in os.environ)
        player.showCursor(testMode)
        self._setupBaseDivs(resolution)

        player.setResolution(
                fullscreen,
                int(debugWindowSize.x), int(debugWindowSize.y),
                0 # color depth
                )

        self._startApp(appClass)
Ejemplo n.º 2
0
    def _setupResolution(self):
        rotation = self.settings.get('app_rotation').lower()
        resolutionStr = self.settings.get('app_resolution').lower()
        windowSizeStr = self.settings.get('app_window_size')
        if self.settings.get('app_windowconfig') == '':
            if resolutionStr != '':
                resolution = self.settings.getPoint2D('app_resolution')
            else:
                resolution = libavg.player.getScreenResolution()

            if windowSizeStr != '':
                windowSize = self.settings.getPoint2D('app_window_size')
            else:
                windowSize = resolution

            if rotation in ('left', 'right'):
                resolution = Point2D(resolution.y, resolution.x)
                windowSize = Point2D(windowSize.y, windowSize.x)

            self._resolution = resolution
            self._windowSize = windowSize
        else:
            if rotation != 'normal' or windowSizeStr != '':
                raise TypeError(
                    'App parameters: app_windowconfig is incompatible ' +
                    'with app_window_size and app_rotation')
            player.setWindowConfig(self.settings.get('app_windowconfig'))
            self._resolution = self.settings.getPoint2D('app_resolution')
Ejemplo n.º 3
0
def getScaledDim (size, max = None, min = None):
    width, height = size
    if width == 0 or height == 0:
        return size

    if max:
        max = Point2D(max)
        assert (max.x > 0 and max.y > 0)
        if width > max.x:
            height = height * (max.x / width)
            width = max.x
        if height > max.y:
            width = width * (max.y / height)
            height = max.y

    if min:
        min = Point2D(min)
        assert (min.x > 0 and min.y > 0)
        if width < min.x:
            height = height * (min.x / width)
            width = min.x
        if height < min.y:
            width = width * (min.y / height)
            height = min.y

    return Point2D(width, height)
Ejemplo n.º 4
0
    def __init__(self, posx, posy, game):
        Point2D.__init__(self, 0, 0)
        self.startx = posx
        self.starty = posy
        self.game = game

        self.node = self.createNode(game, posx, posy)
        self.reset()
Ejemplo n.º 5
0
 def __sendFakeTouch(self, cursorID, pos, touchType, mirror=False):
     offset = Point2D(0,0)
     if self.__dualTouch:
         offset = Point2D(40, 0)
     if mirror:
         pos = 2*(self._initialPos)-pos
         offset = -offset
     player.getTestHelper().fakeTouchEvent(cursorID,
             touchType, self.__source, self.__clampPos(pos+offset))
Ejemplo n.º 6
0
    def __init__(self, player, pos):
        Point2D.__init__(self, pos)
        self.player = player
        self.node = g_player.createNode('image',
                {'href':'finger.png', 'size': config.BATPOINT_SIZE})
        avg.ContinuousAnim(self.node, "angle", 0, config.FINGER_ROT_SPEED, False).start()
        player.game.addNode(self.node)
        self.updateNode()

        self.dependants=[]
        self.lines=[]
        self.__cursorID = None
 def chooseVideo(self, event, videoNode):
     if self.bigVideoNode:
         self.removeBigVideo()
     destSize = videoNode.size * 2
     destPos = Point2D(720, 550) - destSize / 2
     absPos = videoNode.getAbsPos(Point2D(0, 0))
     frame = videoNode.getCurFrame()
     self.bigVideoNode = avg.VideoNode(href=videoNode.href,
                                       loop=True,
                                       sensitive=False,
                                       parent=self)
     self.bigVideoNode.play()
     self.bigVideoNode.seekToFrame(frame)
     avg.EaseInOutAnim(self.bigVideoNode, "pos", 1000, absPos, destPos,
                       False, 300, 300).start()
     avg.EaseInOutAnim(self.bigVideoNode, "size", 1000, videoNode.size,
                       destSize, False, 300, 300).start()
Ejemplo n.º 8
0
 def __clearDualtouchState(self):
     if self.__mouseState == self.MOUSE_STATE_DOWN:
         if self.__secondTouch:
             self.__releaseTouch(self.__cursorID+1)
         else:
             self.__sendFakeTouch(self.__cursorID+1, Point2D(0,0),
                     avg.Event.CURSOR_DOWN, mirror=True)
         self.__secondTouch = not(self.__secondTouch)
Ejemplo n.º 9
0
    def testDebugWindowSize(self):
        class DebugwindowApp(TestAppBase):
            testInstance = self

            def init(self):
                self.testInstance.assert_(not player.isFullscreen())
                rootNodeSize = player.getRootNode().size
                self.testInstance.assertEqual(rootNodeSize, TEST_RESOLUTION)

                # windowSize = player.getWindowResolution()
                # self.testInstance.assertEqual(windowSize, Point2D(TEST_RESOLUTION)/2)
                self.requestStop()

        DebugwindowApp.start(resolution=TEST_RESOLUTION,
                             debugWindowSize=Point2D(TEST_RESOLUTION) / 2)
Ejemplo n.º 10
0
 def __releaseTouch(self, cursorID):
     self.__sendFakeTouch(cursorID, Point2D(0, 0), avg.Event.CURSOR_UP)
Ejemplo n.º 11
0
def getOffsetForMovedPivot(oldPivot, newPivot, angle):
    oldPos = Point2D(0,0).getRotated(angle, oldPivot)
    newPos = Point2D(0,0).getRotated(angle, newPivot)
    return oldPos - newPos