mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
TAV: subtitle font handling
This commit is contained in:
@@ -76,6 +76,8 @@ let gui = require("playgui")
|
||||
let seqread = undefined
|
||||
let fullFilePathStr = fullFilePath.full
|
||||
|
||||
let fontUploaded = false
|
||||
|
||||
// Select seqread driver to use
|
||||
if (fullFilePathStr.startsWith('$:/TAPE') || fullFilePathStr.startsWith('$:\\TAPE')) {
|
||||
seqread = require("seqreadtape")
|
||||
@@ -133,7 +135,7 @@ function processSubtitlePacket(packetSize) {
|
||||
sys.free(textBytes)
|
||||
subtitleText = textStr
|
||||
subtitleVisible = true
|
||||
gui.displaySubtitle(subtitleText, subtitlePosition)
|
||||
gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -156,7 +158,7 @@ function processSubtitlePacket(packetSize) {
|
||||
// Re-display current subtitle at new position if visible
|
||||
if (subtitleVisible && subtitleText.length > 0) {
|
||||
gui.clearSubtitleArea()
|
||||
gui.displaySubtitle(subtitleText, subtitlePosition)
|
||||
gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,6 +182,8 @@ function processSubtitlePacket(packetSize) {
|
||||
|
||||
sys.free(fontData)
|
||||
}
|
||||
|
||||
fontUploaded = true
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ function getVisualLength(line) {
|
||||
return unicode.visualStrlen(withoutTags)
|
||||
}
|
||||
|
||||
function displayFormattedLine(line) {
|
||||
function displayFormattedLine(line, useUnicode) {
|
||||
// Parse line and handle <b> and <i> tags with colour changes
|
||||
// Default subtitle colour: yellow (231), formatted text: white (254)
|
||||
|
||||
@@ -38,7 +38,7 @@ function displayFormattedLine(line) {
|
||||
// Helper function to flush the buffer
|
||||
function flushBuffer() {
|
||||
if (buffer.length > 0) {
|
||||
unicode.print(buffer)
|
||||
useUnicode ? unicode.print(buffer) : print(buffer)
|
||||
buffer = ""
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function displayFormattedLine(line) {
|
||||
con.color_pair(231, 0)
|
||||
}
|
||||
|
||||
function displaySubtitle(text, position = 0) {
|
||||
function displaySubtitle(text, useUnicode = false, position = 0) {
|
||||
if (!text || text.length === 0) {
|
||||
clearSubtitleArea()
|
||||
return
|
||||
@@ -156,7 +156,7 @@ function displaySubtitle(text, position = 0) {
|
||||
con.move(row, startCol)
|
||||
|
||||
// Parse and display line with formatting tag support
|
||||
displayFormattedLine(line)
|
||||
displayFormattedLine(line, useUnicode)
|
||||
}
|
||||
|
||||
con.color_pair(oldFgColour, oldBgColour)
|
||||
|
||||
Reference in New Issue
Block a user