2011-09-05 00:22:00 +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.
|
|
|
|
*
|
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1995-1997 Presto Studios, Inc.
|
|
|
|
*
|
|
|
|
* 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 PEGASUS_HOTSPOT_H
|
|
|
|
#define PEGASUS_HOTSPOT_H
|
|
|
|
|
|
|
|
#include "common/list.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
|
|
|
|
#include "pegasus/constants.h"
|
|
|
|
#include "pegasus/types.h"
|
2011-09-05 20:46:00 +00:00
|
|
|
#include "pegasus/util.h"
|
2011-09-05 00:22:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Hot spots combine a pixel area, an ID value and an active flag.
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-09-05 00:22:00 +00:00
|
|
|
A point is considered in a hot spot if the point is in the hot spot's pixel area and
|
|
|
|
the active flag is set.
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-09-05 00:22:00 +00:00
|
|
|
In addition, hot spots have a 32 bit word of bit flags for filtering use.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-09-06 19:42:54 +00:00
|
|
|
namespace Common {
|
|
|
|
class ReadStream;
|
|
|
|
}
|
|
|
|
|
2011-09-05 00:22:00 +00:00
|
|
|
namespace Pegasus {
|
|
|
|
|
2011-09-06 19:42:54 +00:00
|
|
|
// Our implementation of QuickDraw regions
|
|
|
|
class Region {
|
|
|
|
public:
|
|
|
|
Region() {}
|
|
|
|
Region(Common::ReadStream *stream);
|
|
|
|
Region(const Common::Rect &rect);
|
|
|
|
|
|
|
|
Common::Rect getBoundingBox() const { return _bounds; }
|
|
|
|
|
|
|
|
bool pointInRegion(const Common::Point &point) const;
|
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void moveTo(CoordType h, CoordType v);
|
2011-09-06 19:42:54 +00:00
|
|
|
void moveTo(const Common::Point &point);
|
2011-12-16 19:17:50 +00:00
|
|
|
void translate(CoordType h, CoordType v);
|
2011-09-06 19:42:54 +00:00
|
|
|
void translate(const Common::Point &point);
|
2011-12-16 19:17:50 +00:00
|
|
|
void getCenter(CoordType &h, CoordType &v) const;
|
2011-09-06 19:42:54 +00:00
|
|
|
void getCenter(Common::Point &point) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Common::Rect _bounds;
|
|
|
|
|
|
|
|
struct Run {
|
|
|
|
uint16 start, end;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Vector : public Common::List<Run> {
|
|
|
|
public:
|
|
|
|
uint16 y;
|
|
|
|
};
|
|
|
|
|
|
|
|
Common::List<Vector> _vectors;
|
|
|
|
};
|
|
|
|
|
2011-09-05 20:46:00 +00:00
|
|
|
class Hotspot : public IDObject {
|
2011-09-05 00:22:00 +00:00
|
|
|
public:
|
2011-12-16 19:17:50 +00:00
|
|
|
Hotspot(const HotSpotID);
|
2011-09-05 00:22:00 +00:00
|
|
|
virtual ~Hotspot();
|
2011-09-06 19:42:54 +00:00
|
|
|
|
|
|
|
void setArea(const Region ®ion) { _spotArea = region; }
|
2011-09-05 00:22:00 +00:00
|
|
|
void setArea(const Common::Rect &);
|
2011-12-16 19:17:50 +00:00
|
|
|
void setArea(const CoordType, const CoordType, const CoordType, const CoordType);
|
2011-09-05 00:22:00 +00:00
|
|
|
void getBoundingBox(Common::Rect &) const;
|
2011-09-06 19:42:54 +00:00
|
|
|
void getArea(Region &) const;
|
2011-09-05 00:22:00 +00:00
|
|
|
void getCenter(Common::Point&) const;
|
2011-12-16 19:17:50 +00:00
|
|
|
void getCenter(CoordType&, CoordType&) const;
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void moveSpotTo(const CoordType, const CoordType);
|
2011-09-05 00:22:00 +00:00
|
|
|
void moveSpotTo(const Common::Point);
|
2011-12-16 19:17:50 +00:00
|
|
|
void moveSpot(const CoordType, const CoordType);
|
2011-09-05 00:22:00 +00:00
|
|
|
void moveSpot(const Common::Point);
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-09-05 00:22:00 +00:00
|
|
|
bool pointInSpot(const Common::Point) const;
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-09-05 00:22:00 +00:00
|
|
|
void setActive();
|
|
|
|
void setInactive();
|
|
|
|
bool isSpotActive() const;
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
HotSpotFlags getHotspotFlags() const;
|
|
|
|
void setHotspotFlags(const HotSpotFlags);
|
|
|
|
void setMaskedHotspotFlags(const HotSpotFlags flags, const HotSpotFlags mask);
|
2011-09-05 00:22:00 +00:00
|
|
|
|
|
|
|
protected:
|
2011-09-06 19:42:54 +00:00
|
|
|
Region _spotArea;
|
2011-12-16 19:17:50 +00:00
|
|
|
HotSpotFlags _spotFlags;
|
2011-09-05 00:22:00 +00:00
|
|
|
bool _spotActive;
|
|
|
|
};
|
|
|
|
|
|
|
|
class HotspotList : public Common::List<Hotspot *> {
|
|
|
|
public:
|
|
|
|
HotspotList();
|
|
|
|
virtual ~HotspotList();
|
|
|
|
|
|
|
|
void deleteHotspots();
|
|
|
|
|
|
|
|
Hotspot *findHotspot(const Common::Point);
|
2011-12-16 19:17:50 +00:00
|
|
|
HotSpotID findHotspotID(const Common::Point);
|
|
|
|
Hotspot *findHotspotByID(const HotSpotID);
|
|
|
|
Hotspot *findHotspotByMask(const HotSpotFlags);
|
2011-09-05 00:22:00 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void activateMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
|
2011-09-05 00:22:00 +00:00
|
|
|
void deactivateAllHotspots();
|
2011-12-16 19:17:50 +00:00
|
|
|
void deactivateMaskedHotspots(const HotSpotFlags);
|
2011-09-05 00:22:00 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void activateOneHotspot(const HotSpotID);
|
|
|
|
void deactivateOneHotspot(const HotSpotID);
|
2012-09-26 02:10:32 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void removeOneHotspot(const HotSpotID);
|
|
|
|
void removeMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
|
2011-09-05 00:22:00 +00:00
|
|
|
|
2011-12-16 19:17:50 +00:00
|
|
|
void setHotspotRect(const HotSpotID, const Common::Rect&);
|
|
|
|
void getHotspotRect(const HotSpotID, Common::Rect&);
|
2011-09-05 00:22:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef HotspotList::iterator HotspotIterator;
|
|
|
|
|
2012-08-28 20:36:50 +00:00
|
|
|
#define g_allHotspots (((PegasusEngine *)g_engine)->getAllHotspots())
|
2011-09-05 00:22:00 +00:00
|
|
|
|
|
|
|
} // End of namespace Pegasus
|
|
|
|
|
|
|
|
#endif
|