Choose Your Language

Tuesday, 13 September 2011

Focus & Return (GUIs)

I continue to thrash out the story for Better The Demon, which is slowly coming along in the way of added conversations. However, I have also been looking at some minor issues to do with the new GUIs that will be available in the game. In particular, there are some GUIs that are presented to the player which require a text input. Previously, the player had to click in the text input box and then type what they wanted to say, followed by clicking on another button. This all worked well enough, but I found during testing that it was more natural for me to want to type in information the moment the GUI appeared and then simply hit the Return key to enter my input. To this end, I did a little checking over some OC files to see how it was done ...

Focus & Return In GUIs

In my searching, I discovered that to make the cursor appear in an input box the moment the GUI opened, I needed to add the following parameter to the UISCENE:

OnAdd=UIScene_OnAdd_SetFocus(TextNameInput) where TextNameInput is the name of the UIText box requiring the input.

Then to make it so the Return key worked with this textbox, I needed to ensure the following two parameters were added to the same UIText box:

multiline="false" returnrestricted="true"

Once these two parameters were added, I found I could then add a simple OnReturn section to the same UIText like this:


This OnReturn does exactly the same thing as if the player clicks on the button which has the same command line, but uses OnLeftClick instead of OnReturn.

The good news with all this is that it makes the game flow more intuitively. And there are also some GUI text input windows where this kind of input is almost essential due to time factors involved.

And so the module continues to be written ....


Jimmy said...

Very nice. I love your blog and am following some of the modding ones, too. Keep it up, we love the content!

call New Zealand

Lance Botelle (Bard of Althéa) said...

Hi Jimmy,

Great to hear that you enjoy my blog so much. I try to mix some of the posts between modding and general scripting and personal comments, etc,