| 1 |
/* |
| 2 |
* Copyright (C) 2023 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "GUIGameMessenger.h" |
| 10 |
|
| 11 |
#include "FileItem.h" |
| 12 |
#include "cores/RetroPlayer/process/RPProcessInfo.h" |
| 13 |
#include "cores/RetroPlayer/rendering/RenderContext.h" |
| 14 |
#include "cores/RetroPlayer/savestates/SavestateDatabase.h" |
| 15 |
#include "guilib/GUIComponent.h" |
| 16 |
#include "guilib/GUIMessage.h" |
| 17 |
#include "guilib/GUIWindowManager.h" |
| 18 |
#include "guilib/WindowIDs.h" |
| 19 |
|
| 20 |
using namespace KODI; |
| 21 |
using namespace RETRO; |
| 22 |
|
| 23 |
CGUIGameMessenger::CGUIGameMessenger(CRPProcessInfo& processInfo) |
| 24 |
: m_guiComponent(processInfo.GetRenderContext().GUI()) |
| 25 |
{ |
| 26 |
} |
| 27 |
|
| 28 |
void CGUIGameMessenger::RefreshSavestates(const std::string& savestatePath /* = "" */, |
| 29 |
ISavestate* savestate /* = nullptr */) |
| 30 |
{ |
| 31 |
if (m_guiComponent != nullptr) |
| 32 |
{ |
| 33 |
CGUIMessage message(GUI_MSG_REFRESH_THUMBS, 0, WINDOW_DIALOG_IN_GAME_SAVES); |
| 34 |
|
| 35 |
// Add path, if given |
| 36 |
if (!savestatePath.empty()) |
| 37 |
message.SetStringParam(savestatePath); |
| 38 |
|
| 39 |
// Add savestate info, if given |
| 40 |
if (savestate != nullptr) |
| 41 |
{ |
| 42 |
CFileItemPtr item = std::make_shared<CFileItem>(); |
| 43 |
CSavestateDatabase::GetSavestateItem(*savestate, savestatePath, *item); |
| 44 |
message.SetItem(std::static_pointer_cast<CGUIListItem>(item)); |
| 45 |
} |
| 46 |
|
| 47 |
// Notify the in-game savestate dialog |
| 48 |
m_guiComponent->GetWindowManager().SendThreadMessage(message, WINDOW_DIALOG_IN_GAME_SAVES); |
| 49 |
} |
| 50 |
} |