More work on ZB integration.

This commit is contained in:
Scott Duensing 2023-11-23 17:57:47 -06:00
parent 71fda963ae
commit 48564570b3

View file

@ -21,11 +21,28 @@
--]] --]]
local configId = ID("singemenu.singemenu")
local id = ID("singetoolbar.singemenu") local id = ID("singetoolbar.singemenu")
local tool local tool
local settings local settings
local function utilDump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then
k = '"'..k..'"'
end
s = s .. '['..k..'] = ' .. utilDump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local function configureSinge(self) local function configureSinge(self)
UI = {} UI = {}
@ -125,37 +142,60 @@ local function configureSinge(self)
end end
local function singeEnd(s) local function singeOutput(s)
ide:GetOutput():Write(s) --ide:GetOutput():Write(s)
ide:Print("[] " .. s)
end end
local function startSinge() local function startSinge(self)
local projectPath = ide:GetProject() local message = ""
local cdir = wx.wxFileName.GetCwd()
local wdir
local launch
if not(projectPath) then if settings then
ide:GetOutput():Write("No project path has been defined.\n") if not settings.singe then message = "You must specify the Singe executable in the Singe configuration." end
if not settings.script then message = "You must specify the script to run in the Singe configuration." end
if not settings.video then message = "You must specify the video to use in the Singe configuration." end
else
message = "Please configure Singe first."
end
if message ~= "" then
wx.wxMessageBox(message, "Uh Oh!", wx.wxICON_ERROR + wx.wxOK + wx.wxCENTRE)
return return
end end
--ide:ExecuteCommand(settings.singe .. ' ' .. settings.options, projectPath, singeEnd) wdir = settings.singe:match("(.*[/\\])") or "./"
launch = settings.singe .. ' ' .. settings.options .. ' -v ' .. settings.video .. ' ' .. settings.script
launch = launch:gsub(wdir, "./", 1):gsub(wdir, "")
wdir = wx.wxFileName.DirName(wdir):GetFullPath()
ide:Print(launch)
ide:Print(tprint(settings)) ide:ExecuteCommand(launch, wdir, singeOutput)
ide:Print(ide:GetProject())
--wx.wxFileName.SetCwd(wdir)
--wx.wxExecute(launch)
--wx.wxFileName.SetCwd(cdir)
end end
return { return {
name = "Add `Singe` toolbar button", name = "Singe Integration",
description = "Adds a menu item and toolbar button that will launch `Singe`", description = "Adds menu items and a toolbar button to assist with debugging Singe games.",
author = "Scott Duensing", author = "Scott Duensing",
version = 1.00, version = 1.00,
dependencies = "1.0", dependencies = "1.0",
onRegister = function(self) onRegister = function(self)
local menu = ide:FindTopMenu("&Project") local menu = ide:FindTopMenu("&Project")
menu:Append(id, "Singe Configuration")
ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, function() configureSinge(self) end) menu:Append(id, "Launch Singe")
ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, function() startSinge(self) end)
menu:Append(configId, "Singe Configuration...")
ide:GetMainFrame():Connect(configId, wx.wxEVT_COMMAND_MENU_SELECTED, function() configureSinge(self) end)
settings = self:GetSettings() settings = self:GetSettings()
@ -213,7 +253,7 @@ return {
" ^./.(._.:.<.[.}.|._.1. ", " ^./.(._.:.<.[.}.|._.1. ",
" 2.3.J = T U 4.5.6.7. ", " 2.3.J = T U 4.5.6.7. ",
" 8.9.0.a.b.c.d.e. " " 8.9.0.a.b.c.d.e. "
})) }), "Launch Singe")
tb:Realize() tb:Realize()
end, end,