Exemplo n.º 1
0
 def queryDimensions():
     res = player.getScreenResolution()
     self.assert_(0 < res.x < 10000 and 0 < res.y < 10000)
     ppmm = player.getPixelsPerMM()
     self.assert_(0 < ppmm < 10000)
     mm = player.getPhysicalScreenDimensions()
     self.assert_(0 < mm.x < 10000 and 0 < mm.y < 10000)
     player.assumePixelsPerMM(ppmm)
     newPPMM = player.getPixelsPerMM()
     self.assertAlmostEqual(newPPMM, ppmm)
     newMM = player.getPhysicalScreenDimensions()
     self.assertEqual(newMM, mm)
Exemplo n.º 2
0
    def testFakeFullscreen(self):
        class FakeFullscreenApp(TestAppBase):
            fakeFullscreen = True

            def init(self):
                player.setTimeout(0, player.stop)

        resolution = player.getScreenResolution()
        if os.name == "nt":
            FakeFullscreenApp.start(resolution=resolution)
        else:
            self.assertException(lambda: FakeFullscreenApp.start(resolution=resolution))
Exemplo n.º 3
0
 def queryDimensions():
     res = player.getScreenResolution()
     self.assert_(res.x > 0 and res.y > 0 and res.x < 10000 and res.y < 10000)
     ppmm = player.getPixelsPerMM()
     self.assert_(ppmm > 0 and ppmm < 10000)
     mm = player.getPhysicalScreenDimensions()
     self.assert_(mm.x > 0 and mm.y > 0 and mm.x < 10000 and mm.y < 10000)
     player.assumePixelsPerMM(ppmm)
     newPPMM = player.getPixelsPerMM()
     self.assertAlmostEqual(newPPMM, ppmm)
     newMM = player.getPhysicalScreenDimensions()
     self.assertEqual(newMM, mm)
Exemplo n.º 4
0
 def testFakeFullscreen(self):
     class FakeFullscreenApp(TestAppBase):
         fakeFullscreen = True
         def init(self):
             player.setTimeout(0, player.stop)
           
     resolution = player.getScreenResolution()
     if os.name == 'nt':
         FakeFullscreenApp.start(resolution=resolution)
     else:
         self.assertRaises(RuntimeError,
                 lambda: FakeFullscreenApp.start(resolution=resolution))
Exemplo n.º 5
0
    def onArgvParsed(self, options, args, parser):
        if len(args) != 1:
            parser.print_help()
            sys.exit(1)

        self.node = avg.VideoNode(href=args[0], accelerated=not(options.disableAccel))
        self.node.pause()

        mediaSize = self.node.getMediaSize()
        size = avg.Point2D(max(mediaSize.x, 320), max(mediaSize.y, 120))
        screenSize = player.getScreenResolution()
        size = avg.Point2D(min(size.x, screenSize.x), min(size.y, screenSize.y-80))
        self.settings.set("app_resolution", "%dx%d" %(size.x, size.y))
Exemplo n.º 6
0
 def testAvgDeploy(self):
     class FullscreenApp(TestAppBase):
         testInstance = self
         def init(self):
             self.testInstance.assert_(player.isFullscreen())
             rootNodeSize = player.getRootNode().size
             self.testInstance.assertEqual(rootNodeSize, resolution)
             self.requestStop()
             
     resolution = player.getScreenResolution()
     os.environ['AVG_DEPLOY'] = '1'
     FullscreenApp.start(resolution=resolution)
     del os.environ['AVG_DEPLOY']
Exemplo n.º 7
0
    def testFakeFullscreen(self):
        class FakeFullscreenApp(TestAppBase):
            fakeFullscreen = True

            def init(self):
                player.setTimeout(0, player.stop)

        resolution = player.getScreenResolution()
        if os.name == 'nt':
            FakeFullscreenApp.start(resolution=resolution)
        else:
            self.assertException(
                lambda: FakeFullscreenApp.start(resolution=resolution))
Exemplo n.º 8
0
    def testAvgDeploy(self):
        class FullscreenApp(TestAppBase):
            testInstance = self

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

        resolution = player.getScreenResolution()
        os.environ['AVG_DEPLOY'] = '1'
        FullscreenApp.start(resolution=resolution)
        del os.environ['AVG_DEPLOY']
Exemplo n.º 9
0
    def onArgvParsed(self, options, args, parser):
        if len(args) != 1:
            parser.print_help()
            sys.exit(1)

        self.node = avg.VideoNode(href=args[0],
                                  accelerated=not (options.disableAccel))
        self.node.pause()

        mediaSize = self.node.getMediaSize()
        size = avg.Point2D(max(mediaSize.x, 320), max(mediaSize.y, 120))
        screenSize = player.getScreenResolution()
        size = avg.Point2D(min(size.x, screenSize.x),
                           min(size.y, screenSize.y - 80))
        self.settings.set("app_resolution", "%dx%d" % (size.x, size.y))
