Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: imagazzell on Mon 27/09/2021 04:26:30

Title: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Mon 27/09/2021 04:26:30
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!
Title: Re: Graphical/Functional Questions About CMI Style GUI/Inventory/Menus
Post by: Khris on Mon 27/09/2021 07:14:43
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) Select
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.
Title: Re: Graphical/Functional Questions About CMI Style GUI/Inventory/Menus
Post by: Crimson Wizard on Mon 27/09/2021 07:41:24
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.
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Mon 27/09/2021 22:39:38
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)?
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: 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).
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Tue 28/09/2021 06:01:37
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) Select
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:
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!
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: Khris on Wed 29/09/2021 07:47:59
2. is not directly related to the verb coin. Use my module: GotThere.scm (https://drive.google.com/file/d/1v3NbuPrvATW4LrTVnsNC2HLuoYHnQ-Fr/view?usp=sharing)
Use it like this:
Code (ags) Select
  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) Select
  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.
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Wed 29/09/2021 17:21:32
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?
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: Khris on Wed 29/09/2021 20:50:39
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.
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Wed 29/09/2021 21:21:49
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.
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: Khris on Wed 29/09/2021 23:49:03
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.
Title: Re: Graphical/Functional Questions for CMI Style GUI/Inventory/Menus
Post by: imagazzell on Thu 30/09/2021 00:08:30
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.