Help With Custom Inventory GUI

Started by wormcathedral, Wed 16/12/2020 18:03:36

Previous topic - Next topic

wormcathedral

I'm not 100% sure this qualifies as a 'beginner's question', but I'm still learning a lot, so I think it may count as one.

I've managed to get some things set up (ie: a working save/load system with the help of a good tutorial, and I've started working a little with global variables.)

Basically, my problem here is that I cannot for the life of me get the custom inventory GUI to work! As seen in the video below, items will go into the inventory GUI but the mouse mode will not change to reflect this (apologies for the clunkiness of everything, hahaha, it's a WIP)


I'm not sure if I missed something in the manual or a thread I read, but I've been stumped for a while about this.
I think it may have something to do with the mouse cursor code I use:

Code: ags
void UpdateMouseGraphic() {
  int newGraphic = 16; 
  int lt = GetLocationType(mouse.x, mouse.y);
  if (lt == eLocationHotspot || lt == eLocationObject) newGraphic = 17; 
  else if (lt == eLocationCharacter) newGraphic = 169;  
  if (lt == eModeUseinv) newGraphic = 167; 
  if (newGraphic != mouse.GetModeGraphic(mouse.Mode)) mouse.ChangeModeGraphic(mouse.Mode, newGraphic);


And then in rep ex:
Code: ags
UpdateMouseGraphic();


I apologise if something along this vein has been asked before and I just missed it, or if it's in the manual. Any help would be appreciated, thanks!

eri0o

I watched the video, read the code and read the post and still have no idea what you are trying to do. How exactly is the desired cursor graphic behavior you are after?

Khris

Since your doors are reacting to the mouse even when it's over the GUI, is it possible the inventory GUI is set to not being clickable?

Also, did you turn on custom inventory click handling? If so, you need to check for eMouseLeftInv and eMouseRightInv in on_mouse_click.

wormcathedral

Aha! Apologies for the late reply, I have turned on custom click handling now, but am wondering what exactly I should add to the code so that it... processes the click when I am in the inventory? I was conflicted as to whether or not to turn that option on, as I have seen different answers on the subject. Right now the code is as such:
Code: ags
 if (button == eMouseLeftInv) {
    player.ActiveInventory = item;
    mouse.ChangeModeGraphic(eModeUseinv, item.CursorGraphic);

Code: ags
   if (button== eMouseRightInv) {
         player.ActiveInventory = item;
    mouse.ChangeModeGraphic(eModeUseinv, item.CursorGraphic);

Thank you.

Crimson Wizard

#4
You don't have to do mouse.ChangeModeGraphic for eModeUseinv, if you set player.ActiveInventory that should do same thing automatically.

With the above code clicking on the item with either left or mouse button will select that item.
Other than that, I don't know what to say, as I don't know which exactly result are you trying to get in the end.

SMF spam blocked by CleanTalk