コード例 #1
0
ファイル: gui_layer.py プロジェクト: guanzi0008/dnf_game
 def print_on_enter(id, final):
     """Sample callback function that prints a message to the screen."""
     locals()["manager"] = Manager()
     print('enter pressed, textbox contains "{}"'.format(final))
     try:
         eval(final)
     except SyntaxError:
         print("not a valid command.")
コード例 #2
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneDescriptions, test=False).execute()
コード例 #3
0
            self.on_update()
            return True
        [
            layer.on_mouse_press(event, x, y, button, double)
            for layer in self.layers if layer.active
        ]

    def on_mouse_scroll(self, event, offset_x, offset_y):
        """Called when the mouse wheel is scrolled."""
        [
            layer.on_mouse_scroll(event, offset_x, offset_y)
            for layer in self.layers if layer.active
        ]

    def on_update(self):
        """..."""
        def update_layers():
            [layer.on_update() for layer in self.layers if layer.visible]

        if self.ignore_regular_update:
            self.manager.renderer.clear()
            update_layers()
            self.manager.present()
        else:
            update_layers()


if __name__ == '__main__':
    from dnf_game.scene_manager import Manager
    m = Manager(scene=SceneMap).execute()
コード例 #4
0
def print_on_enter(id, final):
    """Sample callback function that prints a message to the screen."""
    locals()["manager"] = Manager()
    print('enter pressed, textbox contains "{}"'.format(final))
    eval(final)
コード例 #5
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneLayerGuiTextboxTest, test=False).execute()
コード例 #6
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2Tiles2Test, test=False).execute()
コード例 #7
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2FromColorWithAlphaTest, test=True).execute()
コード例 #8
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2GradientSpriteTest, test=True).execute()
コード例 #9
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2GfxdrawTest, test=False).execute()
コード例 #10
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2RectTest, test=True).execute()
コード例 #11
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneLayerInventoryTest, test=True).execute()
コード例 #12
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneLayerMsgLogTest, test=True).execute()
コード例 #13
0
    def insert_layer(self, obj):
        """..."""
        self.layers.append(obj)

    def on_key_press(self, event, mod):
        """Called on keyboard input, when a key is held down."""
        if event.key.keysym.sym == sdl2.SDLK_ESCAPE:
            self.quit()
        elif event.key.keysym.sym in [
                sdl2.SDLK_PAGEUP, sdl2.SDLK_PAGEDOWN, sdl2.SDLK_HOME,
                sdl2.SDLK_END
        ]:
            self.desc_layer.on_key_press(event, mod)
        else:
            self.nav_layer.on_key_press(event, mod)

    def on_mouse_scroll(self, event, offset_x, offset_y):
        """Called when the mouse wheel is scrolled."""
        self.desc_layer.on_mouse_scroll(event, offset_x, offset_y)

    def on_update(self):
        """..."""
        super().on_update()


if __name__ == '__main__':
    from dnf_game.scene_manager import Manager

    Manager(scene=SceneDescriptions).execute()
コード例 #14
0
 def test():
     """..."""
     m = Manager(scene=Terminal, framerate=10,
                 width=1024, height=768, show_fps=False)
     m._scene.text = """[path: C:/Program Files/minisphere;C:/Program Files/Common Files/Microsoft Shared/Windows Live;C:/Program Files (x86)/Common Files/Microsoft Shared/Windows Live;C:/Python34/Lib/site-packages/PyQt4;C:/Python34/;C:/Python34/Scripts;C:/Program Files/ImageMagick-6.9.1-Q16;C:/ProgramData/Oracle/Java/javapath;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;C:/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static;C:/Program Files (x86)/AMD/ATI.ACE/Core-Static;C:/Program Files (x86)/Autodesk/Backburner/;C:/Program Files/Common Files/Autodesk Shared/;C:/Program Files (x86)/Shoes;C:/Program Files (x86)/Two Pilots/PDF2Text Pilot/;C:/Program Files (x86)/Git/cmd;C:/Program Files (x86)/Windows Live/Shared;C:/Program Files (x86)/Bazaar;C:/Program Files (x86)/File Viewer Lite/lib/magick;C:/Program Files (x86)/QuickTime/QTSystem/;C:/Program Files (x86)/infogridpacific/AZARDI/bin;C:/Program Files (x86)/infogridpacific/AZARDI/bin;C:/Program Files/Calibre2/;C:/ProgramData/chocolatey/bin;C:/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit/;C:/c/lib/SDL2-2.0.4--mingw32/bin;C:/c/lib/SFML_2.3.2-GCC_4.9.2/bin;C:/Python35-32/Scripts;C:/Python35-32;C:/cc/cpplint;C:/cc/cppcheck;C:/Program Files (x86)/CodeBlocks/MinGW/bin;C:/Users/Lucas/Documents/batch/bin;C:/Ruby21-x64/bin;C:/Ruby21-x64/sqlite3/bin;C:/Program Files (x86)/Common Files/Hackety Hack/0.r1529/..]"""
     m.execute()
コード例 #15
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneTitle, test=True).execute()
コード例 #16
0
            # os.makedirs('save')
            self._menu.pop(2)

    def change_selection(self, value):
        """..."""
        self.selection += value
        self.selection = self.selection % len(self._menu)
        self.menu_layer.select(self.selection)

    def on_key_press(self, event, mod):
        """Called on keyboard input, when a key is held down."""
        sym = event.key.keysym.sym
        if sym == sdl2.SDLK_UP:
            self.change_selection(-1)
        elif sym == sdl2.SDLK_DOWN:
            self.change_selection(+1)
        elif sym == sdl2.SDLK_RETURN:
            self.manager.set_scene(**self._menu[self.selection]['kwargs'])
        print(self.menu_layer.visible)

    def on_key_release(self, event, mod):
        """Called on keyboard input, when a key is released."""
        sym = event.key.keysym.sym
        if sym == sdl2.SDLK_ESCAPE:
            self.quit()


if __name__ == '__main__':
    from dnf_game.scene_manager import Manager
    Manager(scene=SceneTitle).execute()
コード例 #17
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2TextSizeText, test=True).execute()
コード例 #18
0
ファイル: gui_layer.py プロジェクト: guanzi0008/dnf_game
    from dnf_game.scene_manager.scenes import base_scenes
    from dnf_game.scene_manager.layers import base_layers
    from dnf_game.scene_manager.layers import gui_layer

    class SceneLayerGuiTextboxTest(base_scenes.SceneMultiLayer):
        """..."""
        def __init__(self, **kwargs):
            """..."""
            super().__init__(**kwargs)
            frame = base_layers.Layer(parent=self)
            frame.create_gradient_surface()
            gui = gui_layer.GUILayer(parent=self)
            rect = Rect(0, 0, 150, 30)
            # rect.bottomleft = (gui.left, gui.height)
            rect.bottomright = (self.width, self.height)
            gui.create_textbox(rect=rect,
                               command=print_on_enter,
                               disable_on_execute=False)
            self.insert_layer(frame, gui)

    def print_on_enter(id, final):
        """Sample callback function that prints a message to the screen."""
        locals()["manager"] = Manager()
        print('enter pressed, textbox contains "{}"'.format(final))
        try:
            eval(final)
        except SyntaxError:
            print("not a valid command.")

    Manager(scene=SceneLayerGuiTextboxTest, test=False).execute()
コード例 #19
0
 def test_scene(self):
     """..."""
     Manager(scene=SceneMapEntitiesTest, test=True).execute()
コード例 #20
0
 def test_scene(self):
     """..."""
     Manager(scene=ScenePySDL2FromGradientWithAlpha, test=False).execute()