mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
MYST3: Handle hotspots positionned by variables
This commit is contained in:
parent
f7eeba6076
commit
c2e02c4515
@ -88,7 +88,7 @@ bool Console::Cmd_Infos(int argc, const char **argv) {
|
||||
for(uint j = 0; j < nodeData->hotspots[i].rects.size(); j++) {
|
||||
PolarRect &rect = nodeData->hotspots[i].rects[j];
|
||||
|
||||
DebugPrintf(" rect > pitch: %d heading: %d height: %d width: %d\n",
|
||||
DebugPrintf(" rect > pitch: %d heading: %d width: %d height: %d\n",
|
||||
rect.centerPitch, rect.centerHeading, rect.width, rect.height);
|
||||
}
|
||||
|
||||
|
@ -21,35 +21,42 @@
|
||||
*/
|
||||
|
||||
#include "engines/myst3/hotspot.h"
|
||||
#include "engines/myst3/state.h"
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
bool HotSpot::isPointInRectsCube(const Common::Point &p)
|
||||
{
|
||||
for(uint j = 0;j < rects.size();j++){
|
||||
bool HotSpot::isPointInRectsCube(const Common::Point &p) {
|
||||
for (uint j = 0; j < rects.size(); j++) {
|
||||
Common::Rect rect = Common::Rect(
|
||||
rects[j].centerHeading - rects[j].width / 2,
|
||||
rects[j].centerPitch - rects[j].height / 2,
|
||||
rects[j].centerHeading + rects[j].width / 2,
|
||||
rects[j].centerPitch + rects[j].height / 2);
|
||||
if(rect.contains(p)){
|
||||
if (rect.contains(p))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HotSpot::isPointInRectsFrame(const Common::Point &p)
|
||||
{
|
||||
for(uint j = 0;j < rects.size();j++){
|
||||
Common::Rect rect = Common::Rect(rects[j].width,
|
||||
rects[j].height);
|
||||
rect.translate(rects[j].centerPitch,
|
||||
rects[j].centerHeading);
|
||||
if(rect.contains(p)){
|
||||
return true;
|
||||
bool HotSpot::isPointInRectsFrame(GameState *state, const Common::Point &p) {
|
||||
for (uint j = 0; j < rects.size(); j++) {
|
||||
|
||||
int16 x = rects[j].centerPitch;
|
||||
int16 y = rects[j].centerHeading;
|
||||
int16 w = rects[j].width;
|
||||
int16 h = rects[j].height;
|
||||
|
||||
if (y < 0) {
|
||||
x = state->getVar(x);
|
||||
y = state->getVar(-y);
|
||||
h = -h;
|
||||
}
|
||||
|
||||
Common::Rect rect = Common::Rect(w, h);
|
||||
rect.translate(x, y);
|
||||
if (rect.contains(p))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
namespace Myst3 {
|
||||
|
||||
class GameState;
|
||||
|
||||
struct Opcode {
|
||||
uint8 op;
|
||||
Common::Array<int16> args;
|
||||
@ -53,7 +55,7 @@ public:
|
||||
Common::Array<Opcode> script;
|
||||
|
||||
bool isPointInRectsCube(const Common::Point &p);
|
||||
bool isPointInRectsFrame(const Common::Point & p);
|
||||
bool isPointInRectsFrame(GameState *state, const Common::Point &p);
|
||||
};
|
||||
|
||||
|
||||
|
@ -211,7 +211,7 @@ Common::Array<HotSpot *> Myst3Engine::listHoveredHotspots(NodePtr nodeData) {
|
||||
}
|
||||
|
||||
for (uint j = 0; j < nodeData->hotspots.size(); j++) {
|
||||
if (nodeData->hotspots[j].isPointInRectsFrame(scaledMouse)
|
||||
if (nodeData->hotspots[j].isPointInRectsFrame(_state, scaledMouse)
|
||||
&& _state->evaluate(nodeData->hotspots[j].condition)) {
|
||||
hovered.push_back(&nodeData->hotspots[j]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user