Graphical/Functional Questions for CMI Style GUI/Inventory/Menus

Started by imagazzell, Mon 27/09/2021 04:26:30

Previous topic - Next topic

imagazzell

Hi all,

Hope you're doing well.

I've spent a couple of hours searching the forums, manual, and wiki, but haven't found the answers to exactly what I'm looking for (nor much on the general topic that's at all recent). I feel I've done my due diligence before posting, so I'll feel really dumb if something flew right over my head.

I'm trying to create a game with The Curse of Monkey Island style verb coin, inventory, and game menus. I've started with the Verb Coin template, which seems the right start, but I've got some questions on its intricacies and how to expand upon it:

1. How can I replace the default, plain graphics with my own custom-made images/sprites (e.g., in CMI: a literal coin for the verb coin, a treasure chest for the inventory, a journal for the main game menu)? Any links that I found in old threads that might've shown such examples all appear to be long dead, and I don't see (in the various GUI properties in AGS) where to assign a graphic to use. Surely this kind of thing is possible...?

Edit: Forgive me, I just saw the BackgroundImage parameter right there under the GUI properties, but I swear it wasn't there before. You believe me... Right?...

    1a. Can I assign an animated view to a GUI (e.g., how the coin in CMI shines when activated)?

    1b. Is there a problem with having a singular options menu, containing save, load, quit, etc. buttons all in one? All of the menus that I've seen so far appear to handle just one of those functions each. Is there something wrong with setting up a global main menu GUI with all options that link to sub-menus to carry out those options, the way most modern games function?

2. I'd like to retain identical functionality of the CMI interface (e.g., click and hold to bring up the verb coin, verb coin functionality within the inventory, etc.). I've gathered that this is how it might have worked in the Verb Coin template previously, but appears to have been changed in more recent iterations. Is there a simple way to restore these desired behaviors?


Again, most of the threads I've found on these topics are quite old, and I don't know what information in them is still relevant/useful, so if any of you all can assist me with these points, or at least point me in the right direction, I'd very much appreciate it.

Thank you!
Music Composing Services: https://youtu.be/BbT3kfhgA4E

Khris

You can animate a GUI background manually but it requires some extra work.
I'd use a global int variable, say  gui_count, and when the GUI is opened set it to 80 or something (that's the number of game frames for 2 seconds if you keep the default speed of 40 FPS). Now count it down in repeatedly_execute always, then check if gui_count % 5 == 0 i.e. whether it's a multiple of 5 (assuming an animation where each frame is visible 5 frames). Now change the GUI background accordingly:

Code: ags
function repeatedly_execute_always() {
  if (gui_count > 0) {
    gui_count--;
    if (gui_count % 5 == 0) {
      int frame = 15 - gui_count / 5; // frame starts at 0, ends at 15
      ViewFrame* vf = Game.GetViewFrame(VERBCOIN_BG, 0, frame);
      gVerbCoin.BackgroundGraphic = vf.Graphic;
    }
  }
}


This will animate the GUI background using the first 16 frames of the first loop of view VERBCOIN_BG as soon as gui_count is set to 80 and automatically stop the animation when the counter reaches 0.

As for GUI buttons: you can put them anywhere you like and make them do anything you like, so feel free to rearrange them as desired.

Crimson Wizard

I believe that instead of scripting animated GUI background it may be easier to just place a button covering whole GUI with lowest z-order (behind all other controls), and animate that button using existing Button.Animate function.

imagazzell

Thanks, guys. I appreciate the multiple solutions. I'll report back if I run into trouble implementing either of them.

Any tips on getting the CMI functionality of the verb coin and inventory to work (question 2 in my OP)?
Music Composing Services: https://youtu.be/BbT3kfhgA4E

morganw

You can download the last revision of the old version (with timed clicks) from here:
https://github.com/adventuregamestudio/ags-template-source/archive/440e6acd32faed710aa0512f21ff404b8e80c84b.zip

If you want something that works exactly like CMI it is likely a close match but the part of the reason it was changed was because some players don't even think to try a timed click (outside of using a touch screen).

imagazzell

Quote from: morganw on Tue 28/09/2021 00:01:27
You can download the last revision of the old version (with timed clicks) from here:
https://github.com/adventuregamestudio/ags-template-source/archive/440e6acd32faed710aa0512f21ff404b8e80c84b.zip

If you want something that works exactly like CMI it is likely a close match but the part of the reason it was changed was because some players don't even think to try a timed click (outside of using a touch screen).

Thank you very much, morganw.

I had to update lines 384 and 385 of the VerbCoin GUI to get it to run in v3.5.1 as such:
Code: ags
verbc_border_x = Screen.Width - gVerbCoin.Width;
verbc_border_y = Screen.Height - gVerbCoin.Height;


