Jibble

Author Topic: How would I make this UI  (Read 663 times)

Itta

  • Posts: 12
How would I make this UI
« on: 26 Feb 2018, 00:43 »
I'm looking to have right click bring up a verb token, and left click to move about.  Either a verb coin, or a tiny inventory box in the same sort of position.  How can I make that happen?

Mandle

  • Posts: 7,876
  • NO PIXEL LEFT BEHIND!!!
    • Mandle worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #1 on: 26 Feb 2018, 01:20 »
Use the verb-coin template included in AGS?

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #2 on: 26 Feb 2018, 03:34 »
How do I change it from 'holding left click' to just 'right click'?  Is there a way to use my inventory idea?  What's the best way to set it up, anyhow?

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #3 on: 27 Feb 2018, 09:34 »
You can create your own basic interaction GUI by combining a few basic mechanisms.
The first is handling mouse clicks; that's done in the GlobalScript's on_mouse_click function.
The second is storing the right-click coordinates (for scrolling rooms you're better off storing the hotspot / object / character that was clicked) and displaying a GUI.
The third is handling the GUI's button / inventory clicks.

Pulling this off without some scripting experience can be challenging, but the entire approach is pretty straightforward and linear.
Maybe somebody will came along and drop a post full of code, but until then, what research have you done so far? What have you tried? What exactly do you need help with?

The first step for instance is pretty basic:
Code: [Select]
  if (button == eMouseLeft) Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
  if (button == eMouseRight) ShowInteractionGUI(mouse.x, mouse.y); // custom function above on_mouse_click
Next you write the ShowInteractionGUI function which stores the location type and location and sets the GUI's .Visibility to true. And so on. Step by step.
« Last Edit: 27 Feb 2018, 18:44 by Khris »

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #4 on: 27 Feb 2018, 18:18 »
Thank you! :D  I've done some research and took a class on programming, but as a programmer I really don't seem to have the knack for it.  I'm much more a graphic artist, though that does help in designing the GUI, actually MAKING it is another story.

Cassiebsg

  • Cavefish
  • Posts: 4,987
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #5 on: 27 Feb 2018, 18:35 »
If you like you can use my VerbCoin. It uses the right click to open the GUI and it will stay on until you either choose one of the options, or cancel it (by either right click again or click out side of the gui). It also only shows possible actions. Lets say you have talk, interact and look. If for instance you have only coded Interact and Look, those are the ones that will be shown on the GUI, instead of the normal talk+interact+look. (you can see it in action in my game Unexpected at the Rising Star)
It's based on monkey's verbcoin module (not the one that comes with AGS), only adapted to my needs and wants. :-D

I've once uploaded it for a person that asked: http://www.mediafire.com/file/7m6utchnkwxqd6g/Verbcoin_Right_button.txt.txt

Let me know if that's more or like what you want, and if you wish to use it I'll update the code to fix a couple bugs that are on that version.
There are those who believe that life here began out there...

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #6 on: 27 Feb 2018, 23:42 »
The file's set to private.
Otherwise:  MAN you guys are nice! :D

Ideal Setup:
« Last Edit: 27 Feb 2018, 23:46 by Itta »

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #7 on: 28 Feb 2018, 12:26 »
Seeing that awesome graphics style I thought what the hell, I wanted to do this anyway. I love that interface since 7 days a skeptic.

Here's a module: Coin_340.scm
The only additional setup besides creating the GUI it requires is redirecting the GUI buttons to the module's function, like this:

Code: [Select]
function btnActionLook_OnClick(GUIControl *control, MouseButton button) {
  VerbCoin.Action(eActionLook, button);
}

function btnActionTake_OnClick(GUIControl *control, MouseButton button) {
  VerbCoin.Action(eActionTake, button);
}

function btnActionUse_OnClick(GUIControl *control, MouseButton button) {
  VerbCoin.Action(eActionUse, button);
}

So in other words: create the GUI, set its visibility to "Normal, initially off", set the background image, add the buttons and inventory, then add the OnClick handlers for the buttons the usual way, and add the three VerbCoin.Action(...); lines in the generated functions.

In addition the module provides a VerbCoin.Unhandled() function one is supposed to call in x_Useinv() after all item tests failed.
There's also String VerbCoin.GetCurrentAction() which one can put on a label to show the current hotspot / action:
Code: [Select]
  // in repeatedly_execute()
  lblAction.Text = VerbCoin.GetCurrentAction();

Finally, an open source demo game: download

Cassiebsg

  • Cavefish
  • Posts: 4,987
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #8 on: 28 Feb 2018, 17:51 »
Opps... :-[

Sorry, it's now shared if you still want to look at it.
But since Khris jumped at it, just use his, it's much likely to be better and bug free than mine. (nod)
There are those who believe that life here began out there...

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #9 on: 28 Feb 2018, 20:43 »
The test game keeps crashing >.>;  Something about "Null string supplied to CheckForTranslations"
This may be me though.  I seem to have a weird talent for things to just not work when I use them...
Y'know those cartoon characters who cause things to fizzle out with their touch?  That's me with code :V

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #10 on: 28 Feb 2018, 20:55 »


My games protagonist.  He used to have a much larger sprite but I realized there would be no way I could animate it.

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #11 on: 28 Feb 2018, 21:46 »
By "test game", do you mean the one I provided? It requires AGS 3.4.1. However you should be able to run the Compiled version out of the box. Just remember to extract all files first.

We would also need the full error message, verbatim, and the piece of script it is referring to to help you with that.
« Last Edit: 28 Feb 2018, 21:53 by Khris »

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #12 on: 28 Feb 2018, 22:11 »
---------------------------
Adventure Game Studio
---------------------------
An error has occurred. Please contact the game author for support, as this is likely to be a scripting error and not a bug in AGS.
(ACI version 3.4.1.12)

in "room1.asc", line 28

Error: Null string supplied to CheckForTranslations

---------------------------
OK   
---------------------------

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #13 on: 28 Feb 2018, 23:53 »
I'm not getting that error but I guess I know what's causing it. I fixed the module and demo game accordingly. Try downloading it again.

(Assigning a null String as Label.Text is apparently what causes this.)

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #14 on: 01 Mar 2018, 01:07 »
still crashing.  It says the error is on line 28 of room 1, btw

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #15 on: 01 Mar 2018, 12:16 »
Did you open the source with AGS 3.4.1? Or did you just run the exe in Compiled/Windows?

Line 28 in room 1 is where I'm calling GetCurrentAction(). It returned null before the fix, which is most likely what caused the crash for you. I initialized the String to "" in the module's game_start, and I can see that change in the live version on Google Drive.
Plus, I cannot replicate this; it doesn't crash for me, with or without the fix.

Just put // at the start of the line to turn it into a comment.
« Last Edit: 01 Mar 2018, 12:20 by Khris »

Crimson Wizard

  • Posts: 8,730
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: How would I make this UI
« Reply #16 on: 01 Mar 2018, 13:25 »
Khris, step to reproduce this is: move mouse to the upper side of the screen.

The error message is actually pretty unclear, CheckForTranslations is a function that does not exist (might be a mistake in the engine). The error is reported when game is trying to get translation (whether automatically - for GUI - or after GetTranslation is called).

Well, I guess you already know it is from setting null to lblAction.Text.

EDIT: You have this in Coin.asc:
Code: Adventure Game Studio
  1.   if (g != coinGUI) {
  2.     currentActionLine = null;
  3.     return;
  4.   }
  5.  
I think it's happening when you move mouse over that gray status bar.
« Last Edit: 01 Mar 2018, 13:31 by Crimson Wizard »

Khris

  • Posts: 10,648
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How would I make this UI
« Reply #17 on: 01 Mar 2018, 15:53 »
Right, thanks! Downloads are all fixed.

Itta

  • Posts: 12
Re: How would I make this UI
« Reply #18 on: 01 Mar 2018, 16:01 »
Great~  You're all going in credits if I finish this!
Related, it's fun to see how you interpreted my filler inventory. ^v^