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

Custom play launch commands #2605

Merged
merged 3 commits into from Sep 30, 2022
Merged

Conversation

tong
Copy link
Contributor

@tong tong commented Sep 29, 2022

Adds the possiblity to use a custom player launch command by setting environment variables.

  • ARMORY_PLAY_HTML5
  • ARMORY_PLAY_KROM

The given string gets transformed with python templates using platform specific params:

  • html5: host, port, width, height, url, path, dir, browser
  • krom: pid, audio, location, krom_path, path, resources, width, height

If not set the default launch commands are used.

Html5 example:

export ARMORY_PLAY_HTML5='chrome --app=$url --new-window --window-size=$width,$height --auto-open-devtools-for-tabs'

The default launch commands:

export ARMORY_PLAY_HTML5='$BROWSER $url'
export ARMORY_PLAY_HTML5='$BROWSER http://$host:$port/$path'
export ARMORY_PLAY_HTML5='$BROWSER http://$host:$port/$dir/debug/html5'

The default launch command on krom:

export ARMORY_PLAY_KROM='$krom_path $path $resources --consolepid $pid'

This partly resolves #2476 but without any hacks.

Also resolves the issue introduced with the custom command if the browser can't get determined (#2602) by fallback to webbrowser.open().

@MoritzBrueckner MoritzBrueckner added the Release Notes: Changes A pull request that is a feature change, not a fix. Used to generate release notes. label Sep 29, 2022
@MoritzBrueckner
Copy link
Collaborator

MoritzBrueckner commented Sep 29, 2022

Awesome! I tested your changes and it works again :)

Is it intended that #2476 is automatically closed by this PR (since you wrote that it's only partly resolved)? Otherwise I can remove the auto-closing link.

@tong
Copy link
Contributor Author

tong commented Sep 29, 2022

I think it's ok to close the issue.

What's not working is the handling of bool values since the template modules doesn't support it. Things like:

if fullscreen --fullscreen end

.. have to be hardcoded by the variable by simply adding --fullscreen or not.

@luboslenco luboslenco merged commit 3d43088 into armory3d:main Sep 30, 2022
@tong tong deleted the custom-play-launch-commands branch September 30, 2022 13:12
@MoritzBrueckner
Copy link
Collaborator

Hi, there seems to be another problem with webbrowser.get().name, apparently the name property doesn't always exist: https://forums.armory3d.org/t/not-possible-to-start-in-browser-or-krom-on-macosx/4991

@tong
Copy link
Contributor Author

tong commented Oct 5, 2022

Is a null check enough?
tong@4e51256

@MoritzBrueckner
Copy link
Collaborator

I don't think so, there is a valid browser object returned. Instead that particular browser class doesn't seem to have a name attribute for some reason (instead it has _name, which is confusing). I guess we need to use hasattr(browser, 'name') or getattr(browser, 'name', '') (with default value) here.

@tong
Copy link
Contributor Author

tong commented Oct 5, 2022

main...tong:armory:fix-open-browser-call hopefully works. objections?

@MoritzBrueckner
Copy link
Collaborator

Looks good! Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release Notes: Changes A pull request that is a feature change, not a fix. Used to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom web browser launch options
3 participants