コード例 #1
0
    def setupRocketConsole(self):
        """
        Place a new rocket window onto a texture
        bound to the front of the monitor.
        """
        self.win.setClearColor(Vec4(0.5, 0.5, 0.8, 1))

        faceplate = self.monitorNP.find("**/Faceplate")
        assert faceplate

        mybuffer = self.win.makeTextureBuffer("Console Buffer", 1024, 512)
        tex = mybuffer.getTexture()
        tex.setMagfilter(Texture.FTLinear)
        tex.setMinfilter(Texture.FTLinear)

        faceplate.setTexture(tex, 1)

        self.rocketConsole = RocketRegion.make('console', mybuffer)
        self.rocketConsole.setInputHandler(self.inputHandler)

        self.consoleContext = self.rocketConsole.getContext()
        self.console = console.Console(self, self.consoleContext, 40, 13, self.handleCommand)

        self.console.addLine("Panda DOS")
        self.console.addLine("type 'help'")
        self.console.addLine("")

        self.console.allowEditing(True)
コード例 #2
0
ファイル: mainmenu.py プロジェクト: fcostin/gravbot
    def __init__(self, app):
        GameScreen.__init__(self, app)

        LoadFontFace("menus/Delicious-Roman.otf")

        self.region = RocketRegion.make('pandaRocket', self.app.win)
        self.region.setActive(1)
        context = self.region.getContext()

        self.menu = context.LoadDocument('menus/main_menu.rml')
        self.menu.hook = self
コード例 #3
0
ファイル: alem.py プロジェクト: michaeltchapman/alem
    def __init__(self):

        ShowBase.__init__(self)

        base.setFrameRateMeter(True)

        set_app(self)

        app = self

        # Rocket Gui
        LoadFontFace("gui/Raleway.otf")
        self.region = RocketRegion.make('pandaRocket', app.win)
        self.region.setActive(1)
        self.context = self.region.getContext()
        self.hud = self.context.LoadDocument('gui/hud.rml')
        ih = RocketInputHandler()
        app.mouseWatcher.attachNewNode(ih)
        self.region.setInputHandler(ih)
        self.hud.Show()

        self.cTrav = CollisionTraverser('coltrav')
        #self.cTrav.showCollisions(self.render)
        self.ai_world = AIWorld(render)

        self.enableParticles()

        self.scene = []
        self.player = Player(self)
        self.scene.append(self.player)

        self.backgrounds = self.gen_background()

        self.enemy_manager = EnemyManager(self)
        self.enemies = self.gen_enemies(self.scene)

        self.bullet_manager = BulletManager(self)
        self.bullet_count = 0

        self.taskMgr.add(self.update, "update")

        self.mouse_pos = Point2(0,0)

        self.set_keys()

        self.music = self.loader.loadSfx('sounds/onegameamonthjan.ogg')
        self.music.setVolume(0.2)
        self.music.play()

        self.item_manager = ItemManager(self)

        self.tree_manager = TreeManager(self)
        self.trees = self.gen_trees()
コード例 #4
0
ファイル: Globals.py プロジェクト: czorn/Modifire
def LoadRocket():
    global ROCKET_REGION, ROCKET_CONTEXT
    LoadFontFace("Assets/libRocket/Fonts/Delicious-Roman.otf")
    
    ROCKET_REGION = RocketRegion.make('pandaRocket', base.win)
    ROCKET_REGION.setActive(1)
    ROCKET_REGION.setSort(200)
    ROCKET_CONTEXT = ROCKET_REGION.getContext()
    
    ih = RocketInputHandler()
    base.mouseWatcher.attachNewNode(ih)
    ROCKET_REGION.setInputHandler(ih)
    print 'made region'
