Hi. Yeah, another problem. Sorry.
I'm trying to incorporate a two-button interface, which I've botched together via various examples of how to do it that have been posted on the AGS boards over the year.
Left-click interacts, right-click examines. Moving the mouse over a hotspot, object or character changes the cursor to 'interact'.
That's all working fine, but I'm struggling to get it working with the always-on inventory bar I have down the right of the screen. I'm pretty sure it's a problem with the repeatedly_execute function, I'm just not quite sure what I'm doing with it.
At the moment, when you hover over any part of the inventory (which exists past x=610), the mouse cursor flickers 'interact' mode on and off at about a billion frames per second. You can only select the inventory item if you click during one of the frames when it's in interact mode, so it doubles up as both a graphical bug and an interaction one.
I'm pretty sure this is my problem:
Code: ags
because it's specifying that it should turn the mouse to 'interact' whenever the mouse is over the inventory portion of the screen, not over individual inventory items. I've tried searching for what would be a better code, but to no avail.
But I'm not quite sure as to why it's flickering on and off in the way it does. Any help would be really appreciated.
Full rep_ex code below:
Code: ags
I'm trying to incorporate a two-button interface, which I've botched together via various examples of how to do it that have been posted on the AGS boards over the year.
Left-click interacts, right-click examines. Moving the mouse over a hotspot, object or character changes the cursor to 'interact'.
That's all working fine, but I'm struggling to get it working with the always-on inventory bar I have down the right of the screen. I'm pretty sure it's a problem with the repeatedly_execute function, I'm just not quite sure what I'm doing with it.
At the moment, when you hover over any part of the inventory (which exists past x=610), the mouse cursor flickers 'interact' mode on and off at about a billion frames per second. You can only select the inventory item if you click during one of the frames when it's in interact mode, so it doubles up as both a graphical bug and an interaction one.
I'm pretty sure this is my problem:
// Mouse flickers between interact and pointer when over anywhere on the far right of the screen.
if (mouse.x > 610)
{
if (!gInventory.Visible) mouse.Mode = eModePointer; }
// End of problematic code
because it's specifying that it should turn the mouse to 'interact' whenever the mouse is over the inventory portion of the screen, not over individual inventory items. I've tried searching for what would be a better code, but to no avail.
But I'm not quite sure as to why it's flickering on and off in the way it does. Any help would be really appreciated.
Full rep_ex code below:
function repeatedly_execute() {
if (IsGamePaused()) return;
int mm = mouse.Mode;
int nm; // new mode
Hotspot*h;
Object*o;
int lt = GetLocationType(mouse.x, mouse.y); // what's under the cursor?
if (mm != eModeUseinv) {
if (lt == eLocationNothing) nm = eModeWalkto;
if (lt == eLocationHotspot) {
h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
nm = h.GetProperty("def_curs");
}
if (lt == eLocationObject) {
o = Object.GetAtScreenXY(mouse.x, mouse.y);
nm = o.GetProperty("def_curs");
}
if (lt == eLocationCharacter) {
nm = eModeInteract;
}
// The offending code is presumably in here.
if (mouse.x > 610)
{
if (!gInventory.Visible) mouse.Mode = eModeInteract; }
// End of problematic code
if (nm != mm) mouse.Mode = nm; // only change if necessary to not disturb animated cursors
}
}