Exemplo n.º 1
0
    def checkPandaVersionOutOfDate(self, minDay, minMonth, minYear):
        """ Checks if the panda build is out of date, so users don't complain
        about stuff not working, because they simply didn't update """

        built = PandaSystem.getBuildDate()
        formated = datetime.datetime.strptime(built, "%b %d %Y %H:%M:%S")
        required = datetime.datetime(minYear, minMonth, minDay, 12, 00)

        if formated < required:
            print "ERROR: Your Panda3D Build is out of date. Update to the latest"
            print "git build in order to use the pipeline: "
            print "https://github.com/panda3d/panda3d"
            sys.exit(0)

        # Check version
        versionMinMinor = 9
        versionMinMajor = 1

        versionMismatch = False
        if PandaSystem.getMajorVersion() < versionMinMajor:
            versionMismatch = True
        elif PandaSystem.getMinorVersion() < versionMinMinor:
            versionMismatch = True

        if versionMismatch:
            print "ERROR: Your current panda build (", PandaSystem.getVersionString(), ") is"
            print "not supported! The minimum required build is", str(versionMinMajor) + "." + str(versionMinMinor) + ".0"
            sys.exit(0)
Exemplo n.º 2
0
    def checkPandaVersionOutOfDate(self, minDay, minMonth, minYear):
        """ Checks if the panda build is out of date, so users don't complain
        about stuff not working, because they simply didn't update """

        built = PandaSystem.getBuildDate()
        formated = datetime.datetime.strptime(built, "%b %d %Y %H:%M:%S")
        required = datetime.datetime(minYear, minMonth, minDay, 00, 00)

        if formated < required:
            print "ERROR: Your Panda3D Build is out of date. Update to the latest"
            print "git build in order to use the pipeline: "
            print "https://github.com/panda3d/panda3d"
            sys.exit(0)

        # Check version
        versionMinMinor = 9
        versionMinMajor = 1

        versionMismatch = False
        if PandaSystem.getMajorVersion() < versionMinMajor:
            versionMismatch = True
        elif PandaSystem.getMinorVersion() < versionMinMinor:
            versionMismatch = True

        if versionMismatch:
            print "ERROR: Your current panda build (", PandaSystem.getVersionString(
            ), ") is"
            print "not supported! The minimum required build is", str(
                versionMinMajor) + "." + str(versionMinMinor) + ".0"
            sys.exit(0)
Exemplo n.º 3
0
    def mouseTask(self, task):
        if self.reset:  # It seems that reseting the mouse pointer sometimes take a frame, threfore after a reset ignore the mouse for the next frame. Bad, yes, but better than a flick.
            self.reset = False
            return task.cont

        md = base.win.getPointer(0)
        ox = md.getX() - self.originX
        oy = md.getY() - self.originY
        #print ox,oy,md.getX(),md.getY(),self.originX,self.originY
        self.originX = md.getX()
        self.originY = md.getY()

        # The if statement is not necessary - it exists so if you start the program with the mouse cursor outside the window and then move it into the window the camera will not jerk. It of course could prevent really fast rotation in game.
        if abs(ox) < base.win.getXSize() // 3 and abs(
                oy) < base.win.getYSize() // 3:
            if self.xNode: self.xNode.setH(self.xNode.getH() - ox * self.speed)
            if self.yNode:
                self.yNode.setP(
                    min(max(self.yNode.getP() - oy * self.speed, self.minY),
                        self.maxY))

        xoob = self.originX < base.win.getXSize() // 4 or self.originX > (
            base.win.getXSize() * 3) // 4
        yoob = self.originY < base.win.getYSize() // 4 or self.originY > (
            base.win.getYSize() * 3) // 4

        # OSX had relative mouse support all along, Windows never had, and 1.7.0 added it for Linux.
        if (xoob or yoob) and platform != "darwin" and (
                platform.startswith("win")
                or PandaSystem.getMinorVersion() < 7):
            cx = base.win.getXSize() // 2
            cy = base.win.getYSize() // 2
            if base.win.movePointer(0, cx, cy):
                self.originX = cx
                self.originY = cy
                self.reset = True
                #print 'reset'

        return task.cont
Exemplo n.º 4
0
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.

from __future__ import print_function
__all__ = ['PopupMenu', 'DropDownMenu']

from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import DirectButton, DirectFrame, DGG, OnscreenText
from direct.task import Task

from panda3d.core import PandaSystem, loadPrcFileData
from panda3d.core import NodePath, TextNode, PlaneNode, LineSegs, Texture, PNMImage, CardMaker
from panda3d.core import Vec4, Point3, Vec3, Plane, Point2
from panda3d.core import Triangulator, GeomVertexData, GeomVertexFormat, GeomVertexWriter, Geom, GeomNode, GeomTriangles

SEQUENCE_TYPES = (tuple, list)
atLeast16 = PandaSystem.getMajorVersion() * 10 + PandaSystem.getMinorVersion(
) >= 16
asList = lambda nc: nc if atLeast16 else nc.asList()


class DropDownMenu(DirectObject):
    ALeft = 0
    ACenter = 1
    ARight = 2
    ENone = 0
    EFade = 1
    ESlide = 2
    EStretch = 3
    PLeft = 0
    PRight = 1
    PBottom = 2
    PTop = 3