OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GraphicsSystem Class Reference

#include <C4GraphicsSystem.h>

Collaboration diagram for C4GraphicsSystem:
[legend]

Public Member Functions

 C4GraphicsSystem ()
 
 ~C4GraphicsSystem ()
 
void Default ()
 
void Clear ()
 
bool StartDrawing ()
 
void FinishDrawing ()
 
void Execute ()
 
void FlashMessage (const char *szMessage)
 
void FlashMessageOnOff (const char *strWhat, bool fOn)
 
void DeactivateDebugOutput ()
 
bool Init ()
 
bool InitLoaderScreen (const char *szLoaderSpec)
 
void EnableLoaderDrawing ()
 
bool SaveScreenshotKey (bool fSaveAll)
 
bool SaveScreenshot (bool fSaveAll, float fSaveAllZoom)
 
bool DoSaveScreenshot (bool fSaveAll, const char *szFilename, float fSaveAllZoom)
 
void InvalidateBg ()
 
void OverwriteBg ()
 
bool ToggleShow8BitSurface ()
 
bool ToggleShowNetStatus ()
 
bool ToggleShowVertices ()
 
bool ToggleShowAction ()
 
bool ToggleShowHelp ()
 

Public Attributes

std::unique_ptr< C4MessageBoardMessageBoard
 
C4UpperBoard UpperBoard
 
int32_t iRedrawBackground
 
bool ShowHelp
 
bool ShowVertices
 
bool ShowAction
 
bool ShowCommand
 
bool ShowEntrance
 
bool ShowPathfinder
 
bool ShowNetstatus
 
int Show8BitSurface
 
bool ShowLights
 
bool ShowMenuInfo
 
C4LoaderScreenpLoaderScreen
 

Friends

class C4FullScreen
 

Detailed Description

Definition at line 26 of file C4GraphicsSystem.h.

Constructor & Destructor Documentation

C4GraphicsSystem::C4GraphicsSystem ( )

Definition at line 40 of file C4GraphicsSystem.cpp.

References Default().

41 {
42  Default();
43 }

Here is the call graph for this function:

C4GraphicsSystem::~C4GraphicsSystem ( )

Definition at line 45 of file C4GraphicsSystem.cpp.

References Clear().

46 {
47  Clear();
48 }

Here is the call graph for this function:

Member Function Documentation

void C4GraphicsSystem::Clear ( )

Definition at line 56 of file C4GraphicsSystem.cpp.

References C4ViewportList::Clear(), DeactivateDebugOutput(), MessageBoard, pLoaderScreen, and Viewports.

Referenced by C4Game::Clear(), and ~C4GraphicsSystem().

57 {
58  // Clear message board
59  MessageBoard.reset();
60  // clear loader
61  if (pLoaderScreen) { delete pLoaderScreen; pLoaderScreen=nullptr; }
62  // Close viewports
64  // No debug stuff
66 }
C4LoaderScreen * pLoaderScreen
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
std::unique_ptr< C4MessageBoard > MessageBoard

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::DeactivateDebugOutput ( )

Definition at line 308 of file C4GraphicsSystem.cpp.

References Show8BitSurface, ShowAction, ShowCommand, ShowEntrance, ShowLights, ShowMenuInfo, ShowNetstatus, ShowPathfinder, and ShowVertices.

Referenced by Clear(), and C4Game::ToggleDebugMode().

309 {
310  ShowVertices=false;
311  ShowAction=false;
312  ShowCommand=false;
313  ShowEntrance=false;
314  ShowPathfinder=false; // allow pathfinder! - why this??
315  ShowLights=false;
316  Show8BitSurface=0;
317  ShowNetstatus=false;
318  ShowMenuInfo=false;
319 }

Here is the caller graph for this function:

void C4GraphicsSystem::Default ( )

Definition at line 154 of file C4GraphicsSystem.cpp.

References InvalidateBg(), MessageBoard, pLoaderScreen, Show8BitSurface, ShowAction, ShowCommand, ShowEntrance, ShowHelp, ShowLights, ShowMenuInfo, ShowNetstatus, ShowPathfinder, and ShowVertices.

Referenced by C4GraphicsSystem(), and C4Game::Default().

