Debian Codegraph @

xbmc/games/dialogs/osd/DialogInGameSaves.h

raw
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 #pragma once
10
11 #include "DialogGameVideoSelect.h"
12 #include "FileItem.h"
13 #include "guilib/GUIListItem.h"
14
15 #include <string>
16
17 namespace KODI
18 {
19 namespace GAME
20 {
21 /*!
22 * \ingroup games
23 */
24 class CDialogInGameSaves : public CDialogGameVideoSelect
25 {
26 public:
27 CDialogInGameSaves();
28 ~CDialogInGameSaves() override = default;
29
30 // implementation of CGUIControl via CDialogGameVideoSelect
31 bool OnMessage(CGUIMessage& message) override;
32
33 protected:
34 // implementation of CDialogGameVideoSelect
35 std::string GetHeading() override;
36 void PreInit() override;
37 void GetItems(CFileItemList& items) override;
38 void OnItemFocus(unsigned int index) override;
39 unsigned int GetFocusedItem() const override;
40 void PostExit() override;
41 bool OnClickAction() override;
42 bool OnMenuAction() override;
43 bool OnOverwriteAction() override;
44 bool OnRenameAction() override;
45 bool OnDeleteAction() override;
46
47 void OnNewSave();
48 void OnLoad(CFileItem& focusedItem);
49 void OnOverwrite(CFileItem& focusedItem);
50 void OnRename(CFileItem& focusedItem);
51 void OnDelete(CFileItem& focusedItem);
52
53 private:
54 void InitSavedGames();
55 void OnItemRefresh(const std::string& itemPath, const std::shared_ptr<CGUIListItem>& itemInfo);
56
57 /*!
58 * \brief Translates the GUI list item received in a GUI message into a
59 * CFileItem with savestate properties
60 *
61 * When a savestate is overwritten, we optimistically populate the GUI list
62 * with a simulated savestate for immediate user feedback. Later (about a
63 * quarter second) a message arrives with the real savestate info.
64 *
65 * \param messagePath The savestate path, pass as the message's string param
66 * \param messageItem The savestate info, if known, or empty if unknown
67 *
68 * If messageItem is empty, the savestate will be loaded from disk, which
69 * is potentially expensive.
70 *
71 * \return A savestate item for the GUI, or empty if no savestate information
72 * can be obtained
73 */
74 static CFileItemPtr TranslateMessageItem(const std::string& messagePath,
75 const std::shared_ptr<CGUIListItem>& messageItem);
76
77 CFileItemList m_savestateItems;
78 const CFileItemPtr m_newSaveItem;
79 unsigned int m_focusedItemIndex = false;
80 };
81 } // namespace GAME
82 } // namespace KODI