Merge branch 'main' into optionpanel-4

This commit is contained in:
Chr1Z 2022-12-22 01:44:49 +01:00 committed by GitHub
commit 7561b837ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 79 deletions

View File

@ -93,5 +93,25 @@
"Name": "option_off",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2024962321889555661/6643E5CC9160FF4624672C255D0DF7B313DA00A5/"
},
{
"Name": "SpeechBubble",
"Type": 0,
"URL": "https://i.imgur.com/6MReiEO.png"
},
{
"Name": "Roland",
"Type": 0,
"URL": "https://i.imgur.com/lx6unDY.png"
},
{
"Name": "NextArrow",
"Type": 0,
"URL": "https://i.imgur.com/gXRiKmu.png"
},
{
"Name": "Exit",
"Type": 0,
"URL": "https://i.imgur.com/i0VMjPD.png"
}
]

View File

@ -38,15 +38,8 @@ customizationRowsWithFields["09101"].inputMap[1] = 1
customizationRowsWithFields["09101"].inputMap[2] = 2
customizationRowsWithFields["09101"].inputMap[3] = 3
local function fixUtf16String(str)
return str:gsub("\\u(%w%w%w%w)", function(match)
return string.char(tonumber(match, 16))
end)
end
function onLoad(script_state)
local state = JSON.decode(script_state)
initializeUi(state)
initializeUi(JSON.decode(script_state))
math.randomseed(os.time())
arkhamDb.initialize()
end
@ -55,8 +48,8 @@ function onSave() return JSON.encode(getUiState()) end
-- Returns the zone name where the specified card should be placed, based on its metadata.
---@param cardMetadata Table of card metadata.
---@return Zone name such as "Deck", "SetAside1", etc. See Zones object documentation for a list of
--- valid zones.
---@return Zone String Name of the zone such as "Deck", "SetAside1", etc.
-- See Zones object documentation for a list of valid zones.
function getDefaultCardZone(cardMetadata, bondedList)
if (cardMetadata.id == "09080-m") then -- Have to check the Servitor before other minicards
return "SetAside6"
@ -96,15 +89,15 @@ end
-- This is a callback function which handles the results of ArkhamDb.getDecklist()
-- This method uses an encapsulated coroutine with yields to make the card spawning cleaner.
--
---@param slots Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,
--- and count is the number which should be spawned
---@param slots Table Key-Value table of cardId:count. cardId is the ArkhamDB ID of the card to spawn,
-- and count is the number which should be spawned
---@param investigatorId String ArkhamDB ID (code) for this deck's investigator.
-- Investigator cards should already be added to the slots list if they
-- should be spawned, but this value is separate to check for special
-- handling for certain investigators
---@param bondedList A table of cardID keys to meaningless values. Card IDs in this list were added
--- from a parent bonded card.
---@param customizations ArkhamDB data for customizations on customizable cards
---@param bondedList Table A table of cardID keys to meaningless values. Card IDs in this list were added
-- from a parent bonded card.
---@param customizations String ArkhamDB data for customizations on customizable cards
---@param playerColor String Color name of the player mat to place this deck on (e.g. "Red")
function loadCards(slots, investigatorId, bondedList, customizations, playerColor)
function coinside()
@ -180,8 +173,8 @@ end
-- Callback handler for the main deck spawning. Looks for cards which should start in hand, and
-- draws them for the appropriate player.
-- @param deck Callback-provided spawned deck object
-- @param playerColor Color of the player to draw the cards to
---@param deck Object Callback-provided spawned deck object
---@param playerColor String Color of the player to draw the cards to
function deckSpawned(deck, playerColor)
local handPos = Player[playerColor].getHandTransform(1).position -- Only one hand zone per player
local deckCards = deck.getData().ContainedObjects
@ -196,8 +189,8 @@ end
-- Conver the Raven Quill's selections from card IDs to card names. This could be more elegant
-- but the inputs are very static so we're using some brute force.
-- @param An ArkhamDB string indicating the customization selections for The Raven's Quill. Should
-- be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)
---@param selectionString String provided by ArkhamDB, indicates the customization selections
-- Should be either a single card ID or two separated by a ^ (e.g. XXXXX^YYYYY)
function convertRavenQuillSelections(selectionString)
if (string.len(selectionString) == 5) then
return getCardName(selectionString)
@ -238,7 +231,7 @@ function buildZoneLists(cards)
end
-- Check to see if the deck list has Ancestral Knowledge. If it does, move 5 random skills to SetAside3
---@param cardList Deck list being created
---@param cardList Table Deck list being created
function handleAncestralKnowledge(cardList)
local hasAncestralKnowledge = false
local skillList = {}
@ -264,8 +257,8 @@ function handleAncestralKnowledge(cardList)
end
-- Check for and handle Underworld Market by moving all Illicit cards to UnderSetAside3
---@param cardList Deck list being created
---@param playerColor Color this deck is being loaded for
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
function handleUnderworldMarket(cardList, playerColor)
local hasMarket = false
local illicitList = {}
@ -313,10 +306,10 @@ end
-- If the investigator is Joe Diamond, extract all Insight events to SetAside5 to build the Hunch
-- Deck.
---@param investigatorId ID for the deck's investigator card. Passed separately because the
---@param investigatorId String ID for the deck's investigator card. Passed separately because the
--- investigator may not be included in the cardList
---@param cardList Deck list being created
---@param playerColor Color this deck is being loaded for
---@param cardList Table Deck list being created
---@param playerColor String Color this deck is being loaded for
function handleHunchDeck(investigatorId, cardList, playerColor)
if investigatorId == "05002" then -- Joe Diamond
local insightList = {}
@ -353,8 +346,8 @@ end
-- For any customization upgrade cards in the card list, process the metadata from the deck to
-- set the save state to show the correct checkboxes/text field values
---@param cardList Deck list being created
---@param customizations Deck's meta table, extracted from ArkhamDB's deck structure
---@param cardList Table Deck list being created
---@param customizations Table Deck's meta table, extracted from ArkhamDB's deck structure
function handleCustomizableUpgrades(cardList, customizations)
for _, card in ipairs(cardList) do
if card.metadata.type == "UpgradeSheet" then

