Пример #1
0
 private void loading_done(ResourceInteractiveLoader loader)
 {
     _loading_thread.WaitToFinish();
     EmitSignal(nameof(replace_main_scene), loader.GetResource());
     // Issue: https://github.com/godotengine/godot/issues/33809
     _res_loader.Dispose();
     _res_loader = null;
 }
Пример #2
0
 public void LoadScene(string path)
 {
     this.loader = ResourceLoader.LoadInteractive(path);
     SetProcess(true);
     GetNode <Control>(new NodePath("Control")).Hide();
     GetNode <CenterContainer>(new NodePath("CenterContainer")).Show();
     this.loadingLabel = GetNode <Label>(new NodePath("CenterContainer/LoadingLabel"));
 }
Пример #3
0
        private void FinishProgress()
        {
            if (Log.LoggingLevel == LoggingLevel.All)
            {
                Log.Print("Polling scene loader stage: FINISHED");
            }

            EmitSignal(nameof(SceneChanged), GetTree().CurrentScene); // NOTE: this might return dated info (the last level instead of this new one) because it may take time to changeSceneTo
            _loader = null;
            GetLoadScreen().GetProgressBar().Value = 1f;
        }
    private void ThreadLoad(string ResPath)
    {
        ResourceInteractiveLoader RIL = ResourceLoader.LoadInteractive(ResPath);

        if (RIL == null)
        {
            return;
        }

        int StageCount = 0;

        while (true)
        {
            uint  TimeElapsed  = OS.GetTicksMsec() - TimeStart;
            float TimeProgress = (float)TimeElapsed / (float)(MinimumTime * 1000f) * (float)MaxValue;

            if (StageCount < RIL.GetStageCount())
            {
                StageCount = RIL.GetStage();
            }

            float LoadProgress = (float)StageCount / (float)RIL.GetStageCount() * (float)MaxValue;
            CallDeferred("set_value", (TimeProgress < LoadProgress)?TimeProgress:LoadProgress);

            //Take a break
            OS.DelayMsec(100);

            if (Value >= MaxValue)
            {
                CallDeferred("ThreadDone", RIL.GetResource() as PackedScene);
                return;
            }

            if (StageCount >= RIL.GetStageCount())
            {
                continue;
            }

            //Poll current stats
            Error PollData = RIL.Poll();

            if (PollData == Error.FileEof)
            {
                StageCount = RIL.GetStageCount();
                continue;
            }

            if (PollData != Error.Ok)
            {
                GD.Print("Error Loading");
                return;
            }
        }
    }
Пример #5
0
    private void runGame(string level)
    {
        //todo make loading screen
        loader = ResourceLoader.LoadInteractive(GAME_PATH);

        if (loader == null)
        {
            GD.Print("Could not load level");
            return;
        }
        GD.Print("Loading for level: " + level + " began");
        SetProcess(true);
        currentScene.QueueFree();
        waitFrame = 1;
    }
Пример #6
0
        /// <summary>
        /// Changes the whole Main scene to a PackedScene in a specified path
        /// </summary>
        /// <param name="path"></param>
        public void ChangeScene(string path)
        {
            Game.Self.EmitSignal(nameof(Game.StartedToChangeLevel));

            _loader = ResourceLoader.LoadInteractive(path);

            if (_loader == null || path == "res://")
            {
                Log.Crash("Couldn't load a scene: Loader at path " + path + " was NULL", true);
            }

            GetLoadScreen().StartLoadingVisuals(0.5f);

            Log.Print("Changing scene to: " + path, true);
            Iterator.Coroutine.Run(LoadSceneAndMakeItMainScene());
        }
Пример #7
0
        private void _on_play_pressed()
        {
            _main.Hide();
            _loading.Show();
            var path = "res://level/level.tscn";

            if (ResourceLoader.HasCached(path))
            {
                EmitSignal(nameof(replace_main_scene), ResourceLoader.Load <PackedScene>(path));
            }
            else
            {
                _res_loader     = ResourceLoader.LoadInteractive(path);
                _loading_thread = new Thread();
                _loading_thread.Start(this, "interactive_load", _res_loader);
            }
        }
