{ "Id": "", "GameId": "", "EntryKey": "codeblock://15873444-8d16-4d28-9091-9c623fda5224", "ContentType": "x-mod/codeblock", "Content": "", "Usage": 0, "UsePublish": 1, "UseService": 0, "CoreVersion": "26.5.0.0", "StudioVersion": "", "DynamicLoading": 0, "ContentProto": { "Use": "Json", "Json": { "CoreVersion": { "Major": 0, "Minor": 2 }, "ScriptVersion": { "Major": 1, "Minor": 0 }, "Description": "", "Id": "15873444-8d16-4d28-9091-9c623fda5224", "Language": 1, "Name": "UIPopup", "Type": 5, "Source": 0, "Target": null, "Properties": [ { "Type": "Component", "DefaultValue": "3606e39d-32de-427e-8d23-b38af810a3b4:TextComponent", "SyncDirection": 0, "Attributes": [], "Name": "message" }, { "Type": "Component", "DefaultValue": "94a274e4-4111-40f1-924d-c95a3a1f14d5:ButtonComponent", "SyncDirection": 0, "Attributes": [], "Name": "btnOk" }, { "Type": "Component", "DefaultValue": "0f5de49b-2adc-409a-816d-15aa43df8e0d:ButtonComponent", "SyncDirection": 0, "Attributes": [], "Name": "btnCancel" }, { "Type": "Entity", "DefaultValue": "fb7a3b06-7026-4590-8efe-bb33416dd8f9", "SyncDirection": 0, "Attributes": [], "Name": "popupGroup" }, { "Type": "Entity", "DefaultValue": "aa954759-0e39-430f-85fa-80bf2e5fe31d", "SyncDirection": 0, "Attributes": [], "Name": "popup" }, { "Type": "any", "DefaultValue": "nil", "SyncDirection": 0, "Attributes": [], "Name": "onOk" }, { "Type": "any", "DefaultValue": "nil", "SyncDirection": 0, "Attributes": [], "Name": "onCancel" }, { "Type": "number", "DefaultValue": "0.15", "SyncDirection": 0, "Attributes": [], "Name": "duration" }, { "Type": "number", "DefaultValue": "0.5", "SyncDirection": 0, "Attributes": [], "Name": "from" }, { "Type": "number", "DefaultValue": "1", "SyncDirection": 0, "Attributes": [], "Name": "to" }, { "Type": "boolean", "DefaultValue": "false", "SyncDirection": 0, "Attributes": [], "Name": "isOpen" }, { "Type": "boolean", "DefaultValue": "false", "SyncDirection": 0, "Attributes": [], "Name": "isTweenPlaying" }, { "Type": "number", "DefaultValue": "0", "SyncDirection": 0, "Attributes": [], "Name": "tweenEventId" }, { "Type": "any", "DefaultValue": "nil", "SyncDirection": 0, "Attributes": [], "Name": "okHandler" }, { "Type": "any", "DefaultValue": "nil", "SyncDirection": 0, "Attributes": [], "Name": "cancelHandler" } ], "Methods": [ { "Return": { "Type": "void", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": null }, "Arguments": [ { "Type": "string", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": "message" }, { "Type": "any", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": "onOk" }, { "Type": "any", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": "onCancel" } ], "Code": "if self.isOpen == true then\n\treturn\nend\nself.isOpen = true\nself.popupGroup.Enable = true\nself.message.Text = message\nself.onOk = onOk\nself.onCancel = onCancel\n\n\nself.okHandler = self.btnOk.Entity:ConnectEvent(ButtonClickEvent,self.OnClickOk)\nself.cancelHandler = self.btnCancel.Entity:ConnectEvent(ButtonClickEvent,self.OnClickCancel)\nself:StartTween(true)", "Scope": 2, "ExecSpace": 0, "Attributes": [], "Name": "Open" }, { "Return": { "Type": "void", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": null }, "Arguments": [], "Code": "if self.isTweenPlaying == true then\n\treturn\nend\nif self.onOk ~= nil then\n\tself.onOk()\n\tself.onOk = nil\nend\nself:Close()", "Scope": 2, "ExecSpace": 0, "Attributes": [], "Name": "OnClickOk" }, { "Return": { "Type": "void", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": null }, "Arguments": [], "Code": "if self.isTweenPlaying == true then\n\treturn\nend\nif self.onCancel ~= nil then\n\tself.onCancel()\n\tself.onCancel = nil\nend\nself:Close()", "Scope": 2, "ExecSpace": 0, "Attributes": [], "Name": "OnClickCancel" }, { "Return": { "Type": "void", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": null }, "Arguments": [], "Code": "self.btnOk.Entity:DisconnectEvent(ButtonClickEvent,self.okHandler)\nself.btnCancel.Entity:DisconnectEvent(ButtonClickEvent,self.cancelHandler)\nself:StartTween(false)", "Scope": 2, "ExecSpace": 0, "Attributes": [], "Name": "Close" }, { "Return": { "Type": "void", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": null }, "Arguments": [ { "Type": "boolean", "DefaultValue": null, "SyncDirection": 0, "Attributes": [], "Name": "open" } ], "Code": "\nlocal transform = self.popup.UITransformComponent\nlocal canvasGroup = self.popupGroup.CanvasGroupComponent \nif open == true then\n\tcanvasGroup.GroupAlpha = 0\n\ttransform.UIScale = Vector3(self.from,self.from,1)\nelse\n\ttransform.UIScale = Vector3(self.to,self.to,1)\nend\nself.isTweenPlaying = true\nlocal time = 0\n\n\nlocal preTime = _UtilLogic.ElapsedSeconds\n\nlocal tween = function()\n\tlocal delta = _UtilLogic.ElapsedSeconds - preTime\n\ttime = time + delta\n\tlocal timeValue = time\t\n\tpreTime = _UtilLogic.ElapsedSeconds\n\n\tif time >= self.duration then\n\t\ttimeValue = self.duration\n\t\tif open == false then\n\t\t\tself.popupGroup.Enable = false\n\t\t\tself.isOpen = false\n\t\tend\n\t\tself.isTweenPlaying = false\n\t\t_TimerService:ClearTimer(self.tweenEventId)\n\n\tend\n\tif open == false then\n\t\ttimeValue = self.duration - timeValue\n\tend\n\tlocal tweenValue = _TweenLogic:Ease(self.from, self.to, \n\t\tself.duration, EaseType.SineEaseIn, timeValue)\n\ttransform.UIScale = Vector3(tweenValue,tweenValue,1)\n\tcanvasGroup.GroupAlpha = timeValue / self.duration\nend\nself.tweenEventId = _TimerService:SetTimerRepeat(tween,1/60)\n", "Scope": 2, "ExecSpace": 0, "Attributes": [], "Name": "StartTween" } ], "EntityEventHandlers": [] } } }