mirror of
https://github.com/teverse/teverse
synced 2025-08-25 23:54: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()
|
||||
end
|
||||
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
|
||||
if pointer >= limit then
|
||||
actions[pointer - limit] = nil
|
||||
actions[pointer] = {os.time(), actionName, changes, destroyedObjects, newObjects}
|
||||
changes = {}
|
||||
destroyedObjects = {}
|
||||
newObjects = {}
|
||||
|
||||
if type(callback) == "function" then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
|
||||
actions[pointer] = {os.time(), actionName, changes, destroyedObjects, newObjects}
|
||||
changes = {}
|
||||
destroyedObjects = {}
|
||||
newObjects = {}
|
||||
|
||||
|
||||
actionInProgress = false
|
||||
|
||||
if type(callback) == "function" then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
|
||||
local function undo()
|
||||
|
@ -3,7 +3,8 @@
|
||||
local cameraController = {
|
||||
zoomStep = 3,
|
||||
rotateStep = 0.003,
|
||||
moveStep = 0.5
|
||||
moveStep = 0.5,
|
||||
slow = 0.3
|
||||
}
|
||||
|
||||
cameraController.camera = workspace.camera
|
||||
@ -56,7 +57,7 @@ engine.input:keyPressed(function( inputObj )
|
||||
for key, vector in pairs(cameraController.cameraKeyArray) do
|
||||
-- check this key is pressed (still)
|
||||
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
|
||||
|
||||
|
@ -6,6 +6,7 @@ local toolDesc = ""
|
||||
local toolIcon = "fa:s-hand-pointer"
|
||||
|
||||
local selection = require("tevgit:workshop/controllers/core/selection.lua")
|
||||
local history = require("tevgit:workshop/controllers/core/history.lua")
|
||||
|
||||
local clickEvent = nil
|
||||
|
||||
@ -42,6 +43,9 @@ return {
|
||||
for _,v in pairs(selection.selection) do
|
||||
offsets[v] = v.position - centre
|
||||
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
|
||||
-- fire a ray, exclude selected items.
|
||||
@ -56,8 +60,9 @@ return {
|
||||
end
|
||||
wait()
|
||||
end
|
||||
|
||||
history.endAction()
|
||||
|
||||
print("Centre:", centre, "MouseOffset:", mouseOffset)
|
||||
else
|
||||
-- user clicked an unselected object, let's select it
|
||||
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, {
|
||||
text = toolName,
|
||||
position = guiCoord(0, 5, 0, currentY),
|
||||
size = guiCoord(0, 22, 0, 22),
|
||||
position = guiCoord(0, 4, 0, currentY),
|
||||
size = guiCoord(0, 24, 0, 24),
|
||||
hoverCursor = "fa:s-hand-pointer"
|
||||
}, "primaryText")
|
||||
|
||||
|
@ -16,12 +16,16 @@ local tabs = {
|
||||
{"Properties", "fa:s-clipboard-list", function ()
|
||||
shared.windows.propertyEditor.visible = not shared.windows.propertyEditor.visible
|
||||
end},
|
||||
{"Settings", "fa:s-cog", function ()
|
||||
shared.windows.settings.visible = not shared.windows.settings.visible
|
||||
{"Hierarchy", "fa:s-align-left", function ()
|
||||
shared.windows.hierarchy.visible = not shared.windows.hierarchy.visible
|
||||
end},
|
||||
{"History", "fa:s-history", function ()
|
||||
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 = {}
|
||||
|
||||
function roundToMultiple(number, multiple)
|
||||
if multiple == 0 then
|
||||
return number
|
||||
if multiple == 0 then
|
||||
return number
|
||||
end
|
||||
|
||||
|
||||
return ((number % multiple) > multiple/2) and number + multiple - number%multiple or number - number%multiple
|
||||
end
|
||||
|
||||
@ -39,31 +39,35 @@ controller.setupDocks = function ()
|
||||
controller.docks = {
|
||||
engine.construct("guiFrame", shared.workshop.interface, {
|
||||
name = "_dockTop",
|
||||
size = guiCoord(1, -500, 0, 250 - 72),
|
||||
position = guiCoord(250, 0, 0, 72),
|
||||
size = guiCoord(1, -500, 0, 250 - 76),
|
||||
position = guiCoord(250, 0, 0, 76),
|
||||
backgroundAlpha = 0,
|
||||
handleEvents = false
|
||||
handleEvents = false,
|
||||
cropChildren = false,
|
||||
}),
|
||||
engine.construct("guiFrame", shared.workshop.interface, {
|
||||
name = "_dockLeft",
|
||||
size = guiCoord(0, 250, 1, -72),
|
||||
position = guiCoord(0, 0, 0, 72),
|
||||
size = guiCoord(0, 250, 1, -76),
|
||||
position = guiCoord(0, 0, 0, 76),
|
||||
backgroundAlpha = 0,
|
||||
handleEvents = false
|
||||
handleEvents = false,
|
||||
cropChildren = false,
|
||||
}),
|
||||
engine.construct("guiFrame", shared.workshop.interface, {
|
||||
name = "_dockBottom",
|
||||
size = guiCoord(1, -500, 0, 250),
|
||||
position = guiCoord(0, 250, 1, -250),
|
||||
backgroundAlpha = 0,
|
||||
handleEvents = false
|
||||
handleEvents = false,
|
||||
cropChildren = false,
|
||||
}),
|
||||
engine.construct("guiFrame", shared.workshop.interface, {
|
||||
name = "_dockRight",
|
||||
size = guiCoord(0, 250, 1, -72),
|
||||
position = guiCoord(1, -250, 0, 72),
|
||||
size = guiCoord(0, 250, 1, -76),
|
||||
position = guiCoord(1, -250, 0, 76),
|
||||
backgroundAlpha = 0,
|
||||
handleEvents = false
|
||||
handleEvents = false,
|
||||
cropChildren = false,
|
||||
})
|
||||
}
|
||||
end
|
||||
@ -242,11 +246,11 @@ controller.beginWindowDrag = function(window, dontDock)
|
||||
if not dontDock then
|
||||
for _,dock in pairs(controller.docks) do
|
||||
-- the user's cursor is in this dock.
|
||||
if mPos.x > dock.absolutePosition.x and
|
||||
mPos.x < dock.absolutePosition.x + dock.absoluteSize.x and
|
||||
mPos.y > dock.absolutePosition.y and
|
||||
mPos.y < dock.absolutePosition.y + dock.absoluteSize.y then
|
||||
|
||||
if mPos.x > dock.absolutePosition.x and
|
||||
mPos.x < dock.absolutePosition.x + dock.absoluteSize.x and
|
||||
mPos.y > dock.absolutePosition.y and
|
||||
mPos.y < dock.absolutePosition.y + dock.absoluteSize.y then
|
||||
|
||||
local perWindow = 1 / (#dock.children + 1)
|
||||
local perWindowSize = perWindow * dock.absoluteSize
|
||||
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 create = function(className, parent, properties, style)
|
||||
if not parent then
|
||||
parent = shared.workshop.interface
|
||||
if not parent then
|
||||
parent = shared.workshop.interface
|
||||
end
|
||||
|
||||
local gui = engine.construct(className, parent, properties)
|
||||
@ -43,7 +43,7 @@ return {
|
||||
tooltip:destroy()
|
||||
end)
|
||||
|
||||
wait(delay)
|
||||
wait(delay)
|
||||
if tooltip and tooltip.alive then
|
||||
tooltip.visible = true
|
||||
end
|
||||
@ -73,7 +73,7 @@ return {
|
||||
|
||||
return btn
|
||||
end,
|
||||
|
||||
|
||||
-- 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.
|
||||
window = function(parent, title, size, position, dockable, closable)
|
||||
@ -81,7 +81,10 @@ return {
|
||||
size = size,
|
||||
name = title,
|
||||
position = position,
|
||||
cropChildren = false
|
||||
cropChildren = false,
|
||||
borderColour = colour:fromRGB(55, 59, 64),
|
||||
borderWidth = 2,
|
||||
borderAlpha = 1,
|
||||
}, themer.types.background)
|
||||
|
||||
container:on("changed", function (property, value)
|
||||
@ -89,7 +92,7 @@ return {
|
||||
dock.undock(container) -- just in case
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local titleBar = create("guiFrame", container, {
|
||||
name = "titleBar",
|
||||
position = guiCoord(0, 0, 0, -4),
|
||||
@ -101,7 +104,7 @@ return {
|
||||
titleBar:mouseLeftPressed(function ()
|
||||
dock.beginWindowDrag(container, not dockable)
|
||||
end)
|
||||
|
||||
|
||||
-- create this to hide radius on bottom of titlebar
|
||||
create("guiFrame", titleBar, {
|
||||
size = guiCoord(1, 0, 0, 3),
|
||||
@ -132,15 +135,15 @@ return {
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local content = engine.construct("guiFrame", container, {
|
||||
name = "content",
|
||||
backgroundAlpha = 0,
|
||||
size = guiCoord(1, -12, 1, -27),
|
||||
position = guiCoord(0, 3, 0, 24),
|
||||
cropChildren = false
|
||||
cropChildren = false,
|
||||
})
|
||||
|
||||
|
||||
return container
|
||||
end,
|
||||
|
||||
@ -194,7 +197,7 @@ return {
|
||||
local textDimensions = text.textDimensions
|
||||
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)
|
||||
|
||||
|
||||
local continue = create("guiTextBox", content, {
|
||||
size = guiCoord(0, textDimensions.x + 20, 0, 40),
|
||||
position = guiCoord(0.5, -(textDimensions.x + 20)/2, 0.5, (textDimensions.y/2 + 5)),
|
||||
@ -212,7 +215,7 @@ return {
|
||||
content:destroy()
|
||||
return true
|
||||
else
|
||||
continue:once("mouseLeftPressed", function()
|
||||
continue:once("mouseLeftPressed", function()
|
||||
if type(callback) == "function" then
|
||||
callback()
|
||||
end
|
||||
@ -220,4 +223,4 @@ return {
|
||||
end)
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ return function( workshop )
|
||||
})
|
||||
|
||||
emergencyReload:mouseLeftPressed(function()
|
||||
shared.workshop:reloadCreate()
|
||||
shared.workshop:reloadCreate()
|
||||
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.
|
||||
shared.controllers.env = require("tevgit:workshop/controllers/environment/main.lua")
|
||||
|
||||
|
||||
shared.controllers.history = require("tevgit:workshop/controllers/core/history.lua")
|
||||
|
||||
-- Create the Teverse interface
|
||||
@ -84,5 +84,5 @@ return function( workshop )
|
||||
loadingScreen = nil
|
||||
end
|
||||
|
||||
print("Workshop Loaded. ", #engine.workspace.children)
|
||||
--print("Workshop Loaded. ", #engine.workspace.children) Lets not spam the console
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user