VolantisDev / Launchpad

Step up your non-Steam game! Generate Steam-compatible .exe files to effortlessly launch any game through Steam with overlay support.
https://launchpad.games
MIT License
85 stars 3 forks source link

Get this timeout value from somewhere #236

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 3 years ago

Get this timeout value from somewhere

https://github.com/VolantisDev/Launchpad/blob/103c04579eb6261e3c9492c8087bbc748a49ea7d/Lib/LaunchpadLauncher/Game/GameBase.ahk#L116


        this.Log("Running game...", "Info")

        launcherConfig := this.app.Service("LauncherConfig")

        if (launcherConfig["EnableOverlay"]) {
            this.overlayCallback := ObjBindMethod(this, "OverlayCallback")
            SetTimer(this.overlayCallback, 500)
        }

        loadingWinId := 0

        if (this.config["GameHasLoadingWindow"]) {
            loadingWinId := this.LoadingWindowIsOpen()
        } else {
            this.isLoadingWindowFinished := true
        }

        if (this.pid == 0 && !loadingWinId) {
            this.pid := this.RunGameAction(progress)
        }

        if (progress != "") {
            progress.IncrementValue(1, this.config["GameHasLoadingWindow"] ? "Waiting for loading screen..." : "Waiting for game window...")
        }

        while (!this.isFinished) {
            if (this.isOpen) {
                winId := this.GameWindowIsOpen()

                if (!winId) {
                    this.isFinished := !this.GameIsRunning()

                    if (this.isFinished) {
                        progress.SetDetailText("Game window closed.")
                        Sleep(1000)
                        this.isOpen := false
                    }
                }
            } else {
                if (this.config["GameHasLoadingWindow"] && !this.isLoadingWindowFinished) {
                    loadingWinId := this.LoadingWindowIsOpen()

                    if (loadingWinId) {
                        if (progress != "") {
                            progress.SetDetailText("Game is loading...")
                        }

                        ; TODO: Get this timeout value from somewhere
                        timeoutVal := 60
                        WinWaitClose("ahk_id " . loadingWinId,, timeoutVal)
                        loadingWinId := this.LoadingWindowIsOpen()

                        if (!loadingWinId) {
                            this.isLoadingWindowFinished := true
                            progress.SetDetailText("Loading window closed.")
                        }
                    }
                }

                if (this.isLoadingWindowFinished) {
                    winId := this.GameWindowIsOpen()

                    if (winId != 0) {
                        this.pid := this.GameIsRunning()

                        if (progress != "") {
                            progress.IncrementValue(1, "Monitoring game...")
                        }

                        this.isOpen := true
                    }
                }
            }

            Sleep(this.loopSleep)
        }

        this.Log("Finished running game.", "Info")

2faea88c4296b4bbb30674a8dfbda8614715556e