Пример #8
0
    public override void _Process(float delta)
    {
        if (this.loader == null)
        {
            SetProcess(false);
            return;
        }
        Error error = this.loader.Poll();

        this.loadingLabel.Text = loader.GetStage() + " / " + loader.GetStageCount();
        if (error == Error.FileEof)
        {
            GetTree().QueueDelete(GetTree().Root.GetChild(0));
            GetTree().Root.AddChild(((PackedScene)this.loader.GetResource()).Instance());
            this.loader = null;
        }
    }
    public override void _Process(float delta)
    {
        time += delta; //GAMETIME

        //LOADER
        if (riLoader == null)
        {
            SetProcess(false);
            return;
        }

        if (waitFrames > 0)
        {
            waitFrames--;
            return;//espera antes de cargar
        }

        //tiempo máximo de bloqueo de hilo
        float initTime = OS.GetTicksMsec();

        while (OS.GetTicksMsec() < initTime + timeMaxLoad)
        {
            Error err = riLoader.Poll();//progresando...

            if (err == Error.FileEof)
            {
                //█OOOKKK
                PackedScene packedScene = (PackedScene)riLoader.GetResource();
                riLoader = null;
                instanceScene(packedScene);
                break;
            }
            else if (err == Error.Ok)
            {
                updateLoadingProgress();//informa
            }
            else
            {
                GD.Print("ERROR");//ERROR
                riLoader = null;
                break;
            }
        }
    }
Пример #10
0
    public override void _Process(float delta)
    {
        if (loader == null)
        {
            SetProcess(false);
            return;
        }

        if (wait_frames < 0)
        {
            wait_frames -= 0;
            return;
        }

        var t = OS.GetTicksMsec();

        while (OS.GetTicksMsec() < t + time_max)
        {
            var err = loader.Poll();

            if (err == Error.FileEof)
            {
                Progres = ToLoad;
                var resource = loader.GetResource();
                AlreadyLoaded.Add(current, resource);
                loader = null;
                GetTree().ChangeSceneTo(resource as PackedScene);
                break;
            }
            else if (err == Error.Ok)
            {
                Progres = loader.GetStage();
                ToLoad  = loader.GetStageCount();
            }
            else
            {
                loader = null;
                break;
            }
        }
    }
Пример #11
0
    private void ThreadLoad()
    {
        ResourceInteractiveLoader ril = ResourceLoader.LoadInteractive(scenePath);
        int total = ril.GetStageCount();

        instance.res = null;
        while (true)
        {
            Error err = ril.Poll();
            if (err == Error.FileEof)
            {
                instance.res       = ril.GetResource();
                instance.canChange = true;
                break;
            }
            else if (err != Error.Ok)
            {
                GD.Print("ERROR LOADING");
                break;
            }
        }
    }
Пример #12
0
    public override void _Process(float delta)
    {
        if (loader == null)
        {
            return;
        }

        Error err = loader.Poll();

        if (err == Error.FileEof)
        {
            Resource resource = loader.GetResource();
            loader = null;
            setNewScene((PackedScene)resource);
            return;
        }
        else if (err == Error.Ok)
        {
            updateProgress();
            return;
        }
    }
Пример #13
0
    public override void _Process(float delta)
    {
        if (loader == null)
        {
            GD.Print("Loader done");
            //no need for processing anymore
            SetProcess(false);
            return;
        }

        if (waitFrame > 0)
        {
            //buffer for loading animation scene to appear
            waitFrame -= 1;
            return;
        }

        var t = OS.GetTicksMsec();

        while (OS.GetTicksMsec() < (t + maxWait))
        {
            var loadStatus = loader.Poll();

            if (loadStatus == Error.FileEof)
            {
                //load complete
                var scene = loader.GetResource() as PackedScene;

                Node newInstance = scene.Instance();
                loader = null;

                //do any stuff specific to any nodes


                setNewScene(newInstance);
            }
        }
    }
Пример #14
0
    public void LoadScene(string path)
    {
        if (AlreadyLoaded.ContainsKey(path))
        {
            var resource = AlreadyLoaded[path];
            GetTree().ChangeSceneTo(resource as PackedScene);
            return;
        }
        current = path;
        var     ls = (PackedScene)GD.Load("res://Loading.tscn");
        Loading l  = ls.Instance() as Loading;

        GetTree().CurrentScene.AddChild(l);


        loader = ResourceLoader.LoadInteractive(path);
        if (loader == null)
        {
            return;
        }
        SetProcess(true);

        wait_frames = 1;
    }
Пример #15
0
 public void loadPlanet(string filePath)
 {
     Visible = true;
     loader  = ResourceLoader.LoadInteractive(filePath);
 }
Пример #16
0
 private void FailLoading()
 {
     _loader = null;
 }
Пример #17
0
 public void loadPlanet()
 {
     Visible = true;
     loader  = ResourceLoader.LoadInteractive("res://src/Planet/Planet.tscn");
 }
Пример #18
0
 public override void _Ready()
 {
     loader      = ResourceLoader.LoadInteractive(Menu.GAMEPLAY_SCENE_PATH);
     progressBar = GetNode(Menu.LOADING_PROGRESS_PATH) as ProgressBar;
     SetProcess(false);
 }