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 02:43:38 +00:00
|
|
|
bool OverlayManager::isOverlayEnabled(OverlayType type)
|
2019-01-20 07:05:56 +00:00
|
|
|
{
|
|
|
|
return m_Overlays[type].enabled;
|
|
|
|
}
|
|
|
|
char* OverlayManager::getOverlayText(OverlayType type)
|
|
|
|
{
|
|
|
|
return m_Overlays[type].text;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void OverlayManager::setOverlayRenderer(IOverlayRenderer* renderer)
|
|
|
|
{
|
|
|
|
m_Renderer = renderer;
|
|
|
|
}
|