added physics stop/start button

This commit is contained in:
teverse 2019-06-11 19:19:59 +01:00
parent c700ae8bc3
commit 5daf03d652
4 changed files with 35 additions and 3 deletions

View File

@ -5,6 +5,27 @@ local environmentController = {}
local firstRun = true
local toolsController = require("tevgit:create/controllers/tool.lua")
local physicsButton = toolsController.createButton("testingTab", "fa:s-play", "Run Physics")
physicsButton:mouseLeftReleased(function ()
if engine.physics.running then
engine.physics:pause()
else
engine.physics:resume()
end
end)
engine.physics:changed(function (p,v)
if p == "running" then
if v then
physicsButton.image.texture = "fa:s-pause"
physicsButton.text.text = "Sim Pause"
else
physicsButton.image.texture = "fa:s-play"
physicsButton.text.text = "Sim Run"
end
end
end)
environmentController.createStarterMap = function()
print("creating starter map")
local mainLight = engine.construct("light", workspace, {

View File

@ -67,9 +67,9 @@ function toolsController.createButton(menuName, image, label, height)
local gui = toolsController.ui.createFrame(menu.gui, {size=guiCoord(0,50,height,0)}, "mainTopBar")
if image then
local imgSize = math.min(50, menu.gui.absoluteSize.y) - 5
local img = toolsController.ui.create("guiImage", gui, {size=guiCoord(0, (2/3) * imgSize, 0, (2/3) * imgSize), position=guiCoord(0.5, -((1/3) * imgSize),0,5), texture=image, handleEvents=false}, "mainTopBar")
local img = toolsController.ui.create("guiImage", gui, {name = "image", size=guiCoord(0, (2/3) * imgSize, 0, (2/3) * imgSize), position=guiCoord(0.5, -((1/3) * imgSize),0,5), texture=image, handleEvents=false}, "mainTopBar")
end
local txt = toolsController.ui.create("guiTextBox", gui, {size=guiCoord(1, 0, image and 1/3 or 1, -5), position=guiCoord(0,0,image and 2/3 or 0,0), text=label, fontSize=15, align=enums.align.middle, handleEvents=false}, "mainTopBar")
local txt = toolsController.ui.create("guiTextBox", gui, {name = "text", size=guiCoord(1, 0, image and 1/3 or 1, -5), position=guiCoord(0,0,image and 2/3 or 0,0), text=label, fontSize=15, align=enums.align.middle, handleEvents=false}, "mainTopBar")
toolsController.registerButton(menuName, gui)
return gui
end

View File

@ -126,9 +126,17 @@ uiController.createMainInterface = function(workshop)
position = guiCoord(0,0,0,23)
}, "mainTopBar")
uiController.testingTab = uiController.createFrame(workshop.interface, {
name = "testingTab",
size = guiCoord(1, 0, 0, 60),
position = guiCoord(0,0,0,23)
}, "mainTopBar")
local tabController = uiTabController.registerTabs(uiController.tabs, "secondary", "main")
uiTabController.createTab(uiController.tabs, "File", uiController.topBar)
uiTabController.createTab(uiController.tabs, "Windows", uiController.windowsTab)
uiTabController.createTab(uiController.tabs, "Testing", uiController.testingTab)
toolsController.container = sideBar
@ -136,6 +144,7 @@ uiController.createMainInterface = function(workshop)
toolsController.ui = uiController
toolsController.registerMenu("windowsTab", uiController.windowsTab)
toolsController.registerMenu("testingTab", uiController.testingTab)
--[[local darkmode = true
toolsController.createButton("windowsTab", "fa:s-palette", "Switch themes"):mouseLeftReleased(function ()

View File

@ -9,7 +9,6 @@ return function(workshop)
ui = require("tevgit:create/controllers/ui.lua"),
camera = require("tevgit:create/controllers/camera.lua"),
tool = require("tevgit:create/controllers/tool.lua"),
env = require("tevgit:create/controllers/environment.lua"),
property = require("tevgit:create/controllers/propertyEditor.lua")
}
@ -17,6 +16,9 @@ return function(workshop)
controllers.console.createConsole(workshop)
controllers.property.createUI(workshop)
--loaded here due to dependencies
controllers.env = require("tevgit:create/controllers/environment.lua")
local tools = {
add = require("tevgit:create/tools/add.lua"),
select = require("tevgit:create/tools/select.lua"),