diff --git a/RootDesk/MyDesk/SlayDeckController.codeblock b/RootDesk/MyDesk/SlayDeckController.codeblock index 08ae87b..bb7e05c 100644 --- a/RootDesk/MyDesk/SlayDeckController.codeblock +++ b/RootDesk/MyDesk/SlayDeckController.codeblock @@ -1077,7 +1077,7 @@ "Name": null }, "Arguments": [], - "Code": "local endTurn = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/EndTurnButton\")\nif endTurn ~= nil and endTurn.ButtonComponent ~= nil then\n\tif self.EndTurnHandler ~= nil then\n\t\tendTurn:DisconnectEvent(ButtonClickEvent, self.EndTurnHandler)\n\t\tself.EndTurnHandler = nil\n\tend\n\tself.EndTurnHandler = endTurn:ConnectEvent(ButtonClickEvent, function() self:EndPlayerTurn() end)\nend\nlocal drawPile = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/DrawPile\")\nif drawPile ~= nil and drawPile.ButtonComponent ~= nil then\n\tif self.DrawPileHandler ~= nil then\n\t\tdrawPile:DisconnectEvent(ButtonClickEvent, self.DrawPileHandler)\n\t\tself.DrawPileHandler = nil\n\tend\n\tself.DrawPileHandler = drawPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect(\"draw\") end)\nend\nlocal discardPile = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/DiscardPile\")\nif discardPile ~= nil and discardPile.ButtonComponent ~= nil then\n\tif self.DiscardPileHandler ~= nil then\n\t\tdiscardPile:DisconnectEvent(ButtonClickEvent, self.DiscardPileHandler)\n\t\tself.DiscardPileHandler = nil\n\tend\n\tself.DiscardPileHandler = discardPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect(\"discard\") end)\nend\nlocal inspectClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckInspectHud/Close\")\nif inspectClose ~= nil and inspectClose.ButtonComponent ~= nil then\n\tif self.DeckInspectCloseHandler ~= nil then\n\t\tinspectClose:DisconnectEvent(ButtonClickEvent, self.DeckInspectCloseHandler)\n\t\tself.DeckInspectCloseHandler = nil\n\tend\n\tself.DeckInspectCloseHandler = inspectClose:ConnectEvent(ButtonClickEvent, function() self:CloseDeckInspect() end)\nend\nlocal allDeckButton = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/AllDeckButton\")\nif allDeckButton ~= nil and allDeckButton.ButtonComponent ~= nil then\n\tif self.AllDeckHandler ~= nil then\n\t\tallDeckButton:DisconnectEvent(ButtonClickEvent, self.AllDeckHandler)\n\t\tself.AllDeckHandler = nil\n\tend\n\tself.AllDeckHandler = allDeckButton:ConnectEvent(ButtonClickEvent, function() self:OpenAllDeck() end)\nend\nlocal allDeckClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckAllHud/Close\")\nif allDeckClose ~= nil and allDeckClose.ButtonComponent ~= nil then\n\tif self.AllDeckCloseHandler ~= nil then\n\t\tallDeckClose:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler)\n\t\tself.AllDeckCloseHandler = nil\n\tend\n\tself.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end)\nend\nfor i = 1, 5 do\n\tlocal cardEntity = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CardHand/Card\" .. tostring(i))\n\tif cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then\n\t\tcardEntity:ConnectEvent(UITouchBeginDragEvent, function(ev) self:OnCardDragBegin(i) end)\n\t\tcardEntity:ConnectEvent(UITouchDragEvent, function(ev) self:OnCardDrag(i, ev.TouchPoint) end)\n\t\tcardEntity:ConnectEvent(UITouchEndDragEvent, function(ev) self:OnCardDragEnd(i, ev.TouchPoint) end)\n\tend\nend\nfor i = 1, 3 do\n\tlocal rc = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RewardHud/Reward\" .. tostring(i))\n\tif rc ~= nil and rc.ButtonComponent ~= nil then\n\t\trc:ConnectEvent(ButtonClickEvent, function() self:PickReward(i) end)\n\tend\nend\nlocal skip = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RewardHud/Skip\")\nif skip ~= nil and skip.ButtonComponent ~= nil then\n\tskip:ConnectEvent(ButtonClickEvent, function() self:PickReward(0) end)\nend\nlocal mapNodeIds = {}\nfor r = 1, 7 do\n\tfor c = 1, 4 do\n\t\ttable.insert(mapNodeIds, \"r\" .. tostring(r) .. \"c\" .. tostring(c))\n\tend\nend\ntable.insert(mapNodeIds, \"boss\")\nfor i = 1, #mapNodeIds do\n\tlocal nid = mapNodeIds[i]\n\tlocal mn = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/MapHud/Node_\" .. nid)\n\tif mn ~= nil and mn.ButtonComponent ~= nil then\n\t\tmn:ConnectEvent(ButtonClickEvent, function() self:PickNode(nid) end)\n\tend\nend\nfor i = 1, 3 do\n\tlocal sc = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Card\" .. tostring(i))\n\tif sc ~= nil and sc.ButtonComponent ~= nil then\n\t\tsc:ConnectEvent(ButtonClickEvent, function() self:BuyCard(i) end)\n\tend\nend\nlocal shopLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Leave\")\nif shopLeave ~= nil and shopLeave.ButtonComponent ~= nil then\n\tshopLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nlocal shopRelic = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Relic\")\nif shopRelic ~= nil and shopRelic.ButtonComponent ~= nil then\n\tshopRelic:ConnectEvent(ButtonClickEvent, function() self:BuyRelic() end)\nend\nlocal restLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RestHud/Leave\")\nif restLeave ~= nil and restLeave.ButtonComponent ~= nil then\n\trestLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nfor i = 1, 4 do\n\tlocal ms = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/MonsterSlot\" .. tostring(i))\n\tif ms ~= nil and ms.ButtonComponent ~= nil then\n\t\tms:ConnectEvent(ButtonClickEvent, function() self:SetTarget(i) end)\n\tend\nend\nfor i = 1, 10 do\n\tlocal rs = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/RelicSlot\" .. tostring(i))\n\tif rs ~= nil and rs.UITouchReceiveComponent ~= nil then\n\t\tlocal idx = i\n\t\trs:ConnectEvent(UITouchEnterEvent, function()\n\t\t\tlocal rid = nil\n\t\t\tif self.RunRelics ~= nil then rid = self.RunRelics[idx] end\n\t\t\tif rid ~= nil and self.Relics[rid] ~= nil then\n\t\t\t\tself:ShowTooltip(self.Relics[rid].name, self.Relics[rid].desc, -240 + (idx - 1) * 48)\n\t\t\tend\n\t\tend)\n\t\trs:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)\n\tend\nend\nfor i = 1, 5 do\n\tlocal ps = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/PotionSlot\" .. tostring(i))\n\tif ps ~= nil and ps.UITouchReceiveComponent ~= nil then\n\t\tlocal idx = i\n\t\tps:ConnectEvent(UITouchEnterEvent, function()\n\t\t\tlocal pid = nil\n\t\t\tif self.RunPotions ~= nil then pid = self.RunPotions[idx] end\n\t\t\tif pid ~= nil and self.Potions[pid] ~= nil then\n\t\t\t\tself:ShowTooltip(self.Potions[pid].name, self.Potions[pid].desc, 240 + (idx - 1) * 44)\n\t\t\tend\n\t\tend)\n\t\tps:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)\n\t\tps:ConnectEvent(UITouchDownEvent, function() self:OpenPotionMenu(idx) end)\n\tend\nend\nlocal pmUse = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Use\")\nif pmUse ~= nil and pmUse.ButtonComponent ~= nil then\n\tpmUse:ConnectEvent(ButtonClickEvent, function() self:UsePotion() end)\nend\nlocal pmToss = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Toss\")\nif pmToss ~= nil and pmToss.ButtonComponent ~= nil then\n\tpmToss:ConnectEvent(ButtonClickEvent, function() self:TossPotion() end)\nend\nlocal pmClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Close\")\nif pmClose ~= nil and pmClose.ButtonComponent ~= nil then\n\tpmClose:ConnectEvent(ButtonClickEvent, function() self:ClosePotionMenu() end)\nend\nlocal shopPotion = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Potion\")\nif shopPotion ~= nil and shopPotion.ButtonComponent ~= nil then\n\tshopPotion:ConnectEvent(ButtonClickEvent, function() self:BuyPotion() end)\nend\nlocal chest = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/TreasureHud/Chest\")\nif chest ~= nil and chest.ButtonComponent ~= nil then\n\tchest:ConnectEvent(ButtonClickEvent, function() self:OpenChest() end)\nend\nlocal treasureLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/TreasureHud/Leave\")\nif treasureLeave ~= nil and treasureLeave.ButtonComponent ~= nil then\n\ttreasureLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nlocal jcRelic = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobChoiceHud/RelicButton\")\nif jcRelic ~= nil and jcRelic.ButtonComponent ~= nil then\n\tjcRelic:ConnectEvent(ButtonClickEvent, function() self:PickJobReward(\"relic\") end)\nend\nlocal jcJob = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobChoiceHud/JobButton\")\nif jcJob ~= nil and jcJob.ButtonComponent ~= nil then\n\tjcJob:ConnectEvent(ButtonClickEvent, function() self:PickJobReward(\"job\") end)\nend\nfor i = 1, 3 do\n\tlocal slotIdx = i\n\tlocal jb = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobSelectHud/Job_slot\" .. tostring(i))\n\tif jb ~= nil and jb.ButtonComponent ~= nil then\n\t\tjb:ConnectEvent(ButtonClickEvent, function()\n\t\t\tif self.JobOpts ~= nil and self.JobOpts[slotIdx] ~= nil then\n\t\t\t\tself:SetJob(self.JobOpts[slotIdx].id)\n\t\t\tend\n\t\tend)\n\tend\nend", + "Code": "local endTurn = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/EndTurnButton\")\nif endTurn ~= nil and endTurn.ButtonComponent ~= nil then\n\tif self.EndTurnHandler ~= nil then\n\t\tendTurn:DisconnectEvent(ButtonClickEvent, self.EndTurnHandler)\n\t\tself.EndTurnHandler = nil\n\tend\n\tself.EndTurnHandler = endTurn:ConnectEvent(ButtonClickEvent, function() self:EndPlayerTurn() end)\nend\nlocal drawPile = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/DrawPile\")\nif drawPile ~= nil and drawPile.ButtonComponent ~= nil then\n\tif self.DrawPileHandler ~= nil then\n\t\tdrawPile:DisconnectEvent(ButtonClickEvent, self.DrawPileHandler)\n\t\tself.DrawPileHandler = nil\n\tend\n\tself.DrawPileHandler = drawPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect(\"draw\") end)\nend\nlocal discardPile = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckHud/DiscardPile\")\nif discardPile ~= nil and discardPile.ButtonComponent ~= nil then\n\tif self.DiscardPileHandler ~= nil then\n\t\tdiscardPile:DisconnectEvent(ButtonClickEvent, self.DiscardPileHandler)\n\t\tself.DiscardPileHandler = nil\n\tend\n\tself.DiscardPileHandler = discardPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect(\"discard\") end)\nend\nlocal inspectClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckInspectHud/Close\")\nif inspectClose ~= nil and inspectClose.ButtonComponent ~= nil then\n\tif self.DeckInspectCloseHandler ~= nil then\n\t\tinspectClose:DisconnectEvent(ButtonClickEvent, self.DeckInspectCloseHandler)\n\t\tself.DeckInspectCloseHandler = nil\n\tend\n\tself.DeckInspectCloseHandler = inspectClose:ConnectEvent(ButtonClickEvent, function() self:CloseDeckInspect() end)\nend\nlocal allDeckButton = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/AllDeckButton\")\nif allDeckButton ~= nil and allDeckButton.ButtonComponent ~= nil then\n\tif self.AllDeckHandler ~= nil then\n\t\tallDeckButton:DisconnectEvent(ButtonClickEvent, self.AllDeckHandler)\n\t\tself.AllDeckHandler = nil\n\tend\n\tself.AllDeckHandler = allDeckButton:ConnectEvent(ButtonClickEvent, function() self:OpenAllDeck() end)\nend\nlocal allDeckClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/DeckAllHud/Close\")\nif allDeckClose ~= nil and allDeckClose.ButtonComponent ~= nil then\n\tif self.AllDeckCloseHandler ~= nil then\n\t\tallDeckClose:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler)\n\t\tself.AllDeckCloseHandler = nil\n\tend\n\tself.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end)\nend\nfor i = 1, 5 do\n\tlocal cardEntity = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CardHand/Card\" .. tostring(i))\n\tif cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then\n\t\tlocal cardPath = \"/ui/DefaultGroup/CardHand/Card\" .. tostring(i)\n\t\tcardEntity:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)\n\t\tcardEntity:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)\n\t\tcardEntity:ConnectEvent(UITouchBeginDragEvent, function(ev) self:OnCardDragBegin(i) end)\n\t\tcardEntity:ConnectEvent(UITouchDragEvent, function(ev) self:OnCardDrag(i, ev.TouchPoint) end)\n\t\tcardEntity:ConnectEvent(UITouchEndDragEvent, function(ev) self:OnCardDragEnd(i, ev.TouchPoint) end)\n\tend\nend\nfor i = 1, 3 do\n\tlocal rc = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RewardHud/Reward\" .. tostring(i))\n\tif rc ~= nil and rc.ButtonComponent ~= nil then\n\t\trc:ConnectEvent(ButtonClickEvent, function() self:PickReward(i) end)\n\t\tif rc.UITouchReceiveComponent ~= nil then\n\t\t\tlocal cardPath = \"/ui/DefaultGroup/RewardHud/Reward\" .. tostring(i)\n\t\t\trc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)\n\t\t\trc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)\n\t\tend\n\tend\nend\nlocal skip = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RewardHud/Skip\")\nif skip ~= nil and skip.ButtonComponent ~= nil then\n\tskip:ConnectEvent(ButtonClickEvent, function() self:PickReward(0) end)\nend\nlocal mapNodeIds = {}\nfor r = 1, 7 do\n\tfor c = 1, 4 do\n\t\ttable.insert(mapNodeIds, \"r\" .. tostring(r) .. \"c\" .. tostring(c))\n\tend\nend\ntable.insert(mapNodeIds, \"boss\")\nfor i = 1, #mapNodeIds do\n\tlocal nid = mapNodeIds[i]\n\tlocal mn = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/MapHud/Node_\" .. nid)\n\tif mn ~= nil and mn.ButtonComponent ~= nil then\n\t\tmn:ConnectEvent(ButtonClickEvent, function() self:PickNode(nid) end)\n\tend\nend\nfor i = 1, 3 do\n\tlocal sc = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Card\" .. tostring(i))\n\tif sc ~= nil and sc.ButtonComponent ~= nil then\n\t\tsc:ConnectEvent(ButtonClickEvent, function() self:BuyCard(i) end)\n\t\tif sc.UITouchReceiveComponent ~= nil then\n\t\t\tlocal cardPath = \"/ui/DefaultGroup/ShopHud/Card\" .. tostring(i)\n\t\t\tsc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)\n\t\t\tsc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)\n\t\tend\n\tend\nend\nlocal shopLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Leave\")\nif shopLeave ~= nil and shopLeave.ButtonComponent ~= nil then\n\tshopLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nlocal shopRelic = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Relic\")\nif shopRelic ~= nil and shopRelic.ButtonComponent ~= nil then\n\tshopRelic:ConnectEvent(ButtonClickEvent, function() self:BuyRelic() end)\nend\nlocal restLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/RestHud/Leave\")\nif restLeave ~= nil and restLeave.ButtonComponent ~= nil then\n\trestLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nfor i = 1, 4 do\n\tlocal ms = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/MonsterSlot\" .. tostring(i))\n\tif ms ~= nil and ms.ButtonComponent ~= nil then\n\t\tms:ConnectEvent(ButtonClickEvent, function() self:SetTarget(i) end)\n\tend\nend\nfor i = 1, 10 do\n\tlocal rs = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/RelicSlot\" .. tostring(i))\n\tif rs ~= nil and rs.UITouchReceiveComponent ~= nil then\n\t\tlocal idx = i\n\t\trs:ConnectEvent(UITouchEnterEvent, function()\n\t\t\tlocal rid = nil\n\t\t\tif self.RunRelics ~= nil then rid = self.RunRelics[idx] end\n\t\t\tif rid ~= nil and self.Relics[rid] ~= nil then\n\t\t\t\tself:ShowTooltip(self.Relics[rid].name, self.Relics[rid].desc, -240 + (idx - 1) * 48)\n\t\t\tend\n\t\tend)\n\t\trs:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)\n\tend\nend\nfor i = 1, 5 do\n\tlocal ps = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/TopBar/PotionSlot\" .. tostring(i))\n\tif ps ~= nil and ps.UITouchReceiveComponent ~= nil then\n\t\tlocal idx = i\n\t\tps:ConnectEvent(UITouchEnterEvent, function()\n\t\t\tlocal pid = nil\n\t\t\tif self.RunPotions ~= nil then pid = self.RunPotions[idx] end\n\t\t\tif pid ~= nil and self.Potions[pid] ~= nil then\n\t\t\t\tself:ShowTooltip(self.Potions[pid].name, self.Potions[pid].desc, 240 + (idx - 1) * 44)\n\t\t\tend\n\t\tend)\n\t\tps:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)\n\t\tps:ConnectEvent(UITouchDownEvent, function() self:OpenPotionMenu(idx) end)\n\tend\nend\nlocal pmUse = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Use\")\nif pmUse ~= nil and pmUse.ButtonComponent ~= nil then\n\tpmUse:ConnectEvent(ButtonClickEvent, function() self:UsePotion() end)\nend\nlocal pmToss = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Toss\")\nif pmToss ~= nil and pmToss.ButtonComponent ~= nil then\n\tpmToss:ConnectEvent(ButtonClickEvent, function() self:TossPotion() end)\nend\nlocal pmClose = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/CombatHud/PotionMenu/Close\")\nif pmClose ~= nil and pmClose.ButtonComponent ~= nil then\n\tpmClose:ConnectEvent(ButtonClickEvent, function() self:ClosePotionMenu() end)\nend\nlocal shopPotion = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/ShopHud/Potion\")\nif shopPotion ~= nil and shopPotion.ButtonComponent ~= nil then\n\tshopPotion:ConnectEvent(ButtonClickEvent, function() self:BuyPotion() end)\nend\nlocal chest = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/TreasureHud/Chest\")\nif chest ~= nil and chest.ButtonComponent ~= nil then\n\tchest:ConnectEvent(ButtonClickEvent, function() self:OpenChest() end)\nend\nlocal treasureLeave = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/TreasureHud/Leave\")\nif treasureLeave ~= nil and treasureLeave.ButtonComponent ~= nil then\n\ttreasureLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)\nend\nlocal jcRelic = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobChoiceHud/RelicButton\")\nif jcRelic ~= nil and jcRelic.ButtonComponent ~= nil then\n\tjcRelic:ConnectEvent(ButtonClickEvent, function() self:PickJobReward(\"relic\") end)\nend\nlocal jcJob = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobChoiceHud/JobButton\")\nif jcJob ~= nil and jcJob.ButtonComponent ~= nil then\n\tjcJob:ConnectEvent(ButtonClickEvent, function() self:PickJobReward(\"job\") end)\nend\nfor i = 1, 3 do\n\tlocal slotIdx = i\n\tlocal jb = _EntityService:GetEntityByPath(\"/ui/DefaultGroup/JobSelectHud/Job_slot\" .. tostring(i))\n\tif jb ~= nil and jb.ButtonComponent ~= nil then\n\t\tjb:ConnectEvent(ButtonClickEvent, function()\n\t\t\tif self.JobOpts ~= nil and self.JobOpts[slotIdx] ~= nil then\n\t\t\t\tself:SetJob(self.JobOpts[slotIdx].id)\n\t\t\tend\n\t\tend)\n\tend\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1386,12 +1386,42 @@ "Name": "cardId" } ], - "Code": "local c = self.Cards[cardId]\nif c == nil then\n\tc = { name = cardId, cost = 0, desc = \"\", kind = \"Skill\", class = \"warrior\", rarity = \"normal\" }\nend\nlocal e = _EntityService:GetEntityByPath(base)\nif e ~= nil and e.SpriteGUIRendererComponent ~= nil then\n\tlocal frames = self.CardFrames[self.ClassToFrame[c.class] or \"warrior\"]\n\tlocal ruid = nil\n\tif frames ~= nil then\n\t\truid = frames[c.rarity or \"normal\"]\n\tend\n\tif ruid ~= nil then\n\t\te.SpriteGUIRendererComponent.ImageRUID = ruid\n\t\te.SpriteGUIRendererComponent.Color = Color(1, 1, 1, 1)\n\tend\nend\nself:SetText(base .. \"/Cost\", string.format(\"%d\", c.cost))\nself:SetText(base .. \"/Name\", c.name)\nself:SetText(base .. \"/Desc\", c.desc)\nlocal art = _EntityService:GetEntityByPath(base .. \"/Art\")\nif art ~= nil then\n\tif c.image ~= nil and c.image ~= \"\" then\n\t\tart.Enable = true\n\t\tif art.SpriteGUIRendererComponent ~= nil then\n\t\t\tart.SpriteGUIRendererComponent.ImageRUID = c.image\n\t\tend\n\telse\n\t\tart.Enable = false\n\tend\nend", + "Code": "local c = self.Cards[cardId]\nif c == nil then\n\tc = { name = cardId, cost = 0, desc = \"\", kind = \"Skill\", class = \"warrior\", rarity = \"normal\" }\nend\nlocal e = _EntityService:GetEntityByPath(base)\nif e ~= nil and e.SpriteGUIRendererComponent ~= nil then\n\tif e.UITransformComponent ~= nil then\n\t\te.UITransformComponent.UIScale = Vector3(1, 1, 1)\n\tend\n\tlocal frames = self.CardFrames[self.ClassToFrame[c.class] or \"warrior\"]\n\tlocal ruid = nil\n\tif frames ~= nil then\n\t\truid = frames[c.rarity or \"normal\"]\n\tend\n\tif ruid ~= nil then\n\t\te.SpriteGUIRendererComponent.ImageRUID = ruid\n\t\te.SpriteGUIRendererComponent.Color = Color(1, 1, 1, 1)\n\tend\nend\nself:SetText(base .. \"/Cost\", string.format(\"%d\", c.cost))\nself:SetText(base .. \"/Name\", c.name)\nself:SetText(base .. \"/Desc\", c.desc)\nlocal art = _EntityService:GetEntityByPath(base .. \"/Art\")\nif art ~= nil then\n\tif c.image ~= nil and c.image ~= \"\" then\n\t\tart.Enable = true\n\t\tif art.SpriteGUIRendererComponent ~= nil then\n\t\t\tart.SpriteGUIRendererComponent.ImageRUID = c.image\n\t\tend\n\telse\n\t\tart.Enable = false\n\tend\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], "Name": "ApplyCardFace" }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [ + { + "Type": "string", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": "path" + }, + { + "Type": "boolean", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": "hover" + } + ], + "Code": "local e = _EntityService:GetEntityByPath(path)\nif e == nil or e.UITransformComponent == nil then\n\treturn\nend\nif hover == true and e.Enable == true then\n\te.UITransformComponent.UIScale = Vector3(1.12, 1.12, 1)\nelse\n\te.UITransformComponent.UIScale = Vector3(1, 1, 1)\nend", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "SetCardHover" + }, { "Return": { "Type": "void", diff --git a/tools/deck/gen-slaydeck.mjs b/tools/deck/gen-slaydeck.mjs index 851df12..7c91ea8 100644 --- a/tools/deck/gen-slaydeck.mjs +++ b/tools/deck/gen-slaydeck.mjs @@ -1454,12 +1454,13 @@ function upsertUi() { path: cardPath, modelId: 'uisprite', entryId: 'UISprite', - componentNames: 'MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent', + componentNames: 'MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent', displayOrder: i, components: [ transform({ parentW: 1920, parentH: 1080, anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 }, size: { x: CARD_W, y: CARD_H }, pos: { x: rewardXs[i - 1], y: 0 } }), sprite({ dataId: CARDFRAMES.frames.warrior.normal, color: WHITE, type: 0, raycast: true }), button(), + { '@type': 'MOD.Core.UITouchReceiveComponent', Enable: true }, ], })); const rewardLayout = cardFaceLayout(CARD_W); @@ -1663,12 +1664,13 @@ function upsertUi() { path: cardPath, modelId: 'uisprite', entryId: 'UISprite', - componentNames: 'MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent', + componentNames: 'MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent', displayOrder: i, components: [ transform({ parentW: 1920, parentH: 1080, anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 }, size: { x: CARD_W, y: CARD_H }, pos: { x: shopXs[i - 1], y: 20 } }), sprite({ dataId: CARDFRAMES.frames.warrior.normal, color: WHITE, type: 0, raycast: true }), button(), + { '@type': 'MOD.Core.UITouchReceiveComponent', Enable: true }, ], })); const shopLayout = cardFaceLayout(CARD_W); @@ -2901,6 +2903,9 @@ end for i = 1, 5 do local cardEntity = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand/Card" .. tostring(i)) if cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then + local cardPath = "/ui/DefaultGroup/CardHand/Card" .. tostring(i) + cardEntity:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end) + cardEntity:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end) cardEntity:ConnectEvent(UITouchBeginDragEvent, function(ev) self:OnCardDragBegin(i) end) cardEntity:ConnectEvent(UITouchDragEvent, function(ev) self:OnCardDrag(i, ev.TouchPoint) end) cardEntity:ConnectEvent(UITouchEndDragEvent, function(ev) self:OnCardDragEnd(i, ev.TouchPoint) end) @@ -2910,6 +2915,11 @@ for i = 1, 3 do local rc = _EntityService:GetEntityByPath("/ui/DefaultGroup/RewardHud/Reward" .. tostring(i)) if rc ~= nil and rc.ButtonComponent ~= nil then rc:ConnectEvent(ButtonClickEvent, function() self:PickReward(i) end) + if rc.UITouchReceiveComponent ~= nil then + local cardPath = "/ui/DefaultGroup/RewardHud/Reward" .. tostring(i) + rc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end) + rc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end) + end end end local skip = _EntityService:GetEntityByPath("/ui/DefaultGroup/RewardHud/Skip") @@ -2934,6 +2944,11 @@ for i = 1, 3 do local sc = _EntityService:GetEntityByPath("/ui/DefaultGroup/ShopHud/Card" .. tostring(i)) if sc ~= nil and sc.ButtonComponent ~= nil then sc:ConnectEvent(ButtonClickEvent, function() self:BuyCard(i) end) + if sc.UITouchReceiveComponent ~= nil then + local cardPath = "/ui/DefaultGroup/ShopHud/Card" .. tostring(i) + sc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end) + sc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end) + end end end local shopLeave = _EntityService:GetEntityByPath("/ui/DefaultGroup/ShopHud/Leave") @@ -3214,6 +3229,9 @@ if c == nil then end local e = _EntityService:GetEntityByPath(base) if e ~= nil and e.SpriteGUIRendererComponent ~= nil then + if e.UITransformComponent ~= nil then + e.UITransformComponent.UIScale = Vector3(1, 1, 1) + end local frames = self.CardFrames[self.ClassToFrame[c.class] or "warrior"] local ruid = nil if frames ~= nil then @@ -3241,6 +3259,18 @@ end`, [ { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'base' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, ]), + method('SetCardHover', `local e = _EntityService:GetEntityByPath(path) +if e == nil or e.UITransformComponent == nil then + return +end +if hover == true and e.Enable == true then + e.UITransformComponent.UIScale = Vector3(1.12, 1.12, 1) +else + e.UITransformComponent.UIScale = Vector3(1, 1, 1) +end`, [ + { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'path' }, + { Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'hover' }, + ]), method('ApplyCardVisual', `self:ApplyCardFace("/ui/DefaultGroup/CardHand/Card" .. tostring(slot), cardId)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, diff --git a/ui/DefaultGroup.ui b/ui/DefaultGroup.ui index bb494ac..481c3a5 100644 --- a/ui/DefaultGroup.ui +++ b/ui/DefaultGroup.ui @@ -22768,7 +22768,7 @@ { "id": "0e700002-0000-4000-8000-00000e700002", "path": "/ui/DefaultGroup/RewardHud/Reward1", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Reward1", "path": "/ui/DefaultGroup/RewardHud/Reward1", @@ -22948,6 +22948,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1 @@ -23661,7 +23665,7 @@ { "id": "0e700009-0000-4000-8000-00000e700009", "path": "/ui/DefaultGroup/RewardHud/Reward2", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Reward2", "path": "/ui/DefaultGroup/RewardHud/Reward2", @@ -23841,6 +23845,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1 @@ -24554,7 +24562,7 @@ { "id": "0e700010-0000-4000-8000-00000e700010", "path": "/ui/DefaultGroup/RewardHud/Reward3", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Reward3", "path": "/ui/DefaultGroup/RewardHud/Reward3", @@ -24734,6 +24742,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1 @@ -64504,7 +64516,7 @@ { "id": "0e800003-0000-4000-8000-00000e800003", "path": "/ui/DefaultGroup/ShopHud/Card1", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Card1", "path": "/ui/DefaultGroup/ShopHud/Card1", @@ -64684,6 +64696,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1 @@ -65585,7 +65601,7 @@ { "id": "0e80000b-0000-4000-8000-00000e80000b", "path": "/ui/DefaultGroup/ShopHud/Card2", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Card2", "path": "/ui/DefaultGroup/ShopHud/Card2", @@ -65765,6 +65781,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1 @@ -66666,7 +66686,7 @@ { "id": "0e800013-0000-4000-8000-00000e800013", "path": "/ui/DefaultGroup/ShopHud/Card3", - "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent", + "componentNames": "MOD.Core.UITransformComponent,MOD.Core.SpriteGUIRendererComponent,MOD.Core.ButtonComponent,MOD.Core.UITouchReceiveComponent", "jsonString": { "name": "Card3", "path": "/ui/DefaultGroup/ShopHud/Card3", @@ -66846,6 +66866,10 @@ "OverrideSorting": false, "Transition": 1, "Enable": true + }, + { + "@type": "MOD.Core.UITouchReceiveComponent", + "Enable": true } ], "@version": 1