View File

@ -7,7 +7,7 @@ tourCardTemplate = {
attributes = {
id = "tourCard",
height = 195,
width = 270,
width = 300,
rotation = "0 0 0",
position = "0 300 30",
showAnimation = "FadeIn",
@ -22,7 +22,7 @@ tourCardTemplate = {
height=75,
width=50,
rectAlignment="UpperLeft",
offsetXY = "-65 0",
offsetXY = "-50 0",
-- Image will be set when the card is updated
}
},
@ -34,57 +34,57 @@ tourCardTemplate = {
height=75,
width=50,
rectAlignment="UpperRight",
offsetXY = "65 0"
offsetXY = "50 0"
-- Image will be set when the card is updated
}
},
{
tag = "Panel",
tag = "Image",
attributes = {
id = "tourSpeechBubble",
color = "#F5F5DC",
height = 195,
width = 270,
rectAlignment = "MiddleCenter"
},
children = {
{
tag = "Text",
attributes = {
id = "tourText",
height = 150,
width = 230,
rectAlignment = "UpperCenter",
offsetXY = "0 -10",
resizeTextForBestFit = true,
resizeTextMinSize = 10,
resizeTextMaxSize = 16,
color = "#050505",
alignment = "UpperLeft",
horizontalOverflow = "wrap",
}
}
width = 300,
rectAlignment = "MiddleCenter",
image = "SpeechBubble",
},
},
{
tag = "Text",
attributes = {
id = "tourText",
height = 150,
width = 230,
rectAlignment = "UpperCenter",
offsetXY = "15 -15",
resizeTextForBestFit = true,
resizeTextMinSize = 10,
resizeTextMaxSize = 16,
color = "#050505",
alignment = "UpperLeft",
horizontalOverflow = "wrap",
}
},
{
tag = "Button",
attributes = {
id = "tourNext",
height = 30,
width = 50,
color = "#FF0000",
height = 40,
width = 40,
rectAlignment = "LowerRight",
offsetXY = "-5 5",
offsetXY = "-5 -45",
image = "NextArrow"
},
},
{
tag = "Button",
attributes = {
id = "tourStop",
height = 30,
width = 50,
color = "#FF0000",
height = 40,
width = 40,
rectAlignment = "LowerLeft",
offsetXY = "5 5",
offsetXY = "35 -45",
image = "Exit"
}
},
}

View File

