|
|
|
|
@ -5,7 +5,7 @@ |
|
|
|
|
|
|
|
|
|
import { packedSize, packPixels, pad32, unpackPixels, BinaryReader } from "./helper"; |
|
|
|
|
import { type MonoFormatFile } from "./types"; |
|
|
|
|
import { ElementType, SectionType, type MonoFormatAnimation, type MonoFormatClippedText, type MonoFormatCustomFont, type MonoFormatElement, type MonoFormatElementsAlways, type MonoFormatElementsTimespan, type MonoFormatHScroll, type MonoFormatHScrollText, type MonoFormatImage2D, type MonoFormatLine, type MonoFormatPixelImage, type MonoFormatSection, type MonoFormatSectionFlags, type MonoFormatVScroll } from "./types"; |
|
|
|
|
import { ElementType, SectionType, type MonoFormatAnimation, type MonoFormatClippedText, type MonoFormatCurrentTime, type MonoFormatCustomFont, type MonoFormatElement, type MonoFormatElementsAlways, type MonoFormatElementsTimespan, type MonoFormatHScroll, type MonoFormatHScrollText, type MonoFormatImage2D, type MonoFormatLine, type MonoFormatPixelImage, type MonoFormatSection, type MonoFormatSectionFlags, type MonoFormatVScroll } from "./types"; |
|
|
|
|
|
|
|
|
|
// Magic 0xAF 0x7E 0x2B 0x63 read as uint32 LE
|
|
|
|
|
export const MONOFORMAT_MAGIC_HEADER = 0x632B7EAF; |
|
|
|
|
@ -116,6 +116,7 @@ export class MonoDisplayParser { |
|
|
|
|
case ElementType.Line: return this.#parseLine(r); |
|
|
|
|
case ElementType.ClippedText: return this.#parseClippedText(r, elementStart); |
|
|
|
|
case ElementType.HScrollText: return this.#parseHScrollText(r, elementStart); |
|
|
|
|
case ElementType.CurrentTime: return this.#parseCurrentTime(r); |
|
|
|
|
default: |
|
|
|
|
// Unknown element type - cannot safely skip without knowing size; stop parsing section elements
|
|
|
|
|
return null; |
|
|
|
|
@ -238,6 +239,28 @@ export class MonoDisplayParser { |
|
|
|
|
return { type: ElementType.ClippedText, xOffset, yOffset, width, height, fontIndex, text }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#parseCurrentTime(r: BinaryReader): MonoFormatCurrentTime { |
|
|
|
|
// Layout after type field (already consumed): 14 bytes, total element = 16 bytes (aligned)
|
|
|
|
|
const xOffset = r.readUint16(); |
|
|
|
|
const yOffset = r.readUint16(); |
|
|
|
|
const width = r.readUint16(); |
|
|
|
|
const height = r.readUint16(); |
|
|
|
|
const fontIndex = r.readUint16(); |
|
|
|
|
const utcOffsetMinutes = r.readInt16(); |
|
|
|
|
const flagsByte = r.readByte(); |
|
|
|
|
r.readByte(); // reserved
|
|
|
|
|
return { |
|
|
|
|
type: ElementType.CurrentTime, |
|
|
|
|
xOffset, yOffset, width, height, fontIndex, utcOffsetMinutes, |
|
|
|
|
flags: { |
|
|
|
|
clock12h: !!(flagsByte & 0x01), |
|
|
|
|
showHours: !!(flagsByte & 0x02), |
|
|
|
|
showMinutes: !!(flagsByte & 0x04), |
|
|
|
|
showSeconds: !!(flagsByte & 0x08), |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#parseHScrollText(r: BinaryReader, start: number): MonoFormatHScrollText { |
|
|
|
|
const xOffset = r.readUint16(); |
|
|
|
|
const yOffset = r.readUint16(); |
|
|
|
|
|