diff --git a/packages/frontend/src/components/SkModPlayer.vue b/packages/frontend/src/components/SkModPlayer.vue index df4e6cf3ea..1f29365370 100644 --- a/packages/frontend/src/components/SkModPlayer.vue +++ b/packages/frontend/src/components/SkModPlayer.vue @@ -126,29 +126,27 @@ class CanvasDisplay { const isSensitive = props.module.isSensitive; const url = props.module.url; let hide = ref((prefer.s.nsfw === 'force') ? true : isSensitive && (prefer.s.nsfw !== 'ignore')); -// Goto display function and set the default value there on the first frame. -// Yes, this is my solution to a problem. That or have a constant kicking round doing nothing of note. -let patternHide = ref(false); -let playing = ref(false); -let sliceDisplay = ref(); -let numberRowCanvas = ref(); -let sliceCanvas1 = ref(); -let sliceCanvas2 = ref(); -let sliceCanvas3 = ref(); -let sliceBackground1 = ref(); -let sliceBackground2 = ref(); -let sliceBackground3 = ref(); -let numberRowParent = ref(); -const displayHeight = ref(ROW_BUFFER * CHAR_HEIGHT); -const numberRowOffset = ref(HALF_BUFFER * CHAR_HEIGHT); +const patternHide = ref(true); +const playing = ref(false); +const sliceDisplay = ref(); +const numberRowCanvas = ref(); +const numberRowParent = ref(); +const sliceCanvas1 = ref(); +const sliceCanvas2 = ref(); +const sliceCanvas3 = ref(); +const sliceBackground1 = ref(); +const sliceBackground2 = ref(); +const sliceBackground3 = ref(); +const displayHeight = ref(ROW_BUFFER * CHAR_HEIGHT); +const numberRowOffset = ref(HALF_BUFFER * CHAR_HEIGHT); +const progress = ref(); +const position = ref(0); +const patternScrollSlider = ref(); +const patternScrollSliderShow = ref(false); +const patternScrollSliderPos = ref(0); +const patternDisplay = ref(); let sliceWidth = 0; let sliceHeight = 0; -let progress = ref(); -let position = ref(0); -let patternScrollSlider = ref(); -let patternScrollSliderShow = ref(false); -let patternScrollSliderPos = ref(0); -let patternDisplay = ref(); const player = ref(new ChiptuneJsPlayer(new ChiptuneJsConfig())); let nbChannels = 0; @@ -165,23 +163,24 @@ let slices: CanvasDisplay[] = []; let numberRowPHTML: HTMLSpanElement; function bakeNumberRow() { - if (!numberRowCanvas.value && !numberRowParent.value) return; - numberRowCanvas.value.width = NUMBER_ROW_WIDTH; - numberRowCanvas.value.height = MAX_ROW_NUMBERS * CHAR_HEIGHT + 1; - numberRowPHTML = numberRowParent.value; - let ctx = numberRowCanvas.value.getContext('2d', { alpha: false }) as OffscreenCanvasRenderingContext2D; - ctx.font = '10px monospace'; - ctx.fillStyle = colours.background; - ctx.fillRect( 0, 0, numberRowCanvas.value.width, numberRowCanvas.value.height ); + if (numberRowCanvas.value && numberRowParent.value) { + numberRowCanvas.value.width = NUMBER_ROW_WIDTH; + numberRowCanvas.value.height = MAX_ROW_NUMBERS * CHAR_HEIGHT + 1; + numberRowPHTML = numberRowParent.value; + let ctx = numberRowCanvas.value.getContext('2d', { alpha: false }) as CanvasRenderingContext2D; + ctx.font = '10px monospace'; + ctx.fillStyle = colours.background; + ctx.fillRect( 0, 0, numberRowCanvas.value.width, numberRowCanvas.value.height ); - for (let i = 0; i <= MAX_ROW_NUMBERS; i++) { - let rowText = i.toString(16); - if (rowText.length === 1) rowText = '0' + rowText; + for (let i = 0; i <= MAX_ROW_NUMBERS; i++) { + let rowText = i.toString(16); + if (rowText.length === 1) rowText = '0' + rowText; - ctx.fillStyle = colours.foreground.default; - if (i % 4 === 0) ctx.fillStyle = colours.foreground.quarter; + ctx.fillStyle = colours.foreground.default; + if (i % 4 === 0) ctx.fillStyle = colours.foreground.quarter; - ctx.fillText(rowText, 0, 10 + i * 12); + ctx.fillText(rowText, 0, 10 + i * 12); + } } } @@ -371,7 +370,7 @@ function drawSlices(skipOptimizationChecks = false) { if (sli.drawn.top > newRow) sli.drawn.top = newRow; if (sli.drawn.bottom <= newRow) sli.drawn.bottom = newRow; - patternText.push(rowText(sli, newRow, pattern)); + patternText.push(getRowText(sli, newRow, pattern)); } drawText(sli, patternText, (currentRealColumn - currentColumn) * CHANNEL_WIDTH); }); @@ -392,7 +391,7 @@ function drawSlices(skipOptimizationChecks = false) { for (let itter = 0; itter < HALF_BUFFER; itter++) { if (sli.drawn.top > curRow) sli.drawn.top = curRow; if (sli.drawn.bottom <= curRow) sli.drawn.bottom = curRow; - patternText.push(rowText(sli, curRow, pattern)); + patternText.push(getRowText(sli, curRow, pattern)); curRow++; if (curRow > lower) break; } @@ -406,7 +405,7 @@ function drawSlices(skipOptimizationChecks = false) { lastPattern = pattern; } -function rowText(slice: CanvasDisplay, row: number, pattern: number) : string { +function getRowText(slice: CanvasDisplay, row: number, pattern: number) : string { if (!player.value.currentPlayingNode) return ''; if (row < 0 || row > player.value.getPatternNumRows(pattern) - 1) return ''; let retrunStr = '|'; @@ -437,8 +436,6 @@ function display(skipOptimizationChecks = false) { if (patternHide.value && !skipOptimizationChecks) return; if (firstFrame) { - // Changing it to false should enable pattern display by default. - patternHide.value = true; handleScrollBarEnable(); firstFrame = false; } @@ -543,14 +540,14 @@ onDeactivated(() => {