Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions [editor]/editor_gui/client/currentbrowser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ function createCurrentBrowser ()
currentBrowserGUI.search = guiCreateEdit ( 12, 50, windowWidth, 30, "Search...", false, currentBrowserGUI.browser )
currentBrowserGUI.dropdown = editingControl.dropdown:create{["x"]=12,["y"]=25,["width"]=windowWidth,["height"]=20,["dropWidth"]=windowWidth,["dropHeight"]=200,["relative"]=false,["parent"]=currentBrowserGUI.browser,["rows"]={""}}
--linked to options
dialog.autosnap = editingControl.boolean:create{["x"]=12,["y"]=windowHeight-48,["width"]=115,["height"]=30,["relative"]=false,["parent"]=currentBrowserGUI.browser,["label"]="Autosnap camera"}
currentBrowserGUI.isolate = guiCreateCheckBox ( 12, windowHeight-24, 115, 30, "Isolate element", false, false, currentBrowserGUI.browser )
currentBrowserGUI.close = guiCreateButton ( 132, windowHeight-40, windowWidth, 40, "Close", false, currentBrowserGUI.browser )
dialog.autosnap = editingControl.boolean:create{["x"]=12,["y"]=windowHeight-48,["width"]=windowWidth/2,["height"]=30,["relative"]=false,["parent"]=currentBrowserGUI.browser,["label"]="Autosnap camera"}
currentBrowserGUI.isolate = guiCreateCheckBox ( 12, windowHeight-24, windowWidth/2, 30, "Isolate element", false, false, currentBrowserGUI.browser )
currentBrowserGUI.restore = guiCreateButton ( windowWidth/4 * 2-10, windowHeight-40, windowWidth/4, 40, "Restore", false, currentBrowserGUI.browser )
currentBrowserGUI.close = guiCreateButton ( windowWidth/4 * 3, windowHeight-40, windowWidth/4, 40, "Close", false, currentBrowserGUI.browser )
guiSetProperty(currentBrowserGUI.browser,"RelativeMinSize","w:0.250000 h:0.400000")
--
guiSetAlpha ( currentBrowserGUI.browser, 50 )
Expand All @@ -51,6 +52,7 @@ function createCurrentBrowser ()
currentBrowser.update()
addEventHandler ( "onClientGUIClick", currentBrowserGUI.close, closeCurrentBrowser, false )
addEventHandler ( "onClientGUIClick", currentBrowserGUI.isolate, currentBrowser.isolateClick, false )
addEventHandler ( "onClientGUIClick", currentBrowserGUI.restore, restoreSelectedElement, false )
addEventHandler ( "onClientGUISize", currentBrowserGUI.browser, currentBrowser.resized, false )
currentBrowserGUI.gridlist:addCallback(currentBrowser.gridlistClick)
currentBrowserGUI.gridlist:addDoubleClickCallback(currentBrowser.doubleClick)
Expand All @@ -64,8 +66,10 @@ function currentBrowser.resized()
currentBrowserGUI.dropdown:setSize(windowWidth,20,windowWidth,200,false)
dialog.autosnap:setPosition( 12, windowHeight-48,false )
guiSetPosition ( currentBrowserGUI.isolate, 12, windowHeight-24,false )
guiSetPosition ( currentBrowserGUI.close, 132, windowHeight-40, false )
guiSetSize ( currentBrowserGUI.close, windowWidth, 40, false )
guiSetPosition ( currentBrowserGUI.close, windowWidth/4 * 3, windowHeight-40, false )
guiSetSize ( currentBrowserGUI.close, windowWidth/4, 40, false )
guiSetPosition ( currentBrowserGUI.restore, windowWidth/4 * 2-10, windowHeight-40, false )
guiSetSize ( currentBrowserGUI.restore, windowWidth/4, 40, false )
--
if not isResizing then
addEventHandler ( "onClientClick",root,resizeStop )
Expand Down Expand Up @@ -178,6 +182,7 @@ function currentBrowser.gridlistClick (cellrow)
if cellrow ~= 0 then
local id = currentBrowserGUI.gridlist:getSelectedText()
cSelectedElement = getElementByID ( id )
editor_main.selectElement ( cSelectedElement, 2, false, cSelectedElement, cSelectedElement, true)
if ( dialog.autosnap:getValue() ) then
autoSnap ( cSelectedElement )
end
Expand Down Expand Up @@ -450,6 +455,17 @@ function closeCurrentBrowser()
removeEventHandler ( "onClientElementDestroyed",root,currentBrowser.prepareSearch )
end

function restoreSelectedElement()
if cSelectedElement then
editor_main.destroySelectedElement()
closeCurrentBrowser()

setTimer(function()
showCurrentBrowser()
end, 100, 1)
end
end

function isCurrentBrowserShowing()
return guiGetVisible(currentBrowserGUI.browser)
end
Expand Down
1 change: 1 addition & 0 deletions [editor]/editor_gui/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<export function="openPropertiesBox" type="client" />
<export function="restoreSaveDialog" type="client" />
<export function="stopTest" type="client" />
<export function="restoreSelectedElement" type="client" />

<!-- Browser -->
<script src="client/browser/browserList.lua" type="client" />
Expand Down
15 changes: 10 additions & 5 deletions [editor]/editor_main/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ function disableGameHUD()
end

-- PUBLIC
function selectElement(element, submode, shortcut, dropreleaseLock, dropclonedrop)
function selectElement(element, submode, shortcut, dropreleaseLock, dropclonedrop, ignoreProperties)
local openProperties
submode = submode or g_submode

Expand Down Expand Up @@ -802,8 +802,10 @@ function selectElement(element, submode, shortcut, dropreleaseLock, dropclonedro
createArrowMarker(handle)
end
else
editor_gui.openPropertiesBox( element, false, shortcut )
openProperties = true
if not ignoreProperties then
editor_gui.openPropertiesBox( element, false, shortcut )
openProperties = true
end
end

triggerServerEvent("doLockElement", element)
Expand Down Expand Up @@ -954,7 +956,7 @@ end

-- sets the maximum distance at which an element can be selected
function setMaxSelectDistance(distance)
assert((distance >= 0), "Distance must be a positive number")
assert((distance >= 0), "Distance must be a positive number.")
g_maxSelectDistance = distance
return true
end
Expand All @@ -975,7 +977,10 @@ function getMaxSelectDistance()
return g_maxSelectDistance
end

function destroySelectedElement()
function destroySelectedElement(key)
if key then return
editor_gui.restoreSelectedElement()
end
if g_selectedElement then
local element = g_selectedElement
dropElement(false)
Expand Down