Example #1
0
 def findNewsDir(self):
     if self.NewsOverHttp:
         return self.NewsStageDir
     else:
         searchPath = DSearchPath()
         if AppRunnerGlobal.appRunner:
             searchPath.appendDirectory(
                 Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news'))
         else:
             basePath = os.path.expandvars('$TTMODELS') or './ttmodels'
             searchPath.appendDirectory(
                 Filename.fromOsSpecific(basePath + '/built/' +
                                         self.NewsBaseDir))
             searchPath.appendDirectory(Filename(self.NewsBaseDir))
         pfile = Filename(self.NewsIndexFilename)
         found = vfs.resolveFilename(pfile, searchPath)
         if not found:
             self.notify.warning('findNewsDir - no path: %s' %
                                 self.NewsIndexFilename)
             self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile %
                                  self.NewsIndexFilename)
             return None
         self.notify.debug('found index file %s' % pfile)
         realDir = pfile.getDirname()
         return realDir
Example #2
0
def makeBundle(startDir):
    fstartDir = Filename.fromOsSpecific(startDir)

    # Search for panda3d_mac along $PATH.
    path = DSearchPath()
    if 'PATH' in os.environ:
        path.appendPath(os.environ['PATH'])
    path.appendPath(os.defpath)
    panda3d_mac = path.findFile('panda3d_mac')
    if not panda3d_mac:
        raise Exception("Couldn't find panda3d_mac on path.")

    # Construct a search path to look for the images.
    search = DSearchPath()

    # First on the path: an explicit $PLUGIN_IMAGES env var.
    if ExecutionEnvironment.hasEnvironmentVariable('PLUGIN_IMAGES'):
        search.appendDirectory(Filename.expandFrom('$PLUGIN_IMAGES'))

    # Next on the path: the models/plugin_images directory within the
    # current directory.
    search.appendDirectory('models/plugin_images')

    # Finally on the path: models/plugin_images within the model
    # search path.
    for dir in getModelPath().getDirectories():
        search.appendDirectory(Filename(dir, 'plugin_images'))

    # Now find the icon file on the above search path.
    icons = search.findFile('panda3d.icns')
    if not icons:
        raise Exception("Couldn't find panda3d.icns on model-path.")

    # Generate the bundle directory structure
    rootFilename = Filename(fstartDir)
    bundleFilename = Filename(rootFilename, 'Panda3D.app')
    if os.path.exists(bundleFilename.toOsSpecific()):
        shutil.rmtree(bundleFilename.toOsSpecific())

    plistFilename = Filename(bundleFilename, 'Contents/Info.plist')
    plistFilename.makeDir()
    exeFilename = Filename(bundleFilename, 'Contents/MacOS/panda3d_mac')
    exeFilename.makeDir()
    iconFilename = Filename(bundleFilename, 'Contents/Resources/panda3d.icns')
    iconFilename.makeDir()

    # Copy in Info.plist, the icon file, and the compiled executable.
    shutil.copyfile(
        Filename(fstartDir, "panda3d_mac.plist").toOsSpecific(),
        plistFilename.toOsSpecific())
    shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific())
    print('%s %s' % (panda3d_mac, exeFilename))
    shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific())
    os.chmod(exeFilename.toOsSpecific(), 0o755)

    # All done!
    bundleFilename.touch()
    print(bundleFilename.toOsSpecific())
Example #3
0
def makeBundle(startDir):
    fstartDir = Filename.fromOsSpecific(startDir)

    # Search for panda3d_mac along $PATH.
    path = DSearchPath()
    if 'PATH' in os.environ:
        path.appendPath(os.environ['PATH'])
    path.appendPath(os.defpath)
    panda3d_mac = path.findFile('panda3d_mac')
    if not panda3d_mac:
        raise Exception("Couldn't find panda3d_mac on path.")

    # Construct a search path to look for the images.
    search = DSearchPath()

    # First on the path: an explicit $PLUGIN_IMAGES env var.
    if ExecutionEnvironment.hasEnvironmentVariable('PLUGIN_IMAGES'):
        search.appendDirectory(Filename.expandFrom('$PLUGIN_IMAGES'))

    # Next on the path: the models/plugin_images directory within the
    # current directory.
    search.appendDirectory('models/plugin_images')

    # Finally on the path: models/plugin_images within the model
    # search path.
    for dir in getModelPath().getDirectories():
        search.appendDirectory(Filename(dir, 'plugin_images'))

    # Now find the icon file on the above search path.
    icons = search.findFile('panda3d.icns')
    if not icons:
        raise Exception("Couldn't find panda3d.icns on model-path.")

    # Generate the bundle directory structure
    rootFilename = Filename(fstartDir)
    bundleFilename = Filename(rootFilename, 'Panda3D.app')
    if os.path.exists(bundleFilename.toOsSpecific()):
        shutil.rmtree(bundleFilename.toOsSpecific())

    plistFilename = Filename(bundleFilename, 'Contents/Info.plist')
    plistFilename.makeDir()
    exeFilename = Filename(bundleFilename, 'Contents/MacOS/panda3d_mac')
    exeFilename.makeDir()
    iconFilename = Filename(bundleFilename, 'Contents/Resources/panda3d.icns')
    iconFilename.makeDir()

    # Copy in Info.plist, the icon file, and the compiled executable.
    shutil.copyfile(Filename(fstartDir, "panda3d_mac.plist").toOsSpecific(), plistFilename.toOsSpecific())
    shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific())
    print('%s %s' % (panda3d_mac, exeFilename))
    shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific())
    os.chmod(exeFilename.toOsSpecific(), 0o755)

    # All done!
    bundleFilename.touch()
    print(bundleFilename.toOsSpecific())
def fileSearch(file, libDir = None, exts = []):
    """
    Searches for given file in path
    """
    f1 = Filename.expandFrom(file)
    if f1.exists():
        return f1
    for e in exts:
        f1.setExtension(e)
        if f1.exists():
            return f1
    if libDir is not None:
        f2 = Filename.expandFrom(pandaPath + "/" + libDir + "/" + file)
        if f2.exists():
            return f2
        for e in exts:
            f2.setExtension(e)
            if f2.exists():
                return f2
    return None
Example #5
0
def fileSearch(file, libDir=None, exts=[]):
    """
    Searches for given file in path
    """
    f1 = Filename.expandFrom(file)
    if f1.exists():
        return f1
    for e in exts:
        f1.setExtension(e)
        if f1.exists():
            return f1
    if libDir is not None:
        f2 = Filename.expandFrom(pandaPath + "/" + libDir + "/" + file)
        if f2.exists():
            return f2
        for e in exts:
            f2.setExtension(e)
            if f2.exists():
                return f2
    return None
Example #6
0
    def __init__(self, filePath, fileName):
        self.__filePath = filePath
        self.__fileName = fileName

        vfs = VirtualFileSystem.getGlobalPtr()
        filename = Filename(fileName)
        searchPath = DSearchPath()
        if __debug__:
            searchPath.appendDirectory(Filename.expandFrom('resources/%s' % filePath))
        else:
            searchPath.appendDirectory(Filename.expandFrom(filePath))

        found = vfs.resolveFilename(filename, searchPath)
        if not found:
            raise TileFileIOException('Unable to locate tiled file \"%s\"; File not found on %s' % (fileName, searchPath))

        self.__fileData = json.loads(vfs.readFile(filename, 1))
        self.__verifyData()

        self.__layers = self.__fileData['layers']
Example #7
0
def cogExists(filePrefix):
    searchPath = DSearchPath()
    if AppRunnerGlobal.appRunner:
        searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5'))
    else:
        basePath = os.path.expandvars('$TTMODELS') or './ttmodels'
        searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/phase_3.5'))
    filePrefix = filePrefix.strip('/')
    pfile = Filename(filePrefix)
    found = vfs.resolveFilename(pfile, searchPath)
    if not found:
        return False
    return True
def fileSearch(file, libDir=None, exts=[]):

    f1 = Filename.expandFrom(file)
    if f1.exists():
        #       print "Local file"
        return f1

    for e in exts:
        f1.setExtension(e)
        if f1.exists():
            #           print "Extension: " + e
            return f1
    if libDir is not None:
        f2 = Filename.expandFrom(g.pandaPath + "/" + libDir + "/" + file)
        #       print "Searching library"
        if f2.exists():
            return f2
        for e in exts:
            f2.setExtension(e)
            if f2.exists():
                return f2
    return None
def fileSearch(file, libDir = None, exts = []):

    f1 = Filename.expandFrom(file)
    if f1.exists():
 #       print "Local file"
        return f1

    for e in exts:
        f1.setExtension(e)
        if f1.exists():
 #           print "Extension: " + e
            return f1
    if libDir is not None:
        f2 = Filename.expandFrom(g.pandaPath + "/" + libDir + "/" + file)
 #       print "Searching library"
        if f2.exists():
            return f2
        for e in exts:
            f2.setExtension(e)
            if f2.exists():
                return f2
    return None
Example #10
0
    def __loadCredits(self):
        self.creditsParent = NodePath('credits-parent')
        self.creditsParent.reparentTo(base.a2dTopRight)
        self.creditsParent.setPos(-1.2, 0, -0.75)

        vfs = VirtualFileSystem.getGlobalPtr()
        filename = Filename('credits.txt')
        searchPath = DSearchPath()
        if __debug__:
            searchPath.appendDirectory(Filename.expandFrom('resources/etc'))
        else:
            searchPath.appendDirectory(Filename.expandFrom('etc'))

        found = vfs.resolveFilename(filename, searchPath)
        if not found:
            self.notify.warning('Unable to load credits; credits.txt not found on %s' % searchPath)
            return

        self.creditsData = vfs.readFile(filename, 1).split('\n')
        self.creditsText = []
        self.currentCreditIndex = 0

        cyAxis = 0
        firstPass = True
        for i in range(0, len(self.creditsData)):
            if i % 5 == 0 and i >= 5:
                firstPass = False
                cyAxis = 0
            text = TextNode('credits-node-%s' % i)
            text.setText(self.creditsData[i])
            self.creditsText.append(text)
            if not firstPass:
                text.setTextColor(255, 255, 255, 0)
            textNodePath = self.creditsParent.attachNewNode(text)
            textNodePath.setScale(0.07)
            textNodePath.setPos(0, 0, cyAxis)
            cyAxis -= 0.1

        taskMgr.doMethodLater(5, self.__processCreditsTask, 'process-credits-task')
Example #11
0
    def __init__(self, file, loopCount = 1, volume = 0.5):

        self.filePath = findSound(file)
        self.foundSound = self.filePath is not None
        if self.foundSound:
            self.type = soundType
            self.volume = volume
            self.loopCount = loopCount
            # there's something strange here wuth the filename representation -
            # only expandFrom seems to give file names usable by loadSfx
            fn = self.filePath.toOsSpecific()
            fn1 = str(Filename.expandFrom(fn))
            self.sound = loader.loadSfx(fn1)
            self.sound.setVolume(self.volume)
        else:
            print("Sound " + file + " not found")
Example #12
0
 def findNewsDir(self):
     if self.NewsOverHttp:
         return self.NewsStageDir
     searchPath = DSearchPath()
     if AppRunnerGlobal.appRunner:
         searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news'))
     else:
         basePath = os.path.expandvars('$TTMODELS') or './ttmodels'
         searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir))
         searchPath.appendDirectory(Filename(self.NewsBaseDir))
     pfile = Filename(self.NewsIndexFilename)
     found = vfs.resolveFilename(pfile, searchPath)
     if not found:
         self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename)
         self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename)
         return None
     self.notify.debug('found index file %s' % pfile)
     realDir = pfile.getDirname()
     return realDir
Example #13
0
from panda3d.core import Filename
import os
from tkinter import *
from tkinter.filedialog import *
from direct.directnotify import DirectNotifyGlobal
from .EditorUtil import *
from .LevelStyleManager import *

dnaDirectory = Filename.expandFrom(userfiles)


class DNASerializer:
    notify = DirectNotifyGlobal.directNotify.newCategory('LevelEditor')
    outputFile = None
    # Local AutoSaver variables
    autoSaverMgrRunning = False
    autoSaveCount = 0

    # STYLE/DNA FILE FUNCTIONS
    @staticmethod
    def loadSpecifiedDNAFile():
        path = dnaDirectory.toOsSpecific()
        if not os.path.isdir(path):
            print('LevelEditor Warning: Invalid default DNA directory!')
            print('Using current directory')
            path = '.'
        dnaFilename = askopenfilename(defaultextension='.dna',
                                      filetypes=(('DNA Files', '*.dna'),
                                                 ('All files', '*')),
                                      initialdir=path,
                                      title='Load DNA File',
Example #14
0
from options import options

# If we only need to print version, do this first and leave everything else
# untouched.
if options.print_version:
    try:
        f = Filename(EE.expandString("$MAIN_DIR/VERSION")).toOsSpecific()
        print open(f).read()
    except IOError:
        print "Version unknown. Can't find the VERSION file."
    sys.exit()

from pandac.PandaModules import loadPrcFile
from pandac.PandaModules import Filename
# Config file should be loaded as soon as possible.
loadPrcFile(Filename.expandFrom("$MAIN_DIR/etc/azure.prc"))
from direct.showbase.ShowBase import ShowBase

from core import Core


class Azure(ShowBase):
    def __init__(self):
        """Program entry point."""
        # TODO(Nemesis#13): rewrite ShowBase to not use globals.

        # This basically sets up our rendering node-tree, some builtins and
        # the master loop (which iterates each frame).
        ShowBase.__init__(self)

        # Turn off Panda3D's standard camera handling.