From 59d4b5754c238d53200f5b5be24d54f4e1e6833f Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 23 Sep 2017 11:52:16 +0000 Subject: [PATCH] * Dink now continues to download and install dmods when in the background, but everywhere else pauses automatically * After installing a dmod, you can now choose to play it now or go back to the browse dmod list * DMOD data downloaded from dink network is now cached for that session (it's not going to change so quickly, so why stress DN.com if we don't have to) * (Bugfix) "installing ..." text message is no longer truncated in a weird way sometimes * (Bugfix) Fixed another issue where a base graphic could fill in with a missing .bmp in a sequence when it shouldn't git-svn-id: svn://rtsoft.com/rtsvn/projects/RTDink@1505 353e56fe-9613-0410-8469-b96ad8e6f29c --- script/win_installer/readme.txt | 11 +++++ source/App.cpp | 4 +- source/GUI/BrowseMenu.cpp | 12 ++++- source/GUI/DMODInstallMenu.cpp | 69 ++++++++++++++++++++++++--- source/dink/FFReader.cpp | 56 ++++++++++++++-------- source/dink/FFReader.h | 2 +- source/dink/dink.cpp | 57 +++++++++++++++------- source/dink/dink.h | 2 +- windows_vs2017/winRTDink.vcxproj.user | 2 +- 9 files changed, 166 insertions(+), 49 deletions(-) diff --git a/script/win_installer/readme.txt b/script/win_installer/readme.txt index 358e3b0..ce16545 100644 --- a/script/win_installer/readme.txt +++ b/script/win_installer/readme.txt @@ -180,7 +180,18 @@ first so it should be ok anyway) * (Bugfix) dmod installer no longer chokes on zero byte files (I'm looking at you, 9gems) * (Bugfix) Fixed memory leak and possible crash related to script loading * (Bugfix) Fixed issue with the checkerboard shadow processing where the 8 bit RLE decoder failed because it was expecting an 8 bit target (most bmps don't use RLE, but Alliance does in places) +* (Bugfix) Fixed issue with loading certain 16 bit bmps incorrectly, fixed tilted text in Infinidink * Went ahead and decided to accept 252,252,252 as alpha if it's index 255 on an 8bit sprite. This fixed the white background issue with Alliance dmod as well as Dinkcraft * FEATURE: Can now download all DMODs from Dink Network directly from inside the game via Dan's php interface. Can sort by rating, latest update date, or alphabetically +- Note: Just to be safe, save state version has changed, so old save states won't load + +------ Change log for 1.7.9 ---------- + +* Dink now continues to download and install dmods when in the background, but everywhere else pauses automatically +* After installing a dmod, you can now choose to play it now or go back to the browse dmod list +* DMOD data downloaded from dink network is now cached for that session (it's not going to change so quickly, so why stress DN.com if we don't have to) +* (Bugfix) "installing ..." text message is no longer truncated in a weird way sometimes +* (Bugfix) Fixed another issue where a base graphic could fill in with a missing .bmp in a sequence when it shouldn't + - Note: Just to be safe, save state version has changed, so old save states won't load \ No newline at end of file diff --git a/source/App.cpp b/source/App.cpp index 1a547f8..9cde167 100644 --- a/source/App.cpp +++ b/source/App.cpp @@ -182,8 +182,8 @@ App::App() m_bDidPostInit = false; m_bHasDMODSupport = true; //for mobiles - m_version = 1.78f; - m_versionString = "V1.7.8"; + m_version = 1.79f; + m_versionString = "V1.7.9"; m_build = 1; m_bCheatsEnabled = false; diff --git a/source/GUI/BrowseMenu.cpp b/source/GUI/BrowseMenu.cpp index cc95b90..12cac90 100644 --- a/source/GUI/BrowseMenu.cpp +++ b/source/GUI/BrowseMenu.cpp @@ -473,8 +473,18 @@ void BrowseOnPostIntroTransition(VariantList *pVList) Entity *pBG = pVList->Get(0).GetEntity(); - DownloadDMODList(pBG); + //fresh download or use cached data? + if (g_dmodData.empty()) + { + DownloadDMODList(pBG); + } + else + { + //use what we got + BrowseMenuAddScrollContent(pBG, NULL); + } + //CreateQuickTipFirstTimeOnly(pBG, "interface/iphone/quicktip_dmod.rttex", false); } diff --git a/source/GUI/DMODInstallMenu.cpp b/source/GUI/DMODInstallMenu.cpp index 85a30eb..d4f9aa1 100644 --- a/source/GUI/DMODInstallMenu.cpp +++ b/source/GUI/DMODInstallMenu.cpp @@ -11,6 +11,9 @@ #include "Network/NetHTTP.h" #include "Entity/HTTPComponent.h" +#ifdef WINAPI +extern bool g_bAppCanRunInBackground; +#endif void DMODInstallMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from { @@ -43,6 +46,14 @@ void DMODInstallMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=ent } } + + if (pEntClicked->GetName() == "Abort") + { + //slide it off the screen and then kill the whole menu tree + SlideScreen(pEntClicked->GetParent(), false); + GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); + BrowseMenuCreate(pEntClicked->GetParent()->GetParent()); + } //GetEntityRoot()->PrintTreeAsText(); //useful for Loading } @@ -64,6 +75,10 @@ void DMODInstallUpdateStatus(Entity *pMenu, string msg) void DMODInstallShowMsg(Entity *pMenu, string myMsg, bool bSuccess = false) { +#ifdef WINAPI + g_bAppCanRunInBackground = false; +#endif + Entity *pMsg = pMenu->GetEntityByName("status"); Entity *pLabel = pMenu->GetEntityByName("title_label"); @@ -76,20 +91,48 @@ void DMODInstallShowMsg(Entity *pMenu, string myMsg, bool bSuccess = false) pLabel->GetComponentByName("TextRender")->GetVar("text")->Set("Error!"); } else { - pLabel->GetComponentByName("TextRender")->GetVar("text")->Set("Success!"); + pLabel->GetComponentByName("TextRender")->GetVar("text")->Set("New quest added successfully."); } } + if (pMsg) { - pMsg->RemoveComponentByName("Typer"); // a thing that types stuff pMsg->GetComponentByName("TextRender")->GetVar("text")->Set(myMsg); + if (!pMsg->RemoveComponentByName("Typer")) + { + LogMsg("Failed to remove typer;"); + }; // a thing that types stuff + + } Entity *pSkip = pMenu->GetEntityByName("Back"); - if (pSkip) + if (bSuccess) { - pSkip->GetComponentByName("TextRender")->GetVar("text")->Set("`wContinue"); + if (pSkip) + { + pSkip->GetComponentByName("TextRender")->GetVar("text")->Set("`wPlay it now"); + } + + //also add a button to keep browsing DMODs + float yStart = iPhoneMapY(230); + yStart = GetPos2DEntity(pSkip).y; + CL_Vec2f vPos(iPhoneMapX(300), yStart); + + SetPos2DEntity(pSkip, vPos); + + Entity *pEnt = CreateTextButtonEntity(pMenu, "Abort", iPhoneMapX(100), yStart, "Back", true); + SetAlignmentEntity(pEnt, ALIGNMENT_CENTER); + pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&DMODInstallMenuOnSelect); + } + else + { + if (pSkip) + { + pSkip->GetComponentByName("TextRender")->GetVar("text")->Set("`wContinue"); + } + } } @@ -100,9 +143,17 @@ void DMODSetTitleLabel(Entity *pMenu, string myMsg) Entity *pLabel = pMenu->GetEntityByName("title_label"); if (pLabel) { - //pLabel->RemoveComponentByName("Typer"); // a thing that types stuff + pLabel->RemoveComponentByName("Typer"); // a thing that types stuff pLabel->GetComponentByName("TextRender")->GetVar("text")->Set(myMsg); + + + //just kidding, add typer back + + EntityComponent *pTyper = pLabel->AddComponent(new TyperComponent); + pTyper->GetVar("text")->Set("......."); + pTyper->GetVar("speedMS")->Set(uint32(500)); + } @@ -178,7 +229,7 @@ void OnDMODUnpackFinish(VariantList *pVList) Entity *pMenu = pVList->m_variant[0].GetComponent()->GetParent(); DMODInstallSetProgressBar(1); - DMODInstallShowMsg(pMenu, pMenu->GetVar("originalFileName")->GetString()+" installed. Tap continue.", true); + DMODInstallShowMsg(pMenu, pMenu->GetVar("originalFileName")->GetString()+" installed.", true); RemoveFile(GetDMODRootPath()+"temp.dmod"); RemoveFile("temp.dmod"); @@ -265,6 +316,7 @@ void InitNetStuff(VariantList *pVList) Entity * DMODInstallMenuCreate(Entity *pParentEnt, string dmodURL, string installDirectory, string sourceFileName, bool bFromBrowseMenu, string dmodName) { + Entity *pBG = CreateOverlayEntity(pParentEnt, "DMODInstall", ReplaceWithDeviceNameInFileName("interface/iphone/bkgd_stone.rttex"), 0,0); AddFocusIfNeeded(pBG, true); @@ -309,6 +361,11 @@ Entity * DMODInstallMenuCreate(Entity *pParentEnt, string dmodURL, string instal Entity *pStatus = CreateTextLabelEntity(pBG, "status", x, iPhoneMapY(180), "Initializing..."); SetAlignmentEntity(pStatus, ALIGNMENT_CENTER); +#ifdef WINAPI + g_bAppCanRunInBackground = true; +#endif + + if (bFromBrowseMenu) { Entity *pStatus = CreateTextLabelEntity(pBG, "title", x, iPhoneMapY(30), "-= Installing "+dmodName+" =-"); diff --git a/source/dink/FFReader.cpp b/source/dink/FFReader.cpp index 33e059a..e0e2e16 100644 --- a/source/dink/FFReader.cpp +++ b/source/dink/FFReader.cpp @@ -193,7 +193,7 @@ byte * FFReader::LoadFFIntoMemory(int index, int *pSizeOut) } -byte * FFReader::LoadFileIntoMemory( string const &fName, int *pSizeOut ) +byte * FFReader::LoadFileIntoMemory( string const &fName, int *pSizeOut, const string &fFirstFrame) { #ifdef _DEBUG @@ -202,33 +202,48 @@ byte * FFReader::LoadFileIntoMemory( string const &fName, int *pSizeOut ) int len; byte *pBuff = NULL; + bool bUsingDMODDirOnly = false; + + + if (fFirstFrame != fName && !m_dmodGamePath.empty()) + { + //what if load part of a sequence from the DMOD dir, but part from the DInk dir? That would be bad + if (FileExists(m_dmodGamePath + m_basePath + fFirstFrame)) + { + bUsingDMODDirOnly = true; + } + } + if (m_fp) { if (m_bUsingBaseDinkFF && !m_dmodGamePath.empty()) { //you know what? Let's do a last minute try in the dmod dir as well. - if (FileExists(m_dmodGamePath+m_dmodBasePath+fName)) + if (FileExists(m_dmodGamePath + m_dmodBasePath + fName)) { //pBuff = LoadFileIntoMemoryBasic(m_dmodGamePath+m_basePath+fName, &len, false, false); - pBuff = GetFileManager()->Get(m_dmodGamePath+m_dmodBasePath+fName, &len, false); + pBuff = GetFileManager()->Get(m_dmodGamePath + m_dmodBasePath + fName, &len, false); if (!pBuff) SetError(ERROR_LOW_MEM); return pBuff; } } - - int index = GetFFRecordIndexFromFileName(fName); - - if (index != -1) + if (!bUsingDMODDirOnly) { - //we found it! - return LoadFFIntoMemory(index, pSizeOut); + int index = GetFFRecordIndexFromFileName(fName); + + if (index != -1) + { + //we found it! + return LoadFFIntoMemory(index, pSizeOut); + } } - } else - { - + } + + + if (!m_dmodGamePath.empty()) { @@ -238,15 +253,18 @@ byte * FFReader::LoadFileIntoMemory( string const &fName, int *pSizeOut ) pBuff = GetFileManager()->Get(m_dmodGamePath+m_dmodBasePath+fName, &len,false); if (!pBuff) SetError(ERROR_LOW_MEM); return pBuff; - } } - //pBuff = LoadFileIntoMemoryBasic(m_gamePath+m_basePath+fName, &len, false, false); - pBuff = GetFileManager()->Get(m_gamePath+m_basePath+fName,&len, false); - if (len == UINT_MAX) SetError(ERROR_LOW_MEM); - return pBuff; - } + if (!bUsingDMODDirOnly) + { + //pBuff = LoadFileIntoMemoryBasic(m_gamePath+m_basePath+fName, &len, false, false); + pBuff = GetFileManager()->Get(m_gamePath + m_basePath + fName, &len, false); + if (len == UINT_MAX) SetError(ERROR_LOW_MEM); + return pBuff; + } + return NULL; -} \ No newline at end of file +} + diff --git a/source/dink/FFReader.h b/source/dink/FFReader.h index 98d73a6..523c876 100644 --- a/source/dink/FFReader.h +++ b/source/dink/FFReader.h @@ -35,7 +35,7 @@ public: bool DoesFileExist(const string &fName, const string &fFirstFrame); void Init( const string &gamePath, const string &dmodGamePath, const string &baseDir, bool bUsingDinkPak); - byte * LoadFileIntoMemory(string const &fName, int *pSizeout); //you need to delete [] what this gives you on your own + byte * LoadFileIntoMemory(string const &fName, int *pSizeout, const string &fFirstFrame); //you need to delete [] what this gives you on your own eErrorType GetLastError() {return m_error;} private: diff --git a/source/dink/dink.cpp b/source/dink/dink.cpp index e8efac7..c9956ac 100644 --- a/source/dink/dink.cpp +++ b/source/dink/dink.cpp @@ -16,7 +16,7 @@ bool pre_figure_out(const char *line, int load_seq, bool bLoadSpriteOnly); #define C_DINK_SCREEN_TRANSITION_TIME_MS 400 -const float SAVE_FORMAT_VERSION = 2.6f; +const float SAVE_FORMAT_VERSION = 2.7f; const int C_DINK_FADE_TIME_MS = 300; const float G_TRANSITION_SCALE_TRICK = 1.01f; @@ -1533,7 +1533,7 @@ bool LoadSpriteSingleFrame(string fNameBase, int seq, int oo, int picIndex, eTra fName += toString(oo) + ".bmp"; - byte *pMem = pReader->LoadFileIntoMemory(fName, NULL); + byte *pMem = pReader->LoadFileIntoMemory(fName, NULL, fNameBase + "01.bmp"); if (g_dglos.g_seq[seq].m_spaceAllowed != 0) { @@ -1587,6 +1587,18 @@ bool LoadSpriteSingleFrame(string fNameBase, int seq, int oo, int picIndex, eTra } +#ifdef _DEBUG + if (seq == 181 && oo == 11) + { + LogMsg("hey"); + + } +#endif + if (seq == 181 && oo == 11) + { + //hack for exp divider to be trans + transType = TRANSPARENT_WHITE; + } g_pSpriteSurface[picIndex] = LoadBitmapIntoSurface("", transType, IDirectDrawSurface::MODE_SHADOW_GL, pMem, bUseCheckerboardFix); } @@ -1595,7 +1607,9 @@ bool LoadSpriteSingleFrame(string fNameBase, int seq, int oo, int picIndex, eTra if (oo == 1) { +#ifdef _DEBUG LogMsg("load_sprites: Anim %s not found.", (fName).c_str()); +#endif //assert(0); return false; } @@ -2068,10 +2082,10 @@ bool figure_out(const char *line, int load_seq) int seqID = atol(ev[3]); #ifdef _DEBUG - if (seqID == 453) + if (seqID == 104) { - // LogMsg("Loading sand stuff"); + LogMsg("Loading sand stuff"); } #endif @@ -2645,6 +2659,7 @@ void draw_mlevel(int percent, bool bDraw) void draw_status_all(void) { + g_forceBuildBackgroundFromScratch = true; ClearBitmapCopy(); g_dglos.g_guiStrength = *pstrength; @@ -4283,9 +4298,9 @@ int var_equals(char name[20], char newname[20], char math, int script, char rest } #ifdef _DEBUG - if (string(name) == "&startscreen") + if (string(name) == "&vision") { - // LogMsg("Var!"); + LogMsg("Var!"); } #endif int i = get_var(script, name); @@ -4947,7 +4962,7 @@ int32 change_sprite(int32 h, int32 val, int32 * change) //Msg("Searching sprite %s with val %d. Cur is %d", h, val, *change); if (h >= C_MAX_SPRITES_AT_ONCE) { - LogMsg("Error: Can't use sp_ commands on a sprite after it's connected to sprite 1000, can crash. Ignoring command."); + LogMsg("Error: Can't use sp_ commands on a sprite after it's connected to sprite 1000, can crash. Ignoring command."); return 0; } @@ -5353,11 +5368,10 @@ void changedir( int dir1, int k,int base) } - void update_play_changes( void ) { - for (int j = 1; j < 100; j++) + for (int j = 1; j < C_MAX_SPRITES_AT_ONCE; j++) { if (g_dglos.g_smallMap.sprite[j].active) if (g_dglos.g_playerInfo.spmap[*pmap].type[j] != 0) @@ -5562,7 +5576,7 @@ void place_sprites_game(bool bBackgroundOnly ) highest_sprite = 20000; //more than it could ever be rank[r1] = 0; - for (int h1 = 1; h1 < 100; h1++) + for (int h1 = 1; h1 < C_MAX_SPRITES_AT_ONCE; h1++) { if (bs[h1] == false) { @@ -5593,7 +5607,7 @@ void place_sprites_game(bool bBackgroundOnly ) #ifdef _DEBUG if (g_dglos.g_smallMap.sprite[j].seq == 66) { - LogMsg("Garden"); + //LogMsg("Garden"); //bScaledBackgroundSpritesRequired = true; //continue; } @@ -5711,6 +5725,9 @@ void place_sprites_game(bool bBackgroundOnly ) if (strlen(g_dglos.g_smallMap.sprite[j].script) > 1) { +#ifdef _DEBUG + LogMsg("Sprite %d is requesting that script %s is loaded when the map is drawn, vision is %d", j, g_dglos.g_smallMap.sprite[j].script, *pvision); +#endif g_sprite[sprite].script = load_script(g_dglos.g_smallMap.sprite[j].script, sprite, true); } @@ -7664,8 +7681,6 @@ pass: } - - if (compare(ev[1], (char*)"draw_background")) { g_forceBuildBackgroundFromScratch = true; @@ -7931,7 +7946,7 @@ pass: *pvision = g_nlist[0]; g_scriptInstance[script]->sprite = 1000; fill_whole_hard(); - BuildScreenBackground(); + BuildScreenBackground(true, true); } strcpy(pLineIn, h); @@ -10583,7 +10598,7 @@ void init_scripts(void) { for (int k = 1; k < C_MAX_SCRIPTS; k++) { - if (g_scriptInstance[k] != NULL && g_scriptInstance[k]->sprite != 0 && g_scriptInstance[k]->sprite < 300 && g_sprite[g_scriptInstance[k]->sprite].active ) + if (g_scriptInstance[k] != NULL && g_scriptInstance[k]->sprite != 0 && g_scriptInstance[k]->sprite < C_MAX_SPRITES_AT_ONCE && g_sprite[g_scriptInstance[k]->sprite].active ) { if (locate(k,"main")) { @@ -17303,7 +17318,8 @@ bool LoadState(string const &path, bool bLoadPathsOnly) if ( g_dglos.g_gameMode > 2 || g_dglos.m_bRenderBackgroundOnLoad) { - BuildScreenBackground(false, true); + if (g_sprite[1].brain != 13) + BuildScreenBackground(false, true); } if (g_dglos.g_bShowingBitmap.active) @@ -17604,11 +17620,16 @@ void DinkOnForeground() //reinit any lost surfaces that we need to if ( g_dglos.g_gameMode > 2 || g_dglos.m_bRenderBackgroundOnLoad) { - if (g_dglos.m_bRenderBackgroundOnLoad) + if (g_dglos.m_bRenderBackgroundOnLoad && g_sprite[1].brain != 13) { g_forceBuildBackgroundFromScratch = true; } - BuildScreenBackground(false); + + if (g_sprite[1].brain != 13) + { + //brain 13 means mouse so we probably don't need this. Could be wrong though.. + BuildScreenBackground(false); + } } if (g_dglos.g_bShowingBitmap.active) diff --git a/source/dink/dink.h b/source/dink/dink.h index 9b7f8de..84c1304 100644 --- a/source/dink/dink.h +++ b/source/dink/dink.h @@ -169,7 +169,7 @@ const int C_MAX_SCRIPTS = 400; #else const int32 C_MAX_SEQUENCES = 1300; //Max # of sprite animations const int32 C_MAX_SPRITES = 6000; -const int32 C_MAX_SPRITES_AT_ONCE = 300; +const int32 C_MAX_SPRITES_AT_ONCE = 100; //don't change, there are still hardcoded numbers elsewhere and some weird stuff with screen lock and "flub" stuff whatever that is const int32 C_MAX_SCRIPT_CALLBACKS = 100; const int32 max_vars = 250; diff --git a/windows_vs2017/winRTDink.vcxproj.user b/windows_vs2017/winRTDink.vcxproj.user index 7d0e966..62d05f4 100644 --- a/windows_vs2017/winRTDink.vcxproj.user +++ b/windows_vs2017/winRTDink.vcxproj.user @@ -7,7 +7,7 @@ $(OutDir) WindowsLocalDebugger - -game dmods/alliance + -game dmods/akt2