Is there a StringFromClipboard kind of function? And if not, is there a way to automatically activate the textbox of tv_requeststring?
Also, what is the best way to revert to the tool (brush/color/everything) (can george access the tool history?). I tried using tv_brushrestore (see code) but it's unclear to me how to use it correctly.
I'll probably figure it out if I keep bashing my head against the wall, but scripts like this possibly exist out there... I just can't find any.
Edit: updated the code. (again)
Code: Select all
// Variables
dialogueLayerName = "DIALOGUE"
dialogueLayerColor = 7
// Ask user to insert the dialogue
tv_ReadUserString "LukasSketchPanel" "Dialogue" ""
text_to_add = result
IF CMP(text_to_add, "0") // tv_ReadUserString returns 0 if it doesn't exist yet
text_to_add = ""
END
tv_ReqString "multiline" "Dialogue|"text_to_add
IF CMP(result, "Cancel") || CMP(result, "")
EXIT
END
text_to_add = result
tv_writeUserString "LukasSketchPanel" "Dialogue" text_to_add
text_to_add = "'"text_to_add"'"
text_to_add = Replace(text_to_add, "\n", "' '")
text_to_add = text_to_add" 'none'" // 'none' is always used as a terminator in the packed string
Rest = "" // remaining string
LineCount = 1 // Item count
Lines(0) = 0 // Array of lines
While CMP(Rest,"none") == 0
Parse text_to_add Line Rest
Lines(LineCount) = Line
text_to_add = Rest
LineCount = LineCount + 1
END
// Paste brush at center of screen
tv_ProjectInfo
PARSE result projectname ProjectWidth projectheight projectpixelaspect projectframerate projectfield projectprojectstartframe
// ----------------------------------------------------
// Remember settings to revert to after script finished
// ----------------------------------------------------
// Remember color
tv_GetAPen
PARSE result R G B A
// Remember paper
tv_paperinfo
OriginalPaper = result
parse result z paperHardness z paperInvert z paperSize z paperAngle z paperOffsetX z paperOffsetY z paperFlipX z paperFlipY z paperActive z paperName
// Remember shape (line etc)
tv_getactiveshape
OriginalActiveShape = result
// Remember brush
tv_restorebrush backup
OriginalBrush = result
// Remember tool (stamp mode)
tv_GetActiveTool
OriginalTool = result
// Remember layer
tv_LayerCurrentID
OriginalLayer = result
tv_LayerGetImage // Remember frame number
parse result OriginalFrame // original frame number
CharacterCount = 0
FOR i = 1 to LineCount-1
Line = Lines(i)
IF LEN(Line) > CharacterCount
CharacterCount = LEN(Line)
END
END
CharacterWidth = 2700
MinFontSize = 50
MaxFontSize = 120
CharacterWidth = 2700 // Font size for a 1-letter wide character
ReductionFactor = 375 // Reduction in font size for each additional character
FontSize = CharacterWidth - (CharacterCount - 1) * ReductionFactor
CharacterPx = 60
FontSize = ProjectWidth/(CharacterCount * CharacterPx)*100
IF FontSize < MinFontSize
//FontSize = MinFontSize //65 characters is te lang in dit geval op 1920w
END
IF FontSize > MaxFontSize
FontSize = MaxFontSize
END
// Loop backwards trough layers to find DIALOGUE layer:
layerRun = 1
layerPos = 0
WHILE layerRun
tv_LayerGetID layerPos
lid = result
IF CMP(lid,"NONE") == 0
// Start run on layer
tv_LayerInfo lid
PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable layerSelection
IF CMP(layerName, dialogueLayerName) == 1
tv_layerSet lid
layerRun = 0
END
// End run on layer
layerPos = layerPos + 1
ELSE
// Create or go to the dialogue layer
tv_LayerCreate dialogueLayerName
DialogueLayerID = result
tv_layercolor "set" 0 dialogueLayerColor
tv_LayerMove 0 // Move the dialogue layer to top
tv_layershift DialogueLayerID OriginalFrame
layerRun = 0
END
END
// Set text tool:
fontName = "Consolas"
resetVal = 1 // * 1 = true
letterVal = 0 // * 0 = Word
borderSize = 5
borderR = 255
borderG = 255
borderB = 255
stepVal = 9999999 // * Super big step so word is only drawn once
tv_textTool reset resetVal letter letterVal text text font fontName size FontSize border borderSize border_col borderR borderG borderB step stepVal
// Set text color:
textColR = 0
textColG = 150
textColB = 255
tv_SetAPen textColR textColG textColB
// Clear frame of dialogue layer
tv_layeranim
currentFrame = tv_projectcurrentframe
tv_exposurebreak currentFrame
tv_Clear 0
x = projectwidth / 2
y = FontSize * 1.5
FOR i = 1 to LineCount-1 // loop to display elements which are now in an array
Line = Lines(i)
tv_TextTool text '"'Line'"'
button = 0 // left mouse button
tv_Dot x y button
y = y + FontSize
END
// Revert layer (Disabled)
//tv_layerSet OriginalLayer
// Revert brush
tv_brushrestore OriginalBrush
// Revert tool
tv_cmd OriginalTool
// Revert shape mode
tv_SetActiveShape OriginalActiveShape
// Revert A color
tv_SetAPen R" "G" "B" "A // Reset A pen color to start color
// Revert Paper
tv_paper "active" paperActive "offsetx" paperOffsetX "offsety" paperOffsetY "flipx" paperFlipX "flipy" paperFlipY "hardness" paperHardness "invert" paperInvert "size" paperSize "angle" paperAngle "name" paperName
// Include
#INCLUDE "Include.grg"