From e7db256d46b584b2e3ee3e750cd396ab6e86f628 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Sep 2024 18:15:04 +0200 Subject: [PATCH] updated tour positioning --- src/core/tour/TourCard.ttslua | 6 +++--- src/core/tour/TourManager.ttslua | 32 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/core/tour/TourCard.ttslua b/src/core/tour/TourCard.ttslua index 00cc0f23..1def873f 100644 --- a/src/core/tour/TourCard.ttslua +++ b/src/core/tour/TourCard.ttslua @@ -1,4 +1,4 @@ --- Table definition for the tour card layout. This is functionally XMLUI in Lua form, but using +-- Table definition for the tour card layout. This is functionally XMLUI in Lua form, but using -- this for dynamic creation ensures we can handle any player color without needing 10 -- near-duplicate definitions in Global.xml @@ -8,8 +8,8 @@ tourCardTemplate = { id = "tourCard", height = 215, width = 330, - rotation = "0 0 0", - position = "0 300 30", + anchorMin = "0.3 0.75", + anchorMax = "0.3 0.75", showAnimation = "FadeIn", hideAnimation = "FadeOut", active = false diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index 5b7c4f80..fc85a94f 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -31,22 +31,23 @@ do distance = 104 } - -- Global XML coordinates where we can present a card + -- relative XML coordinates where we can present a card local SCREEN_POSITIONS = { - center = "0 0 0", - north = "0 300 0", - east = "600 0 0", - west = "-600 0 0", - south = "0 -300 0", + -- Center is intentionally slightly above the center + center = "0.5 0.6", + north = "0.5 0.75", + east = "0.75 0.5", + west = "0.25 0.5", + south = "0.5 0.25", -- Northwest is only used by the Mandy card, move it a little right than standard so it's -- closer to the importer - northwest = "-500 300 0", - northeast = "600 300 0", - southwest = "-600 -300 0", + northwest = "0.3 0.75", + northeast = "0.75 0.75", + southwest = "0.25 0.25", -- Used by the cards referencing the bottom-right panel, moved a little closer to them - southeast = "675 -365 0" + southeast = "0.875 0.175" } -- Tracks the current state of the tours. Keyed by player color to keep each player's tour @@ -57,9 +58,8 @@ do -- will then show the first card. ---@param playerColor string Player color to start the tour for TourManager.startTour = function(playerColor) - tourState[playerColor] = { - currentCardIndex = 1 - } + tourState[playerColor] = { currentCardIndex = 1 } + -- Camera gets really screwy when we finalize if we don't start settled in ThirdPerson at the -- default position before attaching to the hook. Unfortunately there are no callbacks for when -- the movement is done, but the delay seems to handle it @@ -175,8 +175,10 @@ do Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "image", "Inv-" .. TOUR_SCRIPT[index].narrator) Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), "image", "Inv-" .. TOUR_SCRIPT[index].narrator) Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), "text", "\"" .. TOUR_SCRIPT[index].text .. "\"") + local cardPos = TOUR_SCRIPT[index].position or "north" - Global.UI.setAttribute(internal.getUiId(CARD_ID, playerColor), "position", SCREEN_POSITIONS[cardPos]) + Global.UI.setAttribute(internal.getUiId(CARD_ID, playerColor), "anchorMin", SCREEN_POSITIONS[cardPos]) + Global.UI.setAttribute(internal.getUiId(CARD_ID, playerColor), "anchorMax", SCREEN_POSITIONS[cardPos]) Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), "active", index < #TOUR_SCRIPT) -- Adjust images so the narrator is on the left or right, as defined by the card @@ -247,7 +249,7 @@ do internal.createTourCard = function(playerColor) -- Make sure the card doesn't exist before we create a new one if Global.UI.getAttributes(internal.getUiId(CARD_ID, playerColor)) ~= nil then return end - + tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor) tourCardTemplate.children[1].attributes.id = internal.getUiId(LEFT_NARRATOR_ID, playerColor) tourCardTemplate.children[2].attributes.id = internal.getUiId(RIGHT_NARRATOR_ID, playerColor)