|
@@ -113,24 +113,37 @@ function Console:render()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
if status then
|
|
if status then
|
|
|
- self:enterCommand()
|
|
|
|
|
|
|
+ if self.input_text == "" then return end
|
|
|
|
|
+ local command_line = self.input_text
|
|
|
|
|
+ local parts = splitArgs(command_line)
|
|
|
|
|
+ local args = {}
|
|
|
|
|
+ for i=2,#parts do
|
|
|
|
|
+ args[i-1] = parts[i]
|
|
|
|
|
+ end
|
|
|
|
|
+ self:log("> "..self.input_text, 1)
|
|
|
|
|
+
|
|
|
|
|
+ local fun_name = parts[1]:lower()
|
|
|
|
|
+ local command = self.commands[fun_name]
|
|
|
|
|
+ if not command then
|
|
|
|
|
+ self:log("Command not found : "..fun_name, ERROR)
|
|
|
|
|
+ else
|
|
|
|
|
+ local processed_commands = {}
|
|
|
|
|
+ local f = function()
|
|
|
|
|
+ command(unpack(args))
|
|
|
|
|
+ end
|
|
|
|
|
+ local success, result = xpcall(f, function(err) return debug.traceback(err) end)
|
|
|
|
|
+ if not success then
|
|
|
|
|
+ self:log(result, ERROR)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ self.input_text = ""
|
|
|
|
|
+ self.take_focus = true
|
|
|
end
|
|
end
|
|
|
imgui.End()
|
|
imgui.End()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function Console:enterCommand()
|
|
|
|
|
- if self.input_text == "" then return end
|
|
|
|
|
- local command_line = self.input_text
|
|
|
|
|
- local parts = splitArgs(command_line)
|
|
|
|
|
- local args = {}
|
|
|
|
|
- for i=2,#parts do
|
|
|
|
|
- args[i-1] = parts[i]
|
|
|
|
|
- end
|
|
|
|
|
- self:log("> "..self.input_text, 1)
|
|
|
|
|
- self:processCommand(parts[1]:lower(), args)
|
|
|
|
|
- self.input_text = ""
|
|
|
|
|
- self.take_focus = true
|
|
|
|
|
-end
|
|
|
|
|
|
|
|
|
|
function Console:toggle()
|
|
function Console:toggle()
|
|
|
DebugWindow.toggle(self)
|
|
DebugWindow.toggle(self)
|
|
@@ -171,21 +184,4 @@ function Console:registerCommand(name, fun, help)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function Console:processCommand(fun_name, args)
|
|
|
|
|
- local command = self.commands[fun_name]
|
|
|
|
|
- if not command then
|
|
|
|
|
- self:log("Command not found : "..fun_name, ERROR)
|
|
|
|
|
- return
|
|
|
|
|
- end
|
|
|
|
|
-
|
|
|
|
|
- local processed_commands = {}
|
|
|
|
|
- local f = function()
|
|
|
|
|
- command(unpack(args))
|
|
|
|
|
- end
|
|
|
|
|
- local success, result = xpcall(f, function(err) return debug.traceback(err) end)
|
|
|
|
|
- if not success then
|
|
|
|
|
- self:log(result, ERROR)
|
|
|
|
|
- end
|
|
|
|
|
-end
|
|
|
|
|
-
|
|
|
|
|
return Console
|
|
return Console
|