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 304 of file C4GraphicsSystem.cpp.

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

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

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

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, 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().

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

330 {
331  // Store message
332  SCopy(szMessage, FlashMessageText, C4MaxTitle);
333  // Calculate message time
334  FlashMessageTime = SLen(FlashMessageText) * 2;
335  // Initial position
336  FlashMessageX = -1;
337  FlashMessageY = 10;
338  // Upper board active: stay below upper board
340  FlashMessageY += C4UpperBoardHeight;
341  // More than one viewport: try to stay below portraits etc.
342  if (::Viewports.GetViewportCount() > 1)
343  FlashMessageY += 64;
344  // New flash message: redraw background (might be drawing one message on top of another)
345  InvalidateBg();
346 }
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 348 of file C4GraphicsSystem.cpp.

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

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

349 {
350  StdStrBuf strMessage;
351  strMessage.Format("%s: %s", strWhat, LoadResStr(fOn ? "IDS_CTL_ON" : "IDS_CTL_OFF"));
352  FlashMessage(strMessage.getData());
353 }
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 }
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 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 446 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowAction ( )

Definition at line 428 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowHelp ( )

Definition at line 459 of file C4GraphicsSystem.cpp.

References InvalidateBg(), and ShowHelp.

Referenced by C4Game::InitKeyboard().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowNetStatus ( )

Definition at line 413 of file C4GraphicsSystem.cpp.

References ShowNetstatus.

Referenced by C4Game::InitKeyboard().

414 {
416  return true;
417 }

Here is the caller graph for this function:

bool C4GraphicsSystem::ToggleShowVertices ( )

Definition at line 419 of file C4GraphicsSystem.cpp.

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

Referenced by C4Game::InitKeyboard().

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

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: