Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ZeroBranePackage/projectsettings.lua
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35 lines (31 sloc)
1.12 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local id = ID("projectsettings.settingsmenu") | |
local filename | |
return { | |
name = "Project settings", | |
description = "Adds project settings loaded on project switch.", | |
author = "Paul Kulchenko", | |
version = 0.21, | |
dependencies = "1.30", | |
onRegister = function(self) | |
local menu = ide:FindTopMenu("&Edit") | |
local prefs = menu:FindItem(ID.PREFERENCES):GetSubMenu() | |
menuid = prefs:Append(id, "Settings: Project") | |
local config = self:GetConfig() | |
filename = config.filename or {'.zbstudio/user.lua'} | |
ide:GetMainFrame():Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, | |
function (event) | |
local project = ide:GetProject() | |
if not project then return end | |
for _, file in pairs(filename) do | |
LoadFile(MergeFullPath(project, file)) | |
end | |
end) | |
ide:GetMainFrame():Connect(id, wx.wxEVT_UPDATE_UI, | |
function (event) event:Enable(#filename > 0) end) | |
end, | |
onUnRegister = function(self) | |
ide:RemoveMenuItem(id) | |
end, | |
onProjectPreLoad = function(self, project) ide:AddConfig(project, filename) end, | |
onProjectClose = function(self, project) ide:RemoveConfig(project) end, | |
} |