update console layout
This commit is contained in:
parent
843fbad0bd
commit
e70746ae43
@ -2,17 +2,14 @@
|
|||||||
<panel interval="0"
|
<panel interval="0"
|
||||||
orientation="horizontal"
|
orientation="horizontal"
|
||||||
color="#00000010"
|
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_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_console" size="110,30" onclick="modes:set('console')">@Console</button>
|
||||||
<button id="s_debug" size="110,30" onclick="modes:set('debug')">@Debug</button>
|
<button id="s_debug" size="110,30" onclick="modes:set('debug')">@Debug</button>
|
||||||
</panel>
|
</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"
|
<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
|
<textbox
|
||||||
id='log'
|
id='log'
|
||||||
color='0'
|
color='0'
|
||||||
@ -25,11 +22,17 @@
|
|||||||
markup="md"
|
markup="md"
|
||||||
></textbox>
|
></textbox>
|
||||||
</container>
|
</container>
|
||||||
<splitbox id="editorContainer" split-pos="0.8" pos="0,60"
|
<splitbox id="editorRoot" pos="0,30" size-func="-1,gui.get_viewport()[2]-30"
|
||||||
size-func="unpack(vec2.add(gui.get_viewport(), {-350,-60}))">
|
orientation="horizontal" split-pos="0.7">
|
||||||
|
<splitbox id="editorContainer" split-pos="0.8">
|
||||||
<container color="#00000080">
|
<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
|
<textbox
|
||||||
id='editor'
|
id='editor'
|
||||||
|
pos='0,30'
|
||||||
color='0'
|
color='0'
|
||||||
autoresize='true'
|
autoresize='true'
|
||||||
margin='0'
|
margin='0'
|
||||||
@ -46,8 +49,7 @@
|
|||||||
padding="4" color="#000000A0" max-length="170">
|
padding="4" color="#000000A0" max-length="170">
|
||||||
</panel>
|
</panel>
|
||||||
</splitbox>
|
</splitbox>
|
||||||
<splitbox position-func="gui.get_viewport()[1]-350,0"
|
<splitbox
|
||||||
size-func="350,gui.get_viewport()[2]-40"
|
|
||||||
split-pos="0.25">
|
split-pos="0.25">
|
||||||
<panel id="problemsLog"
|
<panel id="problemsLog"
|
||||||
color="#00000010"
|
color="#00000010"
|
||||||
@ -58,6 +60,7 @@
|
|||||||
<!-- content is generated in script -->
|
<!-- content is generated in script -->
|
||||||
</panel>
|
</panel>
|
||||||
</splitbox>
|
</splitbox>
|
||||||
|
</splitbox>
|
||||||
<textbox id='prompt'
|
<textbox id='prompt'
|
||||||
consumer='submit'
|
consumer='submit'
|
||||||
margin='0'
|
margin='0'
|
||||||
|
|||||||
@ -45,6 +45,19 @@ events.on("core:error", function (msg, traceback)
|
|||||||
table.insert(errors_all, full)
|
table.insert(errors_all, full)
|
||||||
end)
|
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)
|
events.on("core:open_traceback", function(traceback_b64)
|
||||||
local traceback = bjson.frombytes(base64.decode(traceback_b64))
|
local traceback = bjson.frombytes(base64.decode(traceback_b64))
|
||||||
modes:set('debug')
|
modes:set('debug')
|
||||||
@ -62,23 +75,12 @@ events.on("core:open_traceback", function(traceback_b64)
|
|||||||
framestr = frame.source..":"..tostring(frame.currentline).." "
|
framestr = frame.source..":"..tostring(frame.currentline).." "
|
||||||
if file.exists(frame.source) then
|
if file.exists(frame.source) then
|
||||||
callback = string.format(
|
callback = string.format(
|
||||||
"local editor = document.editor "..
|
"open_file_in_editor('%s', %s)",
|
||||||
"local source = file.read('%s'):gsub('\t', ' ') "..
|
|
||||||
"editor.text = source "..
|
|
||||||
"editor.focused = true "..
|
|
||||||
"time.post_runnable(function()"..
|
|
||||||
"editor.caret = editor:linePos(%s) "..
|
|
||||||
"end)",
|
|
||||||
frame.source, frame.currentline-1
|
frame.source, frame.currentline-1
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
callback = "document.editor.text = 'Could not open source file'"
|
callback = "document.editor.text = 'Could not open source file'"
|
||||||
end
|
end
|
||||||
callback = string.format(
|
|
||||||
"%s document.title.text = gui.str('File')..' - %s'",
|
|
||||||
callback,
|
|
||||||
frame.source
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
if frame.name then
|
if frame.name then
|
||||||
framestr = framestr.."("..tostring(frame.name)..")"
|
framestr = framestr.."("..tostring(frame.name)..")"
|
||||||
@ -185,6 +187,8 @@ function set_mode(mode)
|
|||||||
local show_prompt = mode == 'chat' or mode == 'console'
|
local show_prompt = mode == 'chat' or mode == 'console'
|
||||||
|
|
||||||
document.title.text = ""
|
document.title.text = ""
|
||||||
|
document.lockIcon.visible = false
|
||||||
|
document.editorRoot.visible = mode == 'debug'
|
||||||
document.editorContainer.visible = mode == 'debug'
|
document.editorContainer.visible = mode == 'debug'
|
||||||
document.logContainer.visible = mode ~= 'debug'
|
document.logContainer.visible = mode ~= 'debug'
|
||||||
|
|
||||||
@ -201,6 +205,19 @@ function set_mode(mode)
|
|||||||
console_mode = mode
|
console_mode = mode
|
||||||
end
|
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)
|
function on_open(mode)
|
||||||
if modes == nil then
|
if modes == nil then
|
||||||
modes = RadioGroup({
|
modes = RadioGroup({
|
||||||
@ -210,6 +227,24 @@ function on_open(mode)
|
|||||||
}, function (mode)
|
}, function (mode)
|
||||||
set_mode(mode)
|
set_mode(mode)
|
||||||
end, mode or "console")
|
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
|
elseif mode then
|
||||||
modes:set(mode)
|
modes:set(mode)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
<container id="%{id}" size="32" tooltip="%{text}"
|
<container id="%{id}" size="32" tooltip="%{text}"
|
||||||
onclick="events.emit('core:open_traceback', '%{traceback}')">
|
onclick="events.emit('core:open_traceback', '%{traceback}')">
|
||||||
<image src="gui/%{type}" size="32"/>
|
<image src="gui/%{type}" size="32"/>
|
||||||
<container pos="36,2" size="280,32" interactive="false">
|
<label pos="36,2" sizefunc="-1,-1">%{text}</label>
|
||||||
<label>%{text}</label>
|
|
||||||
</container>
|
|
||||||
<image src="gui/cross" interactive="true" size="16" gravity="top-right"
|
<image src="gui/cross" interactive="true" size="16" gravity="top-right"
|
||||||
onclick="document['%{id}']:destruct()"></image>
|
onclick="document['%{id}']:destruct()"></image>
|
||||||
</container>
|
</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",
|
"misc/snow",
|
||||||
"gui/check_mark",
|
"gui/check_mark",
|
||||||
"gui/left_arrow",
|
"gui/left_arrow",
|
||||||
"gui/right_arrow"
|
"gui/right_arrow",
|
||||||
|
"gui/lock"
|
||||||
],
|
],
|
||||||
"fonts": [
|
"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