Exemplo n.º 10
0
    def start(cls, *args, **kwargs):
        import optparse

        parser = optparse.OptionParser()
        parser.add_option(
            "-r",
            "--resolution",
            dest="resolution",
            default=None,
            help="set an explicit resolution",
            metavar="WIDTHxHEIGHT",
        )
        parser.add_option(
            "-w", "--window", dest="window", action="store_true", default=False, help="run the game in a window"
        )

        (options, args) = parser.parse_args()

        if options.resolution is not None:
            import re

            m = re.match("^(\d+)x(\d+)$", options.resolution)

            if m is None:
                sys.stderr.write("\n** ERROR: invalid resolution " "specification %s\n\n" % options.resolution)
                parser.print_help()
                sys.exit(1)
            else:
                kwargs["resolution"] = map(int, m.groups())
        elif not "resolution" in kwargs:
            kwargs["resolution"] = player.getScreenResolution()

        if options.window:
            if options.resolution is None:
                sys.stderr.write("\n** ERROR: in window mode the resolution " "must be set\n\n")
                parser.print_help()
                sys.exit(1)
            else:
                if "AVG_DEPLOY" in os.environ:
                    del os.environ["AVG_DEPLOY"]
        else:
            os.environ["AVG_DEPLOY"] = "1"

        avg.logger.info("Setting resolution to: %s" % str(kwargs["resolution"]))

        super(GameApp, cls).start(*args, **kwargs)
Exemplo n.º 11
0
    def start(cls, *args, **kwargs):
        import optparse

        parser = optparse.OptionParser()
        parser.add_option('-r', '--resolution', dest='resolution',
                default=None, help='set an explicit resolution', metavar='WIDTHxHEIGHT')
        parser.add_option('-w', '--window', dest='window', action='store_true',
                default=False, help='run the game in a window')

        (options, args) = parser.parse_args()

        if options.resolution is not None:
            import re

            m = re.match('^(\d+)x(\d+)$', options.resolution)

            if m is None:
                sys.stderr.write('\n** ERROR: invalid resolution '
                        'specification %s\n\n' % options.resolution)
                parser.print_help()
                sys.exit(1)
            else:
                kwargs['resolution'] = map(int, m.groups())
        elif not 'resolution' in kwargs:
            kwargs['resolution'] = player.getScreenResolution()

        if options.window:
            if options.resolution is None:
                sys.stderr.write('\n** ERROR: in window mode the resolution '
                        'must be set\n\n')
                parser.print_help()
                sys.exit(1)
            else:
                if 'AVG_DEPLOY' in os.environ:
                    del os.environ['AVG_DEPLOY']
        else:
            os.environ['AVG_DEPLOY'] = '1'

        global ownStarter
        ownStarter = True
        
        super(GameApp, cls).start(*args, **kwargs)
Exemplo n.º 12
0
            event.contact.subscribe(avg.Contact.CURSOR_UP, self.__onUp)
            self.__rawContactCircle.opacity = 1
            self.__filteredContactCircle.opacity = 1
            self.__filters = [
                    filter.OneEuroFilter(self.__minCutoff,self.__cutoffSlope),
                    filter.OneEuroFilter(self.__minCutoff,self.__cutoffSlope)]
            self.__onFrame = player.subscribe(player.ON_FRAME, self.__moveContact)

    def __onUp(self, event):
        self.__rawContactCircle.opacity = 0
        self.__filteredContactCircle.opacity = 0
        self.__contact = None
        self.__filters = None
        player.unsubscribe(self.__onFrame)

    def __moveContact(self):
        time = player.getFrameTime()
        rawPos = self.__contact.events[-1].pos
        self.__rawContactCircle.pos = rawPos
        filteredPos = avg.Point2D(self.__filters[0].apply(rawPos.x, time),
                self.__filters[1].apply(rawPos.y, time))
        self.__filteredContactCircle.pos = filteredPos

if 'AVG_DEPLOY' in os.environ:
    resolution = player.getScreenResolution() 
else:
    resolution = (800, 600)

JitterFilter.start(resolution=resolution)

Exemplo n.º 13
0
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Current versions can be found at www.libavg.de
#
# Original author of this file is OXullo Interecans <x at brainrapers dot org>

import os
import tempfile
import libavg
from libavg import avg, player
from libavg.app import settings
from libavg.app import keyboardmanager
from libavg.app.settings import Option
import testcase

res = player.getScreenResolution()


class TestApp(libavg.app.App):
    CUSTOM_SETTINGS = {
        'app_resolution': '160x120',
        'app_window_size': '160x120'
    }

    def testRun(self, onFrameHandlersList=[], mainDiv=None, runtimeOptions={}):
        assert type(onFrameHandlersList) == list
        self.__onFrameHandlersList = onFrameHandlersList
        player.subscribe(player.ON_FRAME, self.__onFrame)
        player.setFramerate(10000)
        player.assumePixelsPerMM(1)
        for k, v in self.CUSTOM_SETTINGS.iteritems():