SCED Intro Tour, Part 3

Adds additional capabilities for tour cards:
- Option to specify exact position for the camera, rather than an object.  This will enable looking at items which are not their own objects, such as the draw chaos token button.
- Option to specify height for object look.  This acts as a camera zoom; we cannot control the zoom at all, much less when attached.  By controlling the height when we're looking at an object we simulate zoom.
- Right/Left narrator image.  This will flip the card so the narrator's image is on the right or left, adding some variety to the presentation.
- Cardinal points for card position.  In addition to just adding variety, this will allow the card to be placed closer to where you want it, including other Global XML elements.
This commit is contained in:
Buhallin 2022-12-18 22:20:42 -08:00
parent 0e3a66bfaa
commit 240a30f3bb
No known key found for this signature in database
GPG Key ID: DB3C362823852294
3 changed files with 85 additions and 22 deletions

View File

@ -7,7 +7,7 @@ tourCardTemplate = {
attributes = {
id = "tourCard",
height = 195,
width = 310,
width = 270,
rotation = "0 0 0",
position = "0 300 30",
showAnimation = "FadeIn",
@ -18,10 +18,23 @@ tourCardTemplate = {
{
tag = "Image",
attributes = {
id = "tourNarratorImage",
id = "tourNarratorImageLeft",
height=75,
width=50,
rectAlignment="UpperLeft"
rectAlignment="UpperLeft",
offsetXY = "-65 0",
-- Image will be set when the card is updated
}
},
{
tag = "Image",
attributes = {
id = "tourNarratorImageRight",
active = false,
height=75,
width=50,
rectAlignment="UpperRight",
offsetXY = "65 0"
-- Image will be set when the card is updated
}
},
@ -30,8 +43,8 @@ tourCardTemplate = {
attributes = {
color = "#F5F5DC",
height = 195,
width = 250,
rectAlignment = "UpperRight"
width = 270,
rectAlignment = "MiddleCenter"
},
children = {
{
@ -70,9 +83,9 @@ tourCardTemplate = {
height = 30,
width = 50,
color = "#FF0000",
rectAlignment = "LowerRight",
offsetXY = "-195 5",
rectAlignment = "LowerLeft",
offsetXY = "5 5",
}
}
},
}
}

View File

@ -6,7 +6,8 @@ do
-- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended
local CARD_ID = "tourCard"
local NARRATOR_ID = "tourNarratorImage"
local LEFT_NARRATOR_ID = "tourNarratorImageLeft"
local RIGHT_NARRATOR_ID = "tourNarratorImageRight"
local TEXT_ID = "tourText"
local NEXT_BUTTON_ID = "tourNext"
local STOP_BUTTON_ID = "tourStop"
@ -19,6 +20,19 @@ do
z = 0,
}
-- Global 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",
northwest = "-600 300 0",
northeast = "600 300 0",
southwest = "-600 -300 0",
southeast = "600 -300 0"
}
-- Tracks the current state of the tours. Keyed by player color to keep each player's tour
-- separate, will hold the camera hook and current card.
local tourState = { }
@ -84,10 +98,21 @@ do
hook.setPositionSmooth(CAMERA_HOME, false, false)
local delay = 0.5
local cardIndex = tourState[playerColor].currentCardIndex
local lookPos
if TOUR_SCRIPT[cardIndex].showObj ~= nil then
local lookAtObj = getObjectFromGUID(TOUR_SCRIPT[cardIndex].showObj)
lookPos = lookAtObj.getPosition()
lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0
-- Since camera isn't directly above the hook, changing the Y affects the visual position of
-- whatever object we're trying to look at. This is an approximation, but close enough to
-- keep the object more centered
lookPos.x = lookPos.x - lookPos.y / 2
elseif TOUR_SCRIPT[cardIndex].showPos ~= nil then
lookPos = TOUR_SCRIPT[cardIndex].showPos
end
if lookPos ~= nil then
Wait.time(function()
local lookAtObj = getObjectFromGUID(TOUR_SCRIPT[cardIndex].showObj)
hook.setPositionSmooth(lookAtObj.getPosition(), false, false)
hook.setPositionSmooth(lookPos, false, false)
end, delay)
delay = delay + 0.5
end
@ -121,8 +146,22 @@ do
---@param playerColor Player color to update card for
internal.updateCardDisplay = function(playerColor)
local index = tourState[playerColor].currentCardIndex
Global.UI.setAttribute(internal.getUiId(NARRATOR_ID, playerColor), "image", TOUR_SCRIPT[index].narrator)
Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "image", TOUR_SCRIPT[index].narrator)
Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), "image", 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])
-- Adjust images so the narrator is on the left or right, as defined by the card
if TOUR_SCRIPT[index].speakerSide == "right" then
Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "active", false)
Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), "active", true)
Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), "rotation", "0 180 0")
else
Global.UI.setAttribute(internal.getUiId(LEFT_NARRATOR_ID, playerColor), "active", true)
Global.UI.setAttribute(internal.getUiId(RIGHT_NARRATOR_ID, playerColor), "active", false)
Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), "rotation", "0 0 0")
end
end
-- Creates a small, transparent object which the camera will be attached to in order to move the
@ -179,12 +218,13 @@ do
return
end
tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor)
tourCardTemplate.children[1].attributes.id = internal.getUiId(NARRATOR_ID, playerColor)
tourCardTemplate.children[2].children[1].attributes.id = internal.getUiId(TEXT_ID, playerColor)
tourCardTemplate.children[3].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)
tourCardTemplate.children[3].attributes.onClick = self.getGUID().."/nextCard"
tourCardTemplate.children[4].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)
tourCardTemplate.children[4].attributes.onClick = self.getGUID().."/stopTour"
tourCardTemplate.children[1].attributes.id = internal.getUiId(LEFT_NARRATOR_ID, playerColor)
tourCardTemplate.children[2].attributes.id = internal.getUiId(RIGHT_NARRATOR_ID, playerColor)
tourCardTemplate.children[3].children[1].attributes.id = internal.getUiId(TEXT_ID, playerColor)
tourCardTemplate.children[4].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)
tourCardTemplate.children[4].attributes.onClick = self.getGUID().."/nextCard"
tourCardTemplate.children[5].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)
tourCardTemplate.children[5].attributes.onClick = self.getGUID().."/stopTour"
internal.setDeepVisibility(tourCardTemplate, playerColor)
local globalXml = Global.UI.getXmlTable()