This is definitely a step closer to what I'm going for, but there are still a few little niggles I have before it's just right. I've gone through the scripting to see if I could figure out how to make the desired adjustments, but it's beyond my skill level at this point in time. If someone would be willing to help add/modify the necessary scripts to get me on track, I'd be most grateful, and would even be happy to compensate you for your time (if such offers are allowed on here; I didn't read any disclaimers against doing so). Feel free to PM me in regards to that.

Here are the adjustments I'd like to make:

  • After activating the verb coin (left-click and hold), I'd like the verb coin to remain on the screen until the mouse button is released, regardless of the cursor position. The current behavior makes the verb coin deactivate when the cursor leaves its edges. Similarly, if you move off of the verb coin within the inventory, it deactivates both the verb coin and the inventory GUI. This is not preferred.
  • I'd like the cursor and verb coin to be accessible again immediately after initiating an event on a hotspot/object, and be able to interrupt the playable character's current action with whatever event you call on next. Currently, the cursor and ability to interact disappear until the current action is completed. I prefer the more free feeling controls found in CMI.
  • Currently, when you click and hold on one of the verb coin buttons, that button's selected sprite stays active until you hover over another button, even if you move the cursor over a non-button area of the verb coin. I'd like the verb coin to return to its idle sprite and no button selection when you move off of any button, even with the mouse click still held.
  • With the inventory open, if no inventory object has been selected, I want the inventory to stay open unless the player (a) left-clicks outside the edges of the inventory, or (b) right-clicks anywhere on the screen. The current behavior closes the inventory when you move the cursor outside its edges, whether you've selected an object or not.
  • I'd like the Esc key (in addition to right-click) to clear inventory objects from the cursor. Currently, only right-click does this.
  • There appears to be a small delay switching from the plain cursor to the hotspot cursor when quickly mousing over a hotspot/object. Can this be fixed?
  • This last one will likely require as much sprite creation work as scripting, but I'd like an outline to appear around the currently selected object when you hold it over another object/hotspot/etc. A rundown of how I can implement this would be great.
Strikethrough = Figured out

Anyone willing and able, please let me know if you can give me a hand with all this, and again, I would be happy to pay you accordinly.

Thanks!
Music Composing Services: https://youtu.be/BbT3kfhgA4E

Khris

2. is not directly related to the verb coin. Use my module: GotThere.scm
Use it like this:
Code: ags
  if (WalkFace(123, 45, eDirectionLeft)) {
    // what happens when the player reachers those coordinates goes in here
  }

This will start a non-blocking walk to the stated coordinates and only run the interaction code inside if the player has reached the target.

5. is pretty simple. Find the on_key_press function in the Global script and add something like
Code: ags
  if (key == eKeyEscape) {
    if (!gMenu.Visible && player.ActiveInventory != null) player.ActiveInventory = null;
  }

This is just example code showing how to implement AGS reacting to keypresses.

6. the change should be instant, how are you switching cursors?

7. the amount of scripting / sprite work depends. An outline sprite can be created programmatically using a DrawingSurface's Pixel methods. The scripting part requires tracking whether there's something below the mouse using  Game.GetLocationType()  and changing the cursor sprite accordingly. You might actually find a working solution for this in the forum search.

imagazzell

Thank you, Khris! I'll try out your solutions as soon as I get back into AGS.

With regards to #6, what I'm referring to is the automatic graphical change that occurs when you hover over an object/hotspot/etc. This change appears to not happen instantly when you are mousing around a little more quickly. Instead, there seems to be a delay, just long enough to be noticeable.

This may or may not be a template specific issue, as I don't recall noticing it before, so can you tell me where I might want to poke around in the scripts, if you don't know of a direct solution?
Music Composing Services: https://youtu.be/BbT3kfhgA4E

Khris

I started a new VerbCoin game in AGS 3.5.0 and I don't see the cursor change? It's just a white arrow. I do see overhotspot text at the bottom of the screen.

imagazzell

I'm using the slightly older template linked by morganw above to get the timed-click-verb-coin and verb-coin-in-inventory functionality. In that template, the cursor changes from a white "X" to a blue one when you hover over a hotspot, etc., but again, the switch seems a little laggy with swifter mouse movements.
Music Composing Services: https://youtu.be/BbT3kfhgA4E

Khris

Oh, I see. I must recommend against using that template. It used to have lots of issues and I'm not sure they were fixed. People kept coming here posting about errors they got.

imagazzell

Well, I can try to go through the newest template and adjust the scripting to suit my needs. I'm just not sure how ubiquitous the necessary scripts are, and I'm still only a novice at scripting. I suppose it could be a decent learning experience, though.
Music Composing Services: https://youtu.be/BbT3kfhgA4E

SMF spam blocked by CleanTalk