2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "GameWindowFullScreen.h"
11 #include "GUIInfoManager.h" //! @todo Remove me
12 #include "GameWindowFullScreenText.h"
13 #include "ServiceBroker.h"
14 #include "application/ApplicationComponents.h"
15 #include "application/ApplicationPlayer.h" //! @todo Remove me
16 #include "cores/RetroPlayer/guibridge/GUIGameRenderManager.h"
17 #include "cores/RetroPlayer/guibridge/GUIRenderHandle.h"
18 #include "games/GameServices.h"
19 #include "games/GameSettings.h"
20 #include "guilib/GUIComponent.h"
21 #include "guilib/GUIControl.h"
22 #include "guilib/GUIDialog.h"
23 #include "guilib/GUIWindowManager.h" //! @todo Remove me
24 #include "guilib/WindowIDs.h"
25 #include "input/actions/Action.h"
26 #include "input/actions/ActionIDs.h"
27 #include "windowing/GraphicContext.h" //! @todo Remove me
30 using namespace KODI::GUILIB
;
31 using namespace RETRO
;
33 CGameWindowFullScreen::CGameWindowFullScreen(void)
34 : CGUIWindow(WINDOW_FULLSCREEN_GAME
, "VideoFullScreen.xml"),
35 m_fullscreenText(new CGameWindowFullScreenText(*this))
37 // initialize CGUIControl
38 m_controlStats
= new GUICONTROLSTATS
;
40 // initialize CGUIWindow
41 m_loadType
= KEEP_IN_MEMORY
;
46 CGameWindowFullScreen::~CGameWindowFullScreen()
50 delete m_controlStats
;
53 void CGameWindowFullScreen::Process(unsigned int currentTime
, CDirtyRegionList
& dirtyregion
)
55 if (m_renderHandle
->IsDirty())
58 m_controlStats
->Reset();
60 CGUIWindow::Process(currentTime
, dirtyregion
);
62 //! @todo This isn't quite optimal - ideally we'd only be dirtying up the actual video render rect
63 //! which is probably the job of the renderer as it can more easily track resizing etc.
64 m_renderRegion
.SetRect(
65 0, 0, static_cast<float>(CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth()),
66 static_cast<float>(CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight()));
69 void CGameWindowFullScreen::Render()
71 m_renderHandle
->Render();
76 void CGameWindowFullScreen::RenderEx()
78 CGUIWindow::RenderEx();
80 m_renderHandle
->RenderEx();
83 bool CGameWindowFullScreen::OnAction(const CAction
& action
)
85 switch (action
.GetID())
88 case ACTION_TRIGGER_OSD
:
93 case ACTION_MOUSE_MOVE
:
95 if (action
.GetAmount(2) || action
.GetAmount(3))
102 case ACTION_MOUSE_LEFT_CLICK
:
107 case ACTION_SHOW_GUI
:
109 // Switch back to the menu
110 CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
113 case ACTION_ASPECT_RATIO
:
115 // Toggle the aspect ratio mode (only if the info is onscreen)
116 // g_application.GetAppPlayer().SetRenderViewMode(CViewModeSettings::GetNextQuickCycleViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode));
123 return CGUIWindow::OnAction(action
);
126 bool CGameWindowFullScreen::OnMessage(CGUIMessage
& message
)
128 switch (message
.GetMessage())
130 case GUI_MSG_SETFOCUS
:
131 case GUI_MSG_LOSTFOCUS
:
133 if (message
.GetSenderId() != WINDOW_FULLSCREEN_GAME
)
141 return CGUIWindow::OnMessage(message
);
144 void CGameWindowFullScreen::FrameMove()
146 m_fullscreenText
->FrameMove();
148 CGUIWindow::FrameMove();
151 void CGameWindowFullScreen::ClearBackground()
153 m_renderHandle
->ClearBackground();
155 CGUIWindow::ClearBackground();
158 bool CGameWindowFullScreen::HasVisibleControls()
160 return m_controlStats
->nCountVisible
> 0;
163 void CGameWindowFullScreen::OnWindowLoaded()
165 CGUIWindow::OnWindowLoaded();
167 // Override the clear colour - we must never clear fullscreen
168 m_clearBackground
= 0;
170 m_fullscreenText
->OnWindowLoaded();
173 void CGameWindowFullScreen::OnInitWindow()
175 GUIINFO::CPlayerGUIInfo
& guiInfo
=
176 CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider();
177 guiInfo
.SetShowInfo(false);
180 CServiceBroker::GetWinSystem()->GetGfxContext().SetFullScreenVideo(true); //! @todo
182 CGUIWindow::OnInitWindow();
185 GAME::CGameSettings
& gameSettings
= CServiceBroker::GetGameServices().GameSettings();
186 if (gameSettings
.ShowOSDHelp())
190 //! @todo We need to route this check through the GUI bridge. By adding the
191 // dependency to the application player here, we are prevented from
192 // having multiple players.
193 const auto& components
= CServiceBroker::GetAppComponents();
194 const auto appPlayer
= components
.GetComponent
<CApplicationPlayer
>();
195 if (!appPlayer
->HasGameAgent())
197 gameSettings
.SetShowOSDHelp(true);
203 void CGameWindowFullScreen::OnDeinitWindow(int nextWindowID
)
205 // Close all active modal dialogs
206 CServiceBroker::GetGUI()->GetWindowManager().CloseInternalModalDialogs(true);
208 CGUIWindow::OnDeinitWindow(nextWindowID
);
210 CServiceBroker::GetWinSystem()->GetGfxContext().SetFullScreenVideo(false); //! @todo
213 void CGameWindowFullScreen::TriggerOSD()
215 CGUIDialog
* pOSD
= GetOSD();
218 if (!pOSD
->IsDialogRunning())
223 CGUIDialog
* CGameWindowFullScreen::GetOSD()
225 return CServiceBroker::GetGUI()->GetWindowManager().GetDialog(WINDOW_DIALOG_GAME_OSD
);
228 void CGameWindowFullScreen::RegisterWindow()
230 m_renderHandle
= CServiceBroker::GetGameRenderManager().RegisterWindow(*this);
233 void CGameWindowFullScreen::UnregisterWindow()
235 m_renderHandle
.reset();