View File

@ -3,18 +3,28 @@
TOUR_SCRIPT = {
{
narrator = "Roland",
text = "Despite my best efforts, looks like you found us. You may live to regret that.\n\nAs long as you're here though we might as well show you around. Ready to get started?",
text = "Despite my best efforts, looks like you found us. You may live to regret that. As long as you're here though we might as well show you around.\n\nUse the arrow to move forrward, and if the horrors get to be too much you can quit whenever you like. Ready to get started?",
position = "center"
},
{
narrator = "Mandy",
text = "If you're going to survive this, you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here.",
text = "To survive this, you'll need a deck. If it's safely hidden away on ArkhamDB I can look it up for you, and even find the newest version from the ID.",
showObj = "a28140",
showDist = 30
distanceFromObj = -10,
position = "west",
speakerSide = "right"
},
{
narrator = "Daniela",
text = "If you're like me and prefer the hands-on approach, you can build a deck yourself.\n\nThese containers have all the Level 0 cards for each class. Once you've had a run-in with the horrors lurking out there, you can find higher level cards to the right.",
showObj = "7e47e1",
showDist = 40
distanceFromObj = -10,
position = "center",
},
{
narrator = "Daniela",
text = "This is a position test.",
showPos = { x = -40.14, y = -10, z = 4.19 },
position = "south",
},
}