hi guys, first post here.
my question is how do I create a display name, so the user can write the character's name.
i didn't want to do it like the old games did, to select from letter to letter to create the name.
is there anything about this or how i create this?
Menu with character's name
Moderator: Moderators
Re: Menu with character's name
Hi LsJack,
Here's a quick loop + key code scanning to type with the keyboard:
Here's a quick loop + key code scanning to type with the keyboard:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression Expression="MyName = "";"/>
</OnLoaded>
<OnUpdate>
<Repeat Name="LetterRepeat" Count="26">
<OnIteration>
<ZExpression>
<Expression>
<![CDATA[/* Scan letters from A = 65 to Z = 90 */
KeyboardInput.CharCode = 65 + LetterRepeat.Iteration;]]>
</Expression>
</ZExpression>
<KeyPress Name="KeyboardInput" CharCode="90">
<OnPressed>
<ZExpression>
<Expression>
<![CDATA[if (keypress == 0)
{
keypress = 1;
/* Convert key code to character */
MyName += chr(65 + LetterRepeat.Iteration);
}]]>
</Expression>
</ZExpression>
</OnPressed>
<OnKeyUp>
<ZExpression Expression="keypress=0;"/>
</OnKeyUp>
</KeyPress>
</OnIteration>
</Repeat>
</OnUpdate>
<OnRender>
<RenderText TextExpression="MyName"/>
</OnRender>
<Content>
<Variable Name="MyName" Type="2"/>
<Variable Name="keypress" Type="4"/>
</Content>
</ZApplication>
Re: Menu with character's name
Hi guys,
Attached is a name entry example that supports [space]0-9A-Za-z[-_] as valid characters, the maximum length is 32 characters, supports the Shift key but not Caps Lock ( at the moment .. i could add that if you want ), and Backspace with automatic input-repeat when you hold it long enough.
+ Welcome!
K
@Ats: You can do this exact thing a little bit easier actually, like this:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression Expression="MyName = "";"/>
</OnLoaded>
<OnUpdate>
<KeyPress Name="KeyInput" Keys="ABCDEFGHIJKLMNOPQRSTUVWXYZ">
<OnKeyDown>
<ZExpression Expression="MyName += substr(KeyInput.Keys, KeyInput.KeyIndex, 1);"/>
</OnKeyDown>
</KeyPress>
</OnUpdate>
<OnRender>
<RenderText TextExpression="MyName"/>
</OnRender>
<Content>
<Variable Name="MyName" Type="2"/>
</Content>
</ZApplication>
@LsJack: The keyboard features in ZGameEditor are primarily meant for controlling things, not for text input. But, with a bit of code you can create your own solution. The question however is, what features do you want/ need exactly?
Attached is a name entry example that supports [space]0-9A-Za-z[-_] as valid characters, the maximum length is 32 characters, supports the Shift key but not Caps Lock ( at the moment .. i could add that if you want ), and Backspace with automatic input-repeat when you hold it long enough.
+ Welcome!
K
- Attachments
-
- Entry.zgeproj
- (9.19 KiB) Downloaded 70 times
Re: Menu with character's name
i need exactly that, the player can write the character's name. i am creating a character menu UI to define some characteristics of the character including its name.Kjell wrote: @LsJack: The keyboard features in ZGameEditor are primarily meant for controlling things, not for text input. But, with a bit of code you can create your own solution. The question however is, what features do you want/ need exactly?
the example was perfect, now i just need to understand how it works properly
thanks, i'm from Brazil, delphi developer, i loved the project.Kjell wrote: + Welcome!
Re: Menu with character's name
Whoops. I always thought that 'OnPressed' was the equivalent of 'just pressed' since it is conjugated in the past and not called 'OnPress'. And that 'OnKeyDown' was the opposite...Kjell wrote:You can do this exact thing a little bit easier actually