diff --git a/RootDesk/MyDesk/SlayDeckController.codeblock b/RootDesk/MyDesk/SlayDeckController.codeblock index ce2e63c..863157c 100644 --- a/RootDesk/MyDesk/SlayDeckController.codeblock +++ b/RootDesk/MyDesk/SlayDeckController.codeblock @@ -1268,7 +1268,7 @@ "Name": null }, "Arguments": [], - "Code": "local function grp(n)\n\tlocal g = _EntityService:GetEntityByPath(\"/ui/\" .. n)\n\tif g ~= nil then g:SetEnable(true) end\nend\ngrp(\"SelectUIGroup\")\ngrp(\"LobbyUIGroup\")\ngrp(\"RunUIGroup\")\ngrp(\"DeckUIGroup\")", + "Code": "local function enableGroup(name)\n\tlocal group = _EntityService:GetEntityByPath(\"/ui/\" .. name)\n\tif group ~= nil then group:SetEnable(true) end\nend\nenableGroup(\"SelectUIGroup\")\nenableGroup(\"LobbyUIGroup\")\nenableGroup(\"RunUIGroup\")\nenableGroup(\"DeckUIGroup\")", "Scope": 2, "ExecSpace": 2, "Attributes": [], @@ -1351,7 +1351,7 @@ "Name": null }, "Arguments": [], - "Code": "local s = self.SoulPoints or 0\nself:SetText(\"/ui/LobbyUIGroup/LobbyHud/SoulLabel\", \"영혼 \" .. string.format(\"%d\", s))\nself:SetText(\"/ui/LobbyUIGroup/SoulShopHud/Souls\", \"영혼 \" .. string.format(\"%d\", s))", + "Code": "local soulPoints = self.SoulPoints or 0\nself:SetText(\"/ui/LobbyUIGroup/LobbyHud/SoulLabel\", \"영혼 \" .. string.format(\"%d\", soulPoints))\nself:SetText(\"/ui/LobbyUIGroup/SoulShopHud/Souls\", \"영혼 \" .. string.format(\"%d\", soulPoints))", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1366,7 +1366,7 @@ "Name": null }, "Arguments": [], - "Code": "if self.LobbyBound == true then\n\treturn\nend\nself.LobbyBound = true\nlocal function bindClick(path, fn)\n\tlocal e = _EntityService:GetEntityByPath(path)\n\tif e ~= nil and (e.ButtonComponent ~= nil or e:AddComponent(\"ButtonComponent\") ~= nil) then\n\t\te:ConnectEvent(ButtonClickEvent, fn)\n\tend\nend\nbindClick(\"/ui/LobbyUIGroup/LobbyHud/AscMinus\", function() self:AdjustAscension(-1) end)\nbindClick(\"/ui/LobbyUIGroup/LobbyHud/AscPlus\", function() self:AdjustAscension(1) end)\nbindClick(\"/ui/LobbyUIGroup/BoardHud/Close\", function() self:CloseBoard() end)\nbindClick(\"/ui/LobbyUIGroup/SoulShopHud/Close\", function() self:CloseSoulShop() end)", + "Code": "if self.LobbyBound == true then\n\treturn\nend\nself.LobbyBound = true\nlocal function bindClick(path, handler)\n\tlocal entity = _EntityService:GetEntityByPath(path)\n\tif entity ~= nil and (entity.ButtonComponent ~= nil or entity:AddComponent(\"ButtonComponent\") ~= nil) then\n\t\tentity:ConnectEvent(ButtonClickEvent, handler)\n\tend\nend\nbindClick(\"/ui/LobbyUIGroup/LobbyHud/AscMinus\", function() self:AdjustAscension(-1) end)\nbindClick(\"/ui/LobbyUIGroup/LobbyHud/AscPlus\", function() self:AdjustAscension(1) end)\nbindClick(\"/ui/LobbyUIGroup/BoardHud/Close\", function() self:CloseBoard() end)\nbindClick(\"/ui/LobbyUIGroup/SoulShopHud/Close\", function() self:CloseSoulShop() end)", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1449,7 +1449,7 @@ "Name": null }, "Arguments": [], - "Code": "self.LobbyTpTries = 0\nlocal eventId = 0\nlocal function go()\n\tself.LobbyTpTries = self.LobbyTpTries + 1\n\tlocal lp = _UserService.LocalPlayer\n\tif lp ~= nil then\n\t\tif lp.CurrentMapName ~= \"lobby\" then\n\t\t\t_TeleportService:TeleportToMapPosition(lp, Vector3(-5, 0.03, 0), \"lobby\")\n\t\tend\n\t\t_TimerService:ClearTimer(eventId)\n\telseif self.LobbyTpTries > 50 then\n\t\t_TimerService:ClearTimer(eventId)\n\tend\nend\neventId = _TimerService:SetTimerRepeat(go, 0.1)", + "Code": "self.LobbyTpTries = 0\nlocal eventId = 0\nlocal function tryTeleport()\n\tself.LobbyTpTries = self.LobbyTpTries + 1\n\tlocal localPlayer = _UserService.LocalPlayer\n\tif localPlayer ~= nil then\n\t\tif localPlayer.CurrentMapName ~= \"lobby\" then\n\t\t\t_TeleportService:TeleportToMapPosition(localPlayer, Vector3(-5, 0.03, 0), \"lobby\")\n\t\tend\n\t\t_TimerService:ClearTimer(eventId)\n\telseif self.LobbyTpTries > 50 then\n\t\t_TimerService:ClearTimer(eventId)\n\tend\nend\neventId = _TimerService:SetTimerRepeat(tryTeleport, 0.1)", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -1464,7 +1464,7 @@ "Name": null }, "Arguments": [], - "Code": "local maps = { \"map01\", \"map02\", \"map03\", \"map04\", \"map05\" }\nlocal target = maps[self.Floor]\nif target == nil then\n\treturn\nend\nlocal lp = _UserService.LocalPlayer\nif lp == nil then\n\treturn\nend\nif lp.CurrentMapName == target then\n\treturn\nend\n_TeleportService:TeleportToMapPosition(lp, Vector3(-6, 0.03, 0), target)", + "Code": "local maps = { \"map01\", \"map02\", \"map03\", \"map04\", \"map05\" }\nlocal target = maps[self.Floor]\nif target == nil then\n\treturn\nend\nlocal localPlayer = _UserService.LocalPlayer\nif localPlayer == nil then\n\treturn\nend\nif localPlayer.CurrentMapName == target then\n\treturn\nend\n_TeleportService:TeleportToMapPosition(localPlayer, Vector3(-6, 0.03, 0), target)", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -4285,7 +4285,7 @@ "Name": "slot" } ], - "Code": "local m = self.Monsters[slot]\nif m == nil or m.entity == nil or not isvalid(m.entity) then\n\treturn\nend\nlocal tr = m.entity.TransformComponent\nif tr == nil then\n\treturn\nend\nlocal wp = tr.WorldPosition\nlocal screen = _UILogic:WorldToScreenPosition(Vector2(wp.x, wp.y + 1.4))\nlocal uipos = _UILogic:ScreenToUIPosition(screen)\nlocal e = _EntityService:GetEntityByPath(\"/ui/RunUIGroup/CombatHud/MonsterStatus\" .. tostring(slot))\nif e ~= nil and e.UITransformComponent ~= nil then\n\te.UITransformComponent.anchoredPosition = uipos\nend", + "Code": "local monster = self.Monsters[slot]\nif monster == nil or monster.entity == nil or not isvalid(monster.entity) then\n\treturn\nend\nlocal transform = monster.entity.TransformComponent\nif transform == nil then\n\treturn\nend\nlocal worldPos = transform.WorldPosition\nlocal screen = _UILogic:WorldToScreenPosition(Vector2(worldPos.x, worldPos.y + 1.4))\nlocal uipos = _UILogic:ScreenToUIPosition(screen)\nlocal slotEntity = _EntityService:GetEntityByPath(\"/ui/RunUIGroup/CombatHud/MonsterStatus\" .. tostring(slot))\nif slotEntity ~= nil and slotEntity.UITransformComponent ~= nil then\n\tslotEntity.UITransformComponent.anchoredPosition = uipos\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], diff --git a/tools/deck/cb/layout.mjs b/tools/deck/cb/layout.mjs index 7308ff6..dac0bbb 100644 --- a/tools/deck/cb/layout.mjs +++ b/tools/deck/cb/layout.mjs @@ -3,19 +3,19 @@ import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_ import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, DISABLED_STOCK_CONTROLS, TRANSPARENT, DARK, GOLD, ATTACK, DEFEND, SKILL, DAMAGE_DIGIT_RUIDS, DAMAGE_POP_MAX_DIGITS, DAMAGE_POP_DIGIT_W, DAMAGE_POP_DIGIT_H, DAMAGE_POP_DIGIT_SPACING, MAX_MONSTERS, HEAD_OFFSET_Y, HP_BAR_W, WHITE, CARD_NAME_TEXT, CARD_DESC_TEXT, cardFaceLayout, CARD_W, CARD_H, CARD_SPACING, CARD_XS, ALIGN_CENTER, ALIGN_BOTTOM_CENTER, guid, transform, sprite, button, text, scrollLayoutGroup, popupLayerFor, uiOrderFor, displayOrderFor, applySortingOverride, entity, uiPath, sectionRoot, isGeneratedUiEntity, appendUiSection } from '../lib/ui-helpers.mjs'; export const layoutMethods = [ - method('PositionMonsterSlot', `local m = self.Monsters[slot] -if m == nil or m.entity == nil or not isvalid(m.entity) then + method('PositionMonsterSlot', `local monster = self.Monsters[slot] +if monster == nil or monster.entity == nil or not isvalid(monster.entity) then return end -local tr = m.entity.TransformComponent -if tr == nil then +local transform = monster.entity.TransformComponent +if transform == nil then return end -local wp = tr.WorldPosition -local screen = _UILogic:WorldToScreenPosition(Vector2(wp.x, wp.y + ${HEAD_OFFSET_Y})) +local worldPos = transform.WorldPosition +local screen = _UILogic:WorldToScreenPosition(Vector2(worldPos.x, worldPos.y + ${HEAD_OFFSET_Y})) local uipos = _UILogic:ScreenToUIPosition(screen) -local e = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/MonsterStatus" .. tostring(slot)) -if e ~= nil and e.UITransformComponent ~= nil then - e.UITransformComponent.anchoredPosition = uipos +local slotEntity = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/MonsterStatus" .. tostring(slot)) +if slotEntity ~= nil and slotEntity.UITransformComponent ~= nil then + slotEntity.UITransformComponent.anchoredPosition = uipos end`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]), ]; diff --git a/tools/deck/cb/navigation.mjs b/tools/deck/cb/navigation.mjs index ca55d00..020d449 100644 --- a/tools/deck/cb/navigation.mjs +++ b/tools/deck/cb/navigation.mjs @@ -5,30 +5,30 @@ import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, export const navigationMethods = [ method('GoLobbyMap', `self.LobbyTpTries = 0 local eventId = 0 -local function go() +local function tryTeleport() self.LobbyTpTries = self.LobbyTpTries + 1 - local lp = _UserService.LocalPlayer - if lp ~= nil then - if lp.CurrentMapName ~= "${LOBBY_MAP}" then - _TeleportService:TeleportToMapPosition(lp, ${LOBBY_SPAWN}, "${LOBBY_MAP}") + local localPlayer = _UserService.LocalPlayer + if localPlayer ~= nil then + if localPlayer.CurrentMapName ~= "${LOBBY_MAP}" then + _TeleportService:TeleportToMapPosition(localPlayer, ${LOBBY_SPAWN}, "${LOBBY_MAP}") end _TimerService:ClearTimer(eventId) elseif self.LobbyTpTries > 50 then _TimerService:ClearTimer(eventId) end end -eventId = _TimerService:SetTimerRepeat(go, 0.1)`), - method('TeleportToActMap', `local maps = { ${ACT_MAPS.map((m) => `"${m}"`).join(', ')} } +eventId = _TimerService:SetTimerRepeat(tryTeleport, 0.1)`), + method('TeleportToActMap', `local maps = { ${ACT_MAPS.map((mapName) => `"${mapName}"`).join(', ')} } local target = maps[self.Floor] if target == nil then return end -local lp = _UserService.LocalPlayer -if lp == nil then +local localPlayer = _UserService.LocalPlayer +if localPlayer == nil then return end -if lp.CurrentMapName == target then +if localPlayer.CurrentMapName == target then return end -_TeleportService:TeleportToMapPosition(lp, Vector3(-6, 0.03, 0), target)`), +_TeleportService:TeleportToMapPosition(localPlayer, Vector3(-6, 0.03, 0), target)`), ]; diff --git a/tools/deck/cb/screens.mjs b/tools/deck/cb/screens.mjs index 02849df..7fe661c 100644 --- a/tools/deck/cb/screens.mjs +++ b/tools/deck/cb/screens.mjs @@ -1,174 +1,174 @@ -import { method, RUN_LENGTH, GOLD_PER_WIN, CARD_PRICE, REST_HEAL, RELIC_PRICE, ACT_COUNT, ACT_MAPS, LOBBY_MAP, LOBBY_SPAWN } from '../lib/codeblock.mjs'; -import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_ROWS, MAP_COLS, CHEST_CLOSED_RUID, CHEST_OPEN_RUID, NODEICONS, CHARS, CAM, RELICS, POTIONS, luaSoulShopTable, frameRuid, luaFramesTable, luaNodeIconsTable, luaRelicsTable, luaPotionsTable, luaIntentsArray, luaEnemiesTable, luaStr, luaJobsTable, luaCardsTable, luaDeckTable } from '../lib/data.mjs'; -import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, DISABLED_STOCK_CONTROLS, TRANSPARENT, DARK, GOLD, ATTACK, DEFEND, SKILL, DAMAGE_DIGIT_RUIDS, DAMAGE_POP_MAX_DIGITS, DAMAGE_POP_DIGIT_W, DAMAGE_POP_DIGIT_H, DAMAGE_POP_DIGIT_SPACING, MAX_MONSTERS, HEAD_OFFSET_Y, HP_BAR_W, WHITE, CARD_NAME_TEXT, CARD_DESC_TEXT, cardFaceLayout, CARD_W, CARD_H, CARD_SPACING, CARD_XS, ALIGN_CENTER, ALIGN_BOTTOM_CENTER, guid, transform, sprite, button, text, scrollLayoutGroup, popupLayerFor, uiOrderFor, displayOrderFor, applySortingOverride, entity, uiPath, sectionRoot, isGeneratedUiEntity, appendUiSection } from '../lib/ui-helpers.mjs'; - -export const screensMethods = [ - method('HideGameHud', `self:SetEntityEnabled("/ui/DefaultGroup/Button_Attack", false) -self:SetEntityEnabled("/ui/DefaultGroup/Button_Jump", false) -self:SetEntityEnabled("/ui/DefaultGroup/UIJoystick", false) -self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/CardHand", false) -self:SetEntityEnabled("/ui/RunUIGroup/CombatHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/RewardHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/MapHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/ShopHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/RestHud", false) -self:SetEntityEnabled("/ui/RunUIGroup/TreasureHud", false) -self:SetEntityEnabled("/ui/SelectUIGroup/JobChoiceHud", false) -self:SetEntityEnabled("/ui/SelectUIGroup/JobSelectHud", false) -self:SetEntityEnabled("/ui/DeckUIGroup/DeckInspectHud", false) -self:SetEntityEnabled("/ui/DeckUIGroup/DeckAllHud", false) -self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", false) -self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false) -self:SetEntityEnabled("/ui/LobbyUIGroup/SoulShopHud", false)`), - method('ActivateUIGroups', `local function grp(n) - local g = _EntityService:GetEntityByPath("/ui/" .. n) - if g ~= nil then g:SetEnable(true) end -end -grp("SelectUIGroup") -grp("LobbyUIGroup") -grp("RunUIGroup") -grp("DeckUIGroup")`, [], 2), - method('ShowState', `self:HideGameHud() -self:SetEntityEnabled("/ui/DefaultGroup/MainMenu", state == "menu") -self:SetEntityEnabled("/ui/SelectUIGroup/CharacterSelectHud", state == "charselect") -self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", state == "lobby") -if state == "map" then - self:SetEntityEnabled("/ui/RunUIGroup/MapHud", true) -elseif state == "combat" then - self:SetEntityEnabled("/ui/RunUIGroup/CombatHud", true) - self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", true) - self:SetEntityEnabled("/ui/RunUIGroup/CardHand", true) -elseif state == "shop" then - self:SetEntityEnabled("/ui/RunUIGroup/ShopHud", true) -elseif state == "rest" then - self:SetEntityEnabled("/ui/RunUIGroup/RestHud", true) -elseif state == "treasure" then - self:SetEntityEnabled("/ui/RunUIGroup/TreasureHud", true) -end`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'state' }]), - method('ShowMainMenu', `self.SelectedClass = "" -self:RenderAscension() -self:ShowState("menu") -self:SetText("/ui/DefaultGroup/MainMenu/Title", "메이플 덱 어드벤처") -self:SetText("/ui/DefaultGroup/MainMenu/Subtitle", "캐릭터를 고르고 덱을 만들어 모험을 시작하세요") -self:SetText("/ui/DefaultGroup/MainMenu/NewGameButton", "새 게임") -self:BindMenuButtons()`), - method('BindMenuButtons', `local buttonEntity = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/NewGameButton") -if buttonEntity ~= nil and (buttonEntity.ButtonComponent ~= nil or buttonEntity:AddComponent("ButtonComponent") ~= nil) then - if self.NewGameHandler ~= nil then - buttonEntity:DisconnectEvent(ButtonClickEvent, self.NewGameHandler) - self.NewGameHandler = nil - end - self.NewGameHandler = buttonEntity:ConnectEvent(ButtonClickEvent, function() self:ShowLobby() end) -end -local warrior = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/WarriorButton") -if warrior ~= nil and (warrior.ButtonComponent ~= nil or warrior:AddComponent("ButtonComponent") ~= nil) then - if self.WarriorSelectHandler ~= nil then - warrior:DisconnectEvent(ButtonClickEvent, self.WarriorSelectHandler) - self.WarriorSelectHandler = nil - end - self.WarriorSelectHandler = warrior:ConnectEvent(ButtonClickEvent, function() self:SelectClass("warrior") end) -end -local thief = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/BanditButton") -if thief ~= nil and (thief.ButtonComponent ~= nil or thief:AddComponent("ButtonComponent") ~= nil) then - if self.ThiefSelectHandler ~= nil then - thief:DisconnectEvent(ButtonClickEvent, self.ThiefSelectHandler) - self.ThiefSelectHandler = nil - end - self.ThiefSelectHandler = thief:ConnectEvent(ButtonClickEvent, function() self:SelectClass("bandit") end) -end -local mage = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/MageButton") -if mage ~= nil and (mage.ButtonComponent ~= nil or mage:AddComponent("ButtonComponent") ~= nil) then - if self.MageSelectHandler ~= nil then - mage:DisconnectEvent(ButtonClickEvent, self.MageSelectHandler) - self.MageSelectHandler = nil - end - self.MageSelectHandler = mage:ConnectEvent(ButtonClickEvent, function() self:SelectClass("magician") end) -end -local allDeckClose = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Close") -if allDeckClose ~= nil and (allDeckClose.ButtonComponent ~= nil or allDeckClose:AddComponent("ButtonComponent") ~= nil) then - if self.AllDeckCloseHandler ~= nil then - allDeckClose:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler) - self.AllDeckCloseHandler = nil - end - self.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end) -end -self:BindClassDeckTabs() -local start = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/StartButton") -if start ~= nil and (start.ButtonComponent ~= nil or start:AddComponent("ButtonComponent") ~= nil) then - if self.StartGameHandler ~= nil then - start:DisconnectEvent(ButtonClickEvent, self.StartGameHandler) - self.StartGameHandler = nil - end - self.StartGameHandler = start:ConnectEvent(ButtonClickEvent, function() self:StartNewGame() end) -end -local charBack = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/BackButton") -if charBack ~= nil and (charBack.ButtonComponent ~= nil or charBack:AddComponent("ButtonComponent") ~= nil) then - if self.CharBackHandler ~= nil then - charBack:DisconnectEvent(ButtonClickEvent, self.CharBackHandler) - self.CharBackHandler = nil - end - self.CharBackHandler = charBack:ConnectEvent(ButtonClickEvent, function() self:ShowLobby() end) -end -local ascMinus = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/AscMinus") -if ascMinus ~= nil and (ascMinus.ButtonComponent ~= nil or ascMinus:AddComponent("ButtonComponent") ~= nil) then - if self.AscMinusHandler ~= nil then - ascMinus:DisconnectEvent(ButtonClickEvent, self.AscMinusHandler) - self.AscMinusHandler = nil - end - self.AscMinusHandler = ascMinus:ConnectEvent(ButtonClickEvent, function() self:AdjustAscension(-1) end) -end -local ascPlus = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/AscPlus") -if ascPlus ~= nil and (ascPlus.ButtonComponent ~= nil or ascPlus:AddComponent("ButtonComponent") ~= nil) then - if self.AscPlusHandler ~= nil then - ascPlus:DisconnectEvent(ButtonClickEvent, self.AscPlusHandler) - self.AscPlusHandler = nil - end - self.AscPlusHandler = ascPlus:ConnectEvent(ButtonClickEvent, function() self:AdjustAscension(1) end) -end`), - method('ShowLobby', `self.SelectedClass = "" -self:RenderAscension() -self:RenderSoulLabel() -self:ShowState("lobby") -self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false) -self:SetEntityEnabled("/ui/LobbyUIGroup/SoulShopHud", false) -self:BindLobbyButtons() -self:BindMenuButtons() -self:GoLobbyMap()`), - method('RenderSoulLabel', `local s = self.SoulPoints or 0 -self:SetText("/ui/LobbyUIGroup/LobbyHud/SoulLabel", "영혼 " .. string.format("%d", s)) -self:SetText("/ui/LobbyUIGroup/SoulShopHud/Souls", "영혼 " .. string.format("%d", s))`), - method('BindLobbyButtons', `if self.LobbyBound == true then - return -end -self.LobbyBound = true -local function bindClick(path, fn) - local e = _EntityService:GetEntityByPath(path) - if e ~= nil and (e.ButtonComponent ~= nil or e:AddComponent("ButtonComponent") ~= nil) then - e:ConnectEvent(ButtonClickEvent, fn) - end -end -bindClick("/ui/LobbyUIGroup/LobbyHud/AscMinus", function() self:AdjustAscension(-1) end) -bindClick("/ui/LobbyUIGroup/LobbyHud/AscPlus", function() self:AdjustAscension(1) end) -bindClick("/ui/LobbyUIGroup/BoardHud/Close", function() self:CloseBoard() end) -bindClick("/ui/LobbyUIGroup/SoulShopHud/Close", function() self:CloseSoulShop() end)`), - method('ShowCodex', `self.CodexMode = true -self.ClassDeckMode = true -local close = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Close") -if close ~= nil and (close.ButtonComponent ~= nil or close:AddComponent("ButtonComponent") ~= nil) then - if self.AllDeckCloseHandler ~= nil then - close:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler) - end - self.AllDeckCloseHandler = close:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end) -end -self:BindClassDeckTabs() -self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", false) -self:SetClassDeckTab("warrior") -local hud = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud") -if hud ~= nil then - hud.Enable = true -end -self:RenderAllDeck()`), - method('ShowBoard', `self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", true)`), - method('CloseBoard', `self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false)`), -]; +import { method, RUN_LENGTH, GOLD_PER_WIN, CARD_PRICE, REST_HEAL, RELIC_PRICE, ACT_COUNT, ACT_MAPS, LOBBY_MAP, LOBBY_SPAWN } from '../lib/codeblock.mjs'; +import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_ROWS, MAP_COLS, CHEST_CLOSED_RUID, CHEST_OPEN_RUID, NODEICONS, CHARS, CAM, RELICS, POTIONS, luaSoulShopTable, frameRuid, luaFramesTable, luaNodeIconsTable, luaRelicsTable, luaPotionsTable, luaIntentsArray, luaEnemiesTable, luaStr, luaJobsTable, luaCardsTable, luaDeckTable } from '../lib/data.mjs'; +import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, DISABLED_STOCK_CONTROLS, TRANSPARENT, DARK, GOLD, ATTACK, DEFEND, SKILL, DAMAGE_DIGIT_RUIDS, DAMAGE_POP_MAX_DIGITS, DAMAGE_POP_DIGIT_W, DAMAGE_POP_DIGIT_H, DAMAGE_POP_DIGIT_SPACING, MAX_MONSTERS, HEAD_OFFSET_Y, HP_BAR_W, WHITE, CARD_NAME_TEXT, CARD_DESC_TEXT, cardFaceLayout, CARD_W, CARD_H, CARD_SPACING, CARD_XS, ALIGN_CENTER, ALIGN_BOTTOM_CENTER, guid, transform, sprite, button, text, scrollLayoutGroup, popupLayerFor, uiOrderFor, displayOrderFor, applySortingOverride, entity, uiPath, sectionRoot, isGeneratedUiEntity, appendUiSection } from '../lib/ui-helpers.mjs'; + +export const screensMethods = [ + method('HideGameHud', `self:SetEntityEnabled("/ui/DefaultGroup/Button_Attack", false) +self:SetEntityEnabled("/ui/DefaultGroup/Button_Jump", false) +self:SetEntityEnabled("/ui/DefaultGroup/UIJoystick", false) +self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/CardHand", false) +self:SetEntityEnabled("/ui/RunUIGroup/CombatHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/RewardHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/MapHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/ShopHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/RestHud", false) +self:SetEntityEnabled("/ui/RunUIGroup/TreasureHud", false) +self:SetEntityEnabled("/ui/SelectUIGroup/JobChoiceHud", false) +self:SetEntityEnabled("/ui/SelectUIGroup/JobSelectHud", false) +self:SetEntityEnabled("/ui/DeckUIGroup/DeckInspectHud", false) +self:SetEntityEnabled("/ui/DeckUIGroup/DeckAllHud", false) +self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", false) +self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false) +self:SetEntityEnabled("/ui/LobbyUIGroup/SoulShopHud", false)`), + method('ActivateUIGroups', `local function enableGroup(name) + local group = _EntityService:GetEntityByPath("/ui/" .. name) + if group ~= nil then group:SetEnable(true) end +end +enableGroup("SelectUIGroup") +enableGroup("LobbyUIGroup") +enableGroup("RunUIGroup") +enableGroup("DeckUIGroup")`, [], 2), + method('ShowState', `self:HideGameHud() +self:SetEntityEnabled("/ui/DefaultGroup/MainMenu", state == "menu") +self:SetEntityEnabled("/ui/SelectUIGroup/CharacterSelectHud", state == "charselect") +self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", state == "lobby") +if state == "map" then + self:SetEntityEnabled("/ui/RunUIGroup/MapHud", true) +elseif state == "combat" then + self:SetEntityEnabled("/ui/RunUIGroup/CombatHud", true) + self:SetEntityEnabled("/ui/RunUIGroup/DeckHud", true) + self:SetEntityEnabled("/ui/RunUIGroup/CardHand", true) +elseif state == "shop" then + self:SetEntityEnabled("/ui/RunUIGroup/ShopHud", true) +elseif state == "rest" then + self:SetEntityEnabled("/ui/RunUIGroup/RestHud", true) +elseif state == "treasure" then + self:SetEntityEnabled("/ui/RunUIGroup/TreasureHud", true) +end`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'state' }]), + method('ShowMainMenu', `self.SelectedClass = "" +self:RenderAscension() +self:ShowState("menu") +self:SetText("/ui/DefaultGroup/MainMenu/Title", "메이플 덱 어드벤처") +self:SetText("/ui/DefaultGroup/MainMenu/Subtitle", "캐릭터를 고르고 덱을 만들어 모험을 시작하세요") +self:SetText("/ui/DefaultGroup/MainMenu/NewGameButton", "새 게임") +self:BindMenuButtons()`), + method('BindMenuButtons', `local buttonEntity = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/NewGameButton") +if buttonEntity ~= nil and (buttonEntity.ButtonComponent ~= nil or buttonEntity:AddComponent("ButtonComponent") ~= nil) then + if self.NewGameHandler ~= nil then + buttonEntity:DisconnectEvent(ButtonClickEvent, self.NewGameHandler) + self.NewGameHandler = nil + end + self.NewGameHandler = buttonEntity:ConnectEvent(ButtonClickEvent, function() self:ShowLobby() end) +end +local warrior = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/WarriorButton") +if warrior ~= nil and (warrior.ButtonComponent ~= nil or warrior:AddComponent("ButtonComponent") ~= nil) then + if self.WarriorSelectHandler ~= nil then + warrior:DisconnectEvent(ButtonClickEvent, self.WarriorSelectHandler) + self.WarriorSelectHandler = nil + end + self.WarriorSelectHandler = warrior:ConnectEvent(ButtonClickEvent, function() self:SelectClass("warrior") end) +end +local thief = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/BanditButton") +if thief ~= nil and (thief.ButtonComponent ~= nil or thief:AddComponent("ButtonComponent") ~= nil) then + if self.ThiefSelectHandler ~= nil then + thief:DisconnectEvent(ButtonClickEvent, self.ThiefSelectHandler) + self.ThiefSelectHandler = nil + end + self.ThiefSelectHandler = thief:ConnectEvent(ButtonClickEvent, function() self:SelectClass("bandit") end) +end +local mage = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/MageButton") +if mage ~= nil and (mage.ButtonComponent ~= nil or mage:AddComponent("ButtonComponent") ~= nil) then + if self.MageSelectHandler ~= nil then + mage:DisconnectEvent(ButtonClickEvent, self.MageSelectHandler) + self.MageSelectHandler = nil + end + self.MageSelectHandler = mage:ConnectEvent(ButtonClickEvent, function() self:SelectClass("magician") end) +end +local allDeckClose = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Close") +if allDeckClose ~= nil and (allDeckClose.ButtonComponent ~= nil or allDeckClose:AddComponent("ButtonComponent") ~= nil) then + if self.AllDeckCloseHandler ~= nil then + allDeckClose:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler) + self.AllDeckCloseHandler = nil + end + self.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end) +end +self:BindClassDeckTabs() +local start = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/StartButton") +if start ~= nil and (start.ButtonComponent ~= nil or start:AddComponent("ButtonComponent") ~= nil) then + if self.StartGameHandler ~= nil then + start:DisconnectEvent(ButtonClickEvent, self.StartGameHandler) + self.StartGameHandler = nil + end + self.StartGameHandler = start:ConnectEvent(ButtonClickEvent, function() self:StartNewGame() end) +end +local charBack = _EntityService:GetEntityByPath("/ui/SelectUIGroup/CharacterSelectHud/BackButton") +if charBack ~= nil and (charBack.ButtonComponent ~= nil or charBack:AddComponent("ButtonComponent") ~= nil) then + if self.CharBackHandler ~= nil then + charBack:DisconnectEvent(ButtonClickEvent, self.CharBackHandler) + self.CharBackHandler = nil + end + self.CharBackHandler = charBack:ConnectEvent(ButtonClickEvent, function() self:ShowLobby() end) +end +local ascMinus = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/AscMinus") +if ascMinus ~= nil and (ascMinus.ButtonComponent ~= nil or ascMinus:AddComponent("ButtonComponent") ~= nil) then + if self.AscMinusHandler ~= nil then + ascMinus:DisconnectEvent(ButtonClickEvent, self.AscMinusHandler) + self.AscMinusHandler = nil + end + self.AscMinusHandler = ascMinus:ConnectEvent(ButtonClickEvent, function() self:AdjustAscension(-1) end) +end +local ascPlus = _EntityService:GetEntityByPath("/ui/DefaultGroup/MainMenu/AscPlus") +if ascPlus ~= nil and (ascPlus.ButtonComponent ~= nil or ascPlus:AddComponent("ButtonComponent") ~= nil) then + if self.AscPlusHandler ~= nil then + ascPlus:DisconnectEvent(ButtonClickEvent, self.AscPlusHandler) + self.AscPlusHandler = nil + end + self.AscPlusHandler = ascPlus:ConnectEvent(ButtonClickEvent, function() self:AdjustAscension(1) end) +end`), + method('ShowLobby', `self.SelectedClass = "" +self:RenderAscension() +self:RenderSoulLabel() +self:ShowState("lobby") +self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false) +self:SetEntityEnabled("/ui/LobbyUIGroup/SoulShopHud", false) +self:BindLobbyButtons() +self:BindMenuButtons() +self:GoLobbyMap()`), + method('RenderSoulLabel', `local soulPoints = self.SoulPoints or 0 +self:SetText("/ui/LobbyUIGroup/LobbyHud/SoulLabel", "영혼 " .. string.format("%d", soulPoints)) +self:SetText("/ui/LobbyUIGroup/SoulShopHud/Souls", "영혼 " .. string.format("%d", soulPoints))`), + method('BindLobbyButtons', `if self.LobbyBound == true then + return +end +self.LobbyBound = true +local function bindClick(path, handler) + local entity = _EntityService:GetEntityByPath(path) + if entity ~= nil and (entity.ButtonComponent ~= nil or entity:AddComponent("ButtonComponent") ~= nil) then + entity:ConnectEvent(ButtonClickEvent, handler) + end +end +bindClick("/ui/LobbyUIGroup/LobbyHud/AscMinus", function() self:AdjustAscension(-1) end) +bindClick("/ui/LobbyUIGroup/LobbyHud/AscPlus", function() self:AdjustAscension(1) end) +bindClick("/ui/LobbyUIGroup/BoardHud/Close", function() self:CloseBoard() end) +bindClick("/ui/LobbyUIGroup/SoulShopHud/Close", function() self:CloseSoulShop() end)`), + method('ShowCodex', `self.CodexMode = true +self.ClassDeckMode = true +local close = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Close") +if close ~= nil and (close.ButtonComponent ~= nil or close:AddComponent("ButtonComponent") ~= nil) then + if self.AllDeckCloseHandler ~= nil then + close:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler) + end + self.AllDeckCloseHandler = close:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end) +end +self:BindClassDeckTabs() +self:SetEntityEnabled("/ui/LobbyUIGroup/LobbyHud", false) +self:SetClassDeckTab("warrior") +local hud = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud") +if hud ~= nil then + hud.Enable = true +end +self:RenderAllDeck()`), + method('ShowBoard', `self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", true)`), + method('CloseBoard', `self:SetEntityEnabled("/ui/LobbyUIGroup/BoardHud", false)`), +];