aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/game.h
blob: 593203e4435566cc9df860cca4d419b351314b0b (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/* 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.
 *
 */
/**************************************************************************
 *                                     ���������������������������������� *
 *                                             Nayma Software srl         *
 *                    e                -= We create much MORE than ALL =- *
 *        u-        z$$$c        '.    ���������������������������������� *
 *      .d"        d$$$$$b        "b.                                     *
 *   .z$*         d$$$$$$$L        ^*$c.                                  *
 *  #$$$.         $$$$$$$$$         .$$$" Project: Roasted Moths........  *
 *    ^*$b       4$$$$$$$$$F      .d$*"                                   *
 *      ^$$.     4$$$$$$$$$F     .$P"     Module:  Game.CPP.............  *
 *        *$.    '$$$$$$$$$     4$P 4                                     *
 *     J   *$     "$$$$$$$"     $P   r    Author:  Giovanni Bajo........  *
 *    z$   '$$$P*4c.*$$$*.z@*R$$$    $.                                   *
 *   z$"    ""       #$F^      ""    '$c                                  *
 *  z$$beu     .ue="  $  "=e..    .zed$$c                                 *
 *      "#$e z$*"   .  `.   ^*Nc e$""                                     *
 *         "$$".  .r"   ^4.  .^$$"                                        *
 *          ^.@*"6L=\ebu^+C$"*b."                                         *
 *        "**$.  "c 4$$$  J"  J$P*"    OS:  [ ] DOS  [X] WIN95  [ ] PORT  *
 *            ^"--.^ 9$"  .--""      COMP:  [ ] WATCOM  [X] VISUAL C++    *
 *                    "                     [ ] EIFFEL  [ ] GCC/GXX/DJGPP *
 *                                                                        *
 * This source code is Copyright (C) Nayma Software.  ALL RIGHTS RESERVED *
 *                                                                        *
 **************************************************************************/

#ifndef TONY_GAME_H
#define TONY_GAME_H

#include "tony/adv.h"
#include "tony/gfxcore.h"
#include "tony/input.h"
#include "tony/loc.h"
#include "tony/utils.h"

namespace Tony {

#define INIT_GFX16_FROMRAW(dwRes, buf16)	\
	raw = new RMResRaw(dwRes);	\
	assert(raw->IsValid());			\
	assert((buf16) == NULL);			\
	(buf16) = new RMGfxSourceBuffer16(false); \
	(buf16)->Init(*raw,raw->Width(),raw->Height()); \
	delete raw;

#define INIT_GFX8_FROMRAW(dwRes, buf8)	\
	raw = new RMResRaw(dwRes);	\
	assert(raw->IsValid());			\
	assert((buf8) == NULL);			\
	(buf8) = new RMGfxSourceBuffer8RLEByte(); \
	(buf8)->Init(*raw, raw->Width(), raw->Height(), true); \
	delete raw;

extern bool bCfgInvLocked;
extern bool bCfgInvNoScroll;
extern bool bCfgTimerizedText;
extern bool bCfgInvUp;
extern bool bCfgAnni30;
extern bool bCfgAntiAlias;
extern bool bCfgSottotitoli;
extern bool bCfgTransparence;
extern bool bCfgInterTips;
extern bool bCfgDubbing;
extern bool bCfgMusic;
extern bool bCfgSFX;
extern int  nCfgTonySpeed;
extern int  nCfgTextSpeed;
extern int	 nCfgDubbingVolume;
extern int	 nCfgMusicVolume;
extern int	 nCfgSFXVolume;
extern bool bSkipSfxNoLoop;

extern bool bPatIrqFreeze;

class RMPointer : public RMGfxTask {
private:
	RMGfxSourceBuffer8 *m_pointer[16];
	RMPoint m_hotspot[16];
	RMPoint m_pos;

	RMItem *m_specialPointer[16];

	int m_nCurPointer;
	int m_nCurSpecialPointer;

	RMGfxSourceBuffer8 *m_nCurCustomPointer;

public:
	enum POINTER {
		PTR_NONE = 0,
		PTR_FRECCIASU,
		PTR_FRECCIAGIU,
		PTR_FRECCIASINISTRA,
		PTR_FRECCIADESTRA,
		PTR_FRECCIAMAPPA,
		PTR_CUSTOM
	};

public:
	// Constructor & destructor
	RMPointer();	
	virtual ~RMPointer();

	// Initialisation
	void Init(void);

	// Deinitialisation
	void Close(void);

	// Process a frame
	void DoFrame(RMGfxTargetBuffer *bigBuf);

	// Overloading of priorities
	int Priority();

	// Overloading draw method
	void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
	
	// Sets the current co-ordinates
	void SetCoord(RMPoint pt) { m_pos = pt; }

	// Overloading of the method to see if rising from the list
	bool RemoveThis();

	// Sets a new action as current
	void SetAction(RMTonyAction action) {	m_nCurPointer = action; }

	// Sets a new pointer
	void SetSpecialPointer(POINTER ptr) {	
		m_nCurSpecialPointer=ptr; 
		if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[ptr-1]->SetPattern(1);  
	}
	POINTER GetSpecialPointer(void) { return (POINTER)m_nCurSpecialPointer; }

	// Set the new custom pointer
	void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { m_nCurCustomPointer = ptr; }

	// Return the current action to be applied according to the pointer
	int CurAction(void);
};

class RMOptionButton: public RMGfxTaskSetPrior {
public:
	RMRect m_rect;
	RMGfxSourceBuffer16 *m_buf;
	bool m_bActive;
	bool m_bHasGfx;
	bool m_bDoubleState;

public:
	RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false);
	RMOptionButton(RMRect pt);
	virtual ~RMOptionButton();

	bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick);
	void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
	void AddToList(RMGfxTargetBuffer &bigBuf);
	bool IsActive() { return m_bActive; }
	void SetActiveState(bool bState) { m_bActive=bState; }
};

