1 /*
2  * This file is part of EasyRPG Player.
3  *
4  * EasyRPG Player is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * EasyRPG Player is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef EP_SCENE_FILE_H
19 #define EP_SCENE_FILE_H
20 
21 // Headers
22 #include <vector>
23 #include "filefinder.h"
24 #include <lcf/rpg/save.h>
25 #include "scene.h"
26 #include "window_help.h"
27 #include "window_savefile.h"
28 #include "sprite.h"
29 
30 
31 /**
32  * Base class used by the save and load scenes.
33  */
34 class Scene_File : public Scene {
35 
36 public:
37 	/**
38 	 * Constructor.
39 	 *
40 	 * @param message title message.
41 	 */
42 	Scene_File(std::string message);
43 
44 	void Start() override;
45 	void Update() override;
46 
47 	virtual void Action(int index) = 0;
48 
49 	virtual bool IsSlotValid(int index) = 0;
50 
51 	bool IsWindowMoving() const;
52 
53 protected:
54 	virtual void CreateHelpWindow();
55 	virtual void PopulateSaveWindow(Window_SaveFile& win, int id);
56 	virtual void PopulatePartyFaces(Window_SaveFile& win, int id, lcf::rpg::Save& savegame);
57 	virtual void UpdateLatestTimestamp(int id, lcf::rpg::Save& savegame);
58 	static std::unique_ptr<Sprite> MakeBorderSprite(int y);
59 	static std::unique_ptr<Sprite> MakeArrowSprite(bool down);
60 
61 	void Refresh();
62 	void MoveFileWindows(int dy, int dt);
63 	void UpdateArrows();
64 
65 	int index = 0;
66 	int top_index = 0;
67 	std::unique_ptr<Window_Help> help_window;
68 	std::vector<std::shared_ptr<Window_SaveFile> > file_windows;
69 	std::unique_ptr<Sprite> border_top;
70 	std::unique_ptr<Sprite> border_bottom;
71 	std::unique_ptr<Sprite> up_arrow;
72 	std::unique_ptr<Sprite> down_arrow;
73 	std::string message;
74 
75 	FilesystemView fs;
76 
77 	double latest_time = 0;
78 	int latest_slot = 0;
79 
80 	int arrow_frame = 0;
81 };
82 
83 #endif
84