6 self
.prompt
= os
.date("%H:%M> ")
12 self
.lines
[13] = self
.prompt
19 function Console
:draw()
23 love
.graphics
.setColor(30,30,30)
24 love
.graphics
.polygon("fill", 0, 0, 0, 200, 800, 200, 800, 0)
25 love
.graphics
.setColor(230,230,230)
26 for i
,v
in ipairs(self
.lines
) do
27 love
.graphics
.print(v
, 10, i
*15)
31 function Console
:input(key
)
33 -- handle opening and closing of console
35 if key
== self
.togglekey
then
43 if key
== self
.togglekey
then
49 --letters are just printed, other keys are special, handle this
51 --return: new inputline, execute old one, shift lines up
52 if key
== "return" or key
== "kp_enter" then
54 if self
.inputbuffer
== "" then
55 self
.lines
[i
-1] = self
.lines
[i
]
57 self
.lines
[i
-2] = self
.lines
[i
]
60 self
.lines
[12] = self
.inputbuffer
--TODO nochmal richtig machen
61 self
:execute(self
.inputbuffer
)
64 --just no action for these
65 elseif key
== "tab" or key
== "lalt" or key
== "ralt" or key
== "lctrl" or key
== "rctrl" or key
== "lshift" or key
== "rshift" or key
== "mode" or key
== "lsuper" or key
== "rsuper" or key
== "capslock" or key
== "menu" then
67 elseif key
== "up" then
68 --previous command --TODO
69 elseif key
== "down" then
71 elseif key
== "left" then
73 elseif key
== "right" then
78 --letters, big or small --TODO: convert symbols
79 if love
.keyboard
.isDown("rshift") or love
.keyboard
.isDown("lshift") then
80 key
= string.upper(key
)
82 self
.inputbuffer
= self
.inputbuffer
.. key
84 self
.lines
[13] = self
.prompt
.. self
.inputbuffer
88 function Console
:execute(string)