How would I make this UI

Started by Itta, Mon 26/02/2018 00:43:47

Previous topic - Next topic

Itta

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

Use the verb-coin template included in AGS?

Itta

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

#3
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: ags
  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.

Itta

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

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

#6
The file's set to private.
Otherwise:  MAN you guys are nice! :D

Ideal Setup:

Khris

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: ags
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: ags
  // in repeatedly_execute()
  lblAction.Text = VerbCoin.GetCurrentAction();


Finally, an open source demo game: download

Cassiebsg

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

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



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

Khris

#11
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.

Itta

---------------------------
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

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

still crashing.  It says the error is on line 28 of room 1, btw

Khris

#15
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.

Crimson Wizard

#16
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: ags

  if (g != coinGUI) {
    currentActionLine = null;
    return;
  }

I think it's happening when you move mouse over that gray status bar.

Khris

Right, thanks! Downloads are all fixed.

Itta

Great~  You're all going in credits if I finish this!
Related, it's fun to see how you interpreted my filler inventory. ^v^

SMF spam blocked by CleanTalk