mirror of
https://github.com/teverse/teverse
synced 2025-08-26 08:04:46 +02:00
Compare commits
7 Commits
713233288a
...
c66a2e37d6
Author | SHA1 | Date | |
---|---|---|---|
c66a2e37d6 | |||
![]() |
9889a3f19f | ||
![]() |
d398e1f7ff | ||
![]() |
f4b85012ae | ||
![]() |
415a69992e | ||
c1f074d0b3 | |||
![]() |
e4e30ca154 |
@ -116,22 +116,25 @@ local function endAction()
|
|||||||
v:disconnect()
|
v:disconnect()
|
||||||
end
|
end
|
||||||
eventListeners = {}
|
eventListeners = {}
|
||||||
|
|
||||||
|
-- if nothing changed dont create an action
|
||||||
|
if count(changes) > 0 or #destroyedObjects > 0 or #newObjects > 0 then
|
||||||
|
pointer = pointer + 1
|
||||||
|
if pointer >= limit then
|
||||||
|
actions[pointer - limit] = nil
|
||||||
|
end
|
||||||
|
|
||||||
pointer = pointer + 1
|
actions[pointer] = {os.time(), actionName, changes, destroyedObjects, newObjects}
|
||||||
if pointer >= limit then
|
changes = {}
|
||||||
actions[pointer - limit] = nil
|
destroyedObjects = {}
|
||||||
|
newObjects = {}
|
||||||
|
|
||||||
|
if type(callback) == "function" then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
actions[pointer] = {os.time(), actionName, changes, destroyedObjects, newObjects}
|
|
||||||
changes = {}
|
|
||||||
destroyedObjects = {}
|
|
||||||
newObjects = {}
|
|
||||||
|
|
||||||
actionInProgress = false
|
actionInProgress = false
|
||||||
|
|
||||||
if type(callback) == "function" then
|
|
||||||
callback()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function undo()
|
local function undo()
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
local cameraController = {
|
local cameraController = {
|
||||||
zoomStep = 3,
|
zoomStep = 3,
|
||||||
rotateStep = 0.003,
|
rotateStep = 0.003,
|
||||||
moveStep = 0.5
|
moveStep = 0.5,
|
||||||
|
slow = 0.3
|
||||||
}
|
}
|
||||||
|
|
||||||
cameraController.camera = workspace.camera
|
cameraController.camera = workspace.camera
|
||||||
@ -56,7 +57,7 @@ engine.input:keyPressed(function( inputObj )
|
|||||||
for key, vector in pairs(cameraController.cameraKeyArray) do
|
for key, vector in pairs(cameraController.cameraKeyArray) do
|
||||||
-- check this key is pressed (still)
|
-- check this key is pressed (still)
|
||||||
if engine.input:isKeyDown(key) then
|
if engine.input:isKeyDown(key) then
|
||||||
cameraPos = cameraPos + (cameraController.camera.rotation * vector * cameraController.moveStep)
|
cameraPos = cameraPos + (cameraController.camera.rotation * vector * cameraController.moveStep) * (engine.input:isKeyDown(enums.key.leftShift) and cameraController.slow or 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ local toolDesc = ""
|
|||||||
local toolIcon = "fa:s-hand-pointer"
|
local toolIcon = "fa:s-hand-pointer"
|
||||||
|
|
||||||
local selection = require("tevgit:workshop/controllers/core/selection.lua")
|
local selection = require("tevgit:workshop/controllers/core/selection.lua")
|
||||||
|
local history = require("tevgit:workshop/controllers/core/history.lua")
|
||||||
|
|
||||||
local clickEvent = nil
|
local clickEvent = nil
|
||||||
|
|
||||||
@ -42,6 +43,9 @@ return {
|
|||||||
for _,v in pairs(selection.selection) do
|
for _,v in pairs(selection.selection) do
|
||||||
offsets[v] = v.position - centre
|
offsets[v] = v.position - centre
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- tell history to monitor changes we make to selected items
|
||||||
|
history.beginAction(selection.selection, "Hand tool drag")
|
||||||
|
|
||||||
while engine.input:isMouseButtonDown(enums.mouseButton.left) do
|
while engine.input:isMouseButtonDown(enums.mouseButton.left) do
|
||||||
-- fire a ray, exclude selected items.
|
-- fire a ray, exclude selected items.
|
||||||
@ -56,8 +60,9 @@ return {
|
|||||||
end
|
end
|
||||||
wait()
|
wait()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
history.endAction()
|
||||||
|
|
||||||
print("Centre:", centre, "MouseOffset:", mouseOffset)
|
|
||||||
else
|
else
|
||||||
-- user clicked an unselected object, let's select it
|
-- user clicked an unselected object, let's select it
|
||||||
if engine.input:isKeyDown(enums.key.leftShift) then
|
if engine.input:isKeyDown(enums.key.leftShift) then
|
||||||
|
@ -45,8 +45,8 @@ for toolName, options in pairs(tools) do
|
|||||||
|
|
||||||
local newTabBtn = ui.create("guiTextBox", toolBar, {
|
local newTabBtn = ui.create("guiTextBox", toolBar, {
|
||||||
text = toolName,
|
text = toolName,
|
||||||
position = guiCoord(0, 5, 0, currentY),
|
position = guiCoord(0, 4, 0, currentY),
|
||||||
size = guiCoord(0, 22, 0, 22),
|
size = guiCoord(0, 24, 0, 24),
|
||||||
hoverCursor = "fa:s-hand-pointer"
|
hoverCursor = "fa:s-hand-pointer"
|
||||||
}, "primaryText")
|
}, "primaryText")
|
||||||
|
|
||||||
|
@ -16,12 +16,16 @@ local tabs = {
|
|||||||
{"Properties", "fa:s-clipboard-list", function ()
|
{"Properties", "fa:s-clipboard-list", function ()
|
||||||
shared.windows.propertyEditor.visible = not shared.windows.propertyEditor.visible
|
shared.windows.propertyEditor.visible = not shared.windows.propertyEditor.visible
|
||||||
end},
|
end},
|
||||||
{"Settings", "fa:s-cog", function ()
|
{"Hierarchy", "fa:s-align-left", function ()
|
||||||
shared.windows.settings.visible = not shared.windows.settings.visible
|
shared.windows.hierarchy.visible = not shared.windows.hierarchy.visible
|
||||||
end},
|
end},
|
||||||
{"History", "fa:s-history", function ()
|
{"History", "fa:s-history", function ()
|
||||||
shared.windows.history.visible = not shared.windows.history.visible
|
shared.windows.history.visible = not shared.windows.history.visible
|
||||||
end}
|
end},
|
||||||
|
{"Seperator"},
|
||||||
|
{"Settings", "fa:s-cog", function ()
|
||||||
|
shared.windows.settings.visible = not shared.windows.settings.visible
|
||||||
|
end},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ local themer = require("tevgit:workshop/controllers/ui/core/themer.lua")
|
|||||||
local controller = {}
|
local controller = {}
|
||||||
|
|
||||||
function roundToMultiple(number, multiple)
|
function roundToMultiple(number, multiple)
|
||||||
if multiple == 0 then
|
if multiple == 0 then
|
||||||
return number
|
return number
|
||||||
end
|
end
|
||||||
|
|
||||||
return ((number % multiple) > multiple/2) and number + multiple - number%multiple or number - number%multiple
|
return ((number % multiple) > multiple/2) and number + multiple - number%multiple or number - number%multiple
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,31 +39,35 @@ controller.setupDocks = function ()
|
|||||||
controller.docks = {
|
controller.docks = {
|
||||||
engine.construct("guiFrame", shared.workshop.interface, {
|
engine.construct("guiFrame", shared.workshop.interface, {
|
||||||
name = "_dockTop",
|
name = "_dockTop",
|
||||||
size = guiCoord(1, -500, 0, 250 - 72),
|
size = guiCoord(1, -500, 0, 250 - 76),
|
||||||
position = guiCoord(250, 0, 0, 72),
|
position = guiCoord(250, 0, 0, 76),
|
||||||
backgroundAlpha = 0,
|
backgroundAlpha = 0,
|
||||||
handleEvents = false
|
handleEvents = false,
|
||||||
|
cropChildren = false,
|
||||||
}),
|
}),
|
||||||
engine.construct("guiFrame", shared.workshop.interface, {
|
engine.construct("guiFrame", shared.workshop.interface, {
|
||||||
name = "_dockLeft",
|
name = "_dockLeft",
|
||||||
size = guiCoord(0, 250, 1, -72),
|
size = guiCoord(0, 250, 1, -76),
|
||||||
position = guiCoord(0, 0, 0, 72),
|
position = guiCoord(0, 0, 0, 76),
|
||||||
backgroundAlpha = 0,
|
backgroundAlpha = 0,
|
||||||
handleEvents = false
|
handleEvents = false,
|
||||||
|
cropChildren = false,
|
||||||
}),
|
}),
|
||||||
engine.construct("guiFrame", shared.workshop.interface, {
|
engine.construct("guiFrame", shared.workshop.interface, {
|
||||||
name = "_dockBottom",
|
name = "_dockBottom",
|
||||||
size = guiCoord(1, -500, 0, 250),
|
size = guiCoord(1, -500, 0, 250),
|
||||||
position = guiCoord(0, 250, 1, -250),
|
position = guiCoord(0, 250, 1, -250),
|
||||||
backgroundAlpha = 0,
|
backgroundAlpha = 0,
|
||||||
handleEvents = false
|
handleEvents = false,
|
||||||
|
cropChildren = false,
|
||||||
}),
|
}),
|
||||||
engine.construct("guiFrame", shared.workshop.interface, {
|
engine.construct("guiFrame", shared.workshop.interface, {
|
||||||
name = "_dockRight",
|
name = "_dockRight",
|
||||||
size = guiCoord(0, 250, 1, -72),
|
size = guiCoord(0, 250, 1, -76),
|
||||||
position = guiCoord(1, -250, 0, 72),
|
position = guiCoord(1, -250, 0, 76),
|
||||||
backgroundAlpha = 0,
|
backgroundAlpha = 0,
|
||||||
handleEvents = false
|
handleEvents = false,
|
||||||
|
cropChildren = false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -242,11 +246,11 @@ controller.beginWindowDrag = function(window, dontDock)
|
|||||||
if not dontDock then
|
if not dontDock then
|
||||||
for _,dock in pairs(controller.docks) do
|
for _,dock in pairs(controller.docks) do
|
||||||
-- the user's cursor is in this dock.
|
-- the user's cursor is in this dock.
|
||||||
if mPos.x > dock.absolutePosition.x and
|
if mPos.x > dock.absolutePosition.x and
|
||||||
mPos.x < dock.absolutePosition.x + dock.absoluteSize.x and
|
mPos.x < dock.absolutePosition.x + dock.absoluteSize.x and
|
||||||
mPos.y > dock.absolutePosition.y and
|
mPos.y > dock.absolutePosition.y and
|
||||||
mPos.y < dock.absolutePosition.y + dock.absoluteSize.y then
|
mPos.y < dock.absolutePosition.y + dock.absoluteSize.y then
|
||||||
|
|
||||||
local perWindow = 1 / (#dock.children + 1)
|
local perWindow = 1 / (#dock.children + 1)
|
||||||
local perWindowSize = perWindow * dock.absoluteSize
|
local perWindowSize = perWindow * dock.absoluteSize
|
||||||
local isVertical = dock.absoluteSize.y > dock.absoluteSize.x
|
local isVertical = dock.absoluteSize.y > dock.absoluteSize.x
|
||||||
|
@ -7,8 +7,8 @@ local dock = require("tevgit:workshop/controllers/ui/core/dock.lua")
|
|||||||
local shared = require("tevgit:workshop/controllers/shared.lua")
|
local shared = require("tevgit:workshop/controllers/shared.lua")
|
||||||
|
|
||||||
local create = function(className, parent, properties, style)
|
local create = function(className, parent, properties, style)
|
||||||
if not parent then
|
if not parent then
|
||||||
parent = shared.workshop.interface
|
parent = shared.workshop.interface
|
||||||
end
|
end
|
||||||
|
|
||||||
local gui = engine.construct(className, parent, properties)
|
local gui = engine.construct(className, parent, properties)
|
||||||
@ -43,7 +43,7 @@ return {
|
|||||||
tooltip:destroy()
|
tooltip:destroy()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
wait(delay)
|
wait(delay)
|
||||||
if tooltip and tooltip.alive then
|
if tooltip and tooltip.alive then
|
||||||
tooltip.visible = true
|
tooltip.visible = true
|
||||||
end
|
end
|
||||||
@ -73,7 +73,7 @@ return {
|
|||||||
|
|
||||||
return btn
|
return btn
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- if closable is true OR a function, a close button will appear in the title bar.
|
-- if closable is true OR a function, a close button will appear in the title bar.
|
||||||
-- when clicked, if closable is a function, it is fired after hiding the window.
|
-- when clicked, if closable is a function, it is fired after hiding the window.
|
||||||
window = function(parent, title, size, position, dockable, closable)
|
window = function(parent, title, size, position, dockable, closable)
|
||||||
@ -81,7 +81,10 @@ return {
|
|||||||
size = size,
|
size = size,
|
||||||
name = title,
|
name = title,
|
||||||
position = position,
|
position = position,
|
||||||
cropChildren = false
|
cropChildren = false,
|
||||||
|
borderColour = colour:fromRGB(55, 59, 64),
|
||||||
|
borderWidth = 2,
|
||||||
|
borderAlpha = 1,
|
||||||
}, themer.types.background)
|
}, themer.types.background)
|
||||||
|
|
||||||
container:on("changed", function (property, value)
|
container:on("changed", function (property, value)
|
||||||
@ -89,7 +92,7 @@ return {
|
|||||||
dock.undock(container) -- just in case
|
dock.undock(container) -- just in case
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local titleBar = create("guiFrame", container, {
|
local titleBar = create("guiFrame", container, {
|
||||||
name = "titleBar",
|
name = "titleBar",
|
||||||
position = guiCoord(0, 0, 0, -4),
|
position = guiCoord(0, 0, 0, -4),
|
||||||
@ -101,7 +104,7 @@ return {
|
|||||||
titleBar:mouseLeftPressed(function ()
|
titleBar:mouseLeftPressed(function ()
|
||||||
dock.beginWindowDrag(container, not dockable)
|
dock.beginWindowDrag(container, not dockable)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- create this to hide radius on bottom of titlebar
|
-- create this to hide radius on bottom of titlebar
|
||||||
create("guiFrame", titleBar, {
|
create("guiFrame", titleBar, {
|
||||||
size = guiCoord(1, 0, 0, 3),
|
size = guiCoord(1, 0, 0, 3),
|
||||||
@ -132,15 +135,15 @@ return {
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local content = engine.construct("guiFrame", container, {
|
local content = engine.construct("guiFrame", container, {
|
||||||
name = "content",
|
name = "content",
|
||||||
backgroundAlpha = 0,
|
backgroundAlpha = 0,
|
||||||
size = guiCoord(1, -12, 1, -27),
|
size = guiCoord(1, -12, 1, -27),
|
||||||
position = guiCoord(0, 3, 0, 24),
|
position = guiCoord(0, 3, 0, 24),
|
||||||
cropChildren = false
|
cropChildren = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
return container
|
return container
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -194,7 +197,7 @@ return {
|
|||||||
local textDimensions = text.textDimensions
|
local textDimensions = text.textDimensions
|
||||||
container.size = guiCoord(0, textDimensions.x + 20, 0, textDimensions.y + 20)
|
container.size = guiCoord(0, textDimensions.x + 20, 0, textDimensions.y + 20)
|
||||||
container.position = guiCoord(0.5, -(textDimensions.x + 20)/2, 0.5, -(textDimensions.y + 20)/2)
|
container.position = guiCoord(0.5, -(textDimensions.x + 20)/2, 0.5, -(textDimensions.y + 20)/2)
|
||||||
|
|
||||||
local continue = create("guiTextBox", content, {
|
local continue = create("guiTextBox", content, {
|
||||||
size = guiCoord(0, textDimensions.x + 20, 0, 40),
|
size = guiCoord(0, textDimensions.x + 20, 0, 40),
|
||||||
position = guiCoord(0.5, -(textDimensions.x + 20)/2, 0.5, (textDimensions.y/2 + 5)),
|
position = guiCoord(0.5, -(textDimensions.x + 20)/2, 0.5, (textDimensions.y/2 + 5)),
|
||||||
@ -212,7 +215,7 @@ return {
|
|||||||
content:destroy()
|
content:destroy()
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
continue:once("mouseLeftPressed", function()
|
continue:once("mouseLeftPressed", function()
|
||||||
if type(callback) == "function" then
|
if type(callback) == "function" then
|
||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
@ -220,4 +223,4 @@ return {
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ return function( workshop )
|
|||||||
})
|
})
|
||||||
|
|
||||||
emergencyReload:mouseLeftPressed(function()
|
emergencyReload:mouseLeftPressed(function()
|
||||||
shared.workshop:reloadCreate()
|
shared.workshop:reloadCreate()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ return function( workshop )
|
|||||||
|
|
||||||
-- Okay now we can load remote files whilst the user is looking at a loading screen.
|
-- Okay now we can load remote files whilst the user is looking at a loading screen.
|
||||||
shared.controllers.env = require("tevgit:workshop/controllers/environment/main.lua")
|
shared.controllers.env = require("tevgit:workshop/controllers/environment/main.lua")
|
||||||
|
|
||||||
shared.controllers.history = require("tevgit:workshop/controllers/core/history.lua")
|
shared.controllers.history = require("tevgit:workshop/controllers/core/history.lua")
|
||||||
|
|
||||||
-- Create the Teverse interface
|
-- Create the Teverse interface
|
||||||
@ -84,5 +84,5 @@ return function( workshop )
|
|||||||
loadingScreen = nil
|
loadingScreen = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Workshop Loaded. ", #engine.workspace.children)
|
--print("Workshop Loaded. ", #engine.workspace.children) Lets not spam the console
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user