From 880e0ec2f320fc84591f62acbc44b106683f4f9f Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 17 May 2018 10:43:16 +0000 Subject: [PATCH] * (html5) - Tweaked the build parms, runs much faster now on Chrome, it was sort of laggy before * (html5) Can now pass in a url to "auto-download" and play a dmod. Example: http://www.rtsoft.com/web/dink?dmod=rtsoft.com/web/srchmili.dmod - in theory, you can now do dink.exe -game http://www.rtsoft.com/web/dink?dmod=rtsoft.com/web/srchmili.dmod from windows as well and it should download git-svn-id: svn://rtsoft.com/rtsvn/projects/RTDink@1610 353e56fe-9613-0410-8469-b96ad8e6f29c --- html5/CustomMain3-2AspectRatioTemplate.html | 2 +- html5/CustomMain4-3AspectRatioTemplate.html | 2 +- html5/CustomMainFullTemplate.html | 2 +- html5/build_release.bat | 6 ++--- source/App.cpp | 26 +++++++++++++++++++++ source/GUI/MainMenu.cpp | 14 ++++++++++- 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/html5/CustomMain3-2AspectRatioTemplate.html b/html5/CustomMain3-2AspectRatioTemplate.html index bf29a8b..1e084fe 100644 --- a/html5/CustomMain3-2AspectRatioTemplate.html +++ b/html5/CustomMain3-2AspectRatioTemplate.html @@ -154,7 +154,7 @@ loader.querySelector(".loadingtext").innerHTML = "Loading stuff..."; var cur = parseInt(m[2])*100; var progressMax = parseInt(m[4])*100; - console.log('cur: ' + cur+' max: '+progressMax) ; + //console.log('cur: ' + cur+' max: '+progressMax) ; Module.progress.style.transform = `scaleX(${cur/progressMax})`; } else { diff --git a/html5/CustomMain4-3AspectRatioTemplate.html b/html5/CustomMain4-3AspectRatioTemplate.html index a17171a..f154bbd 100644 --- a/html5/CustomMain4-3AspectRatioTemplate.html +++ b/html5/CustomMain4-3AspectRatioTemplate.html @@ -154,7 +154,7 @@ loader.querySelector(".loadingtext").innerHTML = "Loading stuff..."; var cur = parseInt(m[2])*100; var progressMax = parseInt(m[4])*100; - console.log('cur: ' + cur+' max: '+progressMax) ; + //console.log('cur: ' + cur+' max: '+progressMax) ; Module.progress.style.transform = `scaleX(${cur/progressMax})`; } else { diff --git a/html5/CustomMainFullTemplate.html b/html5/CustomMainFullTemplate.html index 51c0894..4084248 100644 --- a/html5/CustomMainFullTemplate.html +++ b/html5/CustomMainFullTemplate.html @@ -151,7 +151,7 @@ loader.querySelector(".loadingtext").innerHTML = "Loading stuff..."; var cur = parseInt(m[2])*100; var progressMax = parseInt(m[4])*100; - console.log('cur: ' + cur+' max: '+progressMax) ; + //console.log('cur: ' + cur+' max: '+progressMax) ; Module.progress.style.transform = `scaleX(${cur/progressMax})`; } else { diff --git a/html5/build_release.bat b/html5/build_release.bat index 59570d8..a51141f 100644 --- a/html5/build_release.bat +++ b/html5/build_release.bat @@ -115,7 +115,7 @@ REM **************************************** END SOURCE :unused so far: -s USE_GLFW=3 -s NO_EXIT_RUNTIME=1 -s FORCE_ALIGNED_MEMORY=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -DRT_EMTERPRETER_ENABLED :To skip font loading so it needs no resource files or zlib, add -DC_NO_ZLIB -SET CUSTOM_FLAGS= -DHAS_SOCKLEN_T -DBOOST_ALL_NO_LIB -DPLATFORM_HTML5 -DRT_USE_SDL_AUDIO -DRT_JPG_SUPPORT -DC_GL_MODE -s LEGACY_GL_EMULATION=1 -DPLATFORM_HTML5 -s TOTAL_MEMORY=16MB -Wno-c++11-compat-deprecated-writable-strings -Wno-shift-negative-value -s ALLOW_MEMORY_GROWTH=1 +SET CUSTOM_FLAGS= -DHAS_SOCKLEN_T -DBOOST_ALL_NO_LIB -DPLATFORM_HTML5 -DRT_USE_SDL_AUDIO -DRT_JPG_SUPPORT -DC_GL_MODE -s LEGACY_GL_EMULATION=1 -DPLATFORM_HTML5 -s TOTAL_MEMORY=16MB -s ALLOW_MEMORY_GROWTH=1 -Wno-c++11-compat-deprecated-writable-strings --ignore-dynamic-linking --memory-init-file 0 -Wno-switch :unused: -s FULL_ES2=1 --emrun @@ -129,7 +129,7 @@ SET FINAL_EXTENSION=html IF %DEBUG% EQU 0 ( echo Compiling in release mode -SET CUSTOM_FLAGS=%CUSTOM_FLAGS% -O2 -DNDEBUG -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -DRT_EMTERPRETER_ENABLED -s WASM=1 +SET CUSTOM_FLAGS=%CUSTOM_FLAGS% -O2 -DNDEBUG ) else ( echo Compiling in debug mode SET CUSTOM_FLAGS=%CUSTOM_FLAGS% -D_DEBUG -s GL_UNSAFE_OPTS=0 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s EXCEPTION_DEBUG=1 -s DEMANGLE_SUPPORT=1 -s ALIASING_FUNCTION_POINTERS=0 -s SAFE_HEAP=1 --emrun @@ -153,7 +153,7 @@ call emcc %CUSTOM_FLAGS% %INCLUDE_DIRS% ^ call emcc %CUSTOM_FLAGS% %INCLUDE_DIRS% ^ %APP_SRC% %SRC% %COMPONENT_SRC% temp.bc ^ ---preload-file ../bin/interface@interface/ --preload-file ../bin/audio@audio/ --preload-file ../bin/dink_html5@dink/ --js-library %SHARED%\html5\SharedJSLIB.js -o %APP_NAME%.%FINAL_EXTENSION% +--preload-file ../bin/interface@interface/ --preload-file ../bin/audio@audio/ --preload-file ../bin/dink_html5_uncompressed@dink/ --js-library %SHARED%\html5\SharedJSLIB.js -o %APP_NAME%.%FINAL_EXTENSION% REM Make sure the file compiled ok if not exist %APP_NAME%.js beeper.exe /p diff --git a/source/App.cpp b/source/App.cpp index 816543f..7fd2144 100644 --- a/source/App.cpp +++ b/source/App.cpp @@ -24,6 +24,7 @@ #ifdef PLATFORM_HTML5 #include "html5/HTML5Utils.h" +#include "html5/SharedJSLIB.h" #endif #ifdef WINAPI @@ -357,6 +358,31 @@ bool App::Init() LogMsg("Initializing Dink HD %s", GetVersionString().c_str()); + //add fake parms + + +#ifdef PLATFORM_HTML5 + string crap = JLIB_GetURL(); + + int n = crap.find_last_of('?'); + if (n == string::npos) + { + //I thought maybe this would be useful later to use # instead of ? to prevent caching? Dunno, doesn't hurt to add though + n = crap.find_last_of('#'); + } + if (n != string::npos) + { + //we should fake add whatever this command is + string final = crap.substr(n + 1, crap.length() - n); + GetBaseApp()->AddCommandLineParm(final); + } + + +#endif + //string crap = "http://www.rtsoft.com/web/dink/?-game http://www.rtsoft.com/web/srchmili.dmod"; + + + vector parm = GetBaseApp()->GetCommandLineParms(); string parms; diff --git a/source/GUI/MainMenu.cpp b/source/GUI/MainMenu.cpp index 9e6db9b..38eba84 100644 --- a/source/GUI/MainMenu.cpp +++ b/source/GUI/MainMenu.cpp @@ -233,7 +233,7 @@ string GetNextDMODToInstall(bool &bIsCommandLineInstall, const bool bDeleteComma bIsCommandLineInstall = false; //if (!GetApp()->CanDownloadDMODS()) return ""; //ignore it - if (IsDesktop()) + if (IsDesktop() || GetEmulatedPlatformID() == PLATFORM_ID_HTML5) { vector parms = GetApp()->GetCommandLineParms(); @@ -284,6 +284,18 @@ void MainOnStartLoading(VariantList *pVList) string fName = GetNextDMODToInstall(bIsCommandLineInstall, true); + if (IsInString(fName, "http:") || IsInString(fName, "https:") + || + (GetEmulatedPlatformID() == PLATFORM_ID_HTML5 && IsInString(fName, ".dmod")) + ) + { + //we should download and install this + StringReplace("-game ", "", fName); + StringReplace("dmod=", "", fName); + DMODInstallMenuCreate(pBG->GetParent(), fName, GetDMODRootPath(), "", true, fName); + return; + } + if (!fName.empty()) { DMODInstallMenuCreate(pBG->GetParent(), "", GetDMODRootPath(), GetSavePath()+fName, false, "", !bIsCommandLineInstall);