2012-04-29 23:27:12 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
2012-05-14 05:43:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Tony Tough source code
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997-2003 Nayma Software
|
|
|
|
*/
|
2012-04-29 23:27:12 +00:00
|
|
|
|
|
|
|
#ifndef TONY_INVENTORY_H
|
|
|
|
#define TONY_INVENTORY_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "tony/font.h"
|
2012-05-01 14:23:41 +00:00
|
|
|
#include "tony/game.h"
|
2012-04-29 23:27:12 +00:00
|
|
|
#include "tony/gfxcore.h"
|
|
|
|
#include "tony/loc.h"
|
|
|
|
|
|
|
|
namespace Tony {
|
|
|
|
|
|
|
|
struct RMInventoryItem {
|
2012-06-10 22:43:59 +00:00
|
|
|
RMItem _icon;
|
|
|
|
RMGfxSourceBuffer8RLEByteAA *_pointer;
|
|
|
|
int _status;
|
2012-04-29 23:27:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RMInventory : public RMGfxWoodyBuffer {
|
|
|
|
private:
|
2012-06-16 09:09:08 +00:00
|
|
|
enum InventoryState {
|
2012-04-29 23:27:12 +00:00
|
|
|
CLOSED,
|
|
|
|
OPENING,
|
|
|
|
OPENED,
|
|
|
|
CLOSING,
|
|
|
|
SELECTING
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
2012-06-06 06:31:06 +00:00
|
|
|
int _nItems;
|
|
|
|
RMInventoryItem *_items;
|
2012-05-21 21:53:13 +00:00
|
|
|
|
2012-06-06 06:31:06 +00:00
|
|
|
int _inv[256];
|
|
|
|
int _nInv;
|
|
|
|
int _curPutY;
|
|
|
|
uint32 _curPutTime;
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-06 06:31:06 +00:00
|
|
|
int _curPos;
|
2012-06-16 09:09:08 +00:00
|
|
|
InventoryState _state;
|
2012-06-06 06:31:06 +00:00
|
|
|
bool _bHasFocus;
|
|
|
|
int _nSelectObj;
|
|
|
|
int _nCombine;
|
|
|
|
bool _bCombining;
|
2012-05-21 21:53:13 +00:00
|
|
|
|
2012-06-06 06:31:06 +00:00
|
|
|
bool _bBlinkingRight, _bBlinkingLeft;
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-10 22:43:59 +00:00
|
|
|
int _miniAction;
|
|
|
|
RMItem _miniInterface;
|
2012-06-06 06:31:06 +00:00
|
|
|
RMText _hints[3];
|
2012-05-21 21:53:13 +00:00
|
|
|
|
2012-06-06 06:31:06 +00:00
|
|
|
OSystem::MutexRef _csModifyInterface;
|
2012-04-29 23:27:12 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Prepare the image inventory. It should be recalled whenever the inventory changes
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
void prepare();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Check if the mouse Y position is conrrect, even under the inventory portion of the screen
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
bool checkPointInside(const RMPoint &pt);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
RMInventory();
|
|
|
|
virtual ~RMInventory();
|
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Prepare a frame
|
|
|
|
*/
|
2012-06-06 06:04:33 +00:00
|
|
|
void doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Initialization and closing
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
void init();
|
|
|
|
void close();
|
|
|
|
void reset();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Overload test for removal from OT list
|
|
|
|
*/
|
2012-06-05 16:51:20 +00:00
|
|
|
virtual void removeThis(CORO_PARAM, bool &result);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Overload the drawing of the inventory
|
|
|
|
*/
|
2012-06-05 06:39:55 +00:00
|
|
|
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Method for determining whether the inventory currently has the focus
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
bool haveFocus(const RMPoint &mpos);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Method for determining if the mini interface is active
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
bool miniActive();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Handle the left mouse click (only when the inventory has the focus)
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
bool leftClick(const RMPoint &mpos, int &nCombineObj);
|
2012-05-21 21:53:13 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Handle the right mouse button (only when the inventory has the focus)
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void rightClick(const RMPoint &mpos);
|
|
|
|
bool rightRelease(const RMPoint &mpos, RMTonyAction &curAction);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Warn that an item combine is over
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
void endCombine();
|
2012-05-21 21:53:13 +00:00
|
|
|
|
|
|
|
public:
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Add an item to the inventory
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void addItem(int code);
|
2012-09-02 08:34:11 +00:00
|
|
|
RMInventory &operator+=(RMItem *item);
|
|
|
|
RMInventory &operator+=(RMItem &item);
|
|
|
|
RMInventory &operator+=(int code);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Removes an item
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void removeItem(int code);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* We are on an object?
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
RMItem *whichItemIsIn(const RMPoint &mpt);
|
|
|
|
bool itemInFocus(const RMPoint &mpt);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Change the icon of an item
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void changeItemStatus(uint32 dwCode, uint32 dwStatus);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Save methods
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
int getSaveStateSize();
|
2012-06-06 06:31:06 +00:00
|
|
|
void saveState(byte *state);
|
|
|
|
int loadState(byte *state);
|
2012-04-29 23:27:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RMInterface : public RMGfxSourceBuffer8RLEByte {
|
|
|
|
private:
|
2012-06-06 06:31:06 +00:00
|
|
|
bool _bActive;
|
|
|
|
RMPoint _mpos;
|
|
|
|
RMPoint _openPos;
|
|
|
|
RMPoint _openStart;
|
|
|
|
RMText _hints[5];
|
|
|
|
RMGfxSourceBuffer8RLEByte _hotzone[5];
|
|
|
|
RMRect _hotbbox[5];
|
2012-06-11 22:07:50 +00:00
|
|
|
bool _bPerorate;
|
2012-06-06 06:31:06 +00:00
|
|
|
int _lastHotZone;
|
2012-04-29 23:27:12 +00:00
|
|
|
|
|
|
|
protected:
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Return which box a given point is in
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
int onWhichBox(RMPoint pt);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
|
|
|
public:
|
2012-06-13 22:11:56 +00:00
|
|
|
RMInterface();
|
2012-04-29 23:27:12 +00:00
|
|
|
virtual ~RMInterface();
|
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* The usual DoFrame (poll the graphics engine)
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* TRUE if it is active (you can select items)
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
bool active();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Initialization
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
void init();
|
|
|
|
void close();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Reset the interface
|
|
|
|
*/
|
2012-06-18 06:24:33 +00:00
|
|
|
void reset();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Warns of mouse clicks and releases
|
|
|
|
*/
|
2012-06-06 06:31:06 +00:00
|
|
|
void clicked(const RMPoint &mousepos);
|
|
|
|
bool released(const RMPoint &mousepos, RMTonyAction &action);
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Enables or disables the fifth verb
|
|
|
|
*/
|
2012-06-11 22:07:50 +00:00
|
|
|
void setPerorate(bool bOn);
|
2012-06-18 06:24:33 +00:00
|
|
|
bool getPerorate();
|
2012-04-29 23:27:12 +00:00
|
|
|
|
2012-06-17 17:39:58 +00:00
|
|
|
/**
|
|
|
|
* Overloaded Draw
|
|
|
|
*/
|
2012-06-05 06:39:55 +00:00
|
|
|
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
|
2012-04-29 23:27:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Tony
|
|
|
|
|
|
|
|
#endif
|