OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4UpperBoard.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 #include "C4Include.h"
17 #include "gui/C4UpperBoard.h"
18 
19 #include "graphics/C4Draw.h"
21 
22 C4UpperBoard::C4UpperBoard() = default;
23 
24 C4UpperBoard::~C4UpperBoard() = default;
25 
27 {
28  if (!Config.Graphics.UpperBoard) return;
29  // Make the time strings
30  sprintf(cTimeString,"%02d:%02d:%02d", Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
31  time_t t = time(nullptr); strftime(cTimeString2, sizeof(cTimeString2), "[%H:%M:%S]", localtime(&t));
32  Draw(Output);
33 }
34 
36 {
37  if (!cgo.Surface) return;
38  // Background
40  // Logo
41  C4Facet cgo2;
42  float fLogoZoom = 1.0f;
43  cgo2.Set(cgo.Surface, (int32_t)(cgo.Wdt/2-(::GraphicsResource.fctLogo.Wdt/2)*fLogoZoom), 0,
44  (int32_t)(::GraphicsResource.fctLogo.Wdt*fLogoZoom), (int32_t)(::GraphicsResource.fctLogo.Hgt*fLogoZoom));
46  // Right text sections
47  int32_t iRightOff = 1;
48  // Playing time
49  pDraw->TextOut(cTimeString, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 10, TextYPosition, 0xFFFFFFFF);
50  // Clock
52  pDraw->TextOut(cTimeString2, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 30, TextYPosition, 0xFFFFFFFF);
53  // FPS
54  if (Config.General.FPS)
55  {
56  sprintf(cTimeString, "%d FPS", Game.FPS);
57  pDraw->TextOut(cTimeString, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 30, TextYPosition, 0xFFFFFFFF);
58  }
59  // Scenario title
61 }
62 
64 {
65  // Save facet
66  Output = cgo;
67  if (!::GraphicsResource.fctUpperBoard.Surface) return;
68  // in newgfx, the upperboard may be larger and overlap the scene
70  // Generate textposition
71  sprintf(cTimeString,"%02d:%02d:%02d", Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
74 }
const char * getData() const
Definition: StdBuf.h:442
C4Config Config
Definition: C4Config.cpp:833
int GetLineHeight() const
Definition: C4FontLoader.h:125
C4Game Game
Definition: C4Globals.cpp:52
int32_t FPS
Definition: C4Config.h:46
C4ConfigGeneral General
Definition: C4Config.h:251
#define sprintf
Definition: Standard.h:164
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:103
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:567
char cTimeString[64]
Definition: C4UpperBoard.h:32
int32_t GetScreenWdt()
Definition: C4Gui.h:2821
int32_t GetTextWidth(const char *szText, bool fCheckMarkup=true)
Definition: C4FontLoader.h:140
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4GraphicsResource GraphicsResource
int32_t UpperBoard
Definition: C4Config.h:101
C4ConfigGraphics Graphics
Definition: C4Config.h:253
bool BlitSurfaceTile(C4Surface *sfcSurface, C4Surface *sfcTarget, float iToX, float iToY, float iToWdt, float iToHgt, float iOffsetX, float iOffsetY, C4ShaderCall *shader_call)
Definition: C4Draw.cpp:535
int32_t FPS
Definition: C4Game.h:111
int32_t Time
Definition: C4Game.h:131
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
C4Draw * pDraw
Definition: C4Draw.cpp:42
void Init(C4Facet &cgo)
C4Facet Output
Definition: C4UpperBoard.h:31
float Hgt
Definition: C4Facet.h:118
void Draw(C4Facet &cgo)
C4Surface * Surface
Definition: C4Facet.h:117
float Wdt
Definition: C4Facet.h:118
char cTimeString2[64]
Definition: C4UpperBoard.h:33
int32_t ShowClock
Definition: C4Config.h:102