"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runGenCodeCustom = void 0; var FairyGUI = CS.FairyGUI; var FairyEditor = CS.FairyEditor; const GenCodeSettings_1 = require("./GenCodeSettings"); const App = FairyEditor.App; App.pluginManager.LoadUIPackage(App.pluginManager.basePath + "/" + eval("__dirname") + '/WhootCustomInspector'); class GenCodeCustomInspector extends FairyEditor.View.PluginInspector { combo; setScriptName; scriptName; scriptAnnotation; constructor() { super(); this.panel = FairyGUI.UIPackage.CreateObject("WhootCustomInspector", "Component1").asCom; this.combo = this.panel.GetChild("genType").asComboBox; this.setScriptName = this.panel.GetChild("SetScriptName").asButton; this.scriptName = this.panel.GetChild("scriptName"); this.scriptAnnotation = this.panel.GetChild("scriptAnnotation"); // this.combo = this.panel.GetChild("SetScriptType").asComboBox; let self = this; this.combo.onChanged.Add(() => { self.updateData(); }); this.setScriptName.onChanged.Add(() => { this.updateData(); }); this.scriptName.onFocusOut.Add(() => { this.updateData(); }); this.scriptAnnotation.onFocusOut.Add(() => { this.updateData(); }); this.updateAction = () => { return self.updateUI(); }; } updateData() { let activeDoc = App.activeDoc; let obj = activeDoc.inspectingTarget; //console.log("update==2", this.scriptName.title) GenCodeSettings_1.default.changeComponentSetting(obj.resourceURL, this.combo.value, activeDoc.packageItem.name, this.setScriptName.selected, this.scriptName.title, this.scriptAnnotation.title); } updateUI() { let sels = App.activeDoc.inspectingTargets; let obj = sels.get_Item(0); var data = GenCodeSettings_1.default.getComponentSetting(obj.resourceURL); if (data != null) { this.combo.value = data.scriptType; this.setScriptName.selected = data.isCustomName; this.scriptName.title = data.customName; this.scriptAnnotation.title = data.annotation; } else { this.combo.value = null; this.setScriptName.selected = false; this.scriptName.title = ""; this.scriptAnnotation.title = ""; } return true; //if everything is ok, return false to hide the inspector } } // class MembersGenCodeCustomInspector extends FairyEditor.View.PluginInspector { // private setScriptType: FairyGUI.GButton; // private scriptAnnotation: FairyEditor.Component.TextInput; // public constructor() { // super(); // this.panel = FairyGUI.UIPackage.CreateObject("WhootCustomInspector", "Component2").asCom; // this.setScriptType = this.panel.GetChild("SetScriptType").asButton; // this.scriptAnnotation = this.panel.GetChild("scriptAnnotation") as FairyEditor.Component.TextInput // this.setScriptType.onChanged.Add(() => { // this.updateData() // }); // this.scriptAnnotation.onFocusOut.Add(() => { // this.updateData() // }) // this.updateAction = () => { return this.updateUI(); }; // } // private updateData() { // let activeDoc = App.activeDoc // let obj = activeDoc.inspectingTarget // genSetting.changeMemberSetting(activeDoc.packageItem.GetURL(), obj.id, this.setScriptType.selected, obj.name, this.scriptAnnotation.title) // } // private updateUI(): boolean { // // let sels = App.activeDoc.inspectingTargets // // let obj = sels.get_Item(0); // let activeDoc = App.activeDoc // let obj = activeDoc.inspectingTarget // let data = genSetting.getMemberSetting(activeDoc.packageItem.GetURL(), obj.id) // if (data != null) { // this.setScriptType.selected = data.useCustomScript // this.scriptAnnotation.title = data.annotation // genSetting.changeMemberSetting(activeDoc.packageItem.GetURL(), obj.id, this.setScriptType.selected, obj.name, this.scriptAnnotation.title) // } else { // this.setScriptType.selected = false // this.scriptAnnotation.title = "" // } // //this.setScriptType.selected = obj.customData == "1" // return true; //if everything is ok, return false to hide the inspector // } // } function runGenCodeCustom() { // //Register a inspector // App.inspectorView.AddInspector(() => new MembersGenCodeCustomInspector(), "MembersGenCodeCustomInspectorJS", "成员脚本生成设置"); // //Condition to show it // App.docFactory.ConnectInspector("MembersGenCodeCustomInspectorJS", "component", false, false); //Register a inspector App.inspectorView.AddInspector(() => new GenCodeCustomInspector(), "GenCodeCustomInspectorJS", "组件脚本生成设置"); //Condition to show it App.docFactory.ConnectInspector("GenCodeCustomInspectorJS", "component", true, false); // "none", "graph", "image", "text", "richtext", "inputtext", // "movieclip", "swf", "loader", "group", "list", "loader3D", // "component", "Button", "Label", "Slider", "ProgressBar", "ScrollBar", "ComboBox", "mixed" //FairyEditor.FPackageItem(context.data) } exports.runGenCodeCustom = runGenCodeCustom;