The game will not respond to middle click in the inventory.
General Settings -> Inventory -> Override built-in inventory window click handling is set to False.
(though if I write it as True, nothing happens on_mouse_click(), so I'll stay away from that)
Basically, I want to have:
MouseWheelNorth - go up in inventory (works)
MouseWheelSouth - go down in inventory (works)
LeftClick - work's opposite way, it Uses
RightClick - work's opposite way, it LooksAt
MiddleClick - I want deselect the currently selected item (not totally sure how to do this either). It Uses whatever invitem it's over. Display code is ignored completely.
When I make General Settings -> Inventory -> Override built-in inventory window click handling set to True, it does nothing at all with any mouse click.
function on_mouse_click(MouseButton button)
{
// Game paused?
if (IsGamePaused() == 1) { // do nothing if paused
} else
if (gInventory.Visible) { // if inventory is visible...
//move up and down throught inventory with mouse wheel:
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
//left click look, right click use
if (button == eMouseLeft) {
mouse.Mode=eModeLookat;
}
if (button == eMouseRight) {
mouse.Mode=eModeInteract;
}
if (mouse.IsButtonDown(eMouseMiddle) || button==eMouseMiddle) {
Display("thasth"); //NEVER DISPLAYS
}
Tried putting them in gInventory_OnClick(), same situation. Turned off 'override built-in inventory settings', it just did nothing when clicking in the inventory.
ps. this is in 3.5.0b5
More experimenting, I've set 'General Settings -> Inventory -> Override built-in inventory window click handling' to True, and used on_event() to capture the mouse button presses.
This is finally working, though not sure how to get father than this:
if (gInventory.Visible) {
//move up and down throught inventory with mouse wheel:
if (event==eEventGUIMouseUp) { <-- works
invCustomInv.ScrollUp();
}
if (event==eEventGUIMouseDown) { <-- works
invCustomInv.ScrollDown();
}
//left click look, right click use
if (mouse.Click(eMouseLeft)) { <-- does nothing
mouse.Mode=eModeLookat;
}
if (mouse.Click(eMouseRight)) { <-- does nothing
mouse.Mode=eModeInteract;
}
if (mouse.Click(eMouseMiddle)) { <-- does work sometimes
Display("thasth");
}
}
Okay, well, tried everything in every function and nothing works, or responds. I've spent all day on this, reading the forums and documentation.
So, I'm off to kill myself (j/k), but if anyone wants tell me where to capture: right-click, middle and left-click; and how to go about that (left click, lookat; right click, interact; middle click, get rid of activeinventory and go back to pointer) I would be eternally, eternally grateful.
Overriding the default handling means you need to add a block for eMouseLeftinv and eMouseRightinv to on_mouse_click.
There's also eMouseMiddleInv but there are people out there that don't have a middle mouse button. Using the right button is preferable (after a click, check if (player.ActiveInventory == null) and act accordingly).
Thankyou, I'll try this.
What is mouseleftinv and is it better than mouseleft?
Quote from: bx83 on Mon 29/07/2019 10:33:10
Thankyou, I'll try this.
What is mouseleftinv and is it better than mouseleft?
It's not "better", it's simply the event you
need to use in order to process mouse clicks in your inventory, since when the mouse is over an inventory window, AGS simply ignores eMouseLeft or eMouseRight and expects eMouseLeftInv/eMouseRightInv instead.
(And if I'm wrong about this please someone correct me! Sometimes I don't want to reply in case I'm giving misleading info but I think/hope it's not the case here :) )
It's not better.
When the user left clicks on the room, AGS calls on_mouse_click(eMouseLeft);.
When default inv handling is overridden and the user clicks on an inventory item with the left mouse button, AGS calls on_mouse_click(eMouseLeftinv);.
//move up and down throught inventory with mouse wheel:
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
//left click look, right click use
if (button == eMouseLeftInv) {
mouse.Mode=eModeLookat;
}
if (button == eMouseRightInv) {
mouse.Mode=eModeInteract;
}
if (button == eMouseMiddleInv) {
if (player.ActiveInventory!=null) mouse.Mode=eModeInteract;
}
The above doesn't actually *work* - it changes mode graphic, but it doesn't do 'interact with item' ie. useinv; or 'look at item'.
Adding:
Room.ProcessClick(mouse.x, mouse.y, eModeLookat/eModeInteract);
doesn't work either.
Quote from: bx83 on Mon 29/07/2019 10:46:42
//move up and down throught inventory with mouse wheel:
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
//left click look, right click use
if (button == eMouseLeftInv) {
mouse.Mode=eModeLookat;
}
if (button == eMouseRightInv) {
mouse.Mode=eModeInteract;
}
if (button == eMouseMiddleInv) {
if (player.ActiveInventory!=null) mouse.Mode=eModeInteract;
}
The above doesn't actually *work* - it changes mode graphic, but it doesn't do 'interact with item' ie. useinv; or 'look at item'.
It doesn't work because you're not telling it what to do. Or more precisely, you're only telling it to change the mouse mode, and nothing else.
Where you have:
if (button == eMouseLeftInv) {
mouse.Mode=eModeLookat;
}
Try using instead:
if (button == eMouseLeftInv) {
inventory[game.inv_activated].RunInteraction(eModeLookat);
}
(doing this from memory, so I hope I'm not omitting anything, but that's the idea anyway)
Okay will try this.
I've goth this:
function on_mouse_click(MouseButton button)
{
...
InventoryItem *tInv;
if (button == eMouseRightInv) {
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (player.ActiveInventory==null) {
if (tInv.IsInteractionAvailable(eModeInteract)) {
tInv.RunInteraction(eModeInteract);
}
} else if (player.ActiveInventory!=null) {
player.ActiveInventory==null;
}
}
if (button == eMouseLeftInv) {
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (tInv.IsInteractionAvailable(eModeLookat)) {
tInv.RunInteraction(eModeLookat);
}
}
...but there's an error on line 15: GlobalScript.asc(1708): Error (line 1708): PE04: parse error at 'player'
Works in if, but not on it's own.
Quote from: bx83 on Mon 29/07/2019 11:47:22
...but there's an error on line 15: GlobalScript.asc(1708): Error (line 1708): PE04: parse error at 'player'
Works in if, but not on it's own.
That's because you're using "==" there instead of "=" (comparing vs. assigning values).
Oh woops :P
Okay well now left mouse button works (look at).
But the right mouse button does nothing. At all.
Quote from: bx83 on Mon 29/07/2019 11:53:32
Oh woops :P
Okay well now left mouse button works (look at).
But the right mouse button does nothing. At all.
The only thing that comes to mind that might be screwing with your script is this line:
} else if (player.ActiveInventory!=null) {
Maybe try putting the
else if statement in another line, not immediately after the previous closing bracket? (no idea if this is actually a problem or not, I always start a new line for these things but maybe it just doesn't matter.)
If this doesn't work, then here is where my knowledge ends, I have no idea what might be happening and it's time for someone more knowledgeable to take over :-D
But why don't the lines:
if (player.ActiveInventory==null) {
if (tInv.IsInteractionAvailable(eModeInteract)) {
tInv.RunInteraction(eModeInteract);
do anything? Surely they should make the inventory item you just right-clicked on the ActiveInventory?
You should use:
tInv = inventory[game.inv_activated];
...because checking what is under the mouse isn't 100% reliable (I'm not sure that is the issue here though)
Quote from: bx83 on Mon 29/07/2019 12:10:51
But why don't the lines:
if (player.ActiveInventory==null) {
if (tInv.IsInteractionAvailable(eModeInteract)) {
tInv.RunInteraction(eModeInteract);
do anything? Surely they should make the inventory item you just right-clicked on the ActiveInventory?
At a guess, you aren't ever setting player.ActiveInventory to anything. If you are handling the clicks yourself you need specifically set it.
Quote from: bx83 on Mon 29/07/2019 12:10:51
But why don't the lines:
if (player.ActiveInventory==null) {
if (tInv.IsInteractionAvailable(eModeInteract)) {
tInv.RunInteraction(eModeInteract);
do anything? Surely they should make the inventory item you just right-clicked on the ActiveInventory?
Wait, so what you want to do is make the inventory item you right-clicked on the active inventory item, not trigger an interaction for that item?
In that case, you need to do
if (player.ActiveInventory==null) player.ActiveInventory = inventory[game.inv_activated];
Again, apologies if there are any typos!
The game now works, except right clicking something in the inventory (when activeitem==null) will cause the cursor to change to the inventory item cursor graphic, and then disappear .5 of a second later. It still runs UseInv on whatever else you click in the inventory; but the mouse cursor is nothing until you get out of inventory.
on_mouse_click:
function on_mouse_click(MouseButton button)
{
// Game paused?
if (IsGamePaused() == 1) { // do nothing if paused
} else
if (gInventory.Visible) { // if inventory is visible...
//move up through inventory with mouse wheel
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
//move down through inventory with mouse wheel
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
InventoryItem *tInv;
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (button == eMouseRightInv) {
if (player.ActiveInventory==null) {
player.ActiveInventory=inventory[game.inv_activated];
} else {
tInv.RunInteraction(eModeUseinv);
}
}
if (button == eMouseLeftInv) {
mouse.Mode=eModeLookat;
player.ActiveInventory=null;
tInv.RunInteraction(eModeLookat);
}
UpdateMouseGraphic (which I call whenever the mouse moves):
function UpdateMouseGraphic()
{
int newGraphic; // = 2054;
int lt = GetLocationType(mouse.x, mouse.y);
if (gInventory.Visible)
{
if (mouse.y >= 175 && (mouse.x <= 140 || mouse.x >= 1200))
{
gInventory.Visible = false;
mouse.Mode = PreviousMouseModeOutsideInventory;
return;
}
if (mouse.Mode == eModeLookat) { // LOOKAT
newGraphic = 105; // eye close
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (inve != null) {
newGraphic = 2056; // eye open
}
}
if (mouse.Mode==eModeInteract) { // INTERACTION
newGraphic = 2; // interact off
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (inve != null) {
newGraphic = 286; // interact on
}
}
} else {
The only other place that mentions UseInv is:
function btnIconCurInv_Click(GUIControl* control, MouseButton button)
{
if (player.ActiveInventory != null) mouse.Mode = eModeUseinv;
}
Basically, I want to know why running ModeUseInv or loading the .CursorGraphic (as the cursor) of the target inventory item would make it *not have any mouse graphic at all*.
This is definitely starting to fall outside of my comfort zone, but I do know that in General Settings there's an option to automatically set the cursor graphic to the currently active inventory item, so you don't have to handle the change of graphic by yourself. Maybe remove/hide any code you have that manually changes the cursor graphic to the active inventory item and let AGS handle it? Or alternatively, do everything yourself and disable this option in general settings...
Perhaps I should have a mouse.Mode==eModeUseInv in UpdateMouseGraphic() below eModeInteract block?
All suggestions welcome, I'm afk for 8 hours sleeping in the darkened, freezing nighttime of Sydney Australia.
If I may I rather avoid using leftinv etc, and instead use a repeatedly_execute_always (if needed depending if the cycles are paused when the inventory is up) and a InventoryItem.GetAtScreenXY.
So for example.
int MouseButtonPressed=-1;
function repeatedly_execute_always()
{
if (IsGamePaused() == 1) { // do nothing if paused
}
else
if (gInventory.Visible) { // if inventory is visible...
if (Mouse.IsButtonDown(eMouseWheelNorth) && Mouse.IsButtonDown(eMouseWheelSouth)
&& !Mouse.IsButtonDown(eMouseLeft) && !Mouse.IsButtonDown(eMouseRight))
{
MouseButtonPressed=-1;
}
else
{
if (MouseButtonPressed!=-1)
{
return;
}
}
//move up through inventory with mouse wheel
if (Mouse.IsButtonDown(eMouseWheelNorth)
{ //i think these don't get triggered here this way,so u might need to keep ur code on that mouse click for the wheel events
MouseButtonPressed=eMouseWheelNorth;
invCustomInv.ScrollUp();
}
//move down through inventory with mouse wheel
if (Mouse.IsButtonDown(eMouseWheelSouth))
{
MouseButtonPressed=eMouseWheelSouth;
invCustomInv.ScrollDown();
}
InventoryItem *tInv;
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if Mouse.IsButtonDown(eMouseRight)
{
MouseButtonPressed=eMouseRight;
if (player.ActiveInventory==null) {
player.ActiveInventory=inventory[game.inv_activated];
} else {
tInv.RunInteraction(eModeUseinv);
}
}
if Mouse.IsButtonDown(eMouseLeft)
{
MouseButtonPressed=eMouseLeft;
mouse.Mode=eModeLookat;
player.ActiveInventory=null;
tInv.RunInteraction(eModeLookat);
}
}
}
This looks like a bug in UpdateMouseGraphic(); can you post the entire function?
In general, in my experience it's best to separate concerns as far as possible, and repeatedly_execute(_always) should only deal with tasks where it is required. So I would recommend against detecting clicks in r_e, as opposed to mouse buttons / keys being held down.
Okay here's all the complete functions relating to Inventory stuff:
function show_inventory_window()
{
gInventory.Visible = true;
PreviousMouseModeOutsideInventory = mouse.Mode;
mouse.Mode=eModeLookat;
}
function on_mouse_click(MouseButton button)
{
// Game paused?
if (IsGamePaused() == 1) { // do nothing if paused
} else
if (gInventory.Visible) { // if inventory is visible...
//move up through inventory with mouse wheel
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
//move down through inventory with mouse wheel
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
InventoryItem *tInv;
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (button == eMouseRightInv) {
if (player.ActiveInventory==null) {
player.ActiveInventory=inventory[game.inv_activated];
} else {
tInv.RunInteraction(eModeUseinv);
}
}
if (button == eMouseLeftInv) {
mouse.Mode=eModeLookat;
player.ActiveInventory=null;
tInv.RunInteraction(eModeLookat);
}
} else { //if inventory *is not* visible
if (button == eMouseLeft) {
if (SamAndMaxInterface) {
int lt = GetLocationType(mouse.x, mouse.y);
if (lt == eLocationNothing) {
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
} else {
if (
(mouse.Mode==eModeInteract && !IsInteractionAvailable(mouse.x, mouse.y, eModeInteract)) ||
(mouse.Mode==eModeLookat && !IsInteractionAvailable(mouse.x, mouse.y, eModeLookat)) ||
(mouse.Mode==eModeTalkto && !IsInteractionAvailable(mouse.x, mouse.y, eModeTalkto))
)
{
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
} else {
//if (player.Room!=RM_W_VIL_OS &&
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
}
}
}
}
// cycle cursor 'forwards;
if (button == eMouseWheelSouth) {
mouse.SelectNextMode();
}
// Cycle the cursors 'backwards'
if (button == eMouseWheelNorth) {
if (SamAndMaxInterface) {
if (mouse.Mode > 0) { // If mode isn't WALK, set the previous mode (notice usage of numbers instead of eNums)
mouse.Mode = mouse.Mode-1;
} else {
if (player.ActiveInventory != null) { // WALK mode, and the player has a selected inventory item?
mouse.Mode = eModeUseinv; // Set mouse mode to UseInv
} else {
mouse.Mode = eModeTalkto; // Otherwise just set it to mode TALK (change this line if you add more cursor modes)
}
}
}
}
}
}
function UpdateMouseGraphic()
{
int newGraphic; // = 2054;
int lt = GetLocationType(mouse.x, mouse.y);
if (gInventory.Visible)
{
if (mouse.y >= 175 && (mouse.x <= 140 || mouse.x >= 1200))
{
gInventory.Visible = false;
mouse.Mode = PreviousMouseModeOutsideInventory;
return;
}
if (mouse.Mode == eModeLookat) { // LOOKAT
newGraphic = 105; // eye close
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (inve != null) {
newGraphic = 2056; // eye open
}
}
if (mouse.Mode==eModeInteract) { // INTERACTION
newGraphic = 2; // interact off
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (inve != null) {
newGraphic = 286; // interact on
}
}
} else {
if (mouse.Mode == eModeUseinv)
{
return;
}
if (mouse.Mode == eModeWalkto)
{
newGraphic = 3; // stand still
if (gInventory.Visible == true)
{
} else if (GetWalkableAreaAtRoom(mouse.x, mouse.y)!=0) {
newGraphic = 2054; // walking
}
} else
if (mouse.Mode == eModeLookat) { // LOOKAT
newGraphic = 105; // eye close
Hotspot* hs = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
// Looking at item in inventory
if (gInventory.Visible == true && inve != null) {
if (inve.IsInteractionAvailable(eModeLookat)) {
newGraphic = 2056; // eye open
}
} else {
if (lt == eLocationHotspot) {
if (hs != hotspot[0]) {
if (hs.GetProperty("hidden") == false) {
if(hs.IsInteractionAvailable(eModeLookat)) {
newGraphic = 2056; // eye open
}
}
}
} else
if (lt == eLocationCharacter) {
if (ch != null) {
if (ch.IsInteractionAvailable(eModeLookat)) {
newGraphic = 2056;
}
}
} else
if (lt == eLocationObject && ob.IsInteractionAvailable(eModeLookat) && ob.Visible == true) {
newGraphic = 2056; // eye open
}
}
} else
if (mouse.Mode==eModeInteract) { // INTERACTION
newGraphic = 2; // interact off
Hotspot* hs = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (gInventory.Visible == true && inve != null) {
if (inve.IsInteractionAvailable(eModeLookat)) {
newGraphic = 286;
}
} else {
if (hs != hotspot[0]) {
if (hs.GetProperty("hidden") == false) {
if (hs.IsInteractionAvailable(eModeInteract)) {
newGraphic = 286;
}
}
}
else if (lt == eLocationObject) {
if (ob.Visible) {
if (ob.IsInteractionAvailable(eModeInteract)) {
newGraphic = 286;
}
}
} else
if (lt == eLocationCharacter) {
if (ch != null) {
if (ch.IsInteractionAvailable(eModeInteract)) {
newGraphic = 286;
}
}
}
}
} else
if (mouse.Mode == eModeTalkto) { // TALKTO
newGraphic = 2058; // talk off
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (gInventory.Visible == true && inve != null) {
} else {
if (lt == eLocationCharacter) {
if (ch != null) {
if (ch.IsInteractionAvailable(eModeTalkto)) {
if (ch.GetProperty("convodone")==0) {
newGraphic = 213; // talk on
}
}
}
}
else
if (lt == eLocationObject && ob.Visible && ob.IsInteractionAvailable(eModeTalkto)) {
if (ob.GetProperty("convodone")==0) {
newGraphic = 213;
}
}
}
}
}
if (newGraphic != mouse.GetModeGraphic(mouse.Mode)) {
mouse.ChangeModeGraphic(mouse.Mode, newGraphic);
}
}
I think that's it, if you want me to post other functions I will.
ps SamAndMaxInterface is a variable which is always true, it shouldn't be there now, but whatevs.
Here's a video of it happening.
https://redrom.ltd/img/mouseclickdemo.mp4 (https://redrom.ltd/img/mouseclickdemo.mp4)
I start off by cycling forward and back in the walk/look/use/talk icons, with mouse wheel up/down.
I then demonstrate what happens when I press somewhere: If I press with look on a blank, does-not-have-a-look-interaction surface, Julius (main character) walks there. If I come on a visible surface with look interaction, it does this ('it's a bed of who's who of plant life').
I go to the inventory, and my last icon outside it saved. When I enter the inventory, my icon is Look; click left mouse button, it looks at an inventory item. Or if I right click, the icon goes (for about 20 cycles) to the cursor graphic of the item underneath the mouse, and then blank. If I move it around, I can still run a Use interaction on whatever inventory item I'm over (so, use rope on rope, use rope on knife, etc.) but the icon remains blank. Until I either a) left click something (and it goes back to Look icon), or I b) leave the inventory (in which case it defaults back to the last action I did before entering the inventory.
The Icon for useinv is Blank *anywhere in, around, or near the inventory object* - not just the inventory items:
(https://redrom.ltd/img/screenshotinventory.png)
Something to do with this line in UpdateMouseGraphic(), obviously:
if (mouse.y >= 175 && (mouse.x <= 140 || mouse.x >= 1200))
{
gInventory.Visible = false;
mouse.Mode = PreviousMouseModeOutsideInventory;
return;
}
Here's my Default Setup:
(https://redrom.ltd/img/defaultsetup1.png)
Here's my General Settings:
(https://redrom.ltd/img/generalsettings.png)
(https://redrom.ltd/img/defaultsetup2.png)
As usual, answer's staring my in the face but I don't know what it is :/
Tried adding the line:
if (mouse.y >= 175 && (mouse.x <= 140 || mouse.x >= 1200))
{
gInventory.Visible = false;
if (player.ActiveInventory==null) mouse.Mode = PreviousMouseModeOutsideInventory;
return;
}
And now coming back out of the inventory, the icon is the useinv activeintentory icon (use rope with plantlife etc.), rather than the last used icon outside of inventory, but the icon is *still blank*.
So the activeinventory icon is being made blank somehow. If I cycle with mousewheelnorth/south outside the inventory, it then goes to the other icons; when I come back to activeinventory icon, the icon is *restored* to the old. God knows why, but this is useful information to someone who isn't me I hope :P
Video: https://redrom.ltd/img/mouseclickdemo2.mp4 (https://redrom.ltd/img/mouseclickdemo2.mp4)
Really, nobody?
Add this to the room script:
void on_key_press(eKeyCode k) {
if (key == ekeyM) {
ClaimEvent();
Display("The current mouse mode is %d.", mouse.Mode);
Display("The current mouse cursor sprite is %d.", mouse.GetModeGraphic(mouse.Mode));
}
}
In the room, press the M key and tell us what it says. This is basic debugging btw.
And also btw., your threads keep sounding like you paid for AGS and expect us to do the debugging we're contractually obligated to. Keep in my mind that we're doing this for free, in our spare time, as a favor to other forum people.
Sorry Khris, I provided lots of documentation about it; I wasn't frustrated, just surprised no one got back to me in a day.
That is basic; I was about to do something like that but thought I'd wait for a response which was going to be 'you forgot a semi colon' after doing hours of deugging last night and thisarvo.
It reports the mode is 4 (useinv) and graphic is 0 (ie. nothing - odd it's not a blue cup, so it must be 'null'). Something is making it 0; I managed to press M at the exact moment I right-clicked, it showed the standard icon and then said mode=4 and graphic=626.
Something is resetting it, I don't know what.
You are continually running this, right?
if (newGraphic != mouse.GetModeGraphic(mouse.Mode)) {
mouse.ChangeModeGraphic(mouse.Mode, newGraphic);
}
Your if statements don't look lile you set a value for newGraphic under every circumstance, so you are likely setting it to 0 yourself and not realising.
(0 is the value of an uninitialised int)
I've solved it, mainly for seeing there was an error in UpdateMouseGraphic() which replaced it each time with a newly initiated int (which I thought always had a default value assigned somewhere in the function, but only in the if mode==something blocks).
Basically this system will:
Outside the inventory:
cycle up and down the inventory icons of activeinventory, walkto, lookat, use, and talk to with mousewheelup/down
Right clicking does nothing.
Left clicking applies the mouse mode to the surface below the cursor; or, if there is no surfaces you click on that will respond to this mode, then you walk there (same as Sam and Max and probably 400 other adventure games)
Inside inventory:
Left click looks at inventory items and give you a description of them
Right click will load an item as the activeinventory; then you can Left click on another item, it will runs the target item's itarget_useinv(), and then return the cursor to 'look at' and make activeinveory = null (right clicking with an activeinventory!=null does nothing)
Here's the code:
function on_mouse_click(MouseButton button)
{
// Game paused?
if (IsGamePaused() == 1) { // do nothing if paused
} else
if (gInventory.Visible) { // if inventory is visible...
if (RemoveActiveInventory) {
player.ActiveInventory=null;
RemoveActiveInventory=false;
}
//move up through inventory with mouse wheel
if (button == eMouseWheelNorth) {
invCustomInv.ScrollUp();
}
//move down through inventory with mouse wheel
if (button == eMouseWheelSouth) {
invCustomInv.ScrollDown();
}
InventoryItem *tInv;
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (button == eMouseRightInv) {
if (tInv.IsInteractionAvailable(eModeUseinv)) {
if (player.ActiveInventory==null) {
player.ActiveInventory=inventory[game.inv_activated];
mouse.ChangeModeGraphic(eModeUseinv, inventory[game.inv_activated].CursorGraphic);
}
}
}
if (button == eMouseLeftInv) {
if (player.ActiveInventory!=null) {
tInv.RunInteraction(eModeUseinv);
mouse.Mode=eModeLookat;
RemoveActiveInventory=true;
} else {
mouse.Mode=eModeLookat;
player.ActiveInventory=null;
tInv.RunInteraction(eModeLookat);
}
}
} else { //if inventory *is not* visible
if (button == eMouseLeft) {
if (SamAndMaxInterface) {
int lt = GetLocationType(mouse.x, mouse.y);
if (lt == eLocationNothing) {
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
} else {
if (
(mouse.Mode==eModeInteract && !IsInteractionAvailable(mouse.x, mouse.y, eModeInteract)) ||
(mouse.Mode==eModeLookat && !IsInteractionAvailable(mouse.x, mouse.y, eModeLookat)) ||
(mouse.Mode==eModeTalkto && !IsInteractionAvailable(mouse.x, mouse.y, eModeTalkto))
)
{
Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
} else {
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
}
}
}
}
// cycle cursor 'forwards;
if (button == eMouseWheelSouth) {
mouse.SelectNextMode();
}
// Cycle the cursors 'backwards'
if (button == eMouseWheelNorth) {
if (SamAndMaxInterface) {
if (mouse.Mode > 0) { // If mode isn't WALK, set the previous mode (notice usage of numbers instead of eNums)
mouse.Mode = mouse.Mode-1;
} else {
if (player.ActiveInventory != null) { // WALK mode, and the player has a selected inventory item?
mouse.Mode = eModeUseinv; // Set mouse mode to UseInv
} else {
mouse.Mode = eModeTalkto; // Otherwise just set it to mode TALK (change this line if you add more cursor modes)
}
}
}
}
}
}
function UpdateMouseGraphic()
{
int newGraphic; // = 2054;
int lt = GetLocationType(mouse.x, mouse.y);
if (gInventory.Visible)
{
if (mouse.y >= 175 && (mouse.x <= 140 || mouse.x >= 1200))
{
gInventory.Visible = false;
if (player.ActiveInventory==null) mouse.Mode = PreviousMouseModeOutsideInventory;
return;
}
if (mouse.Mode == eModeLookat) { // LOOKAT
newGraphic = 105; // eye close
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (inve != null) {
if (player.ActiveInventory==null) {
newGraphic = 2056; // eye open
}
}
}
if (mouse.Mode==eModeWalkto) {
if (newGraphic==0) {
player.ActiveInventory=null;
mouse.Mode=eModeLookat;
}
}
} else {
if (mouse.Mode == eModeUseinv)
{
// Display("you clicked an inventory item");
return;
}
if (mouse.Mode == eModeWalkto)
{
newGraphic = 3; // stand still
if (gInventory.Visible == true)
{
}
else
if (GetWalkableAreaAtRoom(mouse.x, mouse.y)!=0)
{
newGraphic = 2054; // walking
}
}
else if (mouse.Mode == eModeLookat) // LOOKAT
{
newGraphic = 105; // eye close
Hotspot* hs = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
// Looking at item in inventory
if (gInventory.Visible == true && inve != null)
{
if (inve.IsInteractionAvailable(eModeLookat))
{
newGraphic = 2056; // eye open
}
} else {
if (lt == eLocationHotspot)
{
if (hs != hotspot[0])
{
if (hs.GetProperty("hidden") == false)
{
if(hs.IsInteractionAvailable(eModeLookat))
{
newGraphic = 2056; // eye open
}
}
}
}
else if (lt == eLocationCharacter)
{
if (ch != null)
{
if (ch.IsInteractionAvailable(eModeLookat))
{
newGraphic = 2056;
}
}
}
else if (lt == eLocationObject && ob.IsInteractionAvailable(eModeLookat) && ob.Visible == true)
{
newGraphic = 2056; // eye open
}
}
}
else if (mouse.Mode==eModeInteract) // INTERACTION
{
newGraphic = 2; // interact off
Hotspot* hs = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
// Interacting with inventory item
if (gInventory.Visible == true && inve != null)
{
if (inve.IsInteractionAvailable(eModeLookat))
{
newGraphic = 286;
}
}
else
{
// Interacting with hotspot
if (hs != hotspot[0])
{
if (hs.GetProperty("hidden") == false)
{
if (hs.IsInteractionAvailable(eModeInteract))
{
newGraphic = 286;
}
}
}
// Interacting with object
// else if ((mouse.x <=eLocationObject-5 || mouse.x>=eLocationObject+5) && (mouse.y<=eLocationObject-5 || mouse.y>=eLocationObject+5)) {
else if (lt == eLocationObject)
{
if (ob.Visible)
{
if (ob.IsInteractionAvailable(eModeInteract))
{
newGraphic = 286;
}
}
}
//interacting with character
else if (lt == eLocationCharacter)
{
if (ch != null)
{
if (ch.IsInteractionAvailable(eModeInteract))
{
newGraphic = 286;
}
}
}
}
}
else if (mouse.Mode == eModeTalkto) // TALKTO
{
newGraphic = 2058; // talk off
Character* ch = Character.GetAtScreenXY(mouse.x, mouse.y);
Object* ob = Object.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem* inve = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (gInventory.Visible == true && inve != null)
{
}
else
{
if (lt == eLocationCharacter)
{
if (ch != null)
{
if (ch.IsInteractionAvailable(eModeTalkto))
{
if (ch.GetProperty("convodone")==0) {
newGraphic = 213; // talk on
}
}
}
}
else
if (lt == eLocationObject && ob.Visible && ob.IsInteractionAvailable(eModeTalkto))
{
if (ob.GetProperty("convodone")==0) {
newGraphic = 213;
}
}
}
}
}
if (mouse.Mode!=eModeUseinv) {
if (newGraphic != mouse.GetModeGraphic(mouse.Mode)) {
mouse.ChangeModeGraphic(mouse.Mode, newGraphic);
}
}
}
function show_inventory_window()
{
gInventory.Visible = true;
PreviousMouseModeOutsideInventory = mouse.Mode;
if (player.ActiveInventory==null) mouse.Mode=eModeLookat;
}
And also, General Settings -> Inventory -> Override built-in inventory clicking to TRUE
Hope this helps someone - thank you all for your time and problem solving :)