155 {
156  MessageBoard = std::make_unique<C4MessageBoard>();
157  InvalidateBg();
158  ShowVertices=false;
159  ShowAction=false;
160  ShowCommand=false;
161  ShowEntrance=false;
162  ShowPathfinder=false;
163  ShowNetstatus=false;
164  Show8BitSurface=0;
165  ShowLights=false;
166  ShowMenuInfo=false;
167  ShowHelp=false;
168  FlashMessageText[0]=0;
169  FlashMessageTime=0; FlashMessageX=FlashMessageY=0;
170  pLoaderScreen=nullptr;
171 }
C4LoaderScreen * pLoaderScreen
std::unique_ptr< C4MessageBoard > MessageBoard

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::DoSaveScreenshot ( bool  fSaveAll,
const char *  szFilename,
float  fSaveAllZoom 
)

Definition at line 217 of file C4GraphicsSystem.cpp.

References Application, C4Viewport::BorderBottom, C4Viewport::BorderLeft, C4Viewport::BorderRight, C4Viewport::BorderTop, FLOAT_RECT::bottom, C4Viewport::Draw(), C4MusicSystem::Execute(), FullScreen, C4ViewportList::GetFirstViewport(), C4Landscape::GetHeight(), C4Surface::GetPixDw(), C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), C4Landscape::GetSky(), C4Landscape::GetWidth(), C4Surface::Hgt, InvalidateBg(), C4Application::isEditor, Landscape, FLOAT_RECT::left, LoadResStr(), C4Surface::Lock(), Log(), C4Application::MusicSystem, NO_OWNER, C4Surface::PageFlip(), C4Sky::ParX, C4Sky::ParY, C4Viewport::Player, C4Window::pSurface, C4ViewportList::RecalculateViewports(), FLOAT_RECT::right, C4Surface::SavePNG(), CPNGFile::ScheduleSaving(), C4TargetFacet::Set(), C4Viewport::SetOutputSize(), FLOAT_RECT::top, C4Surface::Unlock(), and Viewports.

Referenced by SaveScreenshot().

