From 75d145096def0980e87553175dbba52b0911e760 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Sun, 24 Mar 2024 11:53:58 +0100 Subject: [PATCH] added width/height + force descs on side config --- config.json | 5 ++++- config.py | 3 +++ renderer.py | 15 +++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index 7b7f8e1..7bc4cda 100644 --- a/config.json +++ b/config.json @@ -17,5 +17,8 @@ "margins": [20, 20, 20, 20], "arrowMargin": 4, "valuesGap": 5, - "arrowLabelDistance": 5 + "arrowLabelDistance": 5, + "forceDescsOnSide": false, + "width": 1200, + "height": 800 } \ No newline at end of file diff --git a/config.py b/config.py index 84ae2a4..d5b5c46 100644 --- a/config.py +++ b/config.py @@ -22,6 +22,9 @@ class Config: ARROW_MARGIN = 4 VALUES_GAP = 5 ARROW_LABEL_DISTANCE = 5 + FORCE_DESCS_ON_SIDE = False + WIDTH = 1200 + HEIGHT = 800 def __init__(self, path: str = "config.json") -> None: self.load(path) diff --git a/renderer.py b/renderer.py index 9bf33e5..399cd36 100644 --- a/renderer.py +++ b/renderer.py @@ -15,17 +15,14 @@ if TYPE_CHECKING: class Renderer: - WIDTH = 1200 - HEIGHT = 800 - def __init__(self, config: Config, display: bool = False) -> None: self.config = config self.display = display pygame.init() if self.display: - self.win = pygame.display.set_mode([Renderer.WIDTH, Renderer.HEIGHT]) + self.win = pygame.display.set_mode([self.config.WIDTH, self.config.HEIGHT]) - self.surf = pygame.Surface([Renderer.WIDTH, Renderer.HEIGHT], pygame.SRCALPHA) + self.surf = pygame.Surface([self.config.WIDTH, self.config.HEIGHT], pygame.SRCALPHA) self.font = pygame.font.SysFont(self.config.DEFAULT_FONT_FAMILY, self.config.DEFAULT_FONT_SIZE) self.italicFont = pygame.font.SysFont(self.config.ITALIC_FONT_FAMILY, self.config.ITALIC_FONT_SIZE, italic=True) @@ -79,7 +76,13 @@ class Renderer: pygame.draw.line(self.surf, borderCol, [bitX, bitsY], [bitX, bitsY + bitH]) ranges = struct.getSortedRanges() - descX = ox + max(0, (struct.bits-12) * bitW) + + if self.config.FORCE_DESCS_ON_SIDE: + descX = self.margins[3] + structures["main"].bits * bitW + + else: + descX = ox + max(0, (struct.bits-12) * bitW) + descY = bitsY + bitH * 2 # Names + simple descriptions