What caught my eye.
1. The UI assumes there's only 1 cursor mode all the time and never changes. Instead of setting cursor images for all built-in cursors, you could set it only for one (I'd vote for mode 6: Pointer).
Also, disable all modes except chosen one in game_start:
Code: ags
In GlobalScript:
1. You do this in repeatedly_execute:
Code: ags
Is it what BASS did? I don't like it, because that will be very annoying during action sequences. Though, I guess, user can remove this line.
2. Maybe make constant/macros instead of hardcoding "12" pixel edge which triggers inventory right in the function body?
In custom module:
4. The huge "if (!IsGamePaused())" condition block that covers all function body. This is a matter of personal code style, though I would suggest to make it instead
Code: ags
This will reduce nesting level making code more clear to user.
5. "if (mouse.Mode == eModeUseinv) " condition will never be true, because you never set mouse.Mode. Instead, you can just test "player.ActiveInventory == null", or "!= null". This refers to both "if (button == eMouseLeft)" and "else if (button == eMouseRight)" blocks.
6. This, and merging al location types will produce the code:
Code: ags
7. You are using "inventory[game.inv_activated]". IMHO that's bad. Although that may work, "game.inv_activated" is an obsolete variable, and also old-style code (also it is not very obvious how engine sets it).
I'd suggest to just use InventoryItem.GetAtScreenXY, it might be little slower, but it is a click handler, therefore does not matter really. Also you call GetLocationName anyway, and with GetAtScreenXY you'll get InventoryItem pointer with Name and everything. You won't need to compare names too (comparing strings is slowest operation of all, except only getting object under mouse), you will simply compare pointers:
Code: ags
8. I don't think it is good to add "data == theGUI.ID" condition when you check that player clicks on gui. There may be other guis too, and the item should probably be deselected anyway.
9. I think it is simplier to test "if (button == eMouseRightInv)" in "on_mouse_click" to make player LookAt inventory item, rather than in "on_event". This way you won't need to test which mouse button is down, nor which Control is clicked.
//--------------------------------
EDIT:
I suggest to nullify info label at the start of mouse_click. Otherwise, the label text will stay on screen while player talks / does blocking actions.
1. The UI assumes there's only 1 cursor mode all the time and never changes. Instead of setting cursor images for all built-in cursors, you could set it only for one (I'd vote for mode 6: Pointer).
Also, disable all modes except chosen one in game_start:
mouse.DisableMode(eModeInteract);
mouse.DisableMode(eModeLook);
... etc ...
mouse.Mode = eModePointer;
In GlobalScript:
1. You do this in repeatedly_execute:
if (gInventory.Visible)
{
player.StopMoving();
Is it what BASS did? I don't like it, because that will be very annoying during action sequences. Though, I guess, user can remove this line.
2. Maybe make constant/macros instead of hardcoding "12" pixel edge which triggers inventory right in the function body?
In custom module:
4. The huge "if (!IsGamePaused())" condition block that covers all function body. This is a matter of personal code style, though I would suggest to make it instead
if (IsGamePaused())
return;
This will reduce nesting level making code more clear to user.
5. "if (mouse.Mode == eModeUseinv) " condition will never be true, because you never set mouse.Mode. Instead, you can just test "player.ActiveInventory == null", or "!= null". This refers to both "if (button == eMouseLeft)" and "else if (button == eMouseRight)" blocks.
6. This, and merging al location types will produce the code:
if (GetLocationType(mouse.x, mouse.y) != eLocationNone)
{
if (player.ActiveInventory == null)
ProcessClick(mouse.x, mouse.y, eModeInteract);
else
ProcessClick(mouse.x, mouse.y, eModeUseInv);
}
7. You are using "inventory[game.inv_activated]". IMHO that's bad. Although that may work, "game.inv_activated" is an obsolete variable, and also old-style code (also it is not very obvious how engine sets it).
I'd suggest to just use InventoryItem.GetAtScreenXY, it might be little slower, but it is a click handler, therefore does not matter really. Also you call GetLocationName anyway, and with GetAtScreenXY you'll get InventoryItem pointer with Name and everything. You won't need to compare names too (comparing strings is slowest operation of all, except only getting object under mouse), you will simply compare pointers:
InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (player.ActiveInventory != item)
item.RunInteraction(eModeUseinv);
8. I don't think it is good to add "data == theGUI.ID" condition when you check that player clicks on gui. There may be other guis too, and the item should probably be deselected anyway.
9. I think it is simplier to test "if (button == eMouseRightInv)" in "on_mouse_click" to make player LookAt inventory item, rather than in "on_event". This way you won't need to test which mouse button is down, nor which Control is clicked.
//--------------------------------
EDIT:
I suggest to nullify info label at the start of mouse_click. Otherwise, the label text will stay on screen while player talks / does blocking actions.