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_MAIN_GAME_WINDOW_H
24 #define TITANIC_MAIN_GAME_WINDOW_H
25 
26 #include "titanic/core/project_item.h"
27 #include "titanic/events.h"
28 #include "common/array.h"
29 #include "common/scummsys.h"
30 
31 namespace Common {
32 struct Point;
33 }
34 
35 namespace Titanic {
36 
37 class CGameManager;
38 class CGameView;
39 class CScreenManager;
40 class Image;
41 class TitanicEngine;
42 
43 class CMainGameWindow : public CEventTarget {
44 private:
45 	TitanicEngine *_vm;
46 	int _pendingLoadSlot;
47 	uint32 _priorLeftDownTime;
48 	uint32 _priorMiddleDownTime;
49 private:
50 	/**
51 	 * Returns true if a savegame was selected to be loaded
52 	 * from the ScummVM launcher
53 	 */
54 	bool isLoadingFromLauncher() const;
55 
56 	/**
57 	 * Checks for the presence of any savegames and, if present,
58 	 * lets the user pick one to resume
59 	 */
60 	int getSavegameSlot();
61 
62 	/**
63 	 * Creates the game "project" and determine a game save slot
64 	 * to use
65 	 */
66 	int selectSavegame();
67 
68 	/**
69 	 * Used for drawing the PET fullscreen? maybe
70 	 */
71 	void drawPet(CScreenManager *screenManager);
72 
73 	/**
74 	 * Draws the background for the view
75 	 */
76 	void drawView();
77 
78 	/**
79 	 * Draws all the items within the view
80 	 */
81 	void drawViewContents(CScreenManager *screenManager);
82 
83 	void leftButtonDoubleClick(const Point &mousePos);
84 	void middleButtonDoubleClick(const Point &mousePos);
85 
86 	/**
87 	 * Returns true if the player can control the mouse
88 	 */
89 	bool isMouseControlEnabled() const;
90 public:
91 	CGameView *_gameView;
92 	CGameManager *_gameManager;
93 	CProjectItem *_project;
94 	bool _inputAllowed;
95 	Image *_image;
96 	void *_cursor;
97 public:
98 	CMainGameWindow(TitanicEngine *vm);
99 	virtual ~CMainGameWindow();
100 
101 	/**
102 	* Called to handle any regular updates the game requires
103 	*/
104 	void onIdle();
105 
106 	virtual void mouseMove(const Point &mousePos);
107 	virtual void leftButtonDown(const Point &mousePos);
108 	virtual void leftButtonUp(const Point &mousePos);
109 	virtual void middleButtonDown(const Point &mousePos);
110 	virtual void middleButtonUp(const Point &mousePos);
111 	virtual void mouseWheel(const Point &mousePos, bool wheelUp);
112 	virtual void keyDown(Common::KeyState keyState);
113 
114 	/**
115 	 * Called when the application starts
116 	 */
117 	void applicationStarting();
118 
119 	/**
120 	 * Sets the view to be shown
121 	 */
122 	void setActiveView(CViewItem *viewItem);
123 
124 	/**
125 	 * Main draw method for the window
126 	 */
127 	void draw();
128 
129 	/**
130 	 * Called by the event handler when a mouse event has been generated
131 	 */
132 	void mouseChanged();
133 
134 	/**
135 	 * Schedules a savegame to be loaded
136 	 */
137 	void loadGame(int slotId);
138 };
139 
140 } // End of namespace Titanic
141 
142 #endif /* TITANIC_MAIN_GAME_WINDOW_H */
143