mirror of
https://github.com/teverse/teverse
synced 2025-12-24 01:44:47 +01:00
Compare commits
No commits in common. "b688f4a49d41fcf98e3c96aa30f04c6782695f20" and "9e722ea70888267521523ef576ab08f76a82bec1" have entirely different histories.
b688f4a49d
...
9e722ea708
@ -12,7 +12,6 @@ local boundingBox = engine.construct("block", workspace, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
controller.selection = {}
|
controller.selection = {}
|
||||||
controller.destroyingListeners = {}
|
|
||||||
|
|
||||||
controller.callbacks = {}
|
controller.callbacks = {}
|
||||||
|
|
||||||
@ -28,34 +27,14 @@ end
|
|||||||
|
|
||||||
controller.setSelection = function(obj)
|
controller.setSelection = function(obj)
|
||||||
controller.selection = {}
|
controller.selection = {}
|
||||||
|
|
||||||
for _,v in pairs(controller.destroyingListeners) do
|
|
||||||
v:disconnect()
|
|
||||||
end
|
|
||||||
controller.destroyingListeners = {}
|
|
||||||
|
|
||||||
controller.addSelection(obj)
|
controller.addSelection(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function destroyListener()
|
|
||||||
for i,v in pairs(controller.selection) do
|
|
||||||
if v == self.object then
|
|
||||||
table.remove(controller.selection, i)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
controller.destroyingListeners[self.object] = nil
|
|
||||||
|
|
||||||
self:disconnect()
|
|
||||||
end
|
|
||||||
|
|
||||||
controller.addSelection = function(obj)
|
controller.addSelection = function(obj)
|
||||||
if type(obj) == "table" then
|
if type(obj) == "table" then
|
||||||
for _,v in pairs(obj) do
|
for _,v in pairs(obj) do
|
||||||
if v.isA and v:isA("baseClass") then
|
if v.isA and v:isA("baseClass") then
|
||||||
table.insert(controller.selection, v)
|
table.insert(controller.selection, v)
|
||||||
controller.destroyingListeners[v] = v:once("destroying", destroyListener)
|
|
||||||
else
|
else
|
||||||
warn("selecting unknown object")
|
warn("selecting unknown object")
|
||||||
end
|
end
|
||||||
@ -63,7 +42,6 @@ controller.addSelection = function(obj)
|
|||||||
else
|
else
|
||||||
if obj.isA and obj:isA("baseClass") then
|
if obj.isA and obj:isA("baseClass") then
|
||||||
table.insert(controller.selection, obj)
|
table.insert(controller.selection, obj)
|
||||||
controller.destroyingListeners[obj] = obj:once("destroying", destroyListener)
|
|
||||||
else
|
else
|
||||||
warn("selecting unknown object")
|
warn("selecting unknown object")
|
||||||
end
|
end
|
||||||
@ -86,19 +64,17 @@ end
|
|||||||
local boundingEvents = {}
|
local boundingEvents = {}
|
||||||
|
|
||||||
local function boundUpdate()
|
local function boundUpdate()
|
||||||
if not boundingBox or not boundingBox.alive then return end
|
|
||||||
|
|
||||||
--inefficient, is called for each change
|
--inefficient, is called for each change
|
||||||
local bounds = aabb()
|
local bounds = aabb()
|
||||||
|
|
||||||
if #controller.selection > 0 and controller.selection[1].position then
|
if #controller.selection > 0 then
|
||||||
bounds.min = controller.selection[1].position
|
bounds.min = controller.selection[1].position
|
||||||
bounds.max = controller.selection[1].position
|
bounds.max = controller.selection[1].position
|
||||||
|
end
|
||||||
|
|
||||||
for _,v in pairs(controller.selection) do
|
for _,v in pairs(controller.selection) do
|
||||||
bounds:expand(v.position + (v.size/2))
|
bounds:expand(v.position + (v.size/2))
|
||||||
bounds:expand(v.position - (v.size/2))
|
bounds:expand(v.position - (v.size/2))
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
boundingBox.position = bounds:getCentre()
|
boundingBox.position = bounds:getCentre()
|
||||||
@ -111,21 +87,17 @@ controller.registerCallback(function()
|
|||||||
end
|
end
|
||||||
boundingEvents = {}
|
boundingEvents = {}
|
||||||
|
|
||||||
if not boundingBox or not boundingBox.alive then return end
|
|
||||||
|
|
||||||
local bounds = aabb()
|
local bounds = aabb()
|
||||||
|
|
||||||
if #controller.selection > 0 and type(controller.selection[1].position) == "vector3" then
|
if #controller.selection > 0 then
|
||||||
bounds.min = controller.selection[1].position
|
bounds.min = controller.selection[1].position
|
||||||
bounds.max = controller.selection[1].position
|
bounds.max = controller.selection[1].position
|
||||||
|
end
|
||||||
|
|
||||||
for _,v in pairs(controller.selection) do
|
for _,v in pairs(controller.selection) do
|
||||||
if type(v.position) == "vector3" then
|
bounds:expand(v.position + (v.size/2))
|
||||||
bounds:expand(v.position + (v.size/2))
|
bounds:expand(v.position - (v.size/2))
|
||||||
bounds:expand(v.position - (v.size/2))
|
table.insert(boundingEvents, v:changed(boundUpdate))
|
||||||
table.insert(boundingEvents, v:changed(boundUpdate))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
boundingBox.position = bounds:getCentre()
|
boundingBox.position = bounds:getCentre()
|
||||||
|
|||||||
@ -2,7 +2,6 @@ local controller = {}
|
|||||||
|
|
||||||
local shared = require("tevgit:workshop/controllers/shared.lua")
|
local shared = require("tevgit:workshop/controllers/shared.lua")
|
||||||
local selection = require("tevgit:workshop/controllers/core/selection.lua")
|
local selection = require("tevgit:workshop/controllers/core/selection.lua")
|
||||||
local context = require("tevgit:workshop/controllers/ui/core/contextMenu.lua")
|
|
||||||
local ui = require("tevgit:workshop/controllers/ui/core/ui.lua")
|
local ui = require("tevgit:workshop/controllers/ui/core/ui.lua")
|
||||||
|
|
||||||
-- store icons for each class type
|
-- store icons for each class type
|
||||||
@ -190,7 +189,7 @@ local function createHierarchyButton(object, guiParent)
|
|||||||
|
|
||||||
if object:isA("luaSharedFolder") or object:isA("luaServerFolder") or
|
if object:isA("luaSharedFolder") or object:isA("luaServerFolder") or
|
||||||
object:isA("luaClientFolder") then
|
object:isA("luaClientFolder") then
|
||||||
context.bind(btn, context.exampleOptions)
|
contextMenu.bind(btn, luaFolderContextOptions)
|
||||||
else
|
else
|
||||||
-- selectionController.applyContext(btn)
|
-- selectionController.applyContext(btn)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -88,14 +88,4 @@ controller.generateMenu = function(options, position)
|
|||||||
menu.size = guiCoord(0, 160, 0, yPos)
|
menu.size = guiCoord(0, 160, 0, yPos)
|
||||||
end
|
end
|
||||||
|
|
||||||
controller.bind = function(object, options)
|
|
||||||
if not object.mouseRightReleased then
|
|
||||||
return warn("Could not hook onto mouse event?!")
|
|
||||||
end
|
|
||||||
|
|
||||||
object:on("mouseRightReleased", function()
|
|
||||||
controller.generateMenu(options)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return controller
|
return controller
|
||||||
Loading…
x
Reference in New Issue
Block a user