----- Handling T values for Ged <-- search for this for more information -- value from the game => a T for an edit control function GedPropValueToT(value) return type(value) == "table" and setmetatable(table.copy(value), TMeta) or "" end -- a T from an edit control => value for the game function GedTToPropValue(value, default) assert(not default or default == "" or not IsT(default)) if value == "" then return type(default) == "table" and "" or default end assert(#value == 2) -- must have a loc ID generated by the edit field value[2] = ReplaceNonStandardCharacters(value[2]) if type(default) == "table" and #default == 2 and type(default[1]) == "number" then -- is the default a T value with an ID? -- use the loc ID of the default if the text is the same as the default if value[2] == default[2] then return table.raw_copy(default) end -- change the loc ID if editing the default value if value[1] == default[1] then return { RandomLocId(), value[2] } end end return table.raw_copy(value) -- strip T metatables (they can't pass through sockets and cause an assert) end ----- GedPropEditor - prop editors base class GedPropEditors = {} GedPropEditors["buttons"] = "GedPropEditor" DefineClass.GedPropEditor = { __parents = { "XContextControl" }, IdNode = true, LayoutHSpacing = 2, LayoutVSpacing = 2, FoldWhenHidden = true, RolloverAnchor = "left", RolloverTemplate = "GedPropRollover", SelectionBackground = RGB(204, 232, 255), BorderColor = RGBA(0, 0, 0, 0), BorderWidth = 2, prop_meta = false, parent_obj_id = false, panel = false, obj = false, last_set_value = false, selectable = true, selected = false, highlight_search_match = false, accept_os_clipboard_paste = false, } function GedPropEditor:ReassignFocusOrders(x, y) return y + 1 end function GedPropEditor:QueueReassignFocusOrders() local obj = GetParentOfKind(self, "GedPropPanel") if obj then obj:QueueReassignFocusOrders() end end function GedPropEditor:SetSelected(selected) self.selected = selected self:Invalidate() end function GedPropEditor:CalcBackground() if self.enabled and self.selected then return self.SelectionBackground end return XContextControl.CalcBackground(self) end function GedPropEditor:SetHighlightSearchMatch(value) self.highlight_search_match = value end function GedPropEditor:UpdatePropertyNames(internal, prop_name) local prop_meta = self.prop_meta local prop_name = prop_name or (internal and prop_meta.id or (prop_meta.name or prop_meta.id)) local prefix, suffix = "", "" if prop_meta.dlc_name then prefix = " " end if prop_meta.scale_name then suffix = " ("..prop_meta.scale_name..")" end if self.highlight_search_match then prop_name = GedPanelBase.MatchMark .. prop_name end local rollover local editor = prop_meta.editor if self.panel.ShowUnusedPropertyWarnings and not PlaceholderProperties[editor] then local prop_stats = self.panel:Obj("root|prop_stats") if prop_stats and prop_stats[prop_meta.id] then local used_in = prop_stats[prop_meta.id] if used_in == 0 then prefix = " " .. prefix rollover = "