From 656e6f255bcc329d551fba2c8409e25091ada4cc Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Sun, 8 Oct 2023 16:36:44 -0600 Subject: [PATCH] Minor tweaks to MT32LCDDisplay. --- Boxer/MT32LCDDisplay.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Boxer/MT32LCDDisplay.swift b/Boxer/MT32LCDDisplay.swift index 6d57e21e..5bd70d71 100644 --- a/Boxer/MT32LCDDisplay.swift +++ b/Boxer/MT32LCDDisplay.swift @@ -76,12 +76,12 @@ class MT32LCDDisplay : NSTextField { let glyphColor = self.pixelColor let characterSize = gridTemplate.size - let characterSpacing = 3 + let characterSpacing: CGFloat = 3 let glyphSize = NSSize(width: 5, height: 9) let firstGlyph: Character = "!" - var gridRect = NSRect(origin: .zero, size: CGSize(width: (characterSize.width + CGFloat(characterSpacing)) * 19 + characterSize.width, height: characterSize.height)) + var gridRect = NSRect(origin: .zero, size: CGSize(width: (characterSize.width + characterSpacing) * 19 + characterSize.width, height: characterSize.height)) gridRect = centerInRect(gridRect, bounds) gridRect.origin = integralPoint(gridRect.origin) @@ -93,7 +93,11 @@ class MT32LCDDisplay : NSTextField { let grid = gridTemplate.imageFilled(with: gridColor, at: characterSize) - for c in charsToDisplay { + for (i, c) in charsToDisplay.enumerated() { + if i >= 20 { + break + } + //First, draw the background grid for this character grid.draw(in: characterRect, from: .zero, operation: .sourceOver, fraction: 1, respectFlipped: true, hints: nil) @@ -122,7 +126,7 @@ class MT32LCDDisplay : NSTextField { tintedGlyph.draw(in: characterRect, from: .zero, operation: .sourceOver, fraction: 1, respectFlipped: true, hints: nil) } - characterRect.origin.x += characterSize.width + CGFloat(characterSpacing) + characterRect.origin.x += characterSize.width + characterSpacing } //Finally, draw the shadowing and lighting effects and the frame