Пример #1
0
    def disable(self) -> bool:
        if not self.enabled:
            Log.error(f"Scene {self} already disabled")
            return False

        self.camera.hud_scenes.remove(self)
        return True
Пример #2
0
    def enable(self) -> bool:
        if self.enabled:
            Log.error(f"Scene {self} already enabled")
            return False

        self.camera.hud_scenes.append(self)
        return True
Пример #3
0
    def append(self, object):
        if len(self) < self.max_size:
            list.append(self, object)

        elif self.auto_clear:
            self.clear()
            
        else:
            Log.error(f"Cannot add more than {self.max_size} objects to LimitedLenghtObjectArray")
Пример #4
0
    def disable(self, feature) -> None:
        mode = "disable"

        exec(
            compile(source=feature,
                    filename="feature",
                    mode="exec",
                    optimize=1))
        Log.warning("Window.disable() is deprecated and will soon be removed")
Пример #5
0
    def __init__(self, camera):
        from Capsian.values import CPSN_PERSPECTIVE_CAMERA

        super().__init__(camera)

        if not isinstance(camera, CPSN_PERSPECTIVE_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for Scene3D!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Пример #6
0
    def __init__(self, camera):
        from Capsian.values import CPSN_ORTHOGRAPHIC_CAMERA
        
        super().__init__(camera)

        self.dynamic_gui = types.LimitedLenghtObjectArray(200.000, False)

        if not isinstance(camera, CPSN_ORTHOGRAPHIC_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for Scene2D!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Пример #7
0
    def get_texture(self):
        loaded_texture = pyglet.image.load(self.path).get_texture()

        pyglet.gl.glTexParameterf(pyglet.gl.GL_TEXTURE_2D,
                                  self.flags["texture mode"][0],
                                  self.flags["texture mode"][2])

        pyglet.gl.glTexParameterf(pyglet.gl.GL_TEXTURE_2D,
                                  self.flags["texture mode"][1],
                                  self.flags["texture mode"][2])

        Log.successful(f"Successfully loaded texture from file '{self.path}'")
        return pyglet.graphics.TextureGroup(loaded_texture)
Пример #8
0
    def __init__(self, camera):
        from Capsian.values import CPSN_HUD_SCENE, CPSN_PERSPECTIVE_CAMERA

        super().__init__(camera)

        self.hud_batch   = pyglet.graphics.Batch()
        self.dynamic_hud = types.LimitedLenghtObjectArray(30.0000, False)

        if not isinstance(camera, CPSN_PERSPECTIVE_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for OverlayScene!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Пример #9
0
    def set_viewport(self, camera) -> None:
        """
        Description
        -----------
            Sets the rendering viewport to the specified one

        Parameters
        ----------
            camera | The new viewport | PerspectiveCamera\OrthographicCamera
        """

        if not self.alive > 0:
            return

        if not hasattr(camera, "init"):
            Log.critical("The specified camera is not valid")
            return

        camera.init()
Пример #10
0
    def __init__(self, camera, fullscreen_key=key.F11, *args, **kwargs):
        """
        Parameters
        ----------
            camera         | A Capsian Camera Object                         | PerspectiveCamera\OrthographicCamera
            fullscreen_key | The key that will trigger fullscreen on and off

        Additional Parameters (From Pyglet)
        -----------------------------------
            width      | The width of the window                    | int
            height     | The height of the window                   | int
            vsync      | Weather VSync is on or off                 | bool
            resizable  | Weather the window is resizable or not     | bool
            fullscreen | Weather fullscreen is on by default or not | bool
        """

        # Create window
        super().__init__(*args,
                         **kwargs,
                         screen=pyglet.canvas.Display.get_default_screen(
                             pyglet.canvas.Display()))

        # Variable declaration
        self.mouse_lock = False
        self.fullscreen_key = fullscreen_key

        # Others
        self.lighting = False
        engine.main_window = self
        self.alive = 1

        # Looks
        self.move_to_center()

        # Checks weather the camera is compatible
        if not hasattr(camera, "init"):
            Log.critical("The specified camera is not valid")
            return

        self.view_port = camera
        camera.init()
Пример #11
0
    def __init__(self,
                 font: str,
                 font_size: float,
                 text: str,
                 color,
                 transform=Transform(),
                 scene=PlaceholderScene(),
                 *args,
                 **kwargs):
        """
        Parameters
        ----------
            font      | The font you want to use for the label          | str
            font-size | The font size you want to use                   | float
            text      | The text of the label                           | str
            color     | The color of the label                          | list [R, G, B, A]
            scene     | The Capsian Scene of which the label is part of | Scene2D
        """

        if not isinstance(scene, CPSN_HUD_SCENE):
            Log.critical(
                f"Invalid scene type for Static HUD Label. This object can only be used in a GUI scene (CPSN_HUD_SCENE)"
            )
            return

        self.scene = scene

        super().__init__(text=text,
                         font_name=font,
                         font_size=font_size,
                         bold=False,
                         italic=False,
                         x=transform.x,
                         y=transform.y,
                         width=transform.width,
                         height=transform.height,
                         color=color,
                         *args,
                         **kwargs)
Пример #12
0
    def __init__(self, gl_light, color: list):
        """
        Parameters
        ----------
            gl_light | The OpenGL Light value                                  | GL_AMBIENT\GL_DIFFUSE\GL_SPECULAR
            color    | A list of four values describing the color of the light | list [R, G, B, A]
        """

        from Capsian.values import lights

        super().__init__()

        self.type = gl_light
        self.intensity = list(color)

        if not len(lights) > 0:
            self.light = pyglet.gl.GL_LIGHT0
            Log.error(
                "Unable to create light: All 8 light slots available are taken!"
            )
            return

        self.light = lights[0]
        lights.pop(0)
Пример #13
0
 def get_image(self):
     loaded_image = pyglet.image.load(self.path)
     Log.successful(f"Successfully loaded image from file '{path}'")
     return loaded_image
Пример #14
0
 def on_ready(self, time) -> None:
     if not isinstance(self.parent, CPSN_PERSPECTIVE_CAMERA):
         Log.critical(
             "You are trying to add a CharacterController Component to an object that is not CPSN_PERSPECTIVE_CAMERA compatible"
         )
         return