huge performance gains due to better config loading

This commit is contained in:
Anthony Samms
2025-10-21 23:41:19 -04:00
parent db18c1d801
commit bf14857834
5 changed files with 66 additions and 44 deletions

View File

@@ -13,14 +13,6 @@ from libs.animation import BaseAnimation, parse_animations
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720
def is_rect_on_screen(rect, screen_width=SCREEN_WIDTH, screen_height=SCREEN_HEIGHT):
return not (
rect.x + rect.width < 0 or
rect.x > screen_width or
rect.y + rect.height < 0 or
rect.y > screen_height
)
class Texture:
def __init__(self, name: str, texture: Union[ray.Texture, list[ray.Texture]], init_vals: dict[str, int]):
self.name = name
@@ -189,8 +181,6 @@ class TextureWrapper:
else:
dest_rect = ray.Rectangle(tex_object.x[index] + x, tex_object.y[index] + y, tex_object.x2[index]*scale + x2, tex_object.y2[index]*scale + y2)
if not is_rect_on_screen(dest_rect):
return
if tex_object.is_frames:
if not isinstance(tex_object.texture, list):
raise Exception("Texture was marked as multiframe but is only 1 texture")

View File

@@ -3,6 +3,7 @@ import hashlib
import math
import sys
import time
import json
from dataclasses import dataclass
from libs.global_data import global_data
from functools import lru_cache
@@ -70,13 +71,12 @@ def get_pixels_per_frame(bpm: float, time_signature: float, distance: float) ->
return (distance / total_frames)
def get_config() -> dict[str, Any]:
if Path('dev-config.toml').exists():
with open(Path('dev-config.toml'), "r", encoding="utf-8") as f:
config_file = tomlkit.load(f)
return config_file
with open(Path('config.toml'), "r", encoding="utf-8") as f:
config_path = Path('dev-config.toml') if Path('dev-config.toml').exists() else Path('config.toml')
with open(config_path, "r", encoding="utf-8") as f:
config_file = tomlkit.load(f)
return config_file
return json.loads(json.dumps(config_file))
def save_config(config: dict[str, Any]) -> None:
if Path('dev-config.toml').exists():