218 {
219  // Fullscreen only
220  if (Application.isEditor)
221  {
222  Log(LoadResStr("IDS_PRC_SCREENSHOTERROREDITOR"));
223  return false;
224  }
225  // back surface must be present
226  if (!FullScreen.pSurface) return false;
227 
228  // save landscape
229  if (fSaveAll)
230  {
231  // Create full map screenshots at zoom 2x. Fractional zooms (like 1.7x) should work but might cause some trouble at screen borders.
232  float zoom = fSaveAllZoom;
233  // get viewport to draw in
234  C4Viewport *pVP=::Viewports.GetFirstViewport(); if (!pVP) return false;
235  // create image large enough to hold the landscape
236  std::unique_ptr<CPNGFile> png(new CPNGFile());
237  int32_t lWdt = ::Landscape.GetWidth() * zoom, lHgt = ::Landscape.GetHeight() * zoom;
238  if (!png->Create(lWdt, lHgt, false)) return false;
239  // get backbuffer size
240  int32_t bkWdt=C4GUI::GetScreenWdt(), bkHgt=C4GUI::GetScreenHgt();
241  if (!bkWdt || !bkHgt) return false;
242  // facet for blitting
243  C4TargetFacet bkFct;
244  // mark background to be redrawn
245  InvalidateBg();
246  // draw on one big viewport
247  pVP->SetOutputSize(0,0,0,0, bkWdt, bkHgt);
248  // backup and clear sky parallaxity
249  int32_t iParX=::Landscape.GetSky().ParX; ::Landscape.GetSky().ParX=10;
250  int32_t iParY=::Landscape.GetSky().ParY; ::Landscape.GetSky().ParY=10;
251  // backup and clear viewport borders
252  FLOAT_RECT vp_borders = { pVP->BorderLeft, pVP->BorderRight, pVP->BorderTop, pVP->BorderBottom };
253  pVP->BorderLeft = pVP->BorderRight = pVP->BorderTop = pVP->BorderBottom = 0.0f;
254  // temporarily change viewport player
255  int32_t iVpPlr=pVP->Player; pVP->Player=NO_OWNER;
256  // blit all tiles needed
257  for (int32_t iY=0; iY<lHgt; iY+=bkHgt) for (int32_t iX=0; iX<lWdt; iX+=bkWdt)
258  {
259  // get max width/height
260  int32_t bkWdt2=bkWdt,bkHgt2=bkHgt;
261  if (iX+bkWdt2>lWdt) bkWdt2-=iX+bkWdt2-lWdt;
262  if (iY+bkHgt2>lHgt) bkHgt2-=iY+bkHgt2-lHgt;
263  // update facet
264  bkFct.Set(FullScreen.pSurface, 0, 0, ceil(float(bkWdt2)/zoom), ceil(float(bkHgt2)/zoom), iX/zoom, iY/zoom, zoom, 0, 0);
265  // draw there
266  pVP->Draw(bkFct, true, false);
267  // render
269  // get output (locking primary!)
270  if (FullScreen.pSurface->Lock())
271  {
272  // transfer each pixel - slooow...
273  for (int32_t iY2 = 0; iY2 < bkHgt2; ++iY2)
274 #ifndef USE_CONSOLE
275  glReadPixels(0, FullScreen.pSurface->Hgt - iY2 - 1, bkWdt2, 1, GL_BGR, GL_UNSIGNED_BYTE, reinterpret_cast<BYTE *>(png->GetRow(iY + iY2)) + iX * 3);
276 #else
277  for (int32_t iX2=0; iX2<bkWdt2; ++iX2)
278  png->SetPix(iX+iX2, iY+iY2, FullScreen.pSurface->GetPixDw(iX2, iY2, false));
279 #endif
280  // done; unlock
282  // This can take a long time and we would like to pump messages
283  // However, we're currently hogging the primary surface and horrible things might happen if we do that, including initiation of another screenshot
284  // The only thing that can be safely run is music (sound could play but that would just make them out of sync of the game)
286  }
287  }
288  // restore viewport player
289  pVP->Player=iVpPlr;
290  // restore viewport borders
291  pVP->BorderLeft = vp_borders.left;
292  pVP->BorderTop = vp_borders.top;
293  pVP->BorderRight = vp_borders.right;
294  pVP->BorderBottom = vp_borders.bottom;
295  // restore parallaxity
296  ::Landscape.GetSky().ParX=iParX;
297  ::Landscape.GetSky().ParY=iParY;
298  // restore viewport size
300  // save!
301  CPNGFile::ScheduleSaving(png.release(), szFilename);
302  return true;
303  }
304  // Save primary surface in background thread
305  return FullScreen.pSurface->SavePNG(szFilename, false, false, true);
306 }
void Execute(bool force_buffer_checks=false)
void Draw(C4TargetFacet &cgo, bool fDrawGame, bool fDrawOverlay)
Definition: C4Viewport.cpp:200
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
float bottom
Definition: C4Rect.h:25
float right
Definition: C4Rect.h:25
void RecalculateViewports()
Definition: C4Viewport.cpp:989
bool Lock()
Definition: C4Surface.cpp:453
float left
Definition: C4Rect.h:25
bool SavePNG(C4Group &hGroup, const char *szFilename, bool fSaveAlpha=true, bool fSaveOverlayOnly=false)
C4Surface * pSurface
Definition: C4Window.h:275
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
bool Unlock()
Definition: C4Surface.cpp:464
int32_t GetScreenWdt()
Definition: C4Gui.h:2821
static void ScheduleSaving(CPNGFile *png, const char *filename)
Definition: StdPNG.cpp:352
int Hgt
Definition: C4Surface.h:65
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool PageFlip(C4Rect *pSrcRt=nullptr, C4Rect *pDstRt=nullptr)
Definition: C4Surface.cpp:310
C4Landscape Landscape
void Set(const C4Facet &cpy)
Definition: C4Facet.h:182
class C4Sky & GetSky()
const int NO_OWNER
Definition: C4Constants.h:137
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:491
int32_t GetScreenHgt()
Definition: C4Gui.h:2822
int32_t ParX
Definition: C4Sky.h:57
int32_t GetHeight() const
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
float BorderBottom
Definition: C4Viewport.h:38
int32_t ParY
Definition: C4Sky.h:57
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
float BorderTop
Definition: C4Viewport.h:38
int32_t Player
Definition: C4Viewport.h:105
void SetOutputSize(int32_t iDrawX, int32_t iDrawY, int32_t iOutX, int32_t iOutY, int32_t iOutWdt, int32_t iOutHgt)
Definition: C4Viewport.cpp:778
C4Application Application
Definition: C4Globals.cpp:44
float top
Definition: C4Rect.h:25
int32_t GetWidth() const
float BorderRight
Definition: C4Viewport.h:38
float BorderLeft
Definition: C4Viewport.h:38
C4MusicSystem MusicSystem
Definition: C4Application.h:41

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::EnableLoaderDrawing ( )

