2019-01-20 07:05:56 +00:00
|
|
|
#include "overlaymanager.h"
|
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
using namespace Overlay;
|
|
|
|
|
|
|
|
OverlayManager::OverlayManager() :
|
|
|
|
m_Renderer(nullptr)
|
2019-01-20 07:05:56 +00:00
|
|
|
{
|
|
|
|
memset(m_Overlays, 0, sizeof(m_Overlays));
|
2019-02-13 04:39:10 +00:00
|
|
|
|
2019-02-16 02:53:40 +00:00
|
|
|
m_Overlays[OverlayType::OverlayDebug].color = {0xD0, 0xD0, 0x00, 0xFF};
|
2019-02-13 06:36:56 +00:00
|
|
|
m_Overlays[OverlayType::OverlayDebug].fontSize = 20;
|
2019-03-17 22:08:21 +00:00
|
|
|
|
|
|
|
m_Overlays[OverlayType::OverlayStatusUpdate].color = {0xCC, 0x00, 0x00, 0xFF};
|
|
|
|
m_Overlays[OverlayType::OverlayStatusUpdate].fontSize = 36;
|
2019-01-20 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
bool OverlayManager::isOverlayEnabled(OverlayType type)
|
2019-01-20 07:05:56 +00:00
|
|
|
{
|
|
|
|
return m_Overlays[type].enabled;
|
|
|
|
}
|
2019-02-13 06:36:56 +00:00
|
|
|
|
2019-01-20 07:05:56 +00:00
|
|
|
char* OverlayManager::getOverlayText(OverlayType type)
|
|
|
|
{
|
|
|
|
return m_Overlays[type].text;
|
|
|
|
}
|
|
|
|
|
2019-02-13 06:36:56 +00:00
|
|
|
int OverlayManager::getOverlayFontSize(OverlayType type)
|
|
|
|
{
|
|
|
|
return m_Overlays[type].fontSize;
|
|
|
|
}
|
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
void OverlayManager::setOverlayTextUpdated(OverlayType type)
|
|
|
|
{
|
|
|
|
// Only update the overlay state if it's enabled. If it's not enabled,
|
|
|
|
// the renderer has already been notified by setOverlayState().
|
|
|
|
if (m_Overlays[type].enabled && m_Renderer != nullptr) {
|
|
|
|
m_Renderer->notifyOverlayUpdated(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OverlayManager::setOverlayState(OverlayType type, bool enabled)
|
2019-01-20 07:05:56 +00:00
|
|
|
{
|
2019-02-13 02:43:38 +00:00
|
|
|
bool stateChanged = m_Overlays[type].enabled != enabled;
|
|
|
|
|
2019-01-20 07:05:56 +00:00
|
|
|
m_Overlays[type].enabled = enabled;
|
2019-02-13 02:43:38 +00:00
|
|
|
|
|
|
|
if (stateChanged) {
|
|
|
|
if (!enabled) {
|
|
|
|
// Set the text to empty string on disable
|
|
|
|
m_Overlays[type].text[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_Renderer != nullptr) {
|
|
|
|
m_Renderer->notifyOverlayUpdated(type);
|
|
|
|
}
|
2019-01-20 07:05:56 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-13 02:43:38 +00:00
|
|
|
|
2019-02-13 04:39:10 +00:00
|
|
|
SDL_Color OverlayManager::getOverlayColor(OverlayType type)
|
|
|
|
{
|
|
|
|
return m_Overlays[type].color;
|
|
|
|
}
|
|
|
|
|
2019-02-13 02:43:38 +00:00
|
|
|
void OverlayManager::setOverlayRenderer(IOverlayRenderer* renderer)
|
|
|
|
{
|
|
|
|
m_Renderer = renderer;
|
|
|
|
}
|