Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daggerfall-unity: enable automatic runtime download #996

Closed
wants to merge 8 commits into from
Closed

daggerfall-unity: enable automatic runtime download #996

wants to merge 8 commits into from

Conversation

Jpxe
Copy link
Contributor

@Jpxe Jpxe commented Sep 9, 2023

I've added a feature that allows automatic downloading, like we discussed

Check it out and let me know what you think. Improvements and suggestions are welcome of course

New Engine Package Submissions

  • Have you followed the instructions in the build documentation?
  • Have you run the build locally and ensured the package allowed you to launch and play the Steam game?
  • Have you updated the packages.json file?
  • Have you ensured that there is not already a pull request or active engine package for the one you are adding?

Common Code Submissions

  • Have you verified that the changes are isolated to the features or fixes you are wanting to do?
  • Have you tested at least one of the engines to ensure that your changes do not break existing workflow?
  • Have you described what your changes are accomplishing?

@d10sfan
Copy link
Member

d10sfan commented Sep 9, 2023

Looks like a good start thanks! I think the client could be the best place for this since it'll apply to multiple engines so we don't have to re-do it multiple times. This will be very handy for implementing it though, as the checking and all that is a good point

@Jpxe
Copy link
Contributor Author

Jpxe commented Sep 9, 2023

Sounds good! I was also experimenting with installing multiple steam apps, something like this:

# Define an array of app IDs for the required Steam apps
REQUIRED_APP_IDS=("1070560" "ANOTHER_APP_ID" "YET_ANOTHER_APP_ID")

# Function to check if a specific Steam app is installed
is_app_installed() {
    local app_id="$1"
    if [[ ! -z "$app_id" && -d "$STEAM_RUNTIME_PATH/$app_id" ]]; then
        return 0  # App found
    else
        return 1  # App not found
    fi
}

# Function to install a Steam app silently
install_app() {
    local app_id="$1"
    echo "Installing Steam app with App ID: $app_id..."
    steam "steam://dev/console/ +app_install $app_id" >/dev/null 2>&1
}

# Install each required Steam app if not already installed
for app_id in "${REQUIRED_APP_IDS[@]}"; do
    if ! is_app_installed "$app_id"; then
        echo "Required Steam app with App ID $app_id is not installed. Installing now..."
        install_app "$app_id"

        # Check for the Steam app in a loop
        start_time=$(date +%s)
        while true; do
            if is_app_installed "$app_id"; then
                break  # App found, exit the loop
            else
                current_time=$(date +%s)
                elapsed_time=$((current_time - start_time))

                if [ "$elapsed_time" -ge "$MAX_WAIT_SECONDS" ]; then
                    echo "Timeout: Steam app installation took too long."
                    exit 1
                else
                    echo "Waiting for Steam app installation..."
                    sleep 5  # Adjust the sleep interval as needed
                fi
            fi
        done
    else
        echo "Required Steam app with App ID $app_id is already installed."
    fi
done

# The required Steam apps are successfully installed
echo "Required Steam apps are installed and ready."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants