[dismiss]
This wiki is a copy of the original Oblivion CS wiki created and maintained by the UESP.net. See CSwiki:Copy Notice for more info.
Difference between revisions of "Text Input With TSFC"
Jump to navigation
Jump to search
Add commented code
imported>Speedo |
imported>Speedo (Add commented code) |
||
Line 59: | Line 59: | ||
short console | short console | ||
; Key input Variables | |||
long key | long key | ||
long shift | long shift | ||
; StringID variables | |||
long name | long name | ||
long prompt | long prompt | ||
Line 67: | Line 69: | ||
long done | long done | ||
begin menumode 1001 | ; Menumode 1001 = Messagebox displayed | ||
; Most of the actual work is done here | |||
begin menumode 1001 | |||
; Block input if we've already captured the key that's currently pressed | |||
; But - make an exception for the Shift keys | |||
if ((isKeyPressed2 key) && (key != 42) && (key != 54)) | if ((isKeyPressed2 key) && (key != 42) && (key != 54)) | ||
return | return | ||
else | else | ||
set key to GetKeyPress 0 | set key to GetKeyPress 0 | ||
; If more than 1 key is pressed, capture the second key | |||
; (more than 2 key presses are ignored) | |||
if (GetNumKeysPressed > 1) | if (GetNumKeysPressed > 1) | ||
; Use the "shift" variable to temporarily capture the second key | |||
set shift to GetKeyPress 1 | set shift to GetKeyPress 1 | ||
; If "key" has captured a Shift input, flip the variable's contents | |||
; and toggle "shift" on | |||
if ((key == 42) || (key == 54)) | if ((key == 42) || (key == 54)) | ||
set key to shift | set key to shift | ||
set shift to 1 | set shift to 1 | ||
; If "key" didn't capture a Shift input, did "shift" get it? | |||
elseif ((shift == 42) || (shift == 54)) | elseif ((shift == 42) || (shift == 54)) | ||
set shift to 1 | set shift to 1 | ||
; Otherwise Shift isn't pressed, toggle "shift" off | |||
else | else | ||
set shift to 0 | set shift to 0 | ||
endif | endif | ||
; Be sure "shift" is toggled off if only 1 key was pressed | |||
else | else | ||
set shift to 0 | set shift to 0 | ||
Line 87: | Line 104: | ||
endif | endif | ||
; Block Esc, the Shift keys, and others that aren't needed for typing | |||
if ((key == 1) || (key == 42) || (key == 54) || (key > 57)) | if ((key == 1) || (key == 42) || (key == 54) || (key > 57)) | ||
; | ; | ||
elseif (key == 41) ; Open console | |||
; Toggle the console active variable on/of if tilde(~) is pressed | |||
; so the player can use the console normally | |||
elseif (key == 41) ; Open/close console | |||
if (console) | if (console) | ||
set console to 0 | set console to 0 | ||
Line 95: | Line 116: | ||
set console to 1 | set console to 1 | ||
endif | endif | ||
; Block all input if the console is open | |||
elseif (console) | elseif (console) | ||
; | ; | ||
elseif (key == 14) ; Backspace | elseif (key == 14) ; Backspace | ||
StrClearLast name | StrClearLast name | ||
Line 102: | Line 126: | ||
StrAppend prompt name | StrAppend prompt name | ||
StrMessageBox prompt clear done | StrMessageBox prompt clear done | ||
elseif (key) | elseif (key) | ||
StrAppendCharCode name key shift | StrAppendCharCode name key shift | ||
Line 110: | Line 135: | ||
end | end | ||
; Gamemode block does initialization, catches input when a | |||
; button is pressed in the MessageBox | |||
begin gamemode | begin gamemode | ||
set fquestdelaytime to 0.01 | set fquestdelaytime to 0.01 | ||
; Catch input when a MBox button is pressed | |||
if (control) | if (control) | ||
set button to getbuttonpressed | set button to getbuttonpressed | ||
; "Clear All" button | |||
if (button == 0) | if (button == 0) | ||
StrClear name | StrClear name | ||
StrSet prompt "Name:" | StrSet prompt "Name:" | ||
StrMessageBox prompt clear done | StrMessageBox prompt clear done | ||
; "Finish Input" button | |||
elseif (button == 1) | elseif (button == 1) | ||
StrSetName name item | StrSetName name item | ||
Line 124: | Line 156: | ||
set control to 0 | set control to 0 | ||
stopquest TextInput | stopquest TextInput | ||
endif | endif | ||
; Startup: create strings, prompt for input | |||
elseif (control == 0) | elseif (control == 0) | ||
set name to StrNew | set name to StrNew |