コード例 #5
0
ファイル: libRocket.py プロジェクト: mhcrnl/panda_examples
    def __init__(self):
        # Basics
        ShowBase.__init__(self)
        base.disableMouse()
        self.accept("escape", sys.exit)

        # Loading a font
        LoadFontFace("./gnu-freefont_freesans/FreeSans.ttf")

        # Creating all necessary context
        self.region = RocketRegion.make('pandaRocket', base.win)
        self.region.setActive(1)
        self.region.initDebugger()
        self.region.setDebuggerVisible(False)
        self.context = self.region.getContext()

        # Loading documents
        self.documents = {}
        self.documents['main'] = self.context.LoadDocument('./demo.rml')
        # .Show() to display document, .Hide() to hide.
        self.documents['main'].Show()

        self.elementEffects = []

        # setup the mouse
        self.inputHandler = RocketInputHandler()
        base.mouseWatcher.attachNewNode(self.inputHandler)
        self.region.setInputHandler(self.inputHandler)

        # taskMgr.doMethodLater(5, self.loadingFinished, 'HUD Loading Finished')

        # Setup the messages we accept.
        #self.accept('update', self.updateMessage)

        def update(self, dt):
            BaseDirectObject.update(self, dt)
            self.updateElementEffects(dt)

        def destroy(self):
            BaseDirectObject.destroy(self)

            for key in self.documents:
                self.documents[key].Close()
                self.context.UnloadDocument(self.documents[key])
            del self.documents

            del self.context
            base.win.removeDisplayRegion(self.region)
            del self.region
コード例 #6
0
    def __init__(self):
        # Basics
        ShowBase.__init__(self)
        base.disableMouse()
        self.accept("escape", sys.exit)

        # Loading a font
        LoadFontFace("./gnu-freefont_freesans/FreeSans.ttf")

        # Creating all necessary context
        self.region = RocketRegion.make('pandaRocket', base.win)
        self.region.setActive(1)
        self.region.initDebugger()
        self.region.setDebuggerVisible(False)
        self.context = self.region.getContext()

        # Loading documents
        self.documents = {}
        self.documents['main'] = self.context.LoadDocument('./demo.rml')
        # .Show() to display document, .Hide() to hide.
        self.documents['main'].Show()

        self.elementEffects = []

        # setup the mouse
        self.inputHandler = RocketInputHandler()
        base.mouseWatcher.attachNewNode(self.inputHandler)
        self.region.setInputHandler(self.inputHandler)

        # taskMgr.doMethodLater(5, self.loadingFinished, 'HUD Loading Finished')

        # Setup the messages we accept.
        #self.accept('update', self.updateMessage)

	def update(self, dt):
		BaseDirectObject.update(self, dt)
		self.updateElementEffects(dt)
		
	def destroy(self):
		BaseDirectObject.destroy(self)
		 
		for key in self.documents:
			self.documents[key].Close()
			self.context.UnloadDocument(self.documents[key])
		del self.documents
		
		del self.context
		base.win.removeDisplayRegion(self.region)
		del self.region
コード例 #7
0
    def openLoadingDialog(self):
        self.userConfirmed = False

        self.windowRocketRegion = RocketRegion.make('pandaRocket', self.win)
        self.windowRocketRegion.setActive(1)

        self.windowRocketRegion.setInputHandler(self.inputHandler)

        self.windowContext = self.windowRocketRegion.getContext()

        self.loadingDocument = self.windowContext.LoadDocument("loading.rml")
        if not self.loadingDocument:
            raise AssertionError("did not find loading.rml")

        self.loadingDots = 0
        el = self.loadingDocument.GetElementById('loadingLabel')
        self.loadingText = el.first_child
        self.stopLoadingTime = globalClock.getFrameTime() + 3
        self.loadingTask = self.taskMgr.add(self.cycleLoading, 'doc changer')


        # note: you may encounter errors like 'KeyError: 'document'"
        # when invoking events using methods from your own scripts with this
        # obvious code:
        #
        # self.loadingDocument.AddEventListener('aboutToClose',
        #                                       self.onLoadingDialogDismissed, True)
        #
        # A workaround is to define callback methods in standalone Python
        # files with event, self, and document defined to None.
        #
        # see https://www.panda3d.org/forums/viewtopic.php?f=4&t=16412
        #

        # Or, use this indirection technique to work around the problem,
        # by publishing the app into the context, then accessing it through
        # the document's context...

        self.windowContext.app = self
        self.loadingDocument.AddEventListener('aboutToClose',
                                              'document.context.app.handleAboutToClose()', True)

        self.loadingDocument.Show()
