diff --git a/zbstudio/packages/singetoolbar.lua b/zbstudio/packages/singetoolbar.lua index 87735a62d..eea403d91 100644 --- a/zbstudio/packages/singetoolbar.lua +++ b/zbstudio/packages/singetoolbar.lua @@ -21,11 +21,28 @@ --]] +local configId = ID("singemenu.singemenu") local id = ID("singetoolbar.singemenu") local tool 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) UI = {} @@ -125,37 +142,60 @@ local function configureSinge(self) end -local function singeEnd(s) - ide:GetOutput():Write(s) +local function singeOutput(s) + --ide:GetOutput():Write(s) + ide:Print("[] " .. s) end -local function startSinge() - local projectPath = ide:GetProject() +local function startSinge(self) + local message = "" + local cdir = wx.wxFileName.GetCwd() + local wdir + local launch - if not(projectPath) then - ide:GetOutput():Write("No project path has been defined.\n") + if settings then + 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 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:Print(ide:GetProject()) + ide:ExecuteCommand(launch, wdir, singeOutput) + + --wx.wxFileName.SetCwd(wdir) + --wx.wxExecute(launch) + --wx.wxFileName.SetCwd(cdir) end return { - name = "Add `Singe` toolbar button", - description = "Adds a menu item and toolbar button that will launch `Singe`", + name = "Singe Integration", + description = "Adds menu items and a toolbar button to assist with debugging Singe games.", author = "Scott Duensing", version = 1.00, dependencies = "1.0", onRegister = function(self) 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() @@ -213,7 +253,7 @@ return { " ^./.(._.:.<.[.}.|._.1. ", " 2.3.J = T U 4.5.6.7. ", " 8.9.0.a.b.c.d.e. " - })) + }), "Launch Singe") tb:Realize() end,