aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/inventory.h
blob: e2143bb24bcdafb9202a055f7267a25fd662c472 (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
/* 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:  Inventory.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_INVENTORY_H
#define TONY_INVENTORY_H

#include "common/scummsys.h"
#include "common/system.h"
#include "tony/font.h"
#include "tony/game.h"
#include "tony/gfxcore.h"
#include "tony/loc.h"

namespace Tony {

struct RMInventoryItem {
	RMItem icon;
	RMGfxSourceBuffer8RLEByteAA	*pointer;
	int status;
};

class RMInventory : public RMGfxWoodyBuffer {
private:
	enum STATE {
		CLOSED,
		OPENING,
		OPENED,
		CLOSING,
		SELECTING
	};

protected:
	int m_nItems;
	RMInventoryItem *m_items;
	
	int m_inv[256];
	int m_nInv;
	int m_curPutY;
	uint32 m_curPutTime;

	int m_curPos;
	STATE m_state;
	bool m_bHasFocus;
	int m_nSelectObj;
	int m_nCombine;
	bool m_bCombining;
	
	bool m_bBlinkingRight, m_bBlinkingLeft;

	int miniAction;
	RMItem miniInterface;
	RMText m_hints[3];
	
	OSystem::MutexRef m_csModifyInterface;

protected:
	// Prepara l'immagine dell'inventario. Va richiamato ogni volta
	//  che l'inventario cambia
	void Prepare(void);

	// Controlla se la posizione Y del mouse � corretta, anche in base
	// alla posizione dell'inventario su schermo
	bool CheckPointInside(RMPoint &pt);

public:
	RMInventory();
	virtual ~RMInventory();

	// Prepara un frame
	void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen);

	// Inizializzazione e chiusura
	void Init(void);
	void Close(void);
	void Reset(void);

	// Overload per la rimozione da otlist
	virtual void RemoveThis(CORO_PARAM, bool &result);

	// Overload per il disegno (per la posizione x&y e l'interfaccina)
	virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);

	// Metodo per determinare se l'inventario sta comandando gli input
	bool HaveFocus(RMPoint mpos);

	// Metodo per determinare se la mini interfaccia � attiva
	bool MiniActive(void);

	// Gestisce il click sinistro del mouse (solo quando c'ha focus)
	bool LeftClick(RMPoint mpos, int &nCombineObj);
	
	// Gestisce il tasto destro del mouse (solo quando c'ha focus)
	void RightClick(RMPoint mpos);
	bool RightRelease(RMPoint mpos, RMTonyAction &curAction);

	// Avverte che � finito il combine
	void EndCombine(void);
	
public:		
	// Aggiunta di un oggetto all'inventario
	void AddItem(int code);
	RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; }
	RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; }
	RMInventory& operator+=(int code) { AddItem(code); return *this; }

	// Rimozione di oggetto
	void RemoveItem(int code);

	// Siamo sopra un oggetto?
	RMItem* WhichItemIsIn(RMPoint mpt);
	bool ItemInFocus(RMPoint mpt);

	// Cambia l'icona di un oggetto
	void ChangeItemStatus(uint32 dwCode, uint32 dwStatus);

	// Salvataggio
	int GetSaveStateSize(void);
	void SaveState(byte *state);
	int LoadState(byte *state);
};


class RMInterface : public RMGfxSourceBuffer8RLEByte {
private:
	bool m_bActive;
	RMPoint m_mpos;
	RMPoint m_openPos;
	RMPoint m_openStart;
	RMText m_hints[5];
	RMGfxSourceBuffer8RLEByte m_hotzone[5];
	RMRect m_hotbbox[5];
	bool m_bPalesati;
	int m_lastHotZone;

protected:
	// Dice su quale zona calda si trova il punto	
	int OnWhichBox(RMPoint pt);

public:
	virtual ~RMInterface();

	// Il solito DoFrame (polling del motore grafico)
	void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos);		

	// TRUE se � attiva (non si pu� selezionare oggetti)		
	bool Active(); 

	// Inizializzazione
	void Init(void);
	void Close(void);

	// Resetta l'interfaccia
	void Reset(void);

	// Avverte dei click e rilasci del mouse
	void Clicked(RMPoint mousepos);
	bool Released(RMPoint mousepos, RMTonyAction &action);

	// Attiva o disattiva il quinto verbo
	void SetPalesati(bool bOn);
	bool GetPalesati(void);

	// Overloading del Draw per il posizionamente
	virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
};

} // End of namespace Tony

#endif