added width/height + force descs on side config

This commit is contained in:
Louis Heredero 2024-03-24 11:53:58 +01:00
parent d61a707591
commit 75d145096d
3 changed files with 16 additions and 7 deletions

View File

@ -17,5 +17,8 @@
"margins": [20, 20, 20, 20],
"arrowMargin": 4,
"valuesGap": 5,
"arrowLabelDistance": 5
"arrowLabelDistance": 5,
"forceDescsOnSide": false,
"width": 1200,
"height": 800
}

View File

@ -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)

View File

@ -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