Hide some things in save screenshots

Save indicator, mouse cursor, CDisplayText and interface particles
master
krzys-h 2015-08-07 15:59:05 +02:00
parent 6d363ba887
commit f90bb63520
9 changed files with 84 additions and 33 deletions

View File

@ -323,6 +323,9 @@ public:
//@} //@}
bool GetSceneTestMode(); bool GetSceneTestMode();
//! Renders the image in window
void Render();
protected: protected:
//! Creates the window's SDL_Surface //! Creates the window's SDL_Surface
@ -336,8 +339,6 @@ protected:
TEST_VIRTUAL Event CreateUpdateEvent(); TEST_VIRTUAL Event CreateUpdateEvent();
//! Logs debug data for event //! Logs debug data for event
void LogEvent(const Event& event); void LogEvent(const Event& event);
//! Renders the image in window
void Render();
//! Opens the joystick device //! Opens the joystick device
bool OpenJoystick(); bool OpenJoystick();

View File

@ -103,6 +103,7 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
m_waterAddColor = Color(0.0f, 0.0f, 0.0f, 0.0f); m_waterAddColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
m_render = true; m_render = true;
m_screenshotMode = false;
m_shadowVisible = true; m_shadowVisible = true;
m_groundSpotVisible = true; m_groundSpotVisible = true;
m_dirty = true; m_dirty = true;
@ -551,6 +552,16 @@ void CEngine::SetRenderEnable(bool enable)
m_render = enable; m_render = enable;
} }
void CEngine::SetScreenshotMode(bool screenshotMode)
{
m_screenshotMode = screenshotMode;
}
bool CEngine::GetScreenshotMode()
{
return m_screenshotMode;
}
Math::IntPoint CEngine::GetWindowSize() Math::IntPoint CEngine::GetWindowSize()
{ {
return m_size; return m_size;
@ -3895,7 +3906,10 @@ void CEngine::DrawInterface()
m_lastState = -1; m_lastState = -1;
SetState(Gfx::ENG_RSTATE_NORMAL); SetState(Gfx::ENG_RSTATE_NORMAL);
m_particle->DrawParticle(SH_INTERFACE); // draws the particles of the interface if (!m_screenshotMode)
{
m_particle->DrawParticle(SH_INTERFACE); // draws the particles of the interface
}
// 3D objects drawn in front of interface // 3D objects drawn in front of interface
if (m_drawFront) if (m_drawFront)

View File

@ -684,6 +684,12 @@ public:
//! Enables/disables rendering //! Enables/disables rendering
void SetRenderEnable(bool enable); void SetRenderEnable(bool enable);
//! Management of "screenshot mode" (disables interface particle rendering)
//@{
void SetScreenshotMode(bool screenshotMode);
bool GetScreenshotMode();
//@}
//! Returns current size of viewport window //! Returns current size of viewport window
Math::IntPoint GetWindowSize(); Math::IntPoint GetWindowSize();
@ -1326,6 +1332,9 @@ protected:
//! Rendering enabled? //! Rendering enabled?
bool m_render; bool m_render;
//! Screenshot mode?
bool m_screenshotMode;
//! Projection matrix for 3D scene //! Projection matrix for 3D scene
Math::Matrix m_matProj; Math::Matrix m_matProj;
//! View matrix for 3D scene //! View matrix for 3D scene

View File

@ -244,7 +244,6 @@ CRobotMain::CRobotMain()
m_autosaveSlots = 3; m_autosaveSlots = 3;
m_autosaveLast = 0.0f; m_autosaveLast = 0.0f;
m_shotDelay = 0;
m_shotSaving = 0; m_shotSaving = 0;
m_cameraPan = 0.0f; m_cameraPan = 0.0f;
@ -2521,15 +2520,6 @@ bool CRobotMain::EventFrame(const Event &event)
} }
} }
if ( m_shotDelay > 0 && !m_ui->GetDialog()->IsDialog() )
{
m_shotDelay --;
if ( m_shotDelay == 0 )
{
m_engine->WriteScreenShot(m_shotName);
}
}
m_water->EventProcess(event); m_water->EventProcess(event);
m_cloud->EventProcess(event); m_cloud->EventProcess(event);
m_lightning->EventProcess(event); m_lightning->EventProcess(event);
@ -2661,7 +2651,7 @@ bool CRobotMain::EventFrame(const Event &event)
{ {
Math::Point pos, dim; Math::Point pos, dim;
if (m_shotSaving == 0) if (m_shotSaving <= 0)
{ {
dim.x = 10.0f/640.0f; dim.x = 10.0f/640.0f;
dim.y = 10.0f/480.0f; dim.y = 10.0f/480.0f;
@ -2746,6 +2736,35 @@ bool CRobotMain::EventFrame(const Event &event)
return true; return true;
} }
void CRobotMain::ShowSaveIndicator(bool show)
{
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_SAVING);
if (pc != nullptr)
{
Math::Point pos, dim;
if (!show)
{
dim.x = 10.0f/640.0f;
dim.y = 10.0f/480.0f;
pos.x = -20.0f/640.0f;
pos.y = -20.0f/480.0f; // invisible!
}
else
{
dim.x = 32.0f/640.0f;
dim.y = 32.0f/480.0f;
pos.x = (640.0f-24.0f)/640.0f;
pos.y = (480.0f-24.0f)/480.0f;
pos.x -= dim.x/2.0f;
pos.y -= dim.y/2.0f;
}
pc->SetPos(pos);
pc->SetDim(dim);
}
}
//! Makes the event for all robots //! Makes the event for all robots
bool CRobotMain::EventObject(const Event &event) bool CRobotMain::EventObject(const Event &event)
{ {
@ -4962,6 +4981,10 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
//! Saves the current game //! Saves the current game
bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot, char *info) bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot, char *info)
{ {
// Render the indicator to show that we are working
ShowSaveIndicator(true);
m_app->Render(); // update
CLevelParser levelParser(filename); CLevelParser levelParser(filename);
CLevelParserLineUPtr line; CLevelParserLineUPtr line;
@ -5083,10 +5106,20 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
CBotClass::SaveStaticState(file); CBotClass::SaveStaticState(file);
fClose(file); fClose(file);
m_shotDelay = 3; ShowSaveIndicator(false); // force hide for screenshot
m_shotName = CResourceManager::GetSaveLocation() + "/" + filescreenshot; //TODO: Use PHYSFS? MouseMode oldMouseMode = m_app->GetMouseMode();
m_app->SetMouseMode(MOUSE_NONE); // disable the mouse
m_displayText->HideText(true); // hide
m_engine->SetScreenshotMode(true);
m_engine->Render(); // update (but don't show, we're not swapping buffers here!)
m_engine->WriteScreenShot(CResourceManager::GetSaveLocation() + "/" + filescreenshot); //TODO: Use PHYSFS?
m_shotSaving++; m_shotSaving++;
m_engine->SetScreenshotMode(false);
m_displayText->HideText(false);
m_app->SetMouseMode(oldMouseMode);
return true; return true;
} }

View File

@ -377,6 +377,8 @@ protected:
bool EventObject(const Event &event); bool EventObject(const Event &event);
void InitEye(); void InitEye();
void ShowSaveIndicator(bool show);
void CreateScene(bool soluce, bool fixScene, bool resetObject); void CreateScene(bool soluce, bool fixScene, bool resetObject);
void ResetCreate(); void ResetCreate();
@ -587,9 +589,7 @@ protected:
int m_autosaveSlots; int m_autosaveSlots;
float m_autosaveLast; float m_autosaveLast;
unsigned int m_shotDelay; int m_shotSaving;
std::string m_shotName;
unsigned int m_shotSaving;
std::deque<CObject*> m_selectionHistory; std::deque<CObject*> m_selectionHistory;
}; };

