a hook to send serverside any key typed clientside
Type
Improvement
NWN2Game
All
Description
In NWN2, key inputs seems to be deeply hardcoded. as proof, you ll have noticed that there ain't any keyboard shortcut in the different menus (which are simply xml gui files)
That was a problem for me cause i was trying to code a piano, and i would have liked the ability to use my keyboard in a fasttracker way (for those who remember ^^ ), but i guess many minigames could be implemented serverside with this method.
As i kinda found a solution ( a barbaric one, but nonetheless ^^), I'd would like to get comments and/or ways to improve it.
here we go:
-in my "ingamegui.ini" and "ingameguix1.ini", i added, under [mandatory Gui]:
-the getkey.xml file contains this UIText (among other things, the rest is standard gui to open and close)
<UIText name="inputbox" x=0 y=30 width=20 height=20 text=""
fontfamily="International" multiline="false" returnrestricted="true" editable=true
selectable=true maxlength=1 filter="alpha" allowspace="false" allowpunc="false"
update="true"
OnUpdate0=UIObject_Misc_SetLocalVarString(local:0)
OnUpdate1=UIButton_Input_ScreenOpen(local:0,"false")
/>
-the getkeya.xml is as follow (and is a template for the rest of them)
<UIScene name="a" width=10 height=10 x=100 y=100 draggable=true
priority="SCENE_SCRIPT" modal="false"
idelexpiretime=0.1f
<!-- expiretime=0.1f -->
OnCreate=UIObject_Misc_ExecuteServerScript("gui_getkey","a")
/>
- finaly, the gui_getkey script (aside from the pure treatment of the key entered) always empty the inputbox (with SetGUIObjectText(OBJECT_SELF, "SCREEN_GETKEY","inputbox",-1,"") ) and close the calling UIScene (with CloseGUIScrenn (OBJECT_SELF, sInput) ).
when i click on the inputbox, i get myself a catch for any letter typed :)
It works very well on my local machine, but i can't test the influence of a server response time
this method is kinda ulgy, i know (27 xml files (only lower case)) and i don't know yet wether or not i could make it in a hak or override of some sort. plus this is definitely not idiot-proof...
anyway, any comment or advice is welcome :)
Edit:
Rah, the comments section doesn't allow < and > ...
here is what is suposed to be in the blank in the second comment :
Ok, sorry for the barbaric version above, there is way, way simplier
I tried the version below with the event OnLostFocus, which seems to be broken (and abandoned it...) but i just noticed that OnGainedFocus ain't, so...
this is in my getkey.xml (only file required, now) :
[etc...]
the script only handels processing.
UIObject_Input_SetFocus(local:0) being kinda a conditional statement, i think this could be useful for other types of ui programing
in the UIText, add:
OnUpdate2=UIObject_Input_ClearTextfield("inputbox")
and in the getkeya.xml, reenable the expiretime=0.1f
this prevents the client to continuously send requests to the server when he's not responding, so the gui_getkey script can only focus on processing the data.
That mainly means one or two server->client transfert is avoided
You must be Logged In to post comments in this section.
10 - A Masterpiece, Genuinely Groundbreaking 9 - Outstanding, a Must Have 8 - Excellent, Recommended to Anyone 7 - Very Good, Deserves a Look 6 - Good, Qualified Recommendation 5 - Fair, Solid yet Unremarkable 4 - Some Merit, Requires Improvements 3 - Poor Execution, Potential Unrealized 2 - Very Little Appeal 1 - Not Recommended to Anyone