aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/m4_menus.h
blob: 9abf71e9db36881ed7aafdeb666b5abf734b5094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef M4_M4_MENUS_H
#define M4_M4_MENUS_H

#include "common/list.h"
#include "common/ptr.h"

#include "m4/viewmgr.h"
#include "m4/m4.h"
#include "m4/gui.h"
#include "m4/saveload.h"

namespace M4 {

#define M4_DIALOG_FADE_STEPS 5
#define M4_DIALOG_FADE_DELAY 30

typedef Common::List<MenuObject *> MenuObjectList;

class OrionMenuView : public DialogView {
	typedef MenuObjectList::iterator MenuObjectsIterator;
private:
	MenuType _menuType;
	SpriteAsset *_sprites;
	MenuObjectList _menuObjects;
	MenuObject *_currentItem;
	typedef void (*Callback)(OrionMenuView *view);
	OrionMenuView::Callback _escapeHandler, _returnHandler;
	bool _closeFlag;
	bool _calledFromMainMenu;
	bool _interfaceWasVisible;
	int _firstSlotIndex;

	bool loadSprites(const char *seriesName);
	M4Surface *createThumbnail();
	void destroyView();
public:
	OrionMenuView(MadsM4Engine *vm, int x, int y, MenuType menuType, bool calledFromMainMenu,
		bool loadSaveFromHotkey);
	~OrionMenuView();
	MenuType getMenuType() { return _menuType; }
	SpriteAsset *sprites() { return _sprites; }
	MenuObjectList &items() { return _menuObjects; }
	MenuObject *getItem(int objectId);
	void setTopSaveSlot(int slotNumber);
	void refresh(const Common::Rect &areaRect);
	void close() { _closeFlag = true; }

	bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);

	int _originalMidiVolume;
	SaveGameList *_saveNames;
	bool _loadSaveFromHotkey;
};

class OrionCallbacks {
public:
	static void closeMenuFn(DialogView *view, MenuObject *item);
	static void closeMenuFn(OrionMenuView *view);
	static void gameOptionsMenuFn(DialogView *view, MenuObject *item);
	static void gameSaveGameFn(DialogView *view, MenuObject *item);
	static void gameLoadGameFn(DialogView *view, MenuObject *item);
	static void gameExitFn(DialogView *view, MenuObject *item);
	static void optionsDigiSliderFn(DialogView *view, MenuObject *item);
	static void optionsMidiSliderFn(DialogView *view, MenuObject *item);
	static void optionsScrollingFn(DialogView *view, MenuObject *item);
	static void optionsCancelFn(DialogView *view, MenuObject *item);
	static void optionsDoneFn(DialogView *view, MenuObject *item);
	static void optionsReturnFn(OrionMenuView *view);
	static void optionsEscapeFn(OrionMenuView *view);
	static void saveLoadSaveFn(DialogView *view, MenuObject *item);
	static void saveLoadLoadFn(DialogView *view, MenuObject *item);
	static void saveLoadSlotFn(DialogView *view, MenuObject *item);
	static void saveLoadCancelFn(DialogView *view, MenuObject *item);
	static void saveLoadSliderFn(DialogView *view, MenuObject *item);
	static void saveLoadEscapeFn(OrionMenuView *view);
	static void saveLoadReturnFn(OrionMenuView *view);
};

}

#endif