2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
2016-04-03 18:18:29 +00:00
|
|
|
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
2009-05-08 13:28:41 +00:00
|
|
|
*/
|
2016-04-03 18:07:56 +00:00
|
|
|
#include "C4Include.h"
|
|
|
|
#include "gui/C4UpperBoard.h"
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2016-10-20 21:42:46 +00:00
|
|
|
#include "graphics/C4Draw.h"
|
2017-04-30 08:49:09 +00:00
|
|
|
#include "graphics/C4GraphicsResource.h"
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2017-05-03 18:28:00 +00:00
|
|
|
C4UpperBoard::C4UpperBoard() = default;
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2017-05-03 18:28:00 +00:00
|
|
|
C4UpperBoard::~C4UpperBoard() = default;
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4UpperBoard::Execute()
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
|
|
|
if (!Config.Graphics.UpperBoard) return;
|
2009-05-08 13:28:41 +00:00
|
|
|
// Make the time strings
|
|
|
|
sprintf(cTimeString,"%02d:%02d:%02d", Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
|
2017-05-03 18:28:00 +00:00
|
|
|
time_t t = time(nullptr); strftime(cTimeString2, sizeof(cTimeString2), "[%H:%M:%S]", localtime(&t));
|
2009-05-08 13:28:41 +00:00
|
|
|
Draw(Output);
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4UpperBoard::Draw(C4Facet &cgo)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
|
|
|
if (!cgo.Surface) return;
|
2009-05-08 13:28:41 +00:00
|
|
|
// Background
|
2016-11-02 23:58:02 +00:00
|
|
|
pDraw->BlitSurfaceTile(::GraphicsResource.fctUpperBoard.Surface,Output.Surface,0,0,Output.Wdt,Output.Hgt,0,0,nullptr);
|
2010-03-27 16:05:02 +00:00
|
|
|
// Logo
|
2009-05-08 13:28:41 +00:00
|
|
|
C4Facet cgo2;
|
2010-08-15 18:20:59 +00:00
|
|
|
float fLogoZoom = 1.0f;
|
2009-06-05 15:19:15 +00:00
|
|
|
cgo2.Set(cgo.Surface, (int32_t)(cgo.Wdt/2-(::GraphicsResource.fctLogo.Wdt/2)*fLogoZoom), 0,
|
2010-03-28 18:58:01 +00:00
|
|
|
(int32_t)(::GraphicsResource.fctLogo.Wdt*fLogoZoom), (int32_t)(::GraphicsResource.fctLogo.Hgt*fLogoZoom));
|
2009-06-05 15:19:15 +00:00
|
|
|
::GraphicsResource.fctLogo.Draw(cgo2);
|
2009-05-08 13:28:41 +00:00
|
|
|
// Right text sections
|
|
|
|
int32_t iRightOff = 1;
|
|
|
|
// Playing time
|
2011-10-03 14:30:18 +00:00
|
|
|
pDraw->TextOut(cTimeString, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 10, TextYPosition, 0xFFFFFFFF);
|
2009-05-08 13:28:41 +00:00
|
|
|
// Clock
|
|
|
|
if (Config.Graphics.ShowClock)
|
2011-10-03 14:30:18 +00:00
|
|
|
pDraw->TextOut(cTimeString2, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 30, TextYPosition, 0xFFFFFFFF);
|
2009-05-08 13:28:41 +00:00
|
|
|
// FPS
|
|
|
|
if (Config.General.FPS)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
sprintf(cTimeString, "%d FPS", Game.FPS);
|
2011-10-03 14:30:18 +00:00
|
|
|
pDraw->TextOut(cTimeString, ::GraphicsResource.FontRegular, 1.0, cgo.Surface, C4GUI::GetScreenWdt() - (iRightOff++) * TextWidth - 30, TextYPosition, 0xFFFFFFFF);
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
// Scenario title
|
2011-10-03 14:30:18 +00:00
|
|
|
pDraw->TextOut(Game.ScenarioTitle.getData(), ::GraphicsResource.FontRegular, 1.0, cgo.Surface, 10, cgo.Hgt / 2 - ::GraphicsResource.FontRegular.GetLineHeight() / 2, 0xFFFFFFFF);
|
2010-03-28 18:58:01 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
void C4UpperBoard::Init(C4Facet &cgo)
|
2010-03-28 18:58:01 +00:00
|
|
|
{
|
2009-05-08 13:28:41 +00:00
|
|
|
// Save facet
|
|
|
|
Output = cgo;
|
2009-06-05 15:19:15 +00:00
|
|
|
if (!::GraphicsResource.fctUpperBoard.Surface) return;
|
2009-05-08 13:28:41 +00:00
|
|
|
// in newgfx, the upperboard may be larger and overlap the scene
|
2015-11-15 12:53:01 +00:00
|
|
|
Output.Hgt = std::max(Output.Hgt, ::GraphicsResource.fctUpperBoard.Hgt);
|
2009-05-08 13:28:41 +00:00
|
|
|
// Generate textposition
|
|
|
|
sprintf(cTimeString,"%02d:%02d:%02d", Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
|
2009-06-05 15:19:15 +00:00
|
|
|
TextWidth = ::GraphicsResource.FontRegular.GetTextWidth(cTimeString);
|
|
|
|
TextYPosition = cgo.Hgt / 2 - ::GraphicsResource.FontRegular.GetLineHeight() / 2;
|
2009-05-08 13:28:41 +00:00
|
|
|
}
|