def __init__(self, cursorObject=None, useUI=True):
     self.assets = {}
     self.visibleAssets = {}
     self.readFile()
     self.cursorObject = cursorObject
     self.ui = AssetsManagerUI(self, cursorObject) if useUI else None
     self.assetsNodePaths = {}
     Refresh.addListener(self.refresh)
    def __init__(self, assetsManager, cursorObject):
        self.assetsManager = assetsManager
        self.ui = WebUI.get()
        self.ui.node().setScale(1.0)
        self.ui.node().setPos((0, 0, 0))
        self.cursorObject = cursorObject
        self.load()
        self.selection = None
        self.nearest = None

        self.shadowUUID = None

        Refresh.addListener(self.load)
Esempio n. 3
0
    def get(self):
        """
    Get UI

    Gets the UI singleton and initializes it if not already done.
    """
        if WebUI.ui is None:
            WebUI.ui = cefpanda.CEFPanda(transparent=True,
                                         size=[-1.0, 1.0, -1.0, 1.0])
            Refresh.addListener(WebUI.load)
            WebUI.load()

        return WebUI.ui
Esempio n. 4
0
    def __init__(self):
        ShowBase.__init__(self)

        self.initWindow()
        self.taskMgr.add(self.cameraFollowTask, "CameraFollowTask")
        self.taskMgr.add(self.processPlayerInputTask, "UpdateCarPositionTask")

        dae = loader.loadModel("../models/scene.dae")
        dae.reparentTo(render)
        dae.setHpr(0, 90, 0)
        self.scene = dae

        self.addLights()

        render.setShaderAuto()
        base.setBackgroundColor(0.0, 0.0, 0.1)

        RoadInfoSingleton.set(RoadInfo())

        self.car = dae.find("Scene").find("player_car")

        self.playerCarController = PlayerCarController(self.car)
        self.taskMgr.add(self.playerCarController.updatePlayerCar,
                         "UpdatePlayerCar")
        self.taskMgr.add(self.updateAssetManager, "UpdateAssetManager")

        self.last_update_car_time = None
        self.last_update_camera_time = None

        self.bindKeys()
        self.initBuildings()
        self.initDebugVector()

        self.aiFleetController = AIFleetController()

        self.initPostProcessing()
        self.initAssets()

        Refresh.addListener(self.refresh)

        base.mouseInterface.detachNode()

        self.mode = OpenSpaceDriveApp.MODE_PLAY
Esempio n. 5
0
    def processPlayerInputTask(self, task):
        ROLL_LEFT_KEY = "arrow_left"
        ROLL_RIGHT_KEY = "arrow_right"
        TURN_LEFT_KEY = "a"
        TURN_RIGHT_KEY = "d"

        if self.last_update_car_time is None:
            self.last_update_car_time = task.time - 0.01

        dt = task.time - self.last_update_car_time

        self.playerCarController.disable_road_force_field = True if self.keys[
            'q'] or self.keys['e'] else False

        if self.keys['w']:
            gaz = 1.2
            if self.keys['shift']:
                gaz *= 1.0 + self.playerCarController.velocity.length()
            self.playerCarController.acceleration += self.playerCarController.direction.normalized(
            ) * gaz * dt
        elif self.keys['s']:
            self.playerCarController.acceleration -= self.playerCarController.direction.normalized(
            ) * 0.5 * dt
        elif self.keys['space']:
            self.playerCarController.brake(dt)

        if self.keys['q']:
            self.playerCarController.acceleration -= self.playerCarController.upVector(
            ) * 1.2 * dt
        if self.keys['e']:
            self.playerCarController.acceleration += self.playerCarController.upVector(
            ) * 1.2 * dt

        carRotateMatrix = self.car.get_mat().rotateMat(0, axis=1)

        if self.keys['arrow_up']:
            self.playerCarController.angular_velocity += Vec3(0.0, -1.50,
                                                              0) * dt
        if self.keys['arrow_down']:
            self.playerCarController.angular_velocity += Vec3(0.0, 1.50,
                                                              0) * dt

        if self.keys[TURN_LEFT_KEY]:
            self.playerCarController.angular_velocity += Vec3(0.0, 0.0,
                                                              -2.0) * dt
        elif self.keys[TURN_RIGHT_KEY]:
            self.playerCarController.angular_velocity += Vec3(0.0, 0.0,
                                                              2.0) * dt

        if self.keys['enter']:
            self.assetsManager.ui.finalizePlaceAsset()

        if self.keys['escape']:
            self.mode = OpenSpaceDriveApp.MODE_PLAY
            self.assetsManager.ui.cancelPlaceAsset()

        if self.keys[ROLL_LEFT_KEY] or self.keys[ROLL_RIGHT_KEY]:
            factor = 4.0 * dt

            if self.keys[ROLL_RIGHT_KEY]:
                factor *= -1

            self.playerCarController.angular_velocity += Vec3(factor, 0.0, 0.0)

        self.playerCarController.update(dt)

        self.aiFleetController.update(dt, self.camera.getPos())

        self.last_update_car_time = task.time

        if self.assetsManager.ui.shadowUUID is not None:
            self.mode = OpenSpaceDriveApp.MODE_PLACE_ASSET

        if self.keys['f5']:
            Refresh.sendRefresh()

        return Task.cont
Esempio n. 6
0
 def __init__(self, model):
     CarController.__init__(self, model)
     Refresh.addListener(self.refreshBodyShader)
     self.initBodyShader()
     self.ui = WebUI.get()
     self.loadUI()
Esempio n. 7
0
def UpdateSemester():
    UpdateDate()
    Refresh(datastore_client)
    return '', 204