def setP3DFilename(self, p3dFilename, tokens, argv, instanceId, interactiveConsole, p3dOffset=0): """ Called by the browser to specify the p3d file that contains the application itself, along with the web tokens and/or command-line arguments. Once this method has been called, the application is effectively started. """ # One day we will have support for multiple instances within a # Python session. Against that day, we save the instance ID # for this instance. self.instanceId = instanceId self.tokens = tokens self.argv = argv # We build up a token dictionary with care, so that if a given # token appears twice in the token list, we record only the # first value, not the second or later. This is consistent # with the internal behavior of the core API. self.tokenDict = {} for token, keyword in tokens: self.tokenDict.setdefault(token, keyword) # Also store the arguments on sys, for applications that # aren't instance-ready. sys.argv = argv # That means we now know the altHost in effect. self.altHost = self.tokenDict.get('alt_host', None) # Tell the browser that Python is up and running, and ready to # respond to queries. self.notifyRequest('onpythonload') # Now go load the applet. fname = Filename.fromOsSpecific(p3dFilename) vfs = VirtualFileSystem.getGlobalPtr() if not vfs.exists(fname): raise ArgumentError, "No such file: %s" % (p3dFilename) fname.makeAbsolute() mf = Multifile() if p3dOffset == 0: if not mf.openRead(fname): raise ArgumentError, "Not a Panda3D application: %s" % ( p3dFilename) else: if not mf.openRead(fname, p3dOffset): raise ArgumentError, "Not a Panda3D application: %s at offset: %s" % ( p3dFilename, p3dOffset) # Now load the p3dInfo file. self.p3dInfo = None self.p3dPackage = None self.p3dConfig = None self.allowPythonDev = False i = mf.findSubfile('p3d_info.xml') if i >= 0 and hasattr(PandaModules, 'readXmlStream'): stream = mf.openReadSubfile(i) self.p3dInfo = PandaModules.readXmlStream(stream) mf.closeReadSubfile(stream) if self.p3dInfo: self.p3dPackage = self.p3dInfo.FirstChildElement('package') if self.p3dPackage: self.p3dConfig = self.p3dPackage.FirstChildElement('config') xhost = self.p3dPackage.FirstChildElement('host') while xhost: self.__readHostXml(xhost) xhost = xhost.NextSiblingElement('host') if self.p3dConfig: allowPythonDev = self.p3dConfig.Attribute('allow_python_dev') if allowPythonDev: self.allowPythonDev = int(allowPythonDev) guiApp = self.p3dConfig.Attribute('gui_app') if guiApp: self.guiApp = int(guiApp) trueFileIO = self.p3dConfig.Attribute('true_file_io') if trueFileIO: self.trueFileIO = int(trueFileIO) # The interactiveConsole flag can only be set true if the # application has allow_python_dev set. if not self.allowPythonDev and interactiveConsole: raise StandardError, "Impossible, interactive_console set without allow_python_dev." self.interactiveConsole = interactiveConsole if self.allowPythonDev: # Set the fps text to remind the user that # allow_python_dev is enabled. ConfigVariableString('frame-rate-meter-text-pattern').setValue( 'allow_python_dev %0.1f fps') if self.guiApp: initAppForGui() self.initPackedAppEnvironment() # Mount the Multifile under self.multifileRoot. vfs.mount(mf, self.multifileRoot, vfs.MFReadOnly) VFSImporter.reloadSharedPackages() self.loadMultifilePrcFiles(mf, self.multifileRoot) self.gotP3DFilename = True # Send this call to the main thread; don't call it directly. messenger.send('AppRunner_startIfReady', taskChain='default')
def _set_title(self, title): from pandac.PandaModules import ConfigVariableString mygameserver = ConfigVariableString("window-title","Panda") mygameserver.setValue(title)
from panda3d.core import loadPrcFile loadPrcFile("config.prc") from pandac.PandaModules import ConfigVariableString import os import Map GAME = ConfigVariableString('game', 'fft').getValue() # Return map list to a client def execute(server, iterator, source): server.playersinlobby.remove(source) mapnames = map(lambda m: m.split('.')[0], os.listdir(GAME + '/maps')) maps = [] for mapname in mapnames: mp = Map.load(mapname) del mp['tiles'] maps.append(mp) server.send.MAP_LIST(maps, source)
# InfinityServer # Release Version 0.1 ## TODO FOR TEWTOW SERVER ## * CHECK FOR SERVER VERSION DIFERENCES BETWEEN CLIENT & SERVER (REFUSE/DISCONNECT THE CLIENT (OR MAYBE 1337 HAX0R IF SO.)!!! (DONE!) ## * CHECK FOR DCFILE DIFFERENCES AND REFUSE TO LET CLIENT CONNECT IF SO. ## * CHECK FOR ANY SERVER-SIDED VULNS FROM OG TOONTOWN (NICE GOING DISNEY) ## * FINISH DATAGRAMS/MSGTYPES! ## * DATABASE (JSON? MONGODB?) IMPLEMENTATION. (PLAY TOKEN, ETC) from pandac.PandaModules import ConfigVariableString ConfigVariableString('window-type', 'none').setValue('none') import ctypes ctypes.windll.kernel32.SetConsoleTitleA("Toontown/Tewtow Server Emulator by Infinity/Average") from pandac.PandaModules import * from direct.distributed.MsgTypes import * from direct.showbase.DirectObject import DirectObject from direct.task import Task from direct.directbase import DirectStart from direct.distributed.ServerRepository import ServerRepository from direct.distributed.ClientRepository import ClientRepository from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagramIterator import PyDatagramIterator from datetime import datetime
from math import isclose from pandac.PandaModules import ConfigVariableString # pylint: disable=no-name-in-module from adam.visualization.panda3d_interface import SituationVisualizer from adam.visualization.utils import Shape # sets the rendering engine to not run, as it can't be handled by CI system ConfigVariableString("window-type", "none").setValue("none") # This should be the only test to actually instantiate panda3d def test_basic_3d_scene() -> None: app = SituationVisualizer() model_scales = app.get_model_scales() # test grabbing the scale of a model (cube should be 1x1x1) assert isclose(model_scales[Shape.SQUARE.name][0], 1, rel_tol=0.05) assert isclose(model_scales[Shape.SQUARE.name][1], 1, rel_tol=0.05) assert isclose(model_scales[Shape.SQUARE.name][2], 1, rel_tol=0.05) app.add_model(Shape.SQUARE, name="Square0", lookup_name="Square0", position=(1, 2, 2)) app.add_model(Shape.RECTANGULAR, name="rect0", lookup_name="rect0", position=(2, 2, 2)) try: app.add_model(Shape.IRREGULAR,
import sys from panda3d.core import loadPrcFile from pandac.PandaModules import ConfigVariableString loadPrcFile("../config.prc") GAME = ConfigVariableString('game', 'fft').getValue() loadPrcFile(GAME + "/config.prc") IP = ConfigVariableString('ip', '127.0.0.1').getValue() PORT = int(ConfigVariableString('port', '3001').getValue()) CROSS_BTN = ConfigVariableString('cross-btn', '0').getValue() CIRCLE_BTN = ConfigVariableString('circle-btn', '3').getValue() TRIANGLE_BTN = ConfigVariableString('triangle-btn', '2').getValue() SQUARE_BTN = ConfigVariableString('square-btn', '1').getValue() L1_BTN = ConfigVariableString('l1-btn', '4').getValue() L2_BTN = ConfigVariableString('l2-btn', '7').getValue() R1_BTN = ConfigVariableString('r1-btn', '6').getValue() R2_BTN = ConfigVariableString('r2-btn', '9').getValue() START_BTN = ConfigVariableString('start-btn', '8').getValue() SELECT_BTN = ConfigVariableString('select-btn', '5').getValue() SPRITE_SCALE = float(ConfigVariableString('sprite-scale', '2').getValue()) THEME = ConfigVariableString('theme', 'default').getValue()