44 |
44 |
45 implementation |
45 implementation |
46 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
46 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
47 |
47 |
48 var tkbd, tkbdn: TKeyboardState; |
48 var tkbd, tkbdn: TKeyboardState; |
|
49 quitKeyCode: Byte; |
49 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
50 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
|
51 |
50 |
52 |
51 function KeyNameToCode(name: shortstring): word; |
53 function KeyNameToCode(name: shortstring): word; |
52 var code: Word; |
54 var code: Word; |
53 begin |
55 begin |
54 name:= LowerCase(name); |
56 name:= LowerCase(name); |
103 inc(k, 1); |
105 inc(k, 1); |
104 end; |
106 end; |
105 end; |
107 end; |
106 {$ENDIF} |
108 {$ENDIF} |
107 |
109 |
108 |
110 end; |
109 //TODO reimplement this |
111 |
|
112 |
|
113 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
|
114 var |
|
115 Trusted: boolean; |
|
116 s : string; |
|
117 begin |
|
118 hideAmmoMenu:= false; |
|
119 Trusted:= (CurrentTeam <> nil) |
|
120 and (not CurrentTeam^.ExtDriven) |
|
121 and (CurrentHedgehog^.BotLevel = 0); |
|
122 |
|
123 tkbdn[code]:= ord(KeyDown); |
|
124 |
110 // ctrl/cmd + q to close engine and frontend |
125 // ctrl/cmd + q to close engine and frontend |
|
126 if(KeyDown and (code = quitKeyCode)) then |
|
127 begin |
111 {$IFDEF DARWIN} |
128 {$IFDEF DARWIN} |
112 if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then |
129 if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then |
113 {$ELSE} |
130 {$ELSE} |
114 if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then |
131 if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then |
115 {$ENDIF} |
132 {$ENDIF} |
116 begin |
133 ParseCommand('halt', true); |
117 if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true) |
134 end; |
118 end; |
|
119 end; |
|
120 |
|
121 |
|
122 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
|
123 var |
|
124 Trusted: boolean; |
|
125 s : string; |
|
126 begin |
|
127 hideAmmoMenu:= false; |
|
128 Trusted:= (CurrentTeam <> nil) |
|
129 and (not CurrentTeam^.ExtDriven) |
|
130 and (CurrentHedgehog^.BotLevel = 0); |
|
131 |
|
132 tkbdn[code]:= ord(KeyDown); |
|
133 |
135 |
134 if CurrentBinds[code][0] <> #0 then |
136 if CurrentBinds[code][0] <> #0 then |
135 begin |
137 begin |
136 if (code > 3) and (tkbdn[code] <> 0) and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
138 if (code > 3) and (tkbdn[code] <> 0) and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
137 if (tkbd[code] = 0) and (tkbdn[code] <> 0) then |
139 if (tkbd[code] = 0) and (tkbdn[code] <> 0) then |