@ -8,18 +8,27 @@ do
local CARD_ID = "tourCard"
local LEFT_NARRATOR_ID = "tourNarratorImageLeft"
local RIGHT_NARRATOR_ID = "tourNarratorImageRight"
local BUBBLE_ID = "tourSpeechBubble"
local TEXT_ID = "tourText"
local NEXT_BUTTON_ID = "tourNext"
local STOP_BUTTON_ID = "tourStop"
-- Table centerpoint for the camera hook object. Camera handling is a bit erratic so it doesn't
-- always land right where you think it's going to, but it's close
local CAMERA_HOME = {
local HOOK_CAMERA_HOME = {
x = -30.2,
y = 60,
z = 0,
}
-- Default (0) position for the camera, as defined in the mod. If we don't recreate this position
-- EXACTLY when exiting the tour then camera controls get weird
local DEFAULT_CAMERA_POS = {
position = { x = -22.265, y = -2.5, z = 5.2575},
pitch=64.343,
yaw=90.333,
distance=104.7}
-- Global XML coordinates where we can present a card
local SCREEN_POSITIONS = {
center = "0 0 0",
@ -46,9 +55,16 @@ do
}
-- 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 2 sec seems to handle it
-- the movement is done, but the delay seems to handle it
Player[playerColor].setCameraMode("ThirdPerson")
Player[playerColor].lookAt({position={-22.265,-2.5,5.2575},pitch=64.343,yaw=90.333,distance=104.7})
Player[playerColor].lookAt(DEFAULT_CAMERA_POS)
-- Initial camera rotation is painfully slow. White and Orange players are likely oriented
-- correctly, but need a longer start delay for Green and Red
local delay = 0.5
if playerColor ~= "White" and playerColor ~= "Orange" then
delay = 2
broadcastToColor("Starting the tour, please wait...", playerColor)
end
Wait.time(function()
internal.createTourCard(playerColor)
-- XML update to add the new card takes a few frames to load, wait for it to finish then
@ -61,7 +77,7 @@ do
return not Global.UI.loading
end
)
end, 2)
end, delay)
end
-- Shows the next card in the tour script. This method is exposed (rather than being part of
@ -95,7 +111,7 @@ do
internal.showCurrentCard = function(playerColor)
internal.updateCardDisplay(playerColor)
local hook = getObjectFromGUID(tourState[playerColor].cameraHookGuid)
hook.setPositionSmooth(CAMERA_HOME, false, false)
hook.setPositionSmooth(HOOK_CAMERA_HOME, false, false)
local delay = 0.5
local cardIndex = tourState[playerColor].currentCardIndex
local lookPos
@ -136,13 +152,11 @@ do
Player[playerColor].setCameraMode("ThirdPerson")
tourState[playerColor] = nil
Wait.frames(function()
-- This resets to the default camera position. If we don't place the camera exactly at the
-- default, camera controls get weird
Player[playerColor].lookAt({position={-22.265,-2.5,5.2575},pitch=64.343,yaw=90.333,distance=104.7})
Player[playerColor].lookAt(DEFAULT_CAMERA_POS)
end, 3)
end
-- Updates the card UI to show the appropriate narrator and text.
-- Updates the card UI to show the appropriate card configuration.
---@param playerColor Player color to update card for
internal.updateCardDisplay = function(playerColor)
local index = tourState[playerColor].currentCardIndex
@ -156,11 +170,17 @@ do
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")
Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), "rotation", "0 180 0")
Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), "offsetXY", "-15 -15")
Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), "offsetXY", "-35 -45")
Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), "offsetXY", "5 -45")
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")
Global.UI.setAttribute(internal.getUiId(BUBBLE_ID, playerColor), "rotation", "0 0 0")
Global.UI.setAttribute(internal.getUiId(TEXT_ID, playerColor), "offsetXY", "15 -15")
Global.UI.setAttribute(internal.getUiId(NEXT_BUTTON_ID, playerColor), "offsetXY", "-5 -45")
Global.UI.setAttribute(internal.getUiId(STOP_BUTTON_ID, playerColor), "offsetXY", "35 -45")
end
end
@ -173,9 +193,9 @@ do
local hookData = {
Name = "BlockSquare",
Transform = {
posX = CAMERA_HOME.x,
posY = CAMERA_HOME.y,
posZ = CAMERA_HOME.z,
posX = HOOK_CAMERA_HOME.x,
posY = HOOK_CAMERA_HOME.y,
posZ = HOOK_CAMERA_HOME.z,
rotX = 0,
rotY = 270.0,
rotZ = 0,
@ -220,11 +240,12 @@ do
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)
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"
tourCardTemplate.children[3].attributes.id = internal.getUiId(BUBBLE_ID, playerColor)
tourCardTemplate.children[4].attributes.id = internal.getUiId(TEXT_ID, playerColor)
tourCardTemplate.children[5].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)
tourCardTemplate.children[5].attributes.onClick = self.getGUID().."/nextCard"
tourCardTemplate.children[6].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)
tourCardTemplate.children[6].attributes.onClick = self.getGUID().."/stopTour"
internal.setDeepVisibility(tourCardTemplate, playerColor)
local globalXml = Global.UI.getXmlTable()

View File

@ -3,7 +3,7 @@
TOUR_SCRIPT = {
{
narrator = "Roland",
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?",
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 forward, and if the horrors get to be too much you can quit whenever you like. Ready to get started?",
position = "center"
},
{