diff --git a/html5/build_release.bat b/html5/build_release.bat index 61eada2..5b5e7a6 100644 --- a/html5/build_release.bat +++ b/html5/build_release.bat @@ -119,9 +119,9 @@ set APP_SRC=%APP%\App.cpp %APP%\Component\ActionButtonComponent.cpp %APP%\Compon %APP%\GUI\PauseMenu.cpp %APP%\GUI\PopUpMenu.cpp %APP%\GUI\QuickTipMenu.cpp %APP%\GUI\ReadTextMenu.cpp %APP%\GUI\ExpiredMenu.cpp 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 -s TOTAL_MEMORY=16MB +: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 -s TOTAL_MEMORY=16MB -s PRECISE_F32=2 :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 -DRT_PNG_SUPPORT -DC_GL_MODE -s LEGACY_GL_EMULATION=1 -DPLATFORM_HTML5 -s ALLOW_MEMORY_GROWTH=1 -Wno-c++11-compat-deprecated-writable-strings --ignore-dynamic-linking --memory-init-file 0 -Wno-switch -s PRECISE_F32=2 -Wno-writable-strings -Wno-shift-negative-value +SET CUSTOM_FLAGS= -DHAS_SOCKLEN_T -DBOOST_ALL_NO_LIB -DPLATFORM_HTML5 -DRT_USE_SDL_AUDIO -DRT_JPG_SUPPORT -DRT_PNG_SUPPORT -DC_GL_MODE -s LEGACY_GL_EMULATION=1 -DPLATFORM_HTML5 -s ALLOW_MEMORY_GROWTH=1 -Wno-c++11-compat-deprecated-writable-strings --ignore-dynamic-linking --memory-init-file 0 -Wno-switch -Wno-writable-strings -Wno-shift-negative-value :unused: -s FULL_ES2=1 --emrun diff --git a/media/interface/ipad/bkgd_anim_fire.png b/media/interface/ipad/bkgd_anim_fire.png index b90d95f..5483230 100644 Binary files a/media/interface/ipad/bkgd_anim_fire.png and b/media/interface/ipad/bkgd_anim_fire.png differ diff --git a/media/interface/ipad/bkgd_anim_fire.rttex b/media/interface/ipad/bkgd_anim_fire.rttex index 4cb47cd..67a403e 100644 Binary files a/media/interface/ipad/bkgd_anim_fire.rttex and b/media/interface/ipad/bkgd_anim_fire.rttex differ diff --git a/source/App.cpp b/source/App.cpp index 69726ef..e85437d 100644 --- a/source/App.cpp +++ b/source/App.cpp @@ -21,6 +21,8 @@ #include #include "Gamepad/GamepadManager.h" #include "Gamepad/GamepadProvideriCade.h" +#include "GUI/PopUpMenu.h" +#include "GUI/PauseMenu.h" #ifdef PLATFORM_HTML5 #include "html5/HTML5Utils.h" @@ -232,7 +234,7 @@ bool App::GetForceAspectRatio() bool App::UseClassicEscapeMenu() { - if (GetEmulatedPlatformID() == PLATFORM_ID_HTML5) + if (GetEmulatedPlatformID() == PLATFORM_ID_HTML5 && !GetApp()->GetUsingTouchScreen()) { return true; } @@ -1050,6 +1052,101 @@ const char * GetBundleName() return bundleName; } + +void ImportSaveState(string physicalFname) +{ + + Entity *pMenu = GetEntityRoot()->GetEntityByName("GameMenu"); + + string originalDMODDir = g_dglo.m_dmodGameDir; + string newDMODDir; + + bool bSuccess = GetDMODDirFromState(physicalFname, newDMODDir); + //newDMODDir += "/"; + + if (!bSuccess) + { + //RemoveFile(fName, false); + GetAudioManager()->Play("audio/buzzer2.wav"); + PopUpCreate(pMenu, "Error loading save state. Probably an older version, sorry.", "", "cancel", "Continue", "", "", true); + SyncPersistentData(); + + } + else + { + LogMsg("We are in %s, but now we need %s", originalDMODDir.c_str(), newDMODDir.c_str()); + + if (!newDMODDir.empty()) + { + + if (!FileExists(GetDMODRootPath() + newDMODDir + "dmod.diz")) + { + PopUpCreate(pMenu, "Can't find file " + newDMODDir + "dmod.diz" + ", maybe you need to install the DMOD first?", "", "cancel", "Continue", "", "", true); + return; + } + } + + if (originalDMODDir == newDMODDir) + { + LoadStateWithExtra(physicalFname); + } + else + { + //whole different dmod, we need to get fancy here + LogMsg("Switching to correct DMOD dir for this quicksave..."); + //SetDinkGameState(DINK_GAME_STATE_NOT_PLAYING); + + Entity *pNewMenu = DinkQuitGame(); + KillEntity(pMenu); + + DisableAllButtonsEntity(pNewMenu); + SlideScreen(pNewMenu, false); + GetMessageManager()->CallEntityFunction(pNewMenu, 500, "OnDelete", NULL); + + InitDinkPaths(GetBaseAppPath(), "dink", RemoveTrailingBackslash(newDMODDir)); + GameCreate(pNewMenu->GetParent(), 0, physicalFname); + GetBaseApp()->SetGameTickPause(false); + } + } +} + +void ImportNormalSaveSlot(string fileName, string outputFileName) +{ + //well... directly loading it is possible but.. uhh.. DMODs may need their own startup + //scripts so I better just copy the file over instead. + Entity *pMenu = GetEntityRoot()->GetEntityByName("GameMenu"); + + string path = g_dglo.m_dmodGamePathWithDir; + + if (path.empty()) + { + //must be dink and not a DMOD, special case + path = GetSavePath()+"/dink/"; + } + + //fix outputfilename if it's wrong + StripWhiteSpace(outputFileName); + int index = outputFileName.find_first_of('('); + if (index != string::npos) + { + //it probably looks like "save2 (2).dat" due to chrome renaming if it existed, fix it + outputFileName = outputFileName.substr(0, index - 1) + "."+GetFileExtension(outputFileName); + } + LogMsg("Copying %s to %s", fileName.c_str(), (path + outputFileName).c_str()); + + if (!GetFileManager()->Copy(fileName, path + outputFileName, false)) + { + + PopUpCreate(pMenu, ("Error copying " + outputFileName + " into "+ g_dglo.m_dmodGamePathWithDir + outputFileName+"!").c_str(), "", "cancel", "Continue", "", "", true); + + return; + } + + PopUpCreate(pMenu, "Ok, we've put " + outputFileName +" into the active game directory. You can now load this save slot like normal.", "", "cancel", "Continue", "", "", true); + +} + + void App::OnMessage( Message &m ) { m_adManager.OnMessage(m); //gives the AdManager a way to handle messages @@ -1059,45 +1156,24 @@ void App::OnMessage( Message &m ) { if (m.GetType() == MESSAGE_TYPE_HTML5_GOT_UPLOAD) { - LogMsg("Got uploaded file %s", m.GetStringParm().c_str()); string fName = m.GetStringParm(); + string physicalFname = "proton_temp.tmp"; + int fileSize = GetFileSize(physicalFname); + LogMsg("Got uploaded file %s (as %s). %d bytes", m.GetStringParm().c_str(), physicalFname.c_str(), + fileSize); + - - size_t index = fName.find_last_of('_'); - size_t periodPos = fName.find_last_of('.'); - - if (periodPos == string::npos || GetFileExtension(fName) != "dat") return; - - string dmodName = ""; - - if (index != string::npos) + if (fileSize > 1024 * 1000) { - //yeah, it has one - dmodName = fName.substr(index + 1, periodPos - (index + 1)); + //well, it's big, let's assume it's a full save state + ImportSaveState(physicalFname); + } + else + { + ImportNormalSaveSlot(physicalFname, fName); + } - //ok, ready to copy it. But figure out where, and what the filename should be - string destPath = GetSavePath() + "dink/"; - string destFile = fName; - - //modify if needed for a dmod - - if (!dmodName.empty()) - { - destPath = GetDMODRootPath() + dmodName + "/"; - destFile = fName.substr(0, index); - destFile += fName.substr(periodPos, fName.size() - periodPos); - } - - LogMsg("Importing %s to %s", (GetSavePath() + fName).c_str(), (destPath + destFile).c_str()); - - /* - InitDinkPaths(GetBaseAppPath(), "dink", dmoddir); - GameCreate(pBG->GetParent(), 0, "", "Loading " + dmodName); - GameCreate(pMenu->GetParent(), 0, g_dglo.m_savePath + "continue_state.dat"); - Entity *pMenu = DinkQuitGame(); - PopUpCreate(pMenu, "Error loading save state. Probably an older version, sorry.", "", "cancel", "Continue", "", "", true); - */ } } diff --git a/source/Component/CursorComponent.cpp b/source/Component/CursorComponent.cpp index fe39798..c2262bf 100644 --- a/source/Component/CursorComponent.cpp +++ b/source/Component/CursorComponent.cpp @@ -72,7 +72,7 @@ void CursorComponent::OnInput( VariantList *pVList ) - if (IsDesktop() || GetEmulatedPlatformID() == PLATFORM_ID_HTML5) + if (IsDesktop() || (GetEmulatedPlatformID() == PLATFORM_ID_HTML5 && !GetApp()->GetUsingTouchScreen()) ) { //controls for a real mouse @@ -111,12 +111,10 @@ void CursorComponent::OnInput( VariantList *pVList ) } } else - { //controls for a touch screen. Selecting is different - switch (eMessageType(int(pVList->Get(0).GetFloat()))) { case MESSAGE_TYPE_GUI_CLICK_START: diff --git a/source/GUI/AboutMenu.cpp b/source/GUI/AboutMenu.cpp index e491d7f..0ddc09a 100644 --- a/source/GUI/AboutMenu.cpp +++ b/source/GUI/AboutMenu.cpp @@ -192,7 +192,7 @@ void AboutMenuAddScrollContent(Entity *pParent) string msg = - GetAppName()+string("`$ ")+GetApp()->GetVersionString()+" Build "+toString(GetApp()->GetBuild())+"``\nCopyright (c) 1997-2017 Robinson Technologies\n"\ + GetAppName()+string("`$ ")+GetApp()->GetVersionString()+" Build "+toString(GetApp()->GetBuild())+"``\nCopyright (c) 1997-2018 Robinson Technologies\n"\ "\nDink Script Version: `$1.10``\n\n"\ ; @@ -315,40 +315,39 @@ msg += \ //some special links: Entity *pButton; - pButton = CreateTextButtonEntity(pParent, "email", iPhoneMapX(x), y, "Have a suggestion, bug report, or need help? Tap here to email us", true); - pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); - y += pButton->GetVar("size2d")->GetVector2().y; - y += ySpacer; + if (GetApp()->CanDownloadDMODS()) + { + pButton = CreateTextButtonEntity(pParent, "dinknetwork", iPhoneMapX(x), y, "Visit the Dink Network (Dink files, forums and more)", true); + pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); + y += pButton->GetVar("size2d")->GetVector2().y; + y += ySpacer; + } - pButton = CreateTextButtonEntity(pParent, "list", iPhoneMapX(x), y, "Subscribe to the RTsoft Newsletter", true); - pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); - y += pButton->GetVar("size2d")->GetVector2().y; - y += ySpacer; +// +// pButton = CreateTextButtonEntity(pParent, "email", iPhoneMapX(x), y, "Have a suggestion, bug report, or need help? Tap here to email us", true); +// pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); +// y += pButton->GetVar("size2d")->GetVector2().y; +// y += ySpacer; + +// +// pButton = CreateTextButtonEntity(pParent, "list", iPhoneMapX(x), y, "Subscribe to the RTsoft Newsletter", true); +// pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); +// y += pButton->GetVar("size2d")->GetVector2().y; +// y += ySpacer; + pButton = CreateTextButtonEntity(pParent, "twitter", iPhoneMapX(x), y, "Click here for the RTsoft twitter page", true); pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); y += pButton->GetVar("size2d")->GetVector2().y; y += ySpacer; - pButton = CreateTextButtonEntity(pParent, "forums", iPhoneMapX(x), y, "Visit the official RTsoft Dink Forums", true); - pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); - y += pButton->GetVar("size2d")->GetVector2().y; - y += ySpacer; +// +// pButton = CreateTextButtonEntity(pParent, "forums", iPhoneMapX(x), y, "Visit the official RTsoft forums", true); +// pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); +// y += pButton->GetVar("size2d")->GetVector2().y; +// y += ySpacer; - if (GetApp()->CanDownloadDMODS()) - { - - pButton = CreateTextButtonEntity(pParent, "dinknetwork", iPhoneMapX(x), y, "Want to download/make DMODs? Tap here to visit the Dink Network", true); - pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); - y += pButton->GetVar("size2d")->GetVector2().y; - y += ySpacer; - } - - - "\nFound a bug or have a question? Email us at `wsupport@rtsoft.com``.\n"\ - "\nCheck out our other wacky games:\n"; - vTextBoxPos = CL_Vec2f(iPhoneMapX(x),y); msg = "\nIf you like Dink, please check out our other games:\n"; pEnt = CreateTextBoxEntity(pParent, "", vTextBoxPos, vTextBounds, msg); @@ -373,9 +372,9 @@ msg += \ { string adText = "`wDink Smallwood HD for iOS```8 - Love Dink? Then get it on your iPhone and iPad!"; - if (GetEmulatedPlatformID() == PLATFORM_ID_WINDOWS) + if (GetEmulatedPlatformID() == PLATFORM_ID_WINDOWS || GetEmulatedPlatformID() == PLATFORM_ID_HTML5) { - adText = "`wDink Smallwood HD for mobile```8 - Love Dink? Then get it for your iPhone, iPad, or Android device!"; + adText = "`wDink Smallwood HD for mobile```8 - Dink also has free native mobile versions available!"; } AddBlurb(pParent, x, y, "dink_ad", adText); y += iPhoneMapY(blurbSpacingY); @@ -393,9 +392,9 @@ msg += \ vTextBoxPos = CL_Vec2f(iPhoneMapX(x),y); - msg = "`8`$Dink Smallwood HD`` was created by `wSeth A. Robinson`` (code) and `wJustin Martin`` (graphics).\n\n"\ + msg = "`8`$Dink Smallwood HD`` was created by `wSeth A. Robinson`` (code), `wJustin Martin`` (graphics) and includes additional contributions from Dan Walma.\n\n"\ "`8The original `$Dink Smallwood`` was created by `wSeth A. Robinson`` (engine/scripting/music), `wJustin Martin`` (graphics), `wGreg Smith`` (scripting/music), and `wShawn Teal``. It also featured music by `wJoel Bakker`` and `wMitch Brink``."\ - "\n\nSpecial thanks to `wDan Walma`` and the `wdinksmallwood.net`` community for their `$Dink`` improvements."\ + "\n\nSpecial thanks to `wDan Walma`` and the `wdinksmallwood.net`` community for their `$Dink`` creations and support over the years!"\ "\n\n"\ "This product is less buggy thanks to:\n\n`w"\ "Shawn Teal\n"\ diff --git a/source/GUI/EnterURLMenu.cpp b/source/GUI/EnterURLMenu.cpp index 4111caa..f51d4f3 100644 --- a/source/GUI/EnterURLMenu.cpp +++ b/source/GUI/EnterURLMenu.cpp @@ -69,12 +69,12 @@ Entity * EnterURLMenuCreate(Entity *pParentEnt) pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.6f, 0.6f)); vTextAreaPos.y += iPhoneMapY(25); - string msg = "Enter a URL to a .dmod file to download and install. (example: http://rtsoft.com/NewQuest.dmod )"; + string msg = "Enter a URL to a .dmod file to download and install. (example: https://rtsoft.com/NewQuest.dmod )"; switch (GetEmulatedPlatformID()) { case PLATFORM_ID_WINDOWS: - msg = "Enter a URL to a .dmod file to download and install. (example: http://rtsoft.com/NewQuest.dmod ) Use Ctrl-V to paste from the clipboard."; + msg = "Enter a URL to a .dmod file to download and install. (example: https://rtsoft.com/NewQuest.dmod ) Use Ctrl-V to paste from the clipboard."; break; } diff --git a/source/GUI/GameMenu.cpp b/source/GUI/GameMenu.cpp index cbc66a6..4acb1f0 100644 --- a/source/GUI/GameMenu.cpp +++ b/source/GUI/GameMenu.cpp @@ -616,6 +616,15 @@ void BuildControls(float fadeTimeMS) float trans = 0.0f; Entity *pButtonEntity; +#ifdef PLATFORM_HTML5 + if (GetTouchesReceived() > 0) + { + //using a touch screen, go into that mode + GetApp()->SetUsingTouchScreen(true); + } + +#endif + if (GetApp()->GetUsingTouchScreen()) { if (g_dglo.GetActiveView() != DinkGlobals::VIEW_ZOOMED && IsDrawingDinkStatusBar()) diff --git a/source/GUI/PauseMenu.cpp b/source/GUI/PauseMenu.cpp index 6ce892d..2af52d8 100644 --- a/source/GUI/PauseMenu.cpp +++ b/source/GUI/PauseMenu.cpp @@ -229,6 +229,37 @@ void PauseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se } + if (pEntClicked->GetName() == "ExportNormalSave") + { + if (g_lastSaveSlotFileSaved.empty()) + { + PopUpCreate(pMenu, "You haven't used a save machine recently. Go use one and come back!", "", "cancel", "Continue", "", "", true); + return; + } + + string fileName = GetFileNameFromString(g_lastSaveSlotFileSaved); + +#ifdef PLATFORM_HTML5 + HTMLDownloadFileFromFileSystem(g_lastSaveSlotFileSaved, fileName); +#else +#endif + UpdatePauseButtons(pMenu); + PauseEnd(pMenu); + PopUpCreate(pMenu->GetParent(), "Started download of last save slot saved. (" + fileName + ")", "", "cancel", "Continue", "", "", true); + } + + if (pEntClicked->GetName() == "ImportNormalSave") + { +#ifdef PLATFORM_HTML5 + HTMLUploadFileToFileSystem(); +#else + + GetMessageManager()->SendGUIStringEx(MESSAGE_TYPE_HTML5_GOT_UPLOAD, 0, 0, 0, "purpoise_quicksave.dat", 0); +#endif + PauseEnd(pMenu); + + } + if (pEntClicked->GetName() == "ExportQuickSave") { //SaveStateWithExtra(false); @@ -243,6 +274,10 @@ void PauseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se #ifdef PLATFORM_HTML5 HTMLDownloadFileFromFileSystem(DinkGetSavePath() + "quicksave.dat", prepend + "_quicksave.dat"); +#else + + //Fake message for debugging + #endif PauseEnd(pMenu); ShowQuickMessage("Download started"); @@ -255,6 +290,9 @@ void PauseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se #ifdef PLATFORM_HTML5 HTMLUploadFileToFileSystem(); // HTMLDownloadFileFromFileSystem(DinkGetSavePath() + "quicksave.dat", g_dglo.m_dmodGameDir + "_quicksave.dat"); +#else + + GetMessageManager()->SendGUIStringEx(MESSAGE_TYPE_HTML5_GOT_UPLOAD, 0, 0, 0, "purpoise_quicksave.dat", 0); #endif PauseEnd(pMenu); @@ -420,9 +458,9 @@ Entity * PauseMenuCreate(Entity *pParentEnt) pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); //next button -// pButton = CreateTextButtonEntity(pBG, "ExportNormalSave", vEntPos.x, (vEntPos.y + vEntSize.y / 2) + spacer+spacer, "(Export last save slot save)", true); -// SetAlignmentEntity(pButton, ALIGNMENT_DOWN_CENTER); -// pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); + pButton = CreateTextButtonEntity(pBG, "ExportNormalSave", vEntPos.x, (vEntPos.y + vEntSize.y / 2) + spacer+spacer, "(Export save slot to file)", true); + SetAlignmentEntity(pButton, ALIGNMENT_DOWN_CENTER); + pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); } @@ -445,11 +483,13 @@ Entity * PauseMenuCreate(Entity *pParentEnt) pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); SetButtonStyleEntity(pButton, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH); //to get around HTML5 rules on uploading, required because it's only //allowed when initiated by a user click -// -// //next button -// pButton = CreateTextButtonEntity(pBG, "ImportNormalSave", vEntPos.x, (vEntPos.y + vEntSize.y / 2) + spacer + spacer, "(Import save slot file)", true); -// SetAlignmentEntity(pButton, ALIGNMENT_DOWN_CENTER); -// pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); + + //next button + pButton = CreateTextButtonEntity(pBG, "ImportNormalSave", vEntPos.x, (vEntPos.y + vEntSize.y / 2) + spacer + spacer, "(Import save slot file)", true); + SetAlignmentEntity(pButton, ALIGNMENT_DOWN_CENTER); + pButton->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&PauseMenuOnSelect); + SetButtonStyleEntity(pButton, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH); //to get around HTML5 rules on uploading, required because it's only + //allowed when initiated by a user click } diff --git a/source/GUI/PauseMenu.h b/source/GUI/PauseMenu.h index 6eddbd4..82612d0 100644 --- a/source/GUI/PauseMenu.h +++ b/source/GUI/PauseMenu.h @@ -7,4 +7,5 @@ Entity * PauseMenuCreate(Entity *pParentEnt); Entity * DinkQuitGame(); //kills dink and loads the appropriate last menu and returns a pointer to it void PlayMenuMusic(); Entity * DinkRestartGame(); +Entity * DinkQuitGame(); #endif // PauseMenu_h__ \ No newline at end of file diff --git a/source/GUI/PopUpMenu.cpp b/source/GUI/PopUpMenu.cpp index bed0b9f..0200399 100644 --- a/source/GUI/PopUpMenu.cpp +++ b/source/GUI/PopUpMenu.cpp @@ -213,6 +213,11 @@ void PopUpCreate(Entity *pEnt, string msg, string url, string button1Action, str pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER)); pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect); pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself + + if (!url.empty()) + { + SetButtonStyleEntity(pLabel, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH); //to get around HTML5 rules on uploading, required because it's only + } FadeInEntity(pButton, true, 300, 250); if (button2Label.empty()) { @@ -228,6 +233,11 @@ void PopUpCreate(Entity *pEnt, string msg, string url, string button1Action, str pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER)); pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect); pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself + + if (!url.empty()) + { + SetButtonStyleEntity(pLabel, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH); //to get around HTML5 rules on uploading, required because it's only + } FadeInEntity(pButton, true, 300, 350); if (button3Label.empty()) @@ -246,6 +256,11 @@ void PopUpCreate(Entity *pEnt, string msg, string url, string button1Action, str pLabel->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER)); pLabel->GetFunction("OnButtonSelected")->sig_function.connect(&PopUpMenuOnSelect); pLabel->GetVar("url")->Set(url); //just in case we want to know this later, store it in the button itself + + if (!url.empty()) + { + SetButtonStyleEntity(pLabel, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH); //to get around HTML5 rules on uploading, required because it's only + } FadeInEntity(pButton, true, 300, 450); } } diff --git a/source/dink/dink.cpp b/source/dink/dink.cpp index ce399d6..4f0a421 100644 --- a/source/dink/dink.cpp +++ b/source/dink/dink.cpp @@ -34,7 +34,7 @@ DinkGlobals g_dglo; DinkGlobalsStatic g_dglos; //static data, made to write/read from disk int32 g_spriteRank[C_MAX_SPRITES_AT_ONCE]; - +string g_lastSaveSlotFileSaved; int32 C_DINK_MEM_MAX_ALLOWED = (1024*1024*20); int32 C_DINK_TEX_MEM_MAX_ALLOWED = (1024*1024*60); @@ -1016,6 +1016,7 @@ void save_game(int num) CreateDirectoryRecursively(g_dglo.m_savePath, g_dglo.m_gameDir); sprintf(crap, "%ssave%d.dat", g_dglo.m_savePath.c_str(), num); fp = fopen(crap, "wb"); + g_lastSaveSlotFileSaved = crap; if (!fp) { @@ -16843,6 +16844,7 @@ string GetDMODRootPath(string *pDMODNameOutOrNull) void InitDinkPaths(string gamePath, string gameDir, string dmodGameDir) { + g_lastSaveSlotFileSaved = ""; string dmodPath; if (!dmodGameDir.empty()) @@ -16881,6 +16883,8 @@ void InitDinkPaths(string gamePath, string gameDir, string dmodGameDir) bool InitDinkEngine() { + g_lastSaveSlotFileSaved = ""; + OneTimeDinkInit(); finiObjects(); SetDefaultVars(true); @@ -17614,6 +17618,53 @@ bool SaveState(string const &path, bool bSyncSaves) return bOk; //success } +bool GetDMODDirFromState(string const &path, string &dmodDirOut) +{ + LogMsg("Loading %s", path.c_str()); + FILE *fp = fopen(path.c_str(), "rb"); + + if (!fp) + { + LogMsg("Unable to load state, file not found"); + return false; + } + + float version; + LoadFromFile(version, fp); + if (version < SAVE_FORMAT_VERSION) //save_state_version + { + LogMsg("Save state from newer version?!"); + return false; + } + string unused; + + LoadFromFile(dmodDirOut, fp); + LoadFromFile(unused, fp); + + StringReplace("\\", "/", dmodDirOut); + bool bDidRemoveTrailingSlash = false; + + if (dmodDirOut[dmodDirOut.length() - 1] == '/') + { + dmodDirOut = dmodDirOut.substr(0, dmodDirOut.length() - 1); + bDidRemoveTrailingSlash = true; + } + int index = dmodDirOut.find_last_of('/'); + if (index != string::npos) + { + //just grab the last dmod dir part + dmodDirOut = dmodDirOut.substr(index+1, dmodDirOut.length()); + } + + fclose(fp); + + if (bDidRemoveTrailingSlash) + { + //put it back + dmodDirOut += "/"; + } + return true; +} bool LoadState(string const &path, bool bLoadPathsOnly) { @@ -17853,12 +17904,18 @@ void SaveAutoSave() ShowQuickMessage("(Auto-saved)"); }; -void LoadStateWithExtra() +void LoadStateWithExtra(string forcedFileName) { if (!lpDDSBack || g_dglo.m_curLoadState != FINISHED_LOADING) return; //LogMsg("Loading state"); string fName = DinkGetSavePath()+"quicksave.dat"; + + if (!forcedFileName.empty()) + { + fName = forcedFileName; + } + GetAudioManager()->Play("audio/quick_load.wav"); LoadState(fName, false); ShowQuickMessage("State loaded."); diff --git a/source/dink/dink.h b/source/dink/dink.h index 67c7b0d..5f413a6 100644 --- a/source/dink/dink.h +++ b/source/dink/dink.h @@ -732,6 +732,7 @@ enum eDinkGameState }; extern DinkGlobals g_dglo; extern DinkGlobalsStatic g_dglos; //static data, made to write/read from disk +extern string g_lastSaveSlotFileSaved; bool load_game_small(int num, char * line, int *mytime); void InitDinkPaths(string gamePath, string gameDir, string dmodGameDir); @@ -752,6 +753,7 @@ void DinkUnloadUnusedGraphicsByUsageTime(unsigned int timeMS); bool LoadState(string const &path, bool bLoadPathsOnly); bool SaveState(string const &path, bool bSyncSaves = true); +bool GetDMODDirFromState(string const &path, string &dmodDirOut); eDinkGameState GetDinkGameState(); void SetDinkGameState(eDinkGameState state); void DinkModStrength(int mod); @@ -770,7 +772,7 @@ void DinkAddBow(); bool DinkGetSpeedUpMode(); void DinkSetSpeedUpMode(bool bSpeedup); void SaveStateWithExtra(); -void LoadStateWithExtra(); +void LoadStateWithExtra(string forcedFileName=""); void SaveAutoSave(); void DinkOnForeground(); string GetDMODStaticRootPath();