Input2
Author: MetalRain
Added: 9. huhtikuuta 2011 kello 23.37
Edited: 15. huhtikuuta 2011 kello 22.19
Category: Käyttöliittymä
Description
Valtzun toteuttama paranneltu input komento, tukee useita inputteja joiden välillä voi vaihdella.
Code
Select all1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | Global __InputActive
Function ActiveInput(mem=0)
If mem=0 Then
Return __InputActive
Else
__InputActive = mem
EndIf
End Function
Function NewInput()
tmpmem = MakeMEMBlock(27)
__InputActive=tmpmem
PokeInt tmpmem,23,TextHeight("I")
Return tmpmem
End Function
Function DeleteInput(datmem)
If datmem Then DeleteMEMBlock datmem
End Function
Function Input2(datmem,txt$,x,y)
aika=Timer()
active=(datmem=__InputActive)
h=PeekInt(datmem,23)
mx=MouseX():my=MouseY()
blink = PeekInt(datmem,0)
curpos = Max(PeekInt(datmem,4),0)
exs = PeekInt(datmem,9)
exc = PeekByte(datmem,13)
delay = PeekInt(datmem,14)
del = PeekByte(datmem,18)
blinkkaa=Not PeekByte(datmem,8)
mleft=4
mtop=2
riviväli=15
If active Then
For i=0 To 220
tmp=tmp+(i^2)*KeyDown(i)
Next i
If tmp<>exs Then exc=0:delay=0:del=0
k = GetKey()
If KeyHit(181) Then k=47
numpad=0
For i=71 To 83
If i=78 Or i=74 Then i+1
If KeyHit(i) Then numpad=i Then Exit
Next i
If numpad Then
Select numpad
Case 83:k=44
Case 82:k=48
Case 79:k=49
Case 80:k=50
Case 81:k=51
Case 75:k=52
Case 76:k=53
Case 77:k=54
Case 71:k=55
Case 72:k=56
Case 73:k=57
End Select
EndIf
If k Then
exc=k:delay=0:del=0:blink=aika+500:blinkkaa=False:PokeInt datmem,0,blink:PokeByte datmem,8,blinkkaa
EndIf
txtlen=Len(txt)
If (exc>31 And (exc<127 Or exc>159) And ((((tmp=exs) And tmp<>0) And aika>delay) Or k)) And (exc<>45 Or KeyDown(181)=0) Then
If del=0 Then delay=aika+400:del=1 Else delay=aika+20
txt=StrInsert(txt,curpos,Chr(exc))
curpos=curpos+1
blinkkaa=True
ElseIf (exc=8 Or exc=127) And curpos>0 And (aika>delay Or k) Then
If del=0 Then delay=aika+400:del=1 Else delay=aika+20
If exc=127 Then
ttt=curpos
For i=curpos To 1 Step -1
a=Asc(Mid(txt,i,1))
If ((a<48 Or (a>57 And a<65) Or (a>90 And a<97) Or (a>122 And a<192)) And a<>39) Then
If i=ttt Then txt=StrRemove(txt,i,1):curpos-1
Exit
EndIf
txt=StrRemove(txt,i,1)
curpos-1
Next i
Else
txt=StrRemove(txt,curpos,1)
curpos-1
EndIf
blinkkaa=True
ElseIf exc=4 And (aika>delay Or k) Then
If del=0 Then delay=aika+400:del=1 Else delay=aika+20
If curpos<txtlen Then txt=StrRemove(txt,curpos+1,1)
blinkkaa=True
ElseIf k=2 Then
curpos=txtlen
ElseIf k=1 Then
curpos=0
ElseIf (exc=30 Or exc=31) And (aika>delay Or k) Then
If del=0 Then delay=aika+400:del=1 Else delay=aika+20
blinkkaa=True
curpos=Min(Max(curpos+(exc=30)-(exc=31),0),txtlen)
EndIf
EndIf
If aika>blink Then
PokeInt datmem,0,aika+500
PokeByte datmem,8,blinkkaa
EndIf
txtlen=Len(txt)
exs=tmp
offset=1
i=0
Text x+mleft,y+mtop+i*riviväli,txt
If blinkkaa And active Then
ww=TextWidth(Mid(txt,offset,(curpos-offset)+1))
Text x+mleft+ww,y+mtop+i*riviväli,"_"
EndIf
PokeInt datmem,4,curpos
PokeInt datmem,9,exs
PokeByte datmem,13,exc
PokeInt datmem,14,delay
PokeByte datmem,18,del
Return txt
End Function
|
Comments
No comments. You can be first!
Leave a comment
You must be logged in to comment.