1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef TITANIC_PET_LOAD_SAVE_H
24 #define TITANIC_PET_LOAD_SAVE_H
25 
26 #include "titanic/pet_control/pet_glyphs.h"
27 #include "titanic/gfx/text_control.h"
28 
29 namespace Titanic {
30 
31 #define SAVEGAME_SLOTS_COUNT 5
32 
33 class CPetLoadSave : public CPetGlyph {
34 private:
35 	/**
36 	 * Get the rect area for a given savegame name will be displayed in
37 	 */
38 	Rect getSlotBounds(int index);
39 
40 	/**
41 	 * Called when savegame slot highlight changes or the view is reset
42 	 */
43 	void highlightChange();
44 
45 	/**
46 	 * Check for whether a slot is under the passed point
47 	 */
48 	bool checkSlotsHighlight(const Point &pt);
49 
50 	/**
51 	 * Checks if a point is within a given saveame slot
52 	 */
53 	bool isSlotHighlighted(int index, const Point &pt);
54 protected:
55 	CTextControl _slotNames[SAVEGAME_SLOTS_COUNT];
56 	bool _slotInUse[SAVEGAME_SLOTS_COUNT];
57 	CPetGfxElement _btnLoadSave;
58 	CPetGfxElement _gutter;
59 	static int _savegameSlotNum;
60 protected:
61 	/**
62 	 * Reset the slot names list
63 	 */
64 	void resetSlots();
65 
66 	/**
67 	 * Highlight one of the slots
68 	 */
69 	void highlightSlot(int index);
70 public:
71 	/**
72 	 * Setup the glyph
73 	 */
74 	virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
75 
76 	/**
77 	 * Reset the glyph
78 	 */
79 	virtual bool reset();
80 
81 	/**
82 	 * Handles any secondary drawing of the glyph
83 	 */
84 	virtual void draw2(CScreenManager *screenManager);
85 
86 	/**
87 	 * Called for mouse button down messages
88 	 */
89 	virtual bool MouseButtonDownMsg(const Point &pt);
90 
91 	/**
92 	 * Handles keypresses when the glyph is focused
93 	 */
94 	virtual bool KeyCharMsg(int key);
95 
96 	/**
97 	 * Resets highlighting on the save slots
98 	 */
resetSaves()99 	virtual void resetSaves() { resetSlots(); }
100 
101 	/**
102 	 * Highlights a save slot
103 	 */
104 	virtual void highlightSave(int index) = 0;
105 
106 	/**
107 	 * Unhighlight a save slot
108 	 */
109 	virtual void unhighlightSave(int index) = 0;
110 
111 	/**
112 	 * Executes the loading or saving
113 	 */
114 	virtual void execute() = 0;
115 };
116 
117 } // End of namespace Titanic
118 
119 #endif
120