From a575a74b8d3e0bedcc89136ae0806a4c5426b75a Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Thu, 5 Oct 2023 20:26:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BE=D0=BB=D0=B5=D0=B5=20UI=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B8=D0=B5=20=D1=81=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Libraries/GUI.lua | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 4113bc65..690ef769 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -1389,7 +1389,7 @@ end local function switchAndLabelDraw(switchAndLabel) switchAndLabel.label.width = switchAndLabel.width - switchAndLabel.switch.localX = switchAndLabel.width - switchAndLabel.switch.width + switchAndLabel.switch.localX = switchAndLabel.width - switchAndLabel.switch.width + 1 switchAndLabel.label.x, switchAndLabel.label.y = switchAndLabel.x + switchAndLabel.label.localX - 1, switchAndLabel.y + switchAndLabel.label.localY - 1 switchAndLabel.switch.x, switchAndLabel.switch.y = switchAndLabel.x + switchAndLabel.switch.localX - 1, switchAndLabel.y + switchAndLabel.switch.localY - 1 @@ -1490,23 +1490,46 @@ end -------------------------------------------------------------------------------- local function switchDraw(switch) - screen.drawText(switch.x - 1, switch.y, switch.colors.passive, "⠰") - screen.drawRectangle(switch.x, switch.y, switch.width, 1, switch.colors.passive, 0x0, " ") - screen.drawText(switch.x + switch.width, switch.y, switch.colors.passive, "⠆") + -- ◖◗ + -- ⠆⠰ - screen.drawText(switch.x - 1, switch.y, switch.colors.active, "⠰") - screen.drawRectangle(switch.x, switch.y, switch.pipePosition - 1, 1, switch.colors.active, 0x0, " ") + -- Sides + if switch.pipePosition > 1 then + screen.drawText(switch.x, switch.y, switch.colors.active, "◖") + end - screen.drawText(switch.x + switch.pipePosition - 2, switch.y, switch.colors.pipe, "⠰") - screen.drawRectangle(switch.x + switch.pipePosition - 1, switch.y, 2, 1, switch.colors.pipe, 0x0, " ") - screen.drawText(switch.x + switch.pipePosition + 1, switch.y, switch.colors.pipe, "⠆") + if switch.pipePosition < switch.width - 1 then + screen.drawText(switch.x + switch.width - 1, switch.y, switch.colors.passive, "◗") + end + + -- Background + if switch.width > 2 then + -- Active + local width = switch.pipePosition - 1 + + if width > 0 then + screen.drawRectangle(switch.x + 1, switch.y, width, 1, switch.colors.active, 0x0, " ") + end + + -- Passive + width = switch.width - switch.pipePosition - 1 + + if width > 0 then + screen.drawRectangle(switch.x + switch.pipePosition, switch.y, width, 1, switch.colors.passive, 0x0, " ") + end + end + + -- Pipe + screen.drawText(switch.x + switch.pipePosition - 1, switch.y, switch.colors.pipe, "◖") + screen.set(switch.x + switch.pipePosition, switch.y, switch.colors.pipe, switch.colors.pipe, " ") + screen.drawText(switch.x + switch.pipePosition + 1, switch.y, switch.colors.pipe, "◗") return switch end local function switchSetState(switch, state) switch.state = state - switch.pipePosition = switch.state and switch.width - 1 or 1 + switch.pipePosition = switch.state and switch.width - 2 or 1 return switch end @@ -1520,9 +1543,9 @@ local function switchEventHandler(workspace, switch, e1, ...) switch:addAnimation( function(animation) if switch.state then - switch.pipePosition = number.round(1 + animation.position * (switch.width - 2)) + switch.pipePosition = number.round(1 + animation.position * (switch.width - 3)) else - switch.pipePosition = number.round(1 + (1 - animation.position) * (switch.width - 2)) + switch.pipePosition = number.round(1 + (1 - animation.position) * (switch.width - 3)) end end,