View File

@ -222,8 +222,11 @@ void CScreenIO::IOWriteScene()
int sel = pl->GetSelect(); int sel = pl->GetSelect();
if ( sel == -1 ) return; if ( sel == -1 ) return;
std::string dir;
pe->GetText(info, 100); pe->GetText(info, 100);
m_interface->DeleteControl(EVENT_WINDOW5);
std::string dir;
if (static_cast<unsigned int>(sel) >= m_saveList.size()) if (static_cast<unsigned int>(sel) >= m_saveList.size())
{ {
dir = m_main->GetPlayerProfile()->GetSaveFile("save"+clearName(info)); dir = m_main->GetPlayerProfile()->GetSaveFile("save"+clearName(info));

View File

@ -153,7 +153,6 @@ bool CScreenIOWrite::EventProcess(const Event &event)
m_main->ChangePhase(PHASE_SIMUL); m_main->ChangePhase(PHASE_SIMUL);
m_main->StopSuspend(); m_main->StopSuspend();
IOWriteScene(); IOWriteScene();
m_interface->DeleteControl(EVENT_WINDOW5);
return false; return false;
} }

View File

@ -31,7 +31,6 @@ namespace Ui
{ {
CScreenLoading::CScreenLoading() CScreenLoading::CScreenLoading()
: m_loadingCounter(0)
{ {
} }
@ -79,18 +78,14 @@ void CScreenLoading::CreateInterface()
pl->SetTextAlign(Gfx::TEXT_ALIGN_CENTER); pl->SetTextAlign(Gfx::TEXT_ALIGN_CENTER);
SetBackground("textures/interface/interface.png"); SetBackground("textures/interface/interface.png");
m_loadingCounter = 1; // enough time to display!
} }
bool CScreenLoading::EventProcess(const Event &event) bool CScreenLoading::EventProcess(const Event &event)
{ {
if ( m_loadingCounter == 0 ) m_app->Render(); // render the frame once before we start loading
{ m_main->ChangePhase(PHASE_SIMUL);
m_main->ChangePhase(PHASE_SIMUL);
} return false;
m_loadingCounter --;
return true;
} }
} // namespace Ui } // namespace Ui

View File

@ -31,9 +31,6 @@ public:
void CreateInterface() override; void CreateInterface() override;
bool EventProcess(const Event &event) override; bool EventProcess(const Event &event) override;
protected:
int m_loadingCounter;
}; };
} // namespace Ui } // namespace Ui