@@ -81,6 +81,11 @@ local function refresh_file_title()
|
||||
document.saveIcon.enabled = edited
|
||||
document.title.text = gui.str('File')..' - '..current_file.filename
|
||||
..(edited and ' *' or '')
|
||||
|
||||
local info = registry.get_info(current_file.filename)
|
||||
if info and info.type == "model" then
|
||||
pcall(run_current_file)
|
||||
end
|
||||
end
|
||||
|
||||
function on_control_combination(keycode)
|
||||
@@ -118,7 +123,6 @@ function run_current_file()
|
||||
local unit = info and info.unit
|
||||
|
||||
if script_type == "model" then
|
||||
print(current_file.filename)
|
||||
clear_output()
|
||||
local _, err = pcall(reload_model, current_file.filename, unit)
|
||||
if err then
|
||||
@@ -256,7 +260,7 @@ function open_file_in_editor(filename, line, mutable)
|
||||
end
|
||||
|
||||
function on_open(mode)
|
||||
registry = require "core:internal/scripts_registry"
|
||||
registry = __vc_scripts_registry
|
||||
|
||||
document.codePanel:setInterval(200, refresh_file_title)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ history = session.get_entry("commands_history")
|
||||
history_pointer = #history
|
||||
|
||||
events.on("core:open_traceback", function()
|
||||
if modes then
|
||||
if modes and modes.current ~= 'debug' then
|
||||
modes:set('debug')
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -43,11 +43,8 @@ function build_files_list(filenames, highlighted_part)
|
||||
end
|
||||
end
|
||||
|
||||
function on_open(mode)
|
||||
registry = require "core:internal/scripts_registry"
|
||||
|
||||
local files_list = document.filesList
|
||||
|
||||
function on_open()
|
||||
registry = __vc_scripts_registry
|
||||
filenames = registry.filenames
|
||||
table.sort(filenames)
|
||||
build_files_list(filenames)
|
||||
|
||||
@@ -176,18 +176,105 @@ function place_pack(panel, packinfo, callback, position_func)
|
||||
end
|
||||
end
|
||||
|
||||
local Version = {};
|
||||
|
||||
function Version.matches_pattern(version)
|
||||
for _, letter in string.gmatch(version, "%.+") do
|
||||
if type(letter) ~= "number" or letter ~= "." then
|
||||
return false;
|
||||
end
|
||||
|
||||
local t = string.split(version, ".");
|
||||
|
||||
return #t == 2 or #t == 3;
|
||||
end
|
||||
end
|
||||
|
||||
function Version.__equal(ver1, ver2)
|
||||
return ver1[1] == ver2[1] and ver1[2] == ver2[2] and ver1[3] == ver2[3];
|
||||
end
|
||||
|
||||
function Version.__more(ver1, ver2)
|
||||
if ver1[1] ~= ver2[1] then return ver1[1] > ver2[1] end;
|
||||
if ver1[2] ~= ver2[2] then return ver1[2] > ver2[2] end;
|
||||
return ver1[3] > ver2[3];
|
||||
end
|
||||
|
||||
function Version.__less(ver1, ver2)
|
||||
return Version.__more(ver2, ver1);
|
||||
end
|
||||
|
||||
function Version.__more_or_equal(ver1, ver2)
|
||||
return not Version.__less(ver1, ver2);
|
||||
end
|
||||
|
||||
function Version.__less_or_equal(ver1, ver2)
|
||||
return not Version.__more(ver1, ver2);
|
||||
end
|
||||
|
||||
function Version.compare(op, ver1, ver2)
|
||||
ver1 = string.split(ver1, ".");
|
||||
ver2 = string.split(ver2, ".");
|
||||
|
||||
if op == "=" then return Version.__equal(ver1, ver2);
|
||||
elseif op == ">" then return Version.__more(ver1, ver2);
|
||||
elseif op == "<" then return Version.__less(ver1, ver2);
|
||||
elseif op == ">=" then return Version.__more_or_equal(ver1, ver2);
|
||||
elseif op == "<=" then return Version.__less_or_equal(ver1, ver2);
|
||||
else return false; end
|
||||
end
|
||||
|
||||
function Version.parse(version)
|
||||
local op = string.sub(version, 1, 2);
|
||||
if op == ">=" or op == "=>" then
|
||||
return ">=", string.sub(version, #op + 1);
|
||||
elseif op == "<=" or op == "=<" then
|
||||
return "<=", string.sub(version, #op + 1);
|
||||
end
|
||||
|
||||
op = string.sub(version, 1, 1);
|
||||
if op == ">" or op == "<" then
|
||||
return op, string.sub(version, #op + 1);
|
||||
end
|
||||
|
||||
return "=", version;
|
||||
end
|
||||
|
||||
local function compare_version(dependent_version, actual_version)
|
||||
if Version.matches_pattern(dependent_version) and Version.matches_pattern(actual_version) then
|
||||
local op, dep_ver = Version.parse_version(dependent_version);
|
||||
Version.compare(op, dep_ver, actual_version);
|
||||
elseif dependent_version == "*" or dependent_version == actual_version then
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
end
|
||||
end
|
||||
|
||||
function check_dependencies(packinfo)
|
||||
if packinfo.dependencies == nil then
|
||||
return
|
||||
end
|
||||
for i,dep in ipairs(packinfo.dependencies) do
|
||||
local depid = dep:sub(2,-1)
|
||||
if dep:sub(1,1) == '!' then
|
||||
local depid, depver = unpack(string.split(dep:sub(2,-1), "@"))
|
||||
|
||||
if dep:sub(1,1) == '!' then
|
||||
if not table.has(packs_all, depid) then
|
||||
return string.format(
|
||||
"%s (%s)", gui.str("error.dependency-not-found"), depid
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
local dep_pack = pack.get_info(depid);
|
||||
|
||||
if not compare_version(depver, dep_pack.version) then
|
||||
local op, ver = Version.parse(depver);
|
||||
|
||||
print(string.format("%s: %s !%s %s (%s)", gui.str("error.dependency-version-not-met"), dep_pack.version, op, ver, depid));
|
||||
return string.format("%s: %s != %s (%s)", gui.str("error.dependency-version-not-met"), dep_pack.version, ver, depid);
|
||||
end
|
||||
|
||||
if table.has(packs_installed, packinfo.id) then
|
||||
table.insert(required, depid)
|
||||
end
|
||||
|
||||
@@ -13,9 +13,9 @@ end
|
||||
function refresh()
|
||||
document.list:clear()
|
||||
|
||||
local available = pack.get_available()
|
||||
local infos = pack.get_info(available)
|
||||
for _, name in ipairs(available) do
|
||||
local allpacks = table.merge(pack.get_available(), pack.get_installed())
|
||||
local infos = pack.get_info(allpacks)
|
||||
for _, name in ipairs(allpacks) do
|
||||
local info = infos[name]
|
||||
local scripts_dir = info.path.."/scripts/app"
|
||||
if not file.exists(scripts_dir) then
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
local WARNING_COLORS = {
|
||||
{208, 104, 107, 255},
|
||||
{250, 75, 139, 255},
|
||||
{250, 151, 75, 255},
|
||||
{246, 233, 44, 255},
|
||||
{252, 200, 149, 255}
|
||||
}
|
||||
|
||||
local GENERAL_WARNING_COLOR = {208, 138, 0, 255}
|
||||
|
||||
function refresh_search()
|
||||
local search_text = document.search_textbox.text
|
||||
@@ -40,6 +49,49 @@ function change_sensitivity(val)
|
||||
refresh_sensitivity()
|
||||
end
|
||||
|
||||
function refresh_binding_marks()
|
||||
local prev_bindings = {}
|
||||
local conflicts_colors = {}
|
||||
local available_colors = table.copy(WARNING_COLORS)
|
||||
|
||||
local bindings = input.get_bindings()
|
||||
table.sort(bindings, function(a, b) return a > b end)
|
||||
|
||||
for _, bind_name in ipairs(bindings) do
|
||||
local key = input.get_binding_text(bind_name)
|
||||
local prev = prev_bindings[key]
|
||||
if prev then
|
||||
local color = GENERAL_WARNING_COLOR
|
||||
local conflict_color = conflicts_colors[key]
|
||||
local available_colors_len = #available_colors
|
||||
if conflict_color then
|
||||
color = conflict_color
|
||||
elseif available_colors_len > 0 then
|
||||
color = available_colors[available_colors_len]
|
||||
conflicts_colors[key] = color
|
||||
table.remove(available_colors, available_colors_len)
|
||||
end
|
||||
|
||||
local tooltip = gui.str("settings.Conflict", "settings")
|
||||
|
||||
local prev_bindmark = "bindmark_" .. prev
|
||||
local cur_bindmark = "bindmark_" .. bind_name
|
||||
document[prev_bindmark].visible = true
|
||||
document[cur_bindmark].visible = true
|
||||
|
||||
document[prev_bindmark].color = color
|
||||
document[cur_bindmark].color = color
|
||||
|
||||
document["bind_" .. prev].tooltip = tooltip
|
||||
document["bind_" .. bind_name].tooltip = tooltip
|
||||
else
|
||||
document["bindmark_" .. bind_name].visible = false
|
||||
document["bind_" .. bind_name].tooltip = ''
|
||||
prev_bindings[key] = bind_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function on_open()
|
||||
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
||||
refresh_sensitivity()
|
||||
@@ -52,4 +104,8 @@ function on_open()
|
||||
id=name, name=gui.str(name)
|
||||
}))
|
||||
end
|
||||
|
||||
document.bindings_panel:setInterval(100, function ()
|
||||
refresh_binding_marks()
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<panel size='400,40' padding='4' color='0' orientation='horizontal'>
|
||||
<panel id='bind_%{id}' size='400,40' padding='4' color='0' orientation='horizontal'>
|
||||
<bindbox binding='%{id}'/>
|
||||
<label margin='6'>%{name}</label>
|
||||
<image id="bindmark_%{id}"src='gui/left_half_block' size='4,28' visible="false"/>
|
||||
<label id='bindlabel_%{id}' color="#ffffffff" margin='6'>%{name}</label>
|
||||
</panel>
|
||||
|
||||
Reference in New Issue
Block a user