コード例 #8
0
ファイル: TestLibRocket.py プロジェクト: czorn/Modifire
from direct.directbase import DirectStart

from pandac.PandaModules import loadPrcFileData
loadPrcFileData('', 'sync-video 0')

#from inventory.BlockInventoryDataSource import BlockInventoryDataSource
#from inventory.BlockInventoryDataFormatter import BlockInventoryDataFormatter
from gui.Scoreboard import Scoreboard
from gui.mylibrocket.ScoreboardFormatter import ScoreboardFormatter

import Globals

LoadFontFace("Assets/libRocket/Fonts/Delicious-Roman.otf")
LoadFontFace("Assets/libRocket/Fonts/SAF.otf")

r = RocketRegion.make('pandaRocket', base.win)
r.setActive(1)
r.initDebugger()
r.setDebuggerVisible(True)
context = r.getContext()
Globals.ROCKET_CONTEXT = context

#b = BlockInventoryDataSource()
#bf = BlockInventoryDataFormatter()
#s = Scoreboard()
#s.NewRow(1, 'Testname')
#s.NewRow(-1, 'Testname2')
#s.Show()
#sf = ScoreboardFormatter()

context.LoadDocument('Assets/libRocket/offline.rml').Show()
コード例 #9
0
ファイル: main.py プロジェクト: MJ-meo-dmt/RisingEditor
    def __init__(self):

        ShowBase.__init__(self)

    #------------------------------------------------------------------#
    #
    #   SETUP BASIC LIBROCKET
    #
    #------------------------------------------------------------------#

        ## LOAD FONT ##
        LoadFontFace("../data_src/gui/fonts/verdana.ttf")

        ## SETUP REGION & INPUT HANDLER ##
        rw = RocketRegion.make('pandaRocket', base.win)
        rw.setActive(1)

        ih = RocketInputHandler()
        base.mouseWatcher.attachNewNode(ih)
        rw.setInputHandler(ih)

        ## CONTEXT ##
        self.context = rw.getContext()

        ## SETUP MAIN EDITOR WINDOW & GUI ##
        self.editorGui = self.context.LoadDocument('gui_src/editor_main.rml')
        self.editorGui.Show()


    #------------------------------------------------------------------#
    #
    #   EDITOR DEFAULT SETUP
    #
    #------------------------------------------------------------------#

        ## BASE DIR ##
        currentDir = os.getcwd()
        self.baseDir = currentDir + os.sep + "models"

        self.levelData = LevelData(self)
        
        ## NEW LEVEL VAR ##
        newLevelName = "unknownLevel"

    #------------------------------------------------------------------#
    #
    #   EDITOR EVENTS
    #
    #------------------------------------------------------------------#

        self.accept('new', self.New)
        self.accept('open', self.Open)
        self.accept('save', self.Save)
        self.accept('import', self.Import)
        self.accept('export', self.Export)


        ########################
        # Just build a basic simple file folder loader viewer thing for now
        # Something that loads or shows the contents of a dir hard coded
        #
        # editor: model, model1, model2, model3
        # and the texture folders, so that when clicked they can be added into the editor scene


        # Temp gizmo runner/ state=1
        self.gizmo = Gizmo(self, 1)


        ##
        # This should run when open file is used.
        self.levelload = LevelLoader(self)
        self.levelload.read("models/jump.lvlml", False)
        self.levelload.run()