Definition at line 191 of file C4GraphicsSystem.cpp.

References pLoaderScreen, and C4LoaderScreen::SetBlackScreen().

Referenced by C4Startup::DoStartup().

192 {
193  // reset black screen loader flag
195 }
C4LoaderScreen * pLoaderScreen
void SetBlackScreen(bool fIsBlack)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::Execute ( )

Definition at line 88 of file C4GraphicsSystem.cpp.

References Application, C4UpperBoard::Execute(), C4ViewportList::Execute(), FinishDrawing(), Game, C4GUI::Screen::HasFullscreenDialog(), iRedrawBackground, C4GUI::IsActive(), C4Application::isEditor, C4Network2::isLobbyActive(), C4Game::IsRunning, MessageBoard, Network, Objects, pGUI, C4GUI::Screen::Render(), C4GameObjects::ResetAudibility(), C4GUI::Screen::SetMouseInGUI(), StartDrawing(), UpperBoard, and Viewports.

Referenced by C4MessageBoard::EnsureLastMessage(), C4Console::Execute(), FullScreenWinProc(), C4FullScreen::PerformUpdate(), and ViewportWinProc().

89 {
90  // activity check
91  if (!StartDrawing()) return;
92 
93  bool fBGDrawn = false;
94 
95  // If lobby running, message board only (page flip done by startup message board)
96  if (!::pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
97  if (::Network.isLobbyActive() || !Game.IsRunning)
98  if (!Application.isEditor)
99  {
100  // Message board
101  if (iRedrawBackground) ClearFullscreenBackground();
102  MessageBoard->Execute();
103  if (!C4GUI::IsActive())
104  { FinishDrawing(); return; }
105  fBGDrawn = true;
106  }
107 
108  // fullscreen GUI?
110  {
111  if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
112  ::pGUI->Render(!fBGDrawn);
113  FinishDrawing();
114  return;
115  }
116 
117 
118  // Reset object audibility
120 
121  // some hack to ensure the mouse is drawn after a dialog close and before any
122  // movement messages
123  if (!C4GUI::IsActive())
124  ::pGUI->SetMouseInGUI(false, false);
125 
126  // Viewports
129 
130  if (!Application.isEditor)
131  {
132  // Upper board
134 
135  // Message board
136  MessageBoard->Execute();
137 
138  // Help & Messages
139  DrawHelp();
140  DrawHoldMessages();
141  DrawFlashMessage();
142  }
143 
144  // InGame-GUI
145  if (C4GUI::IsActive())
146  {
147  ::pGUI->Render(false);
148  }
149 
150  // done
151  FinishDrawing();
152 }
bool IsRunning
Definition: C4Game.h:140
C4Game Game
Definition: C4Globals.cpp:52
bool isLobbyActive() const
Definition: C4Network2.h:204
void ResetAudibility()
C4UpperBoard UpperBoard
bool IsActive()
Definition: C4Gui.h:2817
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
C4Network2 Network
Definition: C4Globals.cpp:53
bool HasFullscreenDialog(bool fIncludeFading)
Definition: C4Gui.cpp:1032
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
void Render(bool fDoBG)
Definition: C4Gui.cpp:730
std::unique_ptr< C4MessageBoard > MessageBoard
void Execute(bool DrawBackground)
Definition: C4Viewport.cpp:860
void SetMouseInGUI(bool fInGUI, bool fByMouse)
Definition: C4Gui.cpp:824
C4Application Application
Definition: C4Globals.cpp:44
C4GameObjects Objects
Definition: C4Globals.cpp:48

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::FinishDrawing ( )

Definition at line 82 of file C4GraphicsSystem.cpp.

References Application, FullScreen, C4Application::isEditor, C4TimeMilliseconds::Now(), C4Surface::PageFlip(), and C4Window::pSurface.

Referenced by Execute().

83 {
85  lastFrame = C4TimeMilliseconds::Now();
86 }
C4Surface * pSurface
Definition: C4Window.h:275
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
bool PageFlip(C4Rect *pSrcRt=nullptr, C4Rect *pDstRt=nullptr)
Definition: C4Surface.cpp:310
C4Application Application
Definition: C4Globals.cpp:44
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::FlashMessage ( const char *  szMessage)

Definition at line 333 of file C4GraphicsSystem.cpp.

References C4MaxTitle, C4UpperBoardHeight, Config, C4ViewportList::GetViewportCount(), C4Config::Graphics, InvalidateBg(), SCopy(), SLen(), C4ConfigGraphics::UpperBoard, and Viewports.

Referenced by C4Network2::AllowJoin(), C4GameControlNetwork::CalcPerformance(), FlashMessageOnOff(), C4Viewport::Init(), C4Game::QuickSave(), C4Game::SlowDown(), C4Game::SpeedUp(), C4Game::ToggleDebugMode(), ToggleShow8BitSurface(), ToggleShowAction(), ToggleShowVertices(), and C4FullScreen::ViewportCheck().

334 {
335  // Store message
336  SCopy(szMessage, FlashMessageText, C4MaxTitle);
337  // Calculate message time
338  FlashMessageTime = SLen(FlashMessageText) * 2;
339  // Initial position
340  FlashMessageX = -1;
341  FlashMessageY = 10;
342  // Upper board active: stay below upper board
344  FlashMessageY += C4UpperBoardHeight;
345  // More than one viewport: try to stay below portraits etc.
346  if (::Viewports.GetViewportCount() > 1)
347  FlashMessageY += 64;
348  // New flash message: redraw background (might be drawing one message on top of another)
349  InvalidateBg();
350 }
C4Config Config
Definition: C4Config.cpp:833
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
const size_t C4MaxTitle
Definition: C4Constants.h:25
const int C4UpperBoardHeight
Definition: C4Constants.h:59
size_t SLen(const char *sptr)
Definition: Standard.h:74
int32_t UpperBoard
Definition: C4Config.h:101
C4ConfigGraphics Graphics
Definition: C4Config.h:253
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
int32_t GetViewportCount()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::FlashMessageOnOff ( const char *  strWhat,
bool  fOn 
)

Definition at line 352 of file C4GraphicsSystem.cpp.

References FlashMessage(), StdStrBuf::Format(), StdStrBuf::getData(), and LoadResStr().

Referenced by C4Game::ToggleDebugMode(), C4MusicSystem::ToggleOnOff(), ToggleShowAction(), and ToggleShowVertices().

353 {
354  StdStrBuf strMessage;
355  strMessage.Format("%s: %s", strWhat, LoadResStr(fOn ? "IDS_CTL_ON" : "IDS_CTL_OFF"));
356  FlashMessage(strMessage.getData());
357 }
const char * getData() const
Definition: StdBuf.h:442
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void FlashMessage(const char *szMessage)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::Init ( )

Definition at line 50 of file C4GraphicsSystem.cpp.

Referenced by C4Game::PreInit().

51 {
52  // Success
53  return true;
54 }

Here is the caller graph for this function:

bool C4GraphicsSystem::InitLoaderScreen ( const char *  szLoaderSpec)

Definition at line 179 of file C4GraphicsSystem.cpp.

References C4LoaderScreen::Init(), pLoaderScreen, and C4LoaderScreen::SetBlackScreen().

Referenced by C4Game::Init(), and C4Application::PreInit().

180 {
181  // create new loader; overwrite current only if successful
182  C4LoaderScreen *pNewLoader = new C4LoaderScreen();
183  pNewLoader->SetBlackScreen(false);
184  if (!pNewLoader->Init(szLoaderSpec)) { delete pNewLoader; return false; }
185  if (pLoaderScreen) delete pLoaderScreen;
186  pLoaderScreen = pNewLoader;
187  // done, success
188  return true;
189 }
bool Init(std::string szLoaderSpec)
C4LoaderScreen * pLoaderScreen
void SetBlackScreen(bool fIsBlack)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsSystem::InvalidateBg ( )
inline

Definition at line 59 of file C4GraphicsSystem.h.

Referenced by C4GUI::Screen::CloseDialog(), Default(), DoSaveScreenshot(), C4GUI::Screen::DrawToolTip(), C4GUI::Screen::ElementPosChanged(), FlashMessage(), FullScreenWinProc(), C4Game::Init(), OverwriteBg(), C4ViewportList::RecalculateViewports(), and ToggleShowHelp().

59 { iRedrawBackground=2; }

Here is the caller graph for this function:

void C4GraphicsSystem::OverwriteBg ( )
inline

Definition at line 60 of file C4GraphicsSystem.h.

References InvalidateBg().

Referenced by C4MessageBoard::Draw().

60 { InvalidateBg(); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::SaveScreenshot ( bool  fSaveAll,
float  fSaveAllZoom 
)

Definition at line 197 of file C4GraphicsSystem.cpp.

References _MAX_PATH, C4Config::AtScreenshotPath(), C4Config::AtUserDataRelativePath(), Config, DoSaveScreenshot(), FileExists(), LoadResStr(), LogF(), and sprintf.

Referenced by C4MessageInput::ProcessCommand(), and SaveScreenshotKey().

198 {
199  // Find a unique screenshot filename by iterating over all possible names
200  // Keep static counter so multiple screenshots in succession do not use same filename even if the background thread hasn't started writing the file yet
201  char szFilename[_MAX_PATH+1];
202  static int32_t iScreenshotIndex=1;
203  const char *strFilePath = nullptr;
204  do
205  sprintf(szFilename,"Screenshot%03i.png",iScreenshotIndex++);
206  while (FileExists(strFilePath = Config.AtScreenshotPath(szFilename)));
207  bool fSuccess=DoSaveScreenshot(fSaveAll, strFilePath, fSaveAllZoom);
208  // log if successful/where it has been stored
209  if (!fSuccess)
210  LogF(LoadResStr("IDS_PRC_SCREENSHOTERROR"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
211  else
212  LogF(LoadResStr("IDS_PRC_SCREENSHOT"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
213  // return success
214  return !!fSuccess;
215 }
C4Config Config
Definition: C4Config.cpp:833
#define sprintf
Definition: Standard.h:164
const char * AtUserDataRelativePath(const char *szFilename)
Definition: C4Config.cpp:644
bool DoSaveScreenshot(bool fSaveAll, const char *szFilename, float fSaveAllZoom)
#define _MAX_PATH
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool FileExists(const char *szFileName)
const char * AtScreenshotPath(const char *szFilename)
Definition: C4Config.cpp:555
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:260

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::SaveScreenshotKey ( bool  fSaveAll)
inline

Definition at line 56 of file C4GraphicsSystem.h.

References SaveScreenshot().

Referenced by C4Game::InitKeyboard(), C4AppDelegate::makeScreenshot:, and C4AppDelegate::makeScreenshotOfWholeMap:.

56 { return SaveScreenshot(fSaveAll, 2.0f); } // keyboard callback for creating screenshot. create at default zoom.
bool SaveScreenshot(bool fSaveAll, float fSaveAllZoom)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::StartDrawing ( )

Definition at line 68 of file C4GraphicsSystem.cpp.

References C4AbstractApp::Active, C4Draw::Active, Application, C4TimeMilliseconds::Now(), and pDraw.

Referenced by Execute().

69 {
70  // only if ddraw is ready
71  if (!pDraw) return false;
72  if (!pDraw->Active) return false;
73 
74  // if the window is not focused, draw no more than MAX_BACKGROUND_FPS frames per second
75  if (!Application.Active && (C4TimeMilliseconds::Now() - lastFrame) < 1000 / MAX_BACKGROUND_FPS)
76  return false;
77 
78  // drawing OK
79  return true;
80 }
bool Active
Definition: C4Draw.h:96
bool Active
Definition: C4App.h:63
C4Draw * pDraw
Definition: C4Draw.cpp:42
C4Application Application
Definition: C4Globals.cpp:44
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShow8BitSurface ( )

Definition at line 450 of file C4GraphicsSystem.cpp.

References C4Window::Active, Console, C4Game::DebugMode, FlashMessage(), Game, LoadResStr(), and Show8BitSurface.

Referenced by C4Game::InitKeyboard().

451 {
452  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
453  Show8BitSurface = (Show8BitSurface + 1) % 3;
454  if (Show8BitSurface == 0)
455  FlashMessage("Default view");
456  else if (Show8BitSurface == 1)
457  FlashMessage("Foreground 8-bit landscape");
458  else if (Show8BitSurface == 2)
459  FlashMessage("Background 8-bit landscape");
460  return true;
461 }
C4Console Console
Definition: C4Globals.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void FlashMessage(const char *szMessage)
bool Active
Definition: C4Window.h:274
bool DebugMode
Definition: C4Game.h:145

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowAction ( )

Definition at line 432 of file C4GraphicsSystem.cpp.

References C4Window::Active, Console, C4Game::DebugMode, FlashMessage(), FlashMessageOnOff(), Game, LoadResStr(), ShowAction, ShowCommand, ShowLights, ShowMenuInfo, and ShowPathfinder.

Referenced by C4Game::InitKeyboard().

433 {
434  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
436  { ShowAction = true; FlashMessage("Actions"); }
437  else if (ShowAction)
438  { ShowAction = false; ShowCommand = true; FlashMessage("Commands"); }
439  else if (ShowCommand)
440  { ShowCommand = false; ShowPathfinder = true; FlashMessage("Pathfinder"); }
441  else if (ShowPathfinder)
442  { ShowPathfinder = false; ShowLights = true; FlashMessage("Lights"); }
443  else if (ShowLights)
444  { ShowLights = false; ShowMenuInfo = true; FlashMessage("Menu Info"); }
445  else if (ShowMenuInfo)
446  { ShowMenuInfo = false; FlashMessageOnOff("Actions/Commands/Pathfinder/Lights/Menus", false); }
447  return true;
448 }
C4Console Console
Definition: C4Globals.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
void FlashMessageOnOff(const char *strWhat, bool fOn)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void FlashMessage(const char *szMessage)
bool Active
Definition: C4Window.h:274
bool DebugMode
Definition: C4Game.h:145

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowHelp ( )

Definition at line 463 of file C4GraphicsSystem.cpp.

References InvalidateBg(), and ShowHelp.

Referenced by C4Game::InitKeyboard().

464 {
465  ShowHelp = !ShowHelp;
466  // Turned off? Invalidate background.
467  if (!ShowHelp) InvalidateBg();
468  return true;
469 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowNetStatus ( )

Definition at line 417 of file C4GraphicsSystem.cpp.

References ShowNetstatus.

Referenced by C4Game::InitKeyboard().

418 {
420  return true;
421 }

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowVertices ( )

Definition at line 423 of file C4GraphicsSystem.cpp.

References C4Window::Active, Console, C4Game::DebugMode, FlashMessage(), FlashMessageOnOff(), Game, LoadResStr(), ShowEntrance, and ShowVertices.

Referenced by C4Game::InitKeyboard().

424 {
425  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
427  ShowEntrance = !ShowEntrance; // vertices and entrance now toggled together
428  FlashMessageOnOff("Entrance+Vertices", ShowVertices || ShowEntrance);
429  return true;
430 }
C4Console Console
Definition: C4Globals.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
void FlashMessageOnOff(const char *strWhat, bool fOn)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void FlashMessage(const char *szMessage)
bool Active
Definition: C4Window.h:274
bool DebugMode
Definition: C4Game.h:145

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4FullScreen
friend

Definition at line 78 of file C4GraphicsSystem.h.

Member Data Documentation

int32_t C4GraphicsSystem::iRedrawBackground

Definition at line 33 of file C4GraphicsSystem.h.

Referenced by Execute().

int C4GraphicsSystem::Show8BitSurface
bool C4GraphicsSystem::ShowAction
bool C4GraphicsSystem::ShowCommand
bool C4GraphicsSystem::ShowEntrance
bool C4GraphicsSystem::ShowHelp

Definition at line 34 of file C4GraphicsSystem.h.

Referenced by Default(), and ToggleShowHelp().

bool C4GraphicsSystem::ShowLights
bool C4GraphicsSystem::ShowMenuInfo
bool C4GraphicsSystem::ShowNetstatus
bool C4GraphicsSystem::ShowPathfinder
bool C4GraphicsSystem::ShowVertices
C4UpperBoard C4GraphicsSystem::UpperBoard

Definition at line 32 of file C4GraphicsSystem.h.

Referenced by Execute(), and C4Game::InitFullscreenComponents().


The documentation for this class was generated from the following files: