| 1 |
/* |
| 2 |
* Copyright (C) 2020-2021 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 "GUIDialogSelectSavestate.h" |
| 10 |
|
| 11 |
#include "ServiceBroker.h" |
| 12 |
#include "games/dialogs/osd/DialogGameSaves.h" |
| 13 |
#include "guilib/GUIComponent.h" |
| 14 |
#include "guilib/GUIWindowManager.h" |
| 15 |
#include "utils/log.h" |
| 16 |
|
| 17 |
using namespace KODI; |
| 18 |
using namespace GAME; |
| 19 |
|
| 20 |
bool CGUIDialogSelectSavestate::ShowAndGetSavestate(const std::string& gamePath, |
| 21 |
std::string& savestatePath) |
| 22 |
{ |
| 23 |
savestatePath = ""; |
| 24 |
|
| 25 |
// Can't ask the user if there's no dialog |
| 26 |
CDialogGameSaves* dialog = GetDialog(); |
| 27 |
if (dialog == nullptr) |
| 28 |
return true; |
| 29 |
|
| 30 |
if (!dialog->Open(gamePath)) |
| 31 |
return true; |
| 32 |
|
| 33 |
if (dialog->IsConfirmed()) |
| 34 |
{ |
| 35 |
savestatePath = dialog->GetSelectedItemPath(); |
| 36 |
return true; |
| 37 |
} |
| 38 |
else if (dialog->IsNewPressed()) |
| 39 |
{ |
| 40 |
CLog::Log(LOGDEBUG, "Select savestate dialog: New savestate selected"); |
| 41 |
return true; |
| 42 |
} |
| 43 |
|
| 44 |
// User canceled the dialog |
| 45 |
return false; |
| 46 |
} |
| 47 |
|
| 48 |
CDialogGameSaves* CGUIDialogSelectSavestate::GetDialog() |
| 49 |
{ |
| 50 |
CDialogGameSaves* dialog = |
| 51 |
CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CDialogGameSaves>( |
| 52 |
WINDOW_DIALOG_GAME_SAVES); |
| 53 |
|
| 54 |
if (dialog != nullptr) |
| 55 |
dialog->Reset(); |
| 56 |
|
| 57 |
return dialog; |
| 58 |
} |