class RMOptionSlide : public RMGfxTaskSetPrior {
private:
	RMOptionButton* m_PushLeft;
	RMOptionButton* m_PushRight;
	RMGfxSourceBuffer16* m_SliderCenter;
	RMGfxSourceBuffer16* m_SliderLeft;
	RMGfxSourceBuffer16* m_SliderRight;
	RMGfxSourceBuffer16* m_SliderSingle;
	int m_nSlideSize;
	RMPoint m_pos;
	int m_nValue;
	int m_nMax;
	int m_nStep;

public:
	RMOptionSlide(RMPoint pt, int m_nRange=100, int m_nStartValue=0, int slideSize=300);
	virtual ~RMOptionSlide();

	bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick);
	void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim);
	void AddToList(RMGfxTargetBuffer& bigBuf);

	int GetValue() { return m_nValue; }
};

class RMOptionScreen : public RMGfxWoodyBuffer {
private:
	RMGfxSourceBuffer16 *m_menu;
	RMGfxSourceBuffer16 *m_QuitConfirm;
	RMGfxSourceBuffer16 *m_HideLoadSave;
	RMOptionButton *m_ButtonQuitYes;
	RMOptionButton *m_ButtonQuitNo;
	RMOptionButton *m_ButtonExit;
	RMOptionButton *m_ButtonQuit;
	RMOptionButton *m_ButtonLoad;
	RMOptionButton *m_ButtonSave;
	RMOptionButton *m_ButtonGameMenu;
	RMOptionButton *m_ButtonGfxMenu;
	RMOptionButton *m_ButtonSoundMenu;
	RMGfxSourceBuffer8 *m_SaveEasy;
	RMGfxSourceBuffer8 *m_SaveHard;
	RMGfxSourceBuffer16 *m_curThumb[6];
	RMString m_curThumbName[6];
	byte m_curThumbDiff[6];
	RMOptionButton *m_ButtonSave_States[6];
	RMOptionButton *m_ButtonSave_ArrowLeft;
	RMOptionButton *m_ButtonSave_ArrowRight;
	RMOptionButton *m_ButtonGfx_Tips;

	RMOptionButton *m_ButtonSound_DubbingOn;
	RMOptionButton *m_ButtonSound_MusicOn;
	RMOptionButton *m_ButtonSound_SFXOn;

	RMOptionSlide *m_SlideTonySpeed;
	RMOptionSlide *m_SlideTextSpeed;


	int m_statePos;
	bool m_bEditSaveName;
	int m_nEditPos;
	char m_EditName[256];
	
	union {
		RMOptionButton *m_ButtonGame_Lock;
		RMOptionButton *m_ButtonGfx_Anni30;
		RMOptionSlide *m_SliderSound_Music;
	};
	union {
		RMOptionButton *m_ButtonGame_TimerizedText;
		RMOptionButton *m_ButtonGfx_AntiAlias;
		RMOptionSlide *m_SliderSound_SFX;
	};
	union {
		RMOptionButton *m_ButtonGame_Scrolling;
		RMOptionButton *m_ButtonGfx_Sottotitoli;
		RMOptionSlide *m_SliderSound_Dubbing;
	};
	union {
		RMOptionButton *m_ButtonGame_InterUp;
		RMOptionButton *m_ButtonGfx_Trans;
	};

	int m_FadeStep;
	bool m_bExit;
	bool m_bQuitConfirm;
	int m_FadeY;
	int m_FadeTime;
	bool m_bLoadMenuOnly;
	bool m_bNoLoadSave;
	bool m_bAlterGfx;

	enum STATE {
		MENUGAME,
		MENUGFX,
		MENUSOUND,
		MENULOAD,
		MENUSAVE
	};

	STATE m_nState;
	STATE m_nLastState;

public:
	RMOptionScreen();
	virtual ~RMOptionScreen();

	bool Init(RMGfxTargetBuffer& bigBuf);
	bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false);
	bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false);
	bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf);
	void ReInit(RMGfxTargetBuffer &bigBuf);
	bool Close();
	bool IsClosing();

	// Metodi in overloading da RMGfxTask
	int Priority();
	void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
	bool RemoveThis();

	// Polling per l'option screen
	void DoFrame(RMInput *m_input);

protected:

	// Inizializza tutto per il nuovo stato
	void InitState(void);
	void CloseState(void);
	void ChangeState(STATE newState);

	// Ridisegna tutto il menu delle opzioni
	void RefreshAll(void);
	void RefreshThumbnails(void);
	
	// Carica lo screenshot per il salvataggio
	bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff);
};

} // End of namespace Tony

#endif