From 6ed030c8f515f2be07d64f1cd92980689e6d2a6c Mon Sep 17 00:00:00 2001 From: zhou2008 <493505110@qq.com> Date: Fri, 26 Feb 2021 22:28:23 +0800 Subject: [PATCH 1/8] dilidili.ml to mirror.opencomputers.ml --- README-zh_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 8b72a02c..c714183b 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -35,7 +35,7 @@ MineOS是一个基于GUI的Minecraft Opencomputers模组的操作系统. 它有 如果由于某种原因Github方法对你不可用(例如, 它在游戏服务器上被列入黑名单, 或者被互联网提供商屏蔽), 使用替代命令直接从dilidili页面下载安装程序: - wget -f https://dilidili.ml:1337/mirror/MineOS/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot + wget -f https://mirror.opencomputers.ml:1337/MineOS/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot 过一会儿, 一个很好的系统安装程序将显示. 安装程序将提示您选择首选语言, 选择并格式化引导卷, 创建用户配置文件并自定义一些设置. From 0fca2d8da8b06456346ce01eeb1a8a7e80ffe451 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 9 Mar 2021 13:24:27 -0600 Subject: [PATCH 2/8] Attempt to add variable shapeLimit. --- Applications/3D Print.app/Main.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index a3f4d7c7..9c3b108c 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -78,7 +78,15 @@ local localization = system.getLocalization(currentScriptDirectory .. "Localizat local currentLayer = 0 local model local savePath -local shapeLimit = 24 + +if component.isAvailable("printer3d") then + local printer3d = component.get("printer3d") + local shapeLimit = printer3d.getMaxShapeCount() + --Might also be getShapeCount(), as it's doc info talks about a config file. +else + local shapeLimit = 24 +end + local viewPixelWidth, viewPixelHeight = 4, 2 local colors, hue, hueStep = {}, 0, 360 / shapeLimit From fdab55767930ed92ebccc3b490b894f79cbeeefd Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Wed, 10 Mar 2021 14:16:39 -0600 Subject: [PATCH 3/8] Dynamically update shape limit and attempt to fix mentioned problems --- Applications/3D Print.app/Main.lua | 32 ++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index 9c3b108c..6f646dac 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -81,10 +81,10 @@ local savePath if component.isAvailable("printer3d") then local printer3d = component.get("printer3d") - local shapeLimit = printer3d.getMaxShapeCount() - --Might also be getShapeCount(), as it's doc info talks about a config file. + shapeLimit = printer3d.getMaxShapeCount() + --Don't use updateShapeLimit, as colors and hue stuff is updated shortly. else - local shapeLimit = 24 + shapeLimit = 24 end local viewPixelWidth, viewPixelHeight = 4, 2 @@ -95,6 +95,20 @@ for i = 1, shapeLimit do hue = hue + hueStep end +local function updateShapeLimit(newLimit) + --No need to update anything if new limit is the same as old. + if newLimit == shapeLimit: + return + --Otherwise, we need to update both limit and all the colors that use the limit. + shapeLimit = newLimit + + colors, hue, hueStep = {}, 0, 360 / shapeLimit + for i = 1, shapeLimit do + colors[i] = color.HSBToInteger(hue, 1, 1) + hue = hue + hueStep + end +end + local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, screen.getHeight() - 1, 0x1E1E1E)) -- local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 92, 32, 0x1E1E1E)) @@ -294,7 +308,17 @@ end local function updateProxies() updateProxy("hologram") updateHologramWidgets() - printButton.disabled = not updateProxy("printer3d") + local hasPrinter = updateProxy("printer3d") + + --Update shape limit if we have a printer connected. + --Probably halfway laggy because it's updating colors now too though, + --but necessary if we want things to work right with no unintended consequences. + if hasPrinter then + local printer3d = component.get("printer3d") + updateShapeLimit(printer3d.getMaxShapeCount()) + end + + printButton.disabled = not hasPrinter end updateProxies() From 725e74d1263a2e0f85e8627aa5dca35e4ed5606a Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 11 Mar 2021 12:07:45 -0600 Subject: [PATCH 4/8] Fix glaring problem and stop repeating lines --- Applications/3D Print.app/Main.lua | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index 6f646dac..dbedbbfe 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -79,26 +79,15 @@ local currentLayer = 0 local model local savePath -if component.isAvailable("printer3d") then - local printer3d = component.get("printer3d") - shapeLimit = printer3d.getMaxShapeCount() - --Don't use updateShapeLimit, as colors and hue stuff is updated shortly. -else - shapeLimit = 24 -end - local viewPixelWidth, viewPixelHeight = 4, 2 - -local colors, hue, hueStep = {}, 0, 360 / shapeLimit -for i = 1, shapeLimit do - colors[i] = color.HSBToInteger(hue, 1, 1) - hue = hue + hueStep -end +local shapeLimit = 0--Temporary, will be set properly shortly local function updateShapeLimit(newLimit) --No need to update anything if new limit is the same as old. - if newLimit == shapeLimit: + if newLimit == shapeLimit then return + end + --Otherwise, we need to update both limit and all the colors that use the limit. shapeLimit = newLimit @@ -109,6 +98,13 @@ local function updateShapeLimit(newLimit) end end +if component.isAvailable("printer3d") then + local printer3d = component.get("printer3d") + updateShapeLimit(printer3d.getMaxShapeCount()) +else + updateShapeLimit(24) +end + local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, screen.getHeight() - 1, 0x1E1E1E)) -- local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 92, 32, 0x1E1E1E)) From 1dfb80ea0fb29c1f0af6eab9293a5acf2a31c996 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 11 Mar 2021 12:12:28 -0600 Subject: [PATCH 5/8] Add coment about design choices --- Applications/3D Print.app/Main.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index dbedbbfe..dff61b2a 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -309,6 +309,8 @@ local function updateProxies() --Update shape limit if we have a printer connected. --Probably halfway laggy because it's updating colors now too though, --but necessary if we want things to work right with no unintended consequences. + --I would have this update in the component add remove part, but updateProxy is + --awesome and tells us if a component is present or not. if hasPrinter then local printer3d = component.get("printer3d") updateShapeLimit(printer3d.getMaxShapeCount()) From 45ce42c9fdc69f7bbf6a829bc8d23af97b54ea25 Mon Sep 17 00:00:00 2001 From: IgorTimofeev <11760002+IgorTimofeev@users.noreply.github.com> Date: Fri, 12 Mar 2021 02:26:40 +0300 Subject: [PATCH 6/8] =?UTF-8?q?=D1=81=D1=83=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/3D Print.app/Main.lua | 105 +++++++++++++++-------------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index dff61b2a..3d1102f4 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -20,7 +20,8 @@ local function updateProxy(name) proxies[name] = component.list(name)() if proxies[name] then proxies[name] = component.proxy(proxies[name]) - return true + + return proxies[name] end end @@ -55,10 +56,12 @@ local function print(model) for i = 1, #model.shapes do local shape = model.shapes[i] + proxy.addShape(shape[1], shape[2], shape[3], shape[4], shape[5], shape[6], shape.texture or "empty", shape.state, shape.tint) end local success, reason = proxy.commit(1) + if not success then GUI.alert(localization.failedToPrint .. ": " .. reason) end @@ -68,6 +71,7 @@ end if options.p then updateProxy("printer3d") print(filesystem.readTable(args[1])) + return end @@ -76,37 +80,13 @@ end local currentScriptDirectory = filesystem.path(system.getCurrentScript()) local localization = system.getLocalization(currentScriptDirectory .. "Localizations/") local currentLayer = 0 +local viewPixelWidth, viewPixelHeight = 4, 2 + local model local savePath - -local viewPixelWidth, viewPixelHeight = 4, 2 -local shapeLimit = 0--Temporary, will be set properly shortly - -local function updateShapeLimit(newLimit) - --No need to update anything if new limit is the same as old. - if newLimit == shapeLimit then - return - end - - --Otherwise, we need to update both limit and all the colors that use the limit. - shapeLimit = newLimit - - colors, hue, hueStep = {}, 0, 360 / shapeLimit - for i = 1, shapeLimit do - colors[i] = color.HSBToInteger(hue, 1, 1) - hue = hue + hueStep - end -end - -if component.isAvailable("printer3d") then - local printer3d = component.get("printer3d") - updateShapeLimit(printer3d.getMaxShapeCount()) -else - updateShapeLimit(24) -end +local shapeLimit local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, screen.getHeight() - 1, 0x1E1E1E)) --- local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 92, 32, 0x1E1E1E)) -------------------------------------------------------------------------------- @@ -224,7 +204,7 @@ modelList:setDirection(GUI.DIRECTION_HORIZONTAL) local disabledListItem = modelList:addItem(localization.disabled) local enabledListItem = modelList:addItem(localization.enabled) -local elementComboBox = addComboBox() +local shapesComboBox = addComboBox() local textureInput = addInput("", localization.texture, true) local tintColorSelector = toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, 0x330040, localization.tintColor)) @@ -301,28 +281,44 @@ local function updateHologramWidgets() addObjectsTo(hologramWidgetsLayout, objects) end +local function updateAddRemoveButtonsState() + addShapeButton.disabled = #model.shapes >= shapeLimit + removeShapeButton.disabled = #model.shapes < 1 or shapesComboBox:count() < 1 +end + local function updateProxies() updateProxy("hologram") updateHologramWidgets() - local hasPrinter = updateProxy("printer3d") + + local printerProxy = updateProxy("printer3d") --Update shape limit if we have a printer connected. --Probably halfway laggy because it's updating colors now too though, --but necessary if we want things to work right with no unintended consequences. --I would have this update in the component add remove part, but updateProxy is --awesome and tells us if a component is present or not. - if hasPrinter then - local printer3d = component.get("printer3d") - updateShapeLimit(printer3d.getMaxShapeCount()) + local newLimit = printerProxy and printerProxy.getMaxShapeCount() or 24 + + --No need to update anything if new limit is the same as old. + if newLimit ~= shapeLimit then + --Otherwise, we need to update both limit and all the colors that use the limit. + shapeLimit = newLimit + + colors, hue, hueStep = {}, 0, 360 / shapeLimit + + for i = 1, shapeLimit do + colors[i] = color.HSBToInteger(hue, 1, 1) + hue = hue + hueStep + end end - - printButton.disabled = not hasPrinter + + printButton.disabled = not printerProxy end updateProxies() local function getSelectedShapeIndex() - local item = elementComboBox:getItem(elementComboBox.selectedItem) + local item = shapesComboBox:getItem(shapesComboBox.selectedItem) return item and item.shapeIndex end @@ -358,22 +354,18 @@ local function updateHologram() end local function updateComboBoxFromModel() - elementComboBox:clear() + shapesComboBox:clear() for i = 1, #model.shapes do if checkShapeState(model.shapes[i]) then - local item = elementComboBox:addItem(tostring(i)) + local item = shapesComboBox:addItem(tostring(i)) + item.shapeIndex = i item.color = colors[i] end end end -local function updateAddRemoveButtonsState() - addShapeButton.disabled = #model.shapes >= shapeLimit - removeShapeButton.disabled = #model.shapes < 1 or elementComboBox:count() < 1 -end - local function updateWidgetsFromModel() labelInput.text = model.label or "" tooltipInput.text = model.tooltip or "" @@ -399,6 +391,7 @@ local function updateModelFromWidgets() model.lightLevel = lightLevelSlider.value > 0 and lightLevelSlider.value or nil local shapeIndex = getSelectedShapeIndex() + if shapeIndex then model.shapes[shapeIndex].texture = #textureInput.text > 0 and textureInput.text or nil model.shapes[shapeIndex].tint = tintSwitch.state and tintColorSelector.color or nil @@ -415,6 +408,7 @@ local function load(path) end local function save(path) + GUI.alert(path) filesystem.writeTable(path, model, true) updateSavePath(path) end @@ -425,10 +419,12 @@ end saveAsItem.onTouch = function() local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(window.height * 0.8), "Save", "Cancel", "File name", "/") + filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:addExtensionFilter(".3dm") filesystemDialog:expandPath(paths.user.desktop) filesystemDialog.filesystemTree.selectedItem = paths.user.desktop + filesystemDialog.onSubmit = function(path) save(path) end @@ -438,9 +434,11 @@ end openItem.onTouch = function() local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(window.height * 0.8), "Open", "Cancel", "File name", "/") + filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:addExtensionFilter(".3dm") filesystemDialog:expandPath(paths.user.desktop) + filesystemDialog.onSubmit = function(path) load(path) @@ -482,11 +480,13 @@ view.draw = function() GUI.drawShadow(view.x, view.y, view.width, view.height, nil, true) local selectedShape, shape = getSelectedShapeIndex() + if selectedShape then for i = 1, #model.shapes do shape = model.shapes[i] local focused, x, y, width, height = getShapeDrawingData(shape) + if focused then screen.drawRectangle(x, y, width, height, i == selectedShape and colors[i] or color.blend(colors[i], 0xFFFFFF, 0.4), 0x0, " ") @@ -514,6 +514,7 @@ toolLayout.eventHandler = function(workspace, toolLayout, e1, e2, e3, e4, e5) end else local child = toolLayout.children[#toolLayout.children] + if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then v = v - 1 toolLayout:setMargin(1, 1, h, v) @@ -554,9 +555,9 @@ view.eventHandler = function(workspace, view, e1, e2, e3, e4, e5) local focused, x, y, width, height = getShapeDrawingData(shape) if focused and e3 >= x and e3 <= x + width - 1 and e4 >= y and e4 <= y + height - 1 then - for j = 1, elementComboBox:count() do - if elementComboBox:getItem(j).shapeIndex == i then - elementComboBox.selectedItem = j + for j = 1, shapesComboBox:count() do + if shapesComboBox:getItem(j).shapeIndex == i then + shapesComboBox.selectedItem = j workspace:draw() break @@ -569,10 +570,12 @@ view.eventHandler = function(workspace, view, e1, e2, e3, e4, e5) end elseif e1 == "drop" then shapeX, shapeY, shapeZ = nil, nil, nil + updateHologram() elseif e1 == "scroll" then local function fix() local shapeIndex = getSelectedShapeIndex() + if shapeX and shapeIndex then local shape = model.shapes[shapeIndex] shape[3] = shapeZ @@ -599,10 +602,11 @@ view.eventHandler = function(workspace, view, e1, e2, e3, e4, e5) updateHologram() end end - elseif e1 == "component_added" or e1 == "component_removed" then + elseif e1 == "component_added" or e1 == "component_removed" and (e3 == "printer3d" or e3 == "hologram") then updateProxies() - workspace:draw() + updateAddRemoveButtonsState() + workspace:draw() updateHologram() end end @@ -634,6 +638,7 @@ flipButton.onTouch = function() for i = 1, #model.shapes do local shape = model.shapes[i] + if axisComboBox.selectedItem == 1 then fix(shape, 1) elseif axisComboBox.selectedItem == 2 then @@ -664,7 +669,7 @@ local function addShape() table.insert(model.shapes, {6, 6, 0, 10, 10, 1, state = modelList.selectedItem == 2 or nil, texture = #textureInput.text > 0 and textureInput.text or nil}) updateComboBoxFromModel() - elementComboBox.selectedItem = elementComboBox:count() + shapesComboBox.selectedItem = shapesComboBox:count() updateWidgetsFromModel() updateAddRemoveButtonsState() end @@ -705,7 +710,7 @@ printButton.onTouch = function() print(model) end -elementComboBox.onItemSelected = function() +shapesComboBox.onItemSelected = function() updateWidgetsFromModel() workspace:draw() From eff71d57cb66ba8400da620794dae0bedaa2fece Mon Sep 17 00:00:00 2001 From: IgorTimofeev <11760002+IgorTimofeev@users.noreply.github.com> Date: Fri, 12 Mar 2021 02:28:33 +0300 Subject: [PATCH 7/8] Update Main.lua --- Applications/3D Print.app/Main.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index 3d1102f4..86c9bf95 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -408,7 +408,6 @@ local function load(path) end local function save(path) - GUI.alert(path) filesystem.writeTable(path, model, true) updateSavePath(path) end From 321878bef6b8034240c2b380baf6673f7df7a912 Mon Sep 17 00:00:00 2001 From: IgorTimofeev <11760002+IgorTimofeev@users.noreply.github.com> Date: Fri, 12 Mar 2021 02:49:17 +0300 Subject: [PATCH 8/8] Update Main.lua --- Applications/3D Print.app/Main.lua | 37 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Applications/3D Print.app/Main.lua b/Applications/3D Print.app/Main.lua index 86c9bf95..45c073e2 100644 --- a/Applications/3D Print.app/Main.lua +++ b/Applications/3D Print.app/Main.lua @@ -286,6 +286,19 @@ local function updateAddRemoveButtonsState() removeShapeButton.disabled = #model.shapes < 1 or shapesComboBox:count() < 1 end +local function updateComboBoxFromModel() + shapesComboBox:clear() + + for i = 1, #model.shapes do + if checkShapeState(model.shapes[i]) then + local item = shapesComboBox:addItem(tostring(i)) + + item.shapeIndex = i + item.color = colors[i] + end + end +end + local function updateProxies() updateProxy("hologram") updateHologramWidgets() @@ -310,6 +323,15 @@ local function updateProxies() colors[i] = color.HSBToInteger(hue, 1, 1) hue = hue + hueStep end + + -- Truncating existing model if it's too fat chick + if model and #model.shapes > newLimit then + while #model.shapes > newLimit do + table.remove(model.shapes, #model.shapes) + end + + updateComboBoxFromModel() + end end printButton.disabled = not printerProxy @@ -353,19 +375,6 @@ local function updateHologram() end end -local function updateComboBoxFromModel() - shapesComboBox:clear() - - for i = 1, #model.shapes do - if checkShapeState(model.shapes[i]) then - local item = shapesComboBox:addItem(tostring(i)) - - item.shapeIndex = i - item.color = colors[i] - end - end -end - local function updateWidgetsFromModel() labelInput.text = model.label or "" tooltipInput.text = model.tooltip or "" @@ -601,7 +610,7 @@ view.eventHandler = function(workspace, view, e1, e2, e3, e4, e5) updateHologram() end end - elseif e1 == "component_added" or e1 == "component_removed" and (e3 == "printer3d" or e3 == "hologram") then + elseif (e1 == "component_added" or e1 == "component_removed") and (e3 == "printer3d" or e3 == "hologram") then updateProxies() updateAddRemoveButtonsState()