update console layout
This commit is contained in:
parent
843fbad0bd
commit
e70746ae43
@ -2,17 +2,14 @@
|
||||
<panel interval="0"
|
||||
orientation="horizontal"
|
||||
color="#00000010"
|
||||
size-func="gui.get_viewport()[1]-350,30">
|
||||
size-func="gui.get_viewport()[1],30">
|
||||
<button id="s_chat" size="110,30" onclick="modes:set('chat')">@Chat</button>
|
||||
<button id="s_console" size="110,30" onclick="modes:set('console')">@Console</button>
|
||||
<button id="s_debug" size="110,30" onclick="modes:set('debug')">@Debug</button>
|
||||
</panel>
|
||||
<container pos="0,30" size-func="gui.get_viewport()[1]-350,30" color="#00000020">
|
||||
<label id="title" pos="8,8"></label>
|
||||
</container>
|
||||
|
||||
<container id="logContainer" pos="0,60"
|
||||
size-func="unpack(vec2.add(gui.get_viewport(), {-350,-100}))">
|
||||
size-func="unpack(vec2.add(gui.get_viewport(), {-450,-100}))">
|
||||
<textbox
|
||||
id='log'
|
||||
color='0'
|
||||
@ -25,38 +22,44 @@
|
||||
markup="md"
|
||||
></textbox>
|
||||
</container>
|
||||
<splitbox id="editorContainer" split-pos="0.8" pos="0,60"
|
||||
size-func="unpack(vec2.add(gui.get_viewport(), {-350,-60}))">
|
||||
<container color="#00000080">
|
||||
<textbox
|
||||
id='editor'
|
||||
color='0'
|
||||
autoresize='true'
|
||||
margin='0'
|
||||
padding='5'
|
||||
multiline='true'
|
||||
line-numbers='true'
|
||||
syntax='lua'
|
||||
size-func="-1,40"
|
||||
text-wrap='false'
|
||||
scroll-step='50'
|
||||
></textbox>
|
||||
</container>
|
||||
<panel id="traceback" gravity="bottom-left"
|
||||
padding="4" color="#000000A0" max-length="170">
|
||||
</panel>
|
||||
</splitbox>
|
||||
<splitbox position-func="gui.get_viewport()[1]-350,0"
|
||||
size-func="350,gui.get_viewport()[2]-40"
|
||||
split-pos="0.25">
|
||||
<panel id="problemsLog"
|
||||
color="#00000010"
|
||||
padding="5,15,5,15">
|
||||
<label margin="0,0,0,5">@Problems</label>
|
||||
</panel>
|
||||
<panel id="filesList" color="#00000010" interval="6" padding="4">
|
||||
<!-- content is generated in script -->
|
||||
<splitbox id="editorRoot" pos="0,30" size-func="-1,gui.get_viewport()[2]-30"
|
||||
orientation="horizontal" split-pos="0.7">
|
||||
<splitbox id="editorContainer" split-pos="0.8">
|
||||
<container color="#00000080">
|
||||
<container size-func="-1,30" color="#00000020">
|
||||
<image id="lockIcon" src="gui/lock" enabled="false" size="16" pos="4,6"></image>
|
||||
<label id="title" pos="26,8"></label>
|
||||
</container>
|
||||
<textbox
|
||||
id='editor'
|
||||
pos='0,30'
|
||||
color='0'
|
||||
autoresize='true'
|
||||
margin='0'
|
||||
padding='5'
|
||||
multiline='true'
|
||||
line-numbers='true'
|
||||
syntax='lua'
|
||||
size-func="-1,40"
|
||||
text-wrap='false'
|
||||
scroll-step='50'
|
||||
></textbox>
|
||||
</container>
|
||||
<panel id="traceback" gravity="bottom-left"
|
||||
padding="4" color="#000000A0" max-length="170">
|
||||
</panel>
|
||||
</splitbox>
|
||||
<splitbox
|
||||
split-pos="0.25">
|
||||
<panel id="problemsLog"
|
||||
color="#00000010"
|
||||
padding="5,15,5,15">
|
||||
<label margin="0,0,0,5">@Problems</label>
|
||||
</panel>
|
||||
<panel id="filesList" color="#00000010" interval="6" padding="4">
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
</splitbox>
|
||||
</splitbox>
|
||||
<textbox id='prompt'
|
||||
consumer='submit'
|
||||
|
||||
@ -45,6 +45,19 @@ events.on("core:error", function (msg, traceback)
|
||||
table.insert(errors_all, full)
|
||||
end)
|
||||
|
||||
function open_file_in_editor(filename, line)
|
||||
local editor = document.editor
|
||||
local source = file.read(filename):gsub('\t', ' ')
|
||||
editor.text = source
|
||||
editor.focused = true
|
||||
if line then
|
||||
time.post_runnable(function()
|
||||
editor.caret = editor:linePos(line)
|
||||
end)
|
||||
end
|
||||
document.title.text = gui.str('File')..' - '..filename
|
||||
end
|
||||
|
||||
events.on("core:open_traceback", function(traceback_b64)
|
||||
local traceback = bjson.frombytes(base64.decode(traceback_b64))
|
||||
modes:set('debug')
|
||||
@ -62,23 +75,12 @@ events.on("core:open_traceback", function(traceback_b64)
|
||||
framestr = frame.source..":"..tostring(frame.currentline).." "
|
||||
if file.exists(frame.source) then
|
||||
callback = string.format(
|
||||
"local editor = document.editor "..
|
||||
"local source = file.read('%s'):gsub('\t', ' ') "..
|
||||
"editor.text = source "..
|
||||
"editor.focused = true "..
|
||||
"time.post_runnable(function()"..
|
||||
"editor.caret = editor:linePos(%s) "..
|
||||
"end)",
|
||||
"open_file_in_editor('%s', %s)",
|
||||
frame.source, frame.currentline-1
|
||||
)
|
||||
else
|
||||
callback = "document.editor.text = 'Could not open source file'"
|
||||
end
|
||||
callback = string.format(
|
||||
"%s document.title.text = gui.str('File')..' - %s'",
|
||||
callback,
|
||||
frame.source
|
||||
)
|
||||
end
|
||||
if frame.name then
|
||||
framestr = framestr.."("..tostring(frame.name)..")"
|
||||
@ -185,6 +187,8 @@ function set_mode(mode)
|
||||
local show_prompt = mode == 'chat' or mode == 'console'
|
||||
|
||||
document.title.text = ""
|
||||
document.lockIcon.visible = false
|
||||
document.editorRoot.visible = mode == 'debug'
|
||||
document.editorContainer.visible = mode == 'debug'
|
||||
document.logContainer.visible = mode ~= 'debug'
|
||||
|
||||
@ -201,6 +205,19 @@ function set_mode(mode)
|
||||
console_mode = mode
|
||||
end
|
||||
|
||||
local function collect_scripts(dirname, dest)
|
||||
if file.isdir(dirname) then
|
||||
local files = file.list(dirname)
|
||||
for i, filename in ipairs(files) do
|
||||
if file.isdir(filename) then
|
||||
collect_scripts(filename, dest)
|
||||
elseif file.ext(filename) == "lua" then
|
||||
table.insert(dest, filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function on_open(mode)
|
||||
if modes == nil then
|
||||
modes = RadioGroup({
|
||||
@ -210,6 +227,24 @@ function on_open(mode)
|
||||
}, function (mode)
|
||||
set_mode(mode)
|
||||
end, mode or "console")
|
||||
|
||||
local files_list = document.filesList
|
||||
local packs = pack.get_installed()
|
||||
|
||||
local scripts = {}
|
||||
for _, packid in ipairs(packs) do
|
||||
collect_scripts(packid..":modules", scripts)
|
||||
collect_scripts(packid..":scripts", scripts)
|
||||
end
|
||||
table.sort(scripts)
|
||||
for _, filename in ipairs(scripts) do
|
||||
local parent = file.parent(filename)
|
||||
files_list:add(gui.template("script_file", {
|
||||
path = parent .. (parent[#parent] == ':' and '' or '/'),
|
||||
name = file.name(filename),
|
||||
filename = filename
|
||||
}))
|
||||
end
|
||||
elseif mode then
|
||||
modes:set(mode)
|
||||
end
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
<container id="%{id}" size="32" tooltip="%{text}"
|
||||
onclick="events.emit('core:open_traceback', '%{traceback}')">
|
||||
<image src="gui/%{type}" size="32"/>
|
||||
<container pos="36,2" size="280,32" interactive="false">
|
||||
<label>%{text}</label>
|
||||
</container>
|
||||
<label pos="36,2" sizefunc="-1,-1">%{text}</label>
|
||||
<image src="gui/cross" interactive="true" size="16" gravity="top-right"
|
||||
onclick="document['%{id}']:destruct()"></image>
|
||||
</container>
|
||||
|
||||
6
res/layouts/templates/script_file.xml
Normal file
6
res/layouts/templates/script_file.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<label hover-color='#30A0FF'
|
||||
interactive='true'
|
||||
markup='md'
|
||||
onclick='open_file_in_editor("%{filename}")'>
|
||||
[#FFFFFF80]%{path}[#FFFFFFFF]%{name}
|
||||
</label>
|
||||
@ -24,7 +24,8 @@
|
||||
"misc/snow",
|
||||
"gui/check_mark",
|
||||
"gui/left_arrow",
|
||||
"gui/right_arrow"
|
||||
"gui/right_arrow",
|
||||
"gui/lock"
|
||||
],
|
||||
"fonts": [
|
||||
{
|
||||
|
||||
BIN
res/textures/gui/lock.png
Normal file
BIN
res/textures/gui/lock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 B |
Loading…
x
Reference in New Issue
Block a user