mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-16 16:27:59 +00:00
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
#include "overlaymanager.h"
|
|
|
|
using namespace Overlay;
|
|
|
|
OverlayManager::OverlayManager() :
|
|
m_Renderer(nullptr)
|
|
{
|
|
memset(m_Overlays, 0, sizeof(m_Overlays));
|
|
|
|
m_Overlays[OverlayType::OverlayDebug].color = {0xD0, 0xD0, 0x00, 0xFF};
|
|
m_Overlays[OverlayType::OverlayDebug].fontSize = 20;
|
|
|
|
m_Overlays[OverlayType::OverlayStatusUpdate].color = {0xCC, 0x00, 0x00, 0xFF};
|
|
m_Overlays[OverlayType::OverlayStatusUpdate].fontSize = 36;
|
|
}
|
|
|
|
bool OverlayManager::isOverlayEnabled(OverlayType type)
|
|
{
|
|
return m_Overlays[type].enabled;
|
|
}
|
|
|
|
char* OverlayManager::getOverlayText(OverlayType type)
|
|
{
|
|
return m_Overlays[type].text;
|
|
}
|
|
|
|
int OverlayManager::getOverlayFontSize(OverlayType type)
|
|
{
|
|
return m_Overlays[type].fontSize;
|
|
}
|
|
|
|
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)
|
|
{
|
|
bool stateChanged = m_Overlays[type].enabled != enabled;
|
|
|
|
m_Overlays[type].enabled = enabled;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
SDL_Color OverlayManager::getOverlayColor(OverlayType type)
|
|
{
|
|
return m_Overlays[type].color;
|
|
}
|
|
|
|
void OverlayManager::setOverlayRenderer(IOverlayRenderer* renderer)
|
|
{
|
|
m_Renderer = renderer;
|
|
}
|