Download CommonLua/Ged/XTemplates/PresetEditor.lua from sirnii/myspace: direct link, hf CLI and curl.
- Browser
- Download file 10.3 kB
-
https://huggingface.co/spaces/sirnii/myspace/resolve/main/CommonLua/Ged/XTemplates/PresetEditor.lua
- Command line
-
hf download hf://spaces/sirnii/myspace/CommonLua/Ged/XTemplates/PresetEditor.lua
-
curl -L -o PresetEditor.lua https://huggingface.co/spaces/sirnii/myspace/resolve/main/CommonLua/Ged/XTemplates/PresetEditor.lua
10.3 kB
| -- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ========== | |
| PlaceObj('XTemplate', { | |
| __is_kind_of = "GedApp", | |
| group = "GedApps", | |
| id = "PresetEditor", | |
| save_in = "Ged", | |
| PlaceObj('XTemplateTemplate', { | |
| '__template', "PresetEditTemplate", | |
| }, { | |
| PlaceObj('XTemplateGroup', { | |
| 'comment', "sub-items", | |
| '__condition', function (parent, context) return parent.ContainerClass ~= "" end, | |
| }, { | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XPanelSizer", | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedPreset" end, | |
| '__condition', function (parent, context) return parent.ContainerGraphItems end, | |
| '__class', "GedGraphEditorPanel", | |
| 'Id', "idPresetContent", | |
| 'Title', "Graph View", | |
| 'SelectionBind', "SelectedObject", | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedPreset" end, | |
| '__condition', function (parent, context) return parent.ContainerTree end, | |
| '__class', "GedTreePanel", | |
| 'Id', "idPresetContent", | |
| 'Title', "Subitems", | |
| 'ActionsClass', "PropertyObject", | |
| 'MoveUp', "GedOpTreeMoveItemUp", | |
| 'MoveDown', "GedOpTreeMoveItemDown", | |
| 'MoveOut', "GedOpTreeMoveItemOutwards", | |
| 'MoveIn', "GedOpTreeMoveItemInwards", | |
| 'Delete', "GedOpTreeDeleteItem", | |
| 'Cut', "GedOpTreeCut", | |
| 'Copy', "GedOpTreeCopy", | |
| 'Paste', "GedOpTreePaste", | |
| 'Duplicate', "GedOpTreeDuplicate", | |
| 'ActionContext', "ContentPanelAction", | |
| 'SearchActionContexts', { | |
| "ContentRootPanelAction", | |
| "ContentPanelAction", | |
| "ContentChildPanelAction", | |
| }, | |
| 'Format', "<EditorView>", | |
| 'AllowObjectsOnly', true, | |
| 'FilterName', "PresetSubItemFilter", | |
| 'SelectionBind', "SelectedObject", | |
| 'MultipleSelection', true, | |
| 'EnableForRootLevelItems', true, | |
| 'ItemClass', function (gedapp) return gedapp.ContainerClass end, | |
| 'RootActionContext', "ContentRootPanelAction", | |
| 'ChildActionContext', "ContentChildPanelAction", | |
| 'FullWidthText', true, | |
| }, { | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "PresetSubItemFilter" end, | |
| '__class', "GedPropPanel", | |
| 'Dock', "bottom", | |
| 'Visible', false, | |
| 'FoldWhenHidden', true, | |
| 'Title', "<FilterName>", | |
| 'EnableSearch', false, | |
| 'DisplayWarnings', false, | |
| 'EnableUndo', false, | |
| 'EnableCollapseDefault', false, | |
| 'EnableShowInternalNames', false, | |
| 'EnableCollapseCategories', false, | |
| 'HideFirstCategory', true, | |
| }), | |
| PlaceObj('XTemplateCode', { | |
| 'comment', "-- Setup preset filter", | |
| 'run', function (self, parent, context) | |
| parent.FilterClass = parent.parent.SubItemFilterClass | |
| end, | |
| }), | |
| PlaceObj('XTemplateFunc', { | |
| 'comment', "-- Setup drag&drop", | |
| 'name', "InitControls(self)", | |
| 'func', function (self) | |
| self:SetDragAndDrop(GetParentOfKind(self, "GedApp").DragAndDrop) | |
| return GedTreePanel.InitControls(self) | |
| end, | |
| }), | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedPreset" end, | |
| '__condition', function (parent, context) return not parent.ContainerTree and not parent.ContainerGraphItems end, | |
| '__class', "GedListPanel", | |
| 'Id', "idPresetContent", | |
| 'Title', "Subitems", | |
| 'ActionsClass', "PropertyObject", | |
| 'MoveUp', "GedOpListMoveUp", | |
| 'MoveDown', "GedOpListMoveDown", | |
| 'Delete', "GedOpListDeleteItem", | |
| 'Cut', "GedOpListCut", | |
| 'Copy', "GedOpListCopy", | |
| 'Paste', "GedOpListPaste", | |
| 'Duplicate', "GedOpListDuplicate", | |
| 'ActionContext', "ContentPanelAction", | |
| 'SearchActionContexts', { | |
| "ContentRootPanelAction", | |
| "ContentPanelAction", | |
| "ContentChildPanelAction", | |
| }, | |
| 'Format', "<EditorView>", | |
| 'AllowObjectsOnly', true, | |
| 'FilterName', "PresetSubItemFilter", | |
| 'SelectionBind', "SelectedObject", | |
| 'MultipleSelection', true, | |
| 'ItemClass', function (gedapp) return gedapp.ContainerClass end, | |
| 'ItemActionContext', "ContentRootPanelAction", | |
| }, { | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "PresetSubItemFilter" end, | |
| '__class', "GedPropPanel", | |
| 'Dock', "bottom", | |
| 'Visible', false, | |
| 'FoldWhenHidden', true, | |
| 'Title', "<FilterName>", | |
| 'EnableSearch', false, | |
| 'DisplayWarnings', false, | |
| 'EnableUndo', false, | |
| 'EnableCollapseDefault', false, | |
| 'EnableShowInternalNames', false, | |
| 'EnableCollapseCategories', false, | |
| 'HideFirstCategory', true, | |
| }), | |
| PlaceObj('XTemplateCode', { | |
| 'comment', "-- Setup preset filter", | |
| 'run', function (self, parent, context) | |
| parent.FilterClass = parent.parent.SubItemFilterClass | |
| end, | |
| }), | |
| PlaceObj('XTemplateFunc', { | |
| 'comment', "-- Setup drag&drop", | |
| 'name', "InitControls(self)", | |
| 'func', function (self) | |
| self:SetDragAndDrop(GetParentOfKind(self, "GedApp").DragAndDrop) | |
| return GedListPanel.InitControls(self) | |
| end, | |
| }), | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedPreset" end, | |
| '__class', "GedBindView", | |
| 'BindView', "SubItems", | |
| 'BindFunc', "GedDynamicItemsMenu", | |
| 'ControlId', "idPresetContent", | |
| 'GetBindParams', function (self, control) return "Preset" end, | |
| 'OnViewChanged', function (self, value, control) | |
| RebuildSubItemsActions(control, value, "New", "main", "main") | |
| end, | |
| }), | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XPanelSizer", | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedObject" end, | |
| '__class', "GedPropPanel", | |
| 'Id', "idProps", | |
| 'Title', "Properties", | |
| 'ActionsClass', "PropertyObject", | |
| 'Copy', "GedOpPropertyCopy", | |
| 'Paste', "GedOpPropertyPaste", | |
| 'ActionContext', "PropPanelAction", | |
| 'SearchActionContexts', { | |
| "PropPanelAction", | |
| "PropAction", | |
| }, | |
| 'RootObjectBindName', "SelectedPreset", | |
| 'PropActionContext', "PropAction", | |
| }, { | |
| PlaceObj('XTemplateCode', { | |
| 'run', function (self, parent, context) | |
| parent.DisplayWarnings = (not context.ContainerClass or context.ContainerClass == "") | |
| end, | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__condition', function (parent, context) local app = GetParentOfKind(parent, "GedApp") | |
| return config.ModdingToolsInUserMode and app.ModItemClass end, | |
| 'Id', "idPanelDockedButtons", | |
| 'IdNode', true, | |
| 'ZOrder', 2, | |
| 'Margins', box(0, 3, 0, 0), | |
| 'Padding', box(2, 2, 2, 2), | |
| 'Dock', "bottom", | |
| 'LayoutMethod', "VList", | |
| 'LayoutVSpacing', 2, | |
| 'FoldWhenHidden', true, | |
| }, { | |
| PlaceObj('XTemplateFunc', { | |
| 'comment', "Bind mods combo", | |
| 'name', "Open", | |
| 'func', function (self, ...) | |
| local app = GetParentOfKind(self, "GedApp") | |
| app:Op("GedOpSetModdingBindings") | |
| end, | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "LastEditedMod" end, | |
| '__class', "GedBindView", | |
| 'ControlId', "idEditingModCombo", | |
| 'OnViewChanged', function (self, value, control) | |
| if not control then return end | |
| control:SetValue(value or "") | |
| end, | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__context', function (parent, context) return "SelectedObject" end, | |
| '__class', "GedBindView", | |
| 'BindView', "mod_id", | |
| 'BindFunc', "GedGetPresetMod", | |
| 'ControlId', "idCloneInModButton", | |
| 'OnViewChanged', function (self, value, control) | |
| if not control then return end | |
| local app = GetParentOfKind(self, "GedApp") | |
| local combo = self:ResolveId("idEditingModCombo") | |
| local mod_id = combo:GetValue() | |
| local editable_mod_selected = mod_id ~= nil and mod_id ~= "" | |
| if value then -- preset is a mod item | |
| local read_only = app.ContainerClass ~= "" and app.connection:Obj("SelectedPreset|read_only") or app.connection:Obj("SelectedObject|read_only") | |
| control:SetEnabled(editable_mod_selected and not read_only) | |
| else | |
| local panel = app:ResolveId("idPresets") | |
| local selection = panel:GetSelection() | |
| local group_selected = selection and #selection == 1 | |
| control:SetEnabled(editable_mod_selected and not group_selected) | |
| end | |
| end, | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XText", | |
| 'VAlign', "center", | |
| 'Text', "To modify a game component, clone it into your mod and keep its original Id. To use it as a base for a new component, use a different Id.", | |
| }), | |
| PlaceObj('XTemplateWindow', nil, { | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XText", | |
| 'Dock', "left", | |
| 'VAlign', "center", | |
| 'MinWidth', 150, | |
| 'LayoutMethod', "HList", | |
| 'LayoutHSpacing', 2, | |
| 'Text', "Editing mod", | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XCombo", | |
| 'Id', "idEditingModCombo", | |
| 'Items', function (self) | |
| local app = GetParentOfKind(self, "GedApp") | |
| return app.connection:Obj("EditableModsCombo") | |
| end, | |
| 'OnValueChanged', function (self, value) | |
| local button = self:ResolveId("idCloneInModButton") | |
| if button then | |
| button:SetEnabled(value ~= nil and value ~= "") | |
| end | |
| end, | |
| }), | |
| }), | |
| PlaceObj('XTemplateWindow', { | |
| '__class', "XTextButton", | |
| 'RolloverTemplate', "GedToolbarRollover", | |
| 'RolloverText', T(723619379046, --[[XTemplate PresetEditor RolloverText]] "Clone the selected preset in the selected mod so it can be modded."), | |
| 'Id', "idCloneInModButton", | |
| 'Margins', box(5, 7, 5, 5), | |
| 'BorderWidth', 2, | |
| 'Padding', box(2, 2, 2, 2), | |
| 'HAlign', "center", | |
| 'Enabled', false, | |
| 'OnPress', function (self, gamepad) | |
| local app = GetParentOfKind(self, "GedApp") | |
| local panel = app:ResolveId("idPresets") | |
| local combo = self:ResolveId("idEditingModCombo") | |
| if app and panel and combo then | |
| local mod_id = combo:GetValue() | |
| app:Op("GedOpClonePresetInMod", "root", panel:GetMultiSelection(), panel.ItemClass(app), mod_id) | |
| end | |
| end, | |
| 'Text', "Clone in selected mod", | |
| }), | |
| }), | |
| }), | |
| }), | |
| PlaceObj('XTemplateProperty', { | |
| 'category', "General", | |
| 'id', "DragAndDrop", | |
| 'default', true, | |
| }), | |
| }) | |