diff --git a/src/blupi.cxx b/src/blupi.cxx index 17e4a74..8c986b5 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -404,7 +404,9 @@ HandleEvent (const SDL_Event & event) case SDL_RENDER_DEVICE_RESET: case SDL_RENDER_TARGETS_RESET: + g_pDecor->InvalidateGrounds (); g_pPixmap->ReloadTargetTextures (); + g_pEvent->LoadBackground (); break; case SDL_USEREVENT: diff --git a/src/decor.cxx b/src/decor.cxx index 2c09017..42be5f3 100644 --- a/src/decor.cxx +++ b/src/decor.cxx @@ -3499,3 +3499,9 @@ CDecor::IsUndo () { return (m_pUndoDecor != nullptr); } + +void +CDecor::InvalidateGrounds () +{ + m_bGroundRedraw = true; +} \ No newline at end of file diff --git a/src/decor.h b/src/decor.h index 98d2231..8011066 100644 --- a/src/decor.h +++ b/src/decor.h @@ -461,6 +461,8 @@ public: void UndoBack (); bool IsUndo (); + void InvalidateGrounds (); + protected: bool GetSeeBits (Point cel, char * pBits, Sint32 index); Sint32 GetSeeIcon (char * pBits, Sint32 index); diff --git a/src/event.cxx b/src/event.cxx index 8babb37..618c424 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -3259,6 +3259,44 @@ CEvent::GetMusicLocation (Sint32 music) return absolute; } +bool +CEvent::LoadBackground () +{ + Point totalDim, iconDim; + std::string filename; + auto backWideName = table[m_index].backWideName; + + filename = table[m_index].backName; + if (filename.find ("%.3d") != std::string::npos) + { + auto id = GetImageWorld (); + filename = string_format (table[m_index].backName, id); + + if (table[m_index].phase == EV_PHASE_LASTWIN) + { + switch (id) + { + case 0: + backWideName = "image/back-disco.png"; + break; + case 1: + backWideName = "image/back-stars.png"; + break; + case 2: + backWideName = "image/back-win.png"; + break; + } + } + } + + totalDim.x = LXLOGIC (); + totalDim.y = LYLOGIC (); + iconDim.x = 0; + iconDim.y = 0; + return m_pPixmap->Cache ( + CHBACK, filename, totalDim, iconDim, table[m_index].mode, backWideName); +} + /** * \brief Change the phase. * @@ -3268,12 +3306,10 @@ CEvent::GetMusicLocation (Sint32 music) bool CEvent::ChangePhase (Uint32 phase) { - Sint32 index, world, time, total, music, i, max; - Point totalDim, iconDim; - std::string filename; - char * pButtonExist; - bool bEnable, bHide; - Term * pTerm; + Sint32 index, world, time, total, music, i, max; + char * pButtonExist; + bool bEnable, bHide; + Term * pTerm; if ( phase != EV_PHASE_SETUPp && phase != EV_PHASE_WRITEp && @@ -3336,37 +3372,7 @@ CEvent::ChangePhase (Uint32 phase) m_phase = phase; // change phase m_index = index; - auto backWideName = table[m_index].backWideName; - - filename = table[m_index].backName; - if (filename.find ("%.3d") != std::string::npos) - { - auto id = GetImageWorld (); - filename = string_format (table[m_index].backName, id); - - if (table[m_index].phase == EV_PHASE_LASTWIN) - { - switch (id) - { - case 0: - backWideName = "image/back-disco.png"; - break; - case 1: - backWideName = "image/back-stars.png"; - break; - case 2: - backWideName = "image/back-win.png"; - break; - } - } - } - - totalDim.x = LXLOGIC (); - totalDim.y = LYLOGIC (); - iconDim.x = 0; - iconDim.y = 0; - if (!m_pPixmap->Cache ( - CHBACK, filename, totalDim, iconDim, table[m_index].mode, backWideName)) + if (!this->LoadBackground ()) { WaitMouse (false); m_tryInsertCount = 40; diff --git a/src/event.h b/src/event.h index b6e5c83..63ca037 100644 --- a/src/event.h +++ b/src/event.h @@ -105,6 +105,7 @@ public: bool IsHelpHide (); bool IsBaseMusicAvailable (Sint32 music, const std::string & format); std::string GetMusicLocation (Sint32 music); + bool LoadBackground (); bool ChangePhase (Uint32 phase); bool MovieToStart (); Uint32 GetPhase ();