Skip to content

Commit

Permalink
Editor, Engine: proper handling of Hotspot WalkOn/MouseOver events
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Jul 24, 2023
1 parent 24576f9 commit eae35f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Editor/AGS.Types/RoomHotspot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ static RoomHotspot()
"$$03 hotspot", "Any click on hotspot","Mouse moves over hotspot",
"$$05 hotspot", "$$08 hotspot", "$$09 hotspot"},
new string[] { "WalkOn", "Look", "Interact", "UseInv", "Talk", "AnyClick", "MouseMove", "PickUp", "Mode8", "Mode9" },
"Hotspot *h, CursorMode mode");
new string[] { /*WalkOn*/"Hotspot *h", /*Look*/"Hotspot *h, CursorMode mode",
/*Interact*/"Hotspot *h, CursorMode mode", /*UseInv*/"Hotspot *h, CursorMode mode",
/*Talk*/"Hotspot *h, CursorMode mode", /*AnyClick*/"Hotspot *h, CursorMode mode",
/*MouseMove*/"Hotspot *h", /*PickUp*/"Hotspot *h, CursorMode mode",
/*Mode8*/"Hotspot *h, CursorMode mode", /*Mode9*/"Hotspot *h, CursorMode mode" });
}

public RoomHotspot(IChangeNotification changeNotifier)
Expand Down
15 changes: 10 additions & 5 deletions Engine/ac/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "ac/gui.h"
#include "ac/roomstatus.h"
#include "ac/screen.h"
#include "ac/dynobj/scripthotspot.h"
#include "ac/dynobj/cc_hotspot.h"
#include "debug/debug_log.h"
#include "main/game_run.h"
#include "script/cc_common.h"
Expand All @@ -49,6 +51,8 @@ extern IGraphicsDriver *gfxDriver;
extern AGSPlatformDriver *platform;
extern RGB old_palette[256];
extern int displayed_room;
extern ScriptHotspot scrHotspot[MAX_ROOM_HOTSPOTS];
extern CCHotspot ccDynamicHotspot;

int in_enters_screen=0,done_es_error = 0;
int in_leaves_screen = -1;
Expand Down Expand Up @@ -157,13 +161,14 @@ void process_event(const EventHappened *evp) {
ObjectEvent obj_evt;

if (evp->data1==EVB_HOTSPOT) {

if (thisroom.Hotspots[evp->data2].EventHandlers != nullptr)
scriptPtr = thisroom.Hotspots[evp->data2].EventHandlers;
const int hotspot_id = evp->data2;
if (thisroom.Hotspots[hotspot_id].EventHandlers != nullptr)
scriptPtr = thisroom.Hotspots[hotspot_id].EventHandlers;
else
evpt=&croom->intrHotspot[evp->data2];
evpt=&croom->intrHotspot[hotspot_id];

obj_evt = ObjectEvent("hotspot%d", evp->data2);
obj_evt = ObjectEvent("hotspot%d", hotspot_id,
RuntimeScriptValue().SetScriptObject(&scrHotspot[hotspot_id], &ccDynamicHotspot));
//Debug::Printf("Running hotspot interaction for hotspot %d, event %d", evp->data2, evp->data3);
}
else if (evp->data1==EVB_ROOM) {
Expand Down
2 changes: 1 addition & 1 deletion Engine/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ObjectEvent
ObjectEvent(const String &block_name, int block_id = 0)
: BlockName(block_name), BlockID(block_id) {}
ObjectEvent(const String &block_name, int block_id,
const RuntimeScriptValue &dyn_obj, int mode)
const RuntimeScriptValue &dyn_obj, int mode = MODE_NONE)
: BlockName(block_name), BlockID(block_id), DynObj(dyn_obj), Mode(mode) {}
};

Expand Down

0 comments on commit eae35f0

Please sign in to comment.