darkf / darkfo

DarkFO, a post-nuclear RPG remake (of Fallout 2)
Apache License 2.0
135 stars 12 forks source link

Add macOS WKWebView-based wrapper #130

Closed MaxDesiatov closed 5 years ago

MaxDesiatov commented 5 years ago

Hi @darkf, thank you for the great project!

I've been finding that browser UI distracts from the gameplay a bit and thought that wrapping the engine in a web view app could improve that. In this PR a wrapper app based on the standard macOS WKWebView is added. It doesn't pull any dependencies and can be built on any macOS device with standard developer tools installed.

Here's how it looks in action:

screenshot 2019-03-04 at 10 39 43

Please let me know if there's any chance this can be merged and if any changes are needed.

darkf commented 5 years ago

Thanks for the contribution.

Other than that I have no real objections, although I cannot test these changes as I don't have a Mac install.

MaxDesiatov commented 5 years ago

I actually thought I could embed a simple HTTP server within the wrapper in a future PR that always listens on localhost:8000 (maybe a port could be configurable, but we could pick a sufficiently rarely used port). This would help in avoiding ip:port config values and users wouldn't need to run python -m SimpleHTTPServer before starting the wrapper. Is it worth trying to embed the server in this same PR?

darkf commented 5 years ago

I'd defer that to a later PR.

That sounds fine too if it's a simple static-serving HTTP server. I actually planned on supplying a simple/fast/hacky one in Python for running the game quickly without much overhead, but I think I didn't commit it because the Windows network stack has some weird performance issues over loopback (and usually I use lighttpd configured to gzip the large assets, which works well.)

Apologies since this doesn't seem to be documented, as for the ip:port values I meant that in the context of a --join argument, to join a multiplayer game (mpserv.py hosts a WebSocket server), which needs the server and port to join. To do that you just use http://whatever/play.html?join=server, although it seems like we hardcode the port here for now. 🤔

(Hosting is also play.html?host=mapname)

MaxDesiatov commented 5 years ago

Thanks, all should be fixed now. I didn't add the command-line arguments since there's no easy way for users to launch GUI apps from command line on macOS. I've added a preferences window though, where URL parameters can be changed to an arbitrary value with artemple being the default. Hope this works.

screenshot 2019-03-05 at 12 07 27
darkf commented 5 years ago

The new PreferencesController still has an "All rights reserved." copyright.

Once that's changed, looks good to me. The preferences dialog is a reasonable solution too.

MaxDesiatov commented 5 years ago

Ah, sorry about that. That's fixed now. Thank you!

darkf commented 5 years ago

Looks good. Thanks for your contribution!