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 28 of file C4GraphicsSystem.h.

Constructor & Destructor Documentation

C4GraphicsSystem::C4GraphicsSystem ( )

Definition at line 41 of file C4GraphicsSystem.cpp.

References Default().

42 {
43  Default();
44 }

Here is the call graph for this function:

C4GraphicsSystem::~C4GraphicsSystem ( )

Definition at line 46 of file C4GraphicsSystem.cpp.

References Clear().

47 {
48  Clear();
49 }

Here is the call graph for this function:

Member Function Documentation

void C4GraphicsSystem::Clear ( )

Definition at line 57 of file C4GraphicsSystem.cpp.

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

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

58 {
59  // Clear message board
60  MessageBoard.reset();
61  // clear loader
62  if (pLoaderScreen) { delete pLoaderScreen; pLoaderScreen=nullptr; }
63  // Close viewports
65  // No debug stuff
67 }
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 305 of file C4GraphicsSystem.cpp.

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

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

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

Here is the caller graph for this function:

void C4GraphicsSystem::Default ( )

Definition at line 155 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().

156 {
157  MessageBoard.reset(new C4MessageBoard);
158  InvalidateBg();
159  ShowVertices=false;
160  ShowAction=false;
161  ShowCommand=false;
162  ShowEntrance=false;
163  ShowPathfinder=false;
164  ShowNetstatus=false;
165  Show8BitSurface=0;
166  ShowLights=false;
167  ShowMenuInfo=false;
168  ShowHelp=false;
169  FlashMessageText[0]=0;
170  FlashMessageTime=0; FlashMessageX=FlashMessageY=0;
171  pLoaderScreen=nullptr;
172 }
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 218 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, C4Surface::Lock(), 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().

219 {
220  // Fullscreen only
221  if (Application.isEditor) return false;
222  // back surface must be present
223  if (!FullScreen.pSurface) return false;
224 
225  // save landscape
226  if (fSaveAll)
227  {
228  // Create full map screenshots at zoom 2x. Fractional zooms (like 1.7x) should work but might cause some trouble at screen borders.
229  float zoom = fSaveAllZoom;
230  // get viewport to draw in
231  C4Viewport *pVP=::Viewports.GetFirstViewport(); if (!pVP) return false;
232  // create image large enough to hold the landscape
233  std::unique_ptr<CPNGFile> png(new CPNGFile());
234  int32_t lWdt = ::Landscape.GetWidth() * zoom, lHgt = ::Landscape.GetHeight() * zoom;
235  if (!png->Create(lWdt, lHgt, false)) return false;
236  // get backbuffer size
237  int32_t bkWdt=C4GUI::GetScreenWdt(), bkHgt=C4GUI::GetScreenHgt();
238  if (!bkWdt || !bkHgt) return false;
239  // facet for blitting
240  C4TargetFacet bkFct;
241  // mark background to be redrawn
242  InvalidateBg();
243  // draw on one big viewport
244  pVP->SetOutputSize(0,0,0,0, bkWdt, bkHgt);
245  // backup and clear sky parallaxity
246  int32_t iParX=::Landscape.GetSky().ParX; ::Landscape.GetSky().ParX=10;
247  int32_t iParY=::Landscape.GetSky().ParY; ::Landscape.GetSky().ParY=10;
248  // backup and clear viewport borders
249  FLOAT_RECT vp_borders = { pVP->BorderLeft, pVP->BorderRight, pVP->BorderTop, pVP->BorderBottom };
250  pVP->BorderLeft = pVP->BorderRight = pVP->BorderTop = pVP->BorderBottom = 0.0f;
251  // temporarily change viewport player
252  int32_t iVpPlr=pVP->Player; pVP->Player=NO_OWNER;
253  // blit all tiles needed
254  for (int32_t iY=0; iY<lHgt; iY+=bkHgt) for (int32_t iX=0; iX<lWdt; iX+=bkWdt)
255  {
256  // get max width/height
257  int32_t bkWdt2=bkWdt,bkHgt2=bkHgt;
258  if (iX+bkWdt2>lWdt) bkWdt2-=iX+bkWdt2-lWdt;
259  if (iY+bkHgt2>lHgt) bkHgt2-=iY+bkHgt2-lHgt;
260  // update facet
261  bkFct.Set(FullScreen.pSurface, 0, 0, ceil(float(bkWdt2)/zoom), ceil(float(bkHgt2)/zoom), iX/zoom, iY/zoom, zoom, 0, 0);
262  // draw there
263  pVP->Draw(bkFct, true, false);
264  // render
266  // get output (locking primary!)
267  if (FullScreen.pSurface->Lock())
268  {
269  // transfer each pixel - slooow...
270  for (int32_t iY2 = 0; iY2 < bkHgt2; ++iY2)
271 #ifndef USE_CONSOLE
272  glReadPixels(0, FullScreen.pSurface->Hgt - iY2 - 1, bkWdt2, 1, GL_BGR, GL_UNSIGNED_BYTE, reinterpret_cast<BYTE *>(png->GetRow(iY + iY2)) + iX * 3);
273 #else
274  for (int32_t iX2=0; iX2<bkWdt2; ++iX2)
275  png->SetPix(iX+iX2, iY+iY2, FullScreen.pSurface->GetPixDw(iX2, iY2, false));
276 #endif
277  // done; unlock
279  // This can take a long time and we would like to pump messages
280  // However, we're currently hogging the primary surface and horrible things might happen if we do that, including initiation of another screenshot
281  // 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)
283  }
284  }
285  // restore viewport player
286  pVP->Player=iVpPlr;
287  // restore viewport borders
288  pVP->BorderLeft = vp_borders.left;
289  pVP->BorderTop = vp_borders.top;
290  pVP->BorderRight = vp_borders.right;
291  pVP->BorderBottom = vp_borders.bottom;
292  // restore parallaxity
293  ::Landscape.GetSky().ParX=iParX;
294  ::Landscape.GetSky().ParY=iParY;
295  // restore viewport size
297  // save!
298  CPNGFile::ScheduleSaving(png.release(), szFilename);
299  return true;
300  }
301  // Save primary surface in background thread
302  return FullScreen.pSurface->SavePNG(szFilename, false, false, true);
303 }
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:27
float right
Definition: C4Rect.h:27
void RecalculateViewports()
Definition: C4Viewport.cpp:992
bool Lock()
Definition: C4Surface.cpp:463
float left
Definition: C4Rect.h:27
bool SavePNG(C4Group &hGroup, const char *szFilename, bool fSaveAlpha=true, bool fSaveOverlayOnly=false)
C4Surface * pSurface
Definition: C4Window.h:279
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
bool Unlock()
Definition: C4Surface.cpp:474
int32_t GetScreenWdt()
Definition: C4Gui.h:2821
static void ScheduleSaving(CPNGFile *png, const char *filename)
Definition: StdPNG.cpp:352
int Hgt
Definition: C4Surface.h:67
bool PageFlip(C4Rect *pSrcRt=nullptr, C4Rect *pDstRt=nullptr)
Definition: C4Surface.cpp:320
C4Landscape Landscape
void Set(const C4Facet &cpy)
Definition: C4Facet.h:184
class C4Sky & GetSky()
const int NO_OWNER
Definition: C4Constants.h:138
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:501
int32_t GetScreenHgt()
Definition: C4Gui.h:2822
int32_t ParX
Definition: C4Sky.h:58
int32_t GetHeight() const
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
float BorderBottom
Definition: C4Viewport.h:38
int32_t ParY
Definition: C4Sky.h:58
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:27
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 192 of file C4GraphicsSystem.cpp.

References pLoaderScreen, and C4LoaderScreen::SetBlackScreen().

Referenced by C4Startup::DoStartup().

193 {
194  // reset black screen loader flag
196 }
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 89 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().

90 {
91  // activity check
92  if (!StartDrawing()) return;
93 
94  bool fBGDrawn = false;
95 
96  // If lobby running, message board only (page flip done by startup message board)
97  if (!::pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
98  if (::Network.isLobbyActive() || !Game.IsRunning)
99  if (!Application.isEditor)
100  {
101  // Message board
102  if (iRedrawBackground) ClearFullscreenBackground();
103  MessageBoard->Execute();
104  if (!C4GUI::IsActive())
105  { FinishDrawing(); return; }
106  fBGDrawn = true;
107  }
108 
109  // fullscreen GUI?
111  {
112  if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
113  ::pGUI->Render(!fBGDrawn);
114  FinishDrawing();
115  return;
116  }
117 
118 
119  // Reset object audibility
121 
122  // some hack to ensure the mouse is drawn after a dialog close and before any
123  // movement messages
124  if (!C4GUI::IsActive())
125  ::pGUI->SetMouseInGUI(false, false);
126 
127  // Viewports
130 
131  if (!Application.isEditor)
132  {
133  // Upper board
135 
136  // Message board
137  MessageBoard->Execute();
138 
139  // Help & Messages
140  DrawHelp();
141  DrawHoldMessages();
142  DrawFlashMessage();
143  }
144 
145  // InGame-GUI
146  if (C4GUI::IsActive())
147  {
148  ::pGUI->Render(false);
149  }
150 
151  // done
152  FinishDrawing();
153 }
bool IsRunning
Definition: C4Game.h:141
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:1194
C4Network2 Network
Definition: C4Globals.cpp:53
bool HasFullscreenDialog(bool fIncludeFading)
Definition: C4Gui.cpp:1035
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
void Render(bool fDoBG)
Definition: C4Gui.cpp:733
std::unique_ptr< C4MessageBoard > MessageBoard
void Execute(bool DrawBackground)
Definition: C4Viewport.cpp:863
void SetMouseInGUI(bool fInGUI, bool fByMouse)
Definition: C4Gui.cpp:827
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 83 of file C4GraphicsSystem.cpp.

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

Referenced by Execute().

84 {
86  lastFrame = C4TimeMilliseconds::Now();
87 }
C4Surface * pSurface
Definition: C4Window.h:279
C4FullScreen FullScreen
Definition: C4Globals.cpp:46
bool PageFlip(C4Rect *pSrcRt=nullptr, C4Rect *pDstRt=nullptr)
Definition: C4Surface.cpp:320
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 330 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().

331 {
332  // Store message
333  SCopy(szMessage, FlashMessageText, C4MaxTitle);
334  // Calculate message time
335  FlashMessageTime = SLen(FlashMessageText) * 2;
336  // Initial position
337  FlashMessageX = -1;
338  FlashMessageY = 10;
339  // Upper board active: stay below upper board
341  FlashMessageY += C4UpperBoardHeight;
342  // More than one viewport: try to stay below portraits etc.
343  if (::Viewports.GetViewportCount() > 1)
344  FlashMessageY += 64;
345  // New flash message: redraw background (might be drawing one message on top of another)
346  InvalidateBg();
347 }
C4Config Config
Definition: C4Config.cpp:831
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const size_t C4MaxTitle
Definition: C4Constants.h:25
const int C4UpperBoardHeight
Definition: C4Constants.h:59
size_t SLen(const char *sptr)
Definition: Standard.h:78
int32_t UpperBoard
Definition: C4Config.h:102
C4ConfigGraphics Graphics
Definition: C4Config.h:254
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 349 of file C4GraphicsSystem.cpp.

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

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

350 {
351  StdStrBuf strMessage;
352  strMessage.Format("%s: %s", strWhat, LoadResStr(fOn ? "IDS_CTL_ON" : "IDS_CTL_OFF"));
353  FlashMessage(strMessage.getData());
354 }
const char * getData() const
Definition: StdBuf.h:450
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
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 51 of file C4GraphicsSystem.cpp.

Referenced by C4Game::PreInit().

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

Here is the caller graph for this function:

bool C4GraphicsSystem::InitLoaderScreen ( const char *  szLoaderSpec)

Definition at line 180 of file C4GraphicsSystem.cpp.

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

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

181 {
182  // create new loader; overwrite current only if successful
183  C4LoaderScreen *pNewLoader = new C4LoaderScreen();
184  pNewLoader->SetBlackScreen(false);
185  if (!pNewLoader->Init(szLoaderSpec)) { delete pNewLoader; return false; }
186  if (pLoaderScreen) delete pLoaderScreen;
187  pLoaderScreen = pNewLoader;
188  // done, success
189  return true;
190 }
C4LoaderScreen * pLoaderScreen
bool Init(const char *szLoaderSpec)
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 61 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().

61 { iRedrawBackground=2; }

Here is the caller graph for this function:

void C4GraphicsSystem::OverwriteBg ( )
inline

Definition at line 62 of file C4GraphicsSystem.h.

References InvalidateBg().

Referenced by C4MessageBoard::Draw().

62 { 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 198 of file C4GraphicsSystem.cpp.

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

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

199 {
200  // Find a unique screenshot filename by iterating over all possible names
201  // 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
202  char szFilename[_MAX_PATH+1];
203  static int32_t iScreenshotIndex=1;
204  const char *strFilePath = nullptr;
205  do
206  sprintf(szFilename,"Screenshot%03i.png",iScreenshotIndex++);
207  while (FileExists(strFilePath = Config.AtScreenshotPath(szFilename)));
208  bool fSuccess=DoSaveScreenshot(fSaveAll, strFilePath, fSaveAllZoom);
209  // log if successful/where it has been stored
210  if (!fSuccess)
211  LogF(LoadResStr("IDS_PRC_SCREENSHOTERROR"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
212  else
213  LogF(LoadResStr("IDS_PRC_SCREENSHOT"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
214  // return success
215  return !!fSuccess;
216 }
C4Config Config
Definition: C4Config.cpp:831
#define sprintf
Definition: Standard.h:171
const char * AtUserDataRelativePath(const char *szFilename)
Definition: C4Config.cpp:642
bool DoSaveScreenshot(bool fSaveAll, const char *szFilename, float fSaveAllZoom)
#define _MAX_PATH
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const char * AtScreenshotPath(const char *szFilename)
Definition: C4Config.cpp:553
bool FileExists(const char *szFilename)
Definition: StdFile.cpp:439
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253

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 58 of file C4GraphicsSystem.h.

References SaveScreenshot().

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

58 { 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 69 of file C4GraphicsSystem.cpp.

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

Referenced by Execute().

70 {
71  // only if ddraw is ready
72  if (!pDraw) return false;
73  if (!pDraw->Active) return false;
74 
75  // if the window is not focused, draw no more than MAX_BACKGROUND_FPS frames per second
76  if (!Application.Active && (C4TimeMilliseconds::Now() - lastFrame) < 1000 / MAX_BACKGROUND_FPS)
77  return false;
78 
79  // drawing OK
80  return true;
81 }
bool Active
Definition: C4Draw.h:96
bool Active
Definition: C4App.h:63
C4Draw * pDraw
Definition: C4Draw.cpp:45
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 447 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

448 {
449  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
450  Show8BitSurface = (Show8BitSurface + 1) % 3;
451  if (Show8BitSurface == 0)
452  FlashMessage("Default view");
453  else if (Show8BitSurface == 1)
454  FlashMessage("Foreground 8-bit landscape");
455  else if (Show8BitSurface == 2)
456  FlashMessage("Background 8-bit landscape");
457  return true;
458 }
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:278
bool DebugMode
Definition: C4Game.h:146

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowAction ( )

Definition at line 429 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

430 {
431  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
433  { ShowAction = true; FlashMessage("Actions"); }
434  else if (ShowAction)
435  { ShowAction = false; ShowCommand = true; FlashMessage("Commands"); }
436  else if (ShowCommand)
437  { ShowCommand = false; ShowPathfinder = true; FlashMessage("Pathfinder"); }
438  else if (ShowPathfinder)
439  { ShowPathfinder = false; ShowLights = true; FlashMessage("Lights"); }
440  else if (ShowLights)
441  { ShowLights = false; ShowMenuInfo = true; FlashMessage("Menu Info"); }
442  else if (ShowMenuInfo)
443  { ShowMenuInfo = false; FlashMessageOnOff("Actions/Commands/Pathfinder/Lights/Menus", false); }
444  return true;
445 }
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:278
bool DebugMode
Definition: C4Game.h:146

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowHelp ( )

Definition at line 460 of file C4GraphicsSystem.cpp.

References InvalidateBg(), and ShowHelp.

Referenced by C4Game::InitKeyboard().

461 {
462  ShowHelp = !ShowHelp;
463  // Turned off? Invalidate background.
464  if (!ShowHelp) InvalidateBg();
465  return true;
466 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowNetStatus ( )

Definition at line 414 of file C4GraphicsSystem.cpp.

References ShowNetstatus.

Referenced by C4Game::InitKeyboard().

415 {
417  return true;
418 }

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowVertices ( )

Definition at line 420 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

421 {
422  if (!Game.DebugMode && !Console.Active) { FlashMessage(LoadResStr("IDS_MSG_NODEBUGMODE")); return false; }
424  ShowEntrance = !ShowEntrance; // vertices and entrance now toggled together
425  FlashMessageOnOff("Entrance+Vertices", ShowVertices || ShowEntrance);
426  return true;
427 }
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:278
bool DebugMode
Definition: C4Game.h:146

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 80 of file C4GraphicsSystem.h.

Member Data Documentation

int32_t C4GraphicsSystem::iRedrawBackground

Definition at line 35 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 36 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 34 of file C4GraphicsSystem.h.

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


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