|
|
|
DefineClass.XDef = { |
|
__parents = { "Preset", "XDefWindow", }, |
|
properties = { |
|
{ category = "Preset", id = "__class", name = "Class", editor = "choice", default = "XWindow", show_recent_items = 7, items = function(self) return ClassDescendantsCombo("XWindow", true) end, }, |
|
{ category = "Preset", id = "DefUndefineClass", name = "Undefine class", editor = "bool", default = false, }, |
|
}, |
|
GlobalMap = "XDefs", |
|
|
|
ContainerClass = "XDefSubItem", |
|
PresetClass = "XDef", |
|
HasCompanionFile = true, |
|
GeneratesClass = true, |
|
HasSortKey = true, |
|
SingleFile = false, |
|
|
|
EditorMenubarName = "XDef Editor", |
|
EditorShortcut = "Alt-Shift-F3", |
|
EditorName = "XDef", |
|
EditorMenubar = "Editors.UI", |
|
EditorIcon = "CommonAssets/UI/Icons/backspace.png", |
|
} |
|
|
|
function XDef:GenerateCompanionFileCode(code, dlc) |
|
local class_exists_err = self:CheckIfIdExistsInGlobal() |
|
if class_exists_err then |
|
return class_exists_err |
|
end |
|
if self.DefUndefineClass then |
|
code:append("UndefineClass('", self.id, "')\n") |
|
end |
|
code:appendf("DefineClass.%s = {\n", self.id, self.id) |
|
self:GenerateParents(code) |
|
self:AppendGeneratedByProps(code) |
|
self:GenerateFlags(code) |
|
self:GenerateConsts(code, dlc) |
|
code:append("}\n\n") |
|
self:GenerateGlobalCode(code) |
|
end |
|
|
|
DefineClass.XDefSubItem = { |
|
__parents = { "Container" }, |
|
properties = { |
|
{ category = "Def", id = "comment", name = "Comment", editor = "text", default = "", }, |
|
}, |
|
TreeView = T(357198499972, "<class> <color 0 128 0><comment>"), |
|
EditorView = Untranslated("<TreeView>"), |
|
EditorName = "Sub Item", |
|
ContainerClass = "XDefSubItem", |
|
} |
|
|
|
DefineClass.XDefGroup = { |
|
__parents = { "XDefSubItem" }, |
|
properties = { |
|
{ category = "Def", id = "__context_of_kind", name = "Require context of kind", editor = "text", default = "" }, |
|
{ category = "Def", id = "__context", name = "Context expression", editor = "expression", params = "parent, context" }, |
|
{ category = "Def", id = "__parent", name = "Parent expression", editor = "expression", params = "parent, context" }, |
|
{ category = "Def", id = "__condition", name = "Condition", editor = "expression", params = "parent, context", }, |
|
}, |
|
TreeView = T(551379353577, "Group<ConditionText> <color 0 128 0><comment>"), |
|
EditorName = "Group", |
|
} |
|
|
|
function XDefGroup.__parent(parent, context) |
|
return parent |
|
end |
|
|
|
function XDefGroup.__context(parent, context) |
|
return context |
|
end |
|
|
|
function XDefGroup.__condition(parent, context) |
|
return true |
|
end |
|
|
|
function XDefGroup:ConditionText() |
|
if self.__condition == g_Classes[self.class].__condition then |
|
return "" |
|
end |
|
|
|
|
|
local name, params, body = GetFuncSource(self.__condition) |
|
if type(body) == "table" then |
|
body = table.concat(body, "\n") |
|
end |
|
if body then |
|
body = body:match("^%s*return%s*(.*)") or body |
|
|
|
body = string.gsub(body, "([%w%d])<(%d)", "%1< %2") |
|
end |
|
return body and " <color 128 128 220>cond:" .. body or "" |
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DefineClass.XDefWindow = { |
|
__parents = { "PropertyObject" }, |
|
properties = { |
|
{ category = "Def", id = "__class", name = "Class", editor = "choice", default = "XWindow", show_recent_items = 7, |
|
items = function() return ClassDescendantsCombo("XWindow", true) end, }, |
|
}, |
|
} |
|
|
|
function XDefWindow:GetPropertyTabs() |
|
return XWindowPropertyTabs |
|
end |
|
|
|
local eval = prop_eval |
|
function XDefWindow:GetProperties() |
|
|
|
local properties = table.icopy(self.properties) |
|
local class = g_Classes[self.__class] |
|
for _, prop_meta in ipairs(class and class:GetProperties()) do |
|
if not eval(prop_meta.dont_save, self, prop_meta) then |
|
properties[#properties + 1] = prop_meta |
|
end |
|
end |
|
return properties |
|
end |
|
|
|
local modified_base_props = {} |
|
|
|
function XDefWindow:SetProperty(id, value) |
|
rawset(self, id, value) |
|
modified_base_props[self] = nil |
|
end |
|
|
|
function XDefWindow:GetProperty(id) |
|
local prop = PropertyObject.GetProperty(self, id) |
|
if prop then |
|
return prop |
|
else |
|
local class = g_Classes[self.__class] |
|
return class and class:GetDefaultPropertyValue(id) |
|
end |
|
end |
|
|
|
function XDefWindow:GetDefaultPropertyValue(id, prop_meta) |
|
local prop_default = PropertyObject.GetDefaultPropertyValue(self, id, prop_meta) |
|
if prop_default then |
|
return prop_default |
|
end |
|
local class = g_Classes[self.__class] |
|
return class and class:GetDefaultPropertyValue(id, prop_meta) or false |
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function XDefWindow:OnEditorSetProperty(prop_id, old_value) |
|
|
|
|
|
|
|
|
|
end |
|
|
|
function XDefWindow:GetError() |
|
local class = g_Classes[self.__class] |
|
if IsKindOf(class, "XContentTemplate") then |
|
if self:GetProperty("RespawnOnContext") and self:GetProperty("ContextUpdateOnOpen") then |
|
return "'RespawnOnContext' and 'ContextUpdateOnOpen' shouldn't be simultaneously true. This will cause children to be 'Opened' twice." |
|
end |
|
end |
|
if IsKindOf(class, "XEditableText") then |
|
if self:GetProperty("Translate") and self:GetProperty("UserText") then |
|
return "'Translated text' and 'User text' properties can't be both set." |
|
end |
|
end |
|
end |
|
|
|
DefineClass.XDefWindowSubItem = { |
|
__parents = { "XDefWindow", "XDefGroup", }, |
|
TreeView = T(700510148795, "<IdNodeColor><__class><ConditionText><opt(PlacementText,' <color 128 128 128>','')><opt(comment,' <color 0 128 0>')>"), |
|
EditorName = "Window", |
|
} |
|
|
|
function XDefWindowSubItem:IdNodeColor() |
|
local idNode = rawget(self, "IdNode") |
|
if idNode == false or (idNode == nil and not _G[self.__class].IdNode) then |
|
return "" |
|
end |
|
for _,item in ipairs(self) do |
|
if IsKindOf(item, "XDefGroup") then |
|
return "<color 75 105 198>" |
|
end |
|
end |
|
return "" |
|
end |
|
|
|
function XDefWindowSubItem:PlacementText() |
|
local class = g_Classes[self.__class] |
|
if class and class:IsKindOf("XOpenLayer") then |
|
return Untranslated(self:GetProperty("Layer") .. " " .. self:GetProperty("Mode")) |
|
else |
|
local dock = self:GetProperty("Dock") |
|
dock = dock and (" Dock:" .. tostring(dock)) or "" |
|
return Untranslated(self:GetProperty("Id") .. dock) |
|
end |
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DefineClass.XWindowFlattened = { |
|
__parents = { "XWindow" }, |
|
} |
|
|
|
function XWindowFlattened:Spawn(args, spawn_children, parent, context, ...) |
|
if spawn_children then |
|
self.SpawnChildren = spawn_children |
|
end |
|
self:SpawnChildren(parent, context, ...) |
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|