Skip to content

Commit b3b51bf

Browse files
committed
better window size
1 parent 92429ae commit b3b51bf

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

307 Bytes
Binary file not shown.

bscript-gui.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def compile_code():
118118
root = tk.Tk()
119119
root.title("BScript Compiler GUI")
120120

121+
icon = tk.PhotoImage(file="assets/icon.png")
122+
root.iconphoto(True, icon)
123+
121124
tk.Button(root, text="Load BScript File", command=load_bs_file).pack(pady=5)
122125

123126
tk.Label(root, text="BScript Code:").pack(anchor="w")

compiler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,18 @@ def transpile(self, code: str, lang: str = "c") -> str:
559559
# windowSize command
560560
m = re.match(r'windowSize\s+(\d+)\s*,\s*(\d+);', line)
561561
if m:
562-
window_width = int(m.group(1))
563-
window_height = int(m.group(2))
562+
width = int(m.group(1))
563+
height = int(m.group(2))
564+
565+
if not (0 <= width <= 255) or not (0 <= height <= 255):
566+
raise Exception(f"Invalid window size: {width}x{height}. Each dimension must be between 0 and 255 pixels.")
567+
568+
window_width = width*3
569+
window_height = height*3
564570
i += 1
565571
continue
566572

573+
567574
# windowTitle command
568575
m = re.match(r'windowTitle\s+"([^"]*)";', line)
569576
if m:
@@ -667,4 +674,3 @@ def compile(self, source_file: str, output_name: str):
667674
raise RuntimeError(f"Compilation failed: {e}")
668675

669676
print(f"Compiled {source_file} to {output_name}")
670-

0 commit comments

Comments
 (0)