1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Fix textures reload with Direct3D

Closes #71
This commit is contained in:
Mathieu Schroeter 2018-08-29 00:05:29 +02:00
parent d8f144164f
commit 2fa6789764
5 changed files with 54 additions and 37 deletions

View File

@ -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:

View File

@ -3499,3 +3499,9 @@ CDecor::IsUndo ()
{
return (m_pUndoDecor != nullptr);
}
void
CDecor::InvalidateGrounds ()
{
m_bGroundRedraw = true;
}

View File

@ -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);

View File

@ -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;

View File

@ -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 ();