def loadFGDFiles(self): """Reads the .fgd files specified in the config file""" self.fgd = Fgd() numVals = LEConfig.fgd_files.getNumUniqueValues() if numVals == 0: QtWidgets.QMessageBox.critical( None, LEGlobals.AppName, "No FGD files specified in local config!", QtWidgets.QMessageBox.Ok) sys.exit(1) vfs = VirtualFileSystem.getGlobalPtr() searchPath = getModelPath().getValue() for i in range(numVals): fgdFilename = LEConfig.fgd_files.getUniqueValue(i) fgdFilename = ExecutionEnvironment.expandString(fgdFilename) fgdFilename = Filename(fgdFilename) vfs.resolveFilename(fgdFilename, searchPath) fgd = FgdParse(fgdFilename.toOsSpecific()) self.fgd.add_include(fgd)
from panda3d.core import CardMaker , NodePath , ExecutionEnvironment from direct.interval.IntervalGlobal import Sequence from panda3d.core import Point3 from random import random , uniform ,seed MAIN_DIR = ExecutionEnvironment.expandString("$MAIN_DIR") class MenuBackground(): def getNP(self): return self.menuNP def _addCard(self,texture): tex = loader.loadTexture(MAIN_DIR+"/../assets/models/bamboo/"+texture) cm = CardMaker('card') ratio = float(tex.getXSize())/tex.getYSize() cm.setFrame(-0.5*ratio,0.5*ratio,-0.5,0.5) card = self.menuNP.attachNewNode(cm.generate()) card.setTexture(tex) return card def __init__(self): seed(1236) self.menuNP = NodePath("menunp") background = self._addCard('bamboo-menu-layer-4.jpg') background.setY( 10) background.setScale(6) for i in range(20): bamboo3 = self._addCard('bamboo-menu-layer-3.png')
class ControlState(DirectObject): """Specific control state classes should inherit from this.""" conf_parser = SafeConfigParser() f = Filename(EE.expandString("$MAIN_DIR/etc/keybindings.ini")) conf_parser.read(f.toOsSpecific()) @classmethod def reloadKeybindings(cls, filenames="etc/keybindings.ini"): """Read the keybindings file again. Existing instances won't update until you call loadKeybindings() on them.""" cls.conf_parser.read(filenames) def __init__(self): self.name = self.__class__.__name__ self.paused = False self.active = False self.keymap = {} self.functionmap = {} self.requested_actions = set() def __repr__(self): t = "ControlState: " + self.name if self.paused: t += " (paused)" if not self.active: t += " (inactive)" t += "\nlistens to the following events:\n" + self.getAllAccepting() t += "\nkeymap:\n" + self.keymap t += "\nfunctionmap:\n" + self.functionmap t += "\nrequested actions:\n" + self.requested_actions t += "\n" return t def __str__(self): return self.name def loadKeybindings(self): """Overrides the hardcoded keymap with those found in the keybindings file (or owerwrites previously loaded ones). Only defined actions are overwritten - no extra actions are added from the keybindings file. """ try: keys_from_file = ControlState.conf_parser.items(self.name) for a in self.keymap: for action, key in keys_from_file: if a == action: for k in map(str.strip, key.split(',')): self.keymap[a] = k except NoSectionError: #notify.warning("".join("Keybindings for section {0} not found. ", # "Using built-in bindings").format(self.name)) pass def activate(self): if self.active is True: return False #notify.info("Activating %s" % self.name) def assignKey(key, action): self.accept(key, self.requested_actions.add, [action]) self.accept(key + "-up", self.requested_actions.discard, [action]) if action in self.functionmap: self.accept(key, self.functionmap[action]) for action, key in self.keymap.items(): if isinstance(key, basestring): assignKey(key, action) elif isinstance(key, list): for k in key: assignKey(k, action) self.loadKeybindings() for task in self.tasks: if callable(task): self.addTask(task, task.__name__, taskChain="world") else: self.addTask(*task, taskChain="world") self.active = True #ControlState.active_states.append(self) def deactivate(self): if self.active is False: return False #notify.info("Deactivating %s" % self.name) self.ignoreAll() self.requested_actions.clear() #for task in self.tasks: # self.removeTask(task) #self.removeAllTasks() self.active = False
try: import panda3d except ImportError: print "It seems you haven't got Panda3D installed properly." sys.exit(1) from panda3d.core import ExecutionEnvironment as EE from panda3d.core import Filename 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):
options and starts the core finite state machine, followed by Panda's task manager.""" import sys import os from panda3d.core import ExecutionEnvironment as EE from panda3d.core import Filename from options import options # If we only need to print version, do this first and leave everything else # untouched. if options.print_version: try: print open(EE.expandString("$MAIN_DIR/VERSION")).read() except IOError: print "Version unknown. Can't find the VERSION file." sys.exit() try: from pandac.PandaModules import loadPrcFile from pandac.PandaModules import Filename except ImportError: print "It seems you haven't got Panda3D installed properly." sys.exit(1) # Config file should be loaded as soon as possible. # TODO(Nemesis#13): this must get smarter loadPrcFile(EE.expandString("$MAIN_DIR/etc/azure.prc")) from direct.showbase.ShowBase import ShowBase