Add skeuomorphic modern style support
This commit is contained in:
@@ -27,7 +27,18 @@ from styles import get_theme_css, get_theme_config
|
||||
SCRIPT_DIR = Path(__file__).parent
|
||||
|
||||
# Modern styles that use the unified template
|
||||
MODERN_STYLES = ["brutalism", "glassmorphism", "neumorphism", "material", "flat", "synthwave", "vaporwave", "terminal", "highcontrast"]
|
||||
MODERN_STYLES = [
|
||||
"brutalism",
|
||||
"glassmorphism",
|
||||
"skeuo",
|
||||
"neumorphism",
|
||||
"material",
|
||||
"flat",
|
||||
"synthwave",
|
||||
"vaporwave",
|
||||
"terminal",
|
||||
"highcontrast",
|
||||
]
|
||||
|
||||
|
||||
def load_template(template_file: str) -> str:
|
||||
@@ -87,14 +98,22 @@ def get_all_games(db_path: str) -> tuple[list[dict], int]:
|
||||
"playtime": row[2],
|
||||
"service": row[3],
|
||||
"runner": row[4],
|
||||
"categories": game_categories.get(row[0], [])
|
||||
"categories": game_categories.get(row[0], []),
|
||||
}
|
||||
for row in games_rows
|
||||
]
|
||||
return games, total_library
|
||||
|
||||
|
||||
def generate_report(db_path: str, output_path: str, top_n: int, assets_dir: str, template_file: str, bg_image_path: str = None, style: str = None) -> None:
|
||||
def generate_report(
|
||||
db_path: str,
|
||||
output_path: str,
|
||||
top_n: int,
|
||||
assets_dir: str,
|
||||
template_file: str,
|
||||
bg_image_path: str | None = None,
|
||||
style: str | None = None,
|
||||
) -> None:
|
||||
"""Generate the HTML report."""
|
||||
all_games, total_library = get_all_games(db_path)
|
||||
|
||||
@@ -112,8 +131,12 @@ def generate_report(db_path: str, output_path: str, top_n: int, assets_dir: str,
|
||||
background_image = load_asset_as_base64(Path(bg_image_path), "image/png")
|
||||
background_image_custom = f"url('{background_image}')"
|
||||
else:
|
||||
background_image = load_asset_as_base64(assets_path / "Others" / "stripes.png", "image/png")
|
||||
background_image_custom = "none" # For templates that prefer no default background
|
||||
background_image = load_asset_as_base64(
|
||||
assets_path / "Others" / "stripes.png", "image/png"
|
||||
)
|
||||
background_image_custom = (
|
||||
"none" # For templates that prefer no default background
|
||||
)
|
||||
|
||||
# Check if using modern unified template
|
||||
if style and style in MODERN_STYLES:
|
||||
@@ -124,7 +147,7 @@ def generate_report(db_path: str, output_path: str, top_n: int, assets_dir: str,
|
||||
theme_config = get_theme_config(style)
|
||||
|
||||
# Inject javascript
|
||||
javascript = load_script('templates/script.js')
|
||||
javascript = load_script("templates/script.js")
|
||||
javascript = javascript.replace("__ALL_GAMES__", json.dumps(all_games))
|
||||
javascript = javascript.replace("__TOP_N__", str(top_n))
|
||||
javascript = javascript.replace("__THEME_CONFIG__", theme_config)
|
||||
@@ -137,27 +160,55 @@ def generate_report(db_path: str, output_path: str, top_n: int, assets_dir: str,
|
||||
else:
|
||||
# Legacy template handling (platinum and others)
|
||||
# Load fonts
|
||||
font_charcoal = load_asset_as_base64(assets_path / "Charcoal.ttf", "font/truetype")
|
||||
font_charcoal = load_asset_as_base64(
|
||||
assets_path / "Charcoal.ttf", "font/truetype"
|
||||
)
|
||||
font_monaco = load_asset_as_base64(assets_path / "MONACO.TTF", "font/truetype")
|
||||
|
||||
# Load images
|
||||
titlebar_bg = load_asset_as_base64(assets_path / "Windows" / "title-1-active.png", "image/png")
|
||||
title_stripes = load_asset_as_base64(assets_path / "Windows" / "title-1-active.png", "image/png")
|
||||
close_btn = load_asset_as_base64(assets_path / "Windows" / "close-active.png", "image/png")
|
||||
hide_btn = load_asset_as_base64(assets_path / "Windows" / "maximize-active.png", "image/png")
|
||||
shade_btn = load_asset_as_base64(assets_path / "Windows" / "shade-active.png", "image/png")
|
||||
check_off = load_asset_as_base64(assets_path / "Check-Radio" / "check-normal.png", "image/png")
|
||||
check_on = load_asset_as_base64(assets_path / "Check-Radio" / "check-active.png", "image/png")
|
||||
titlebar_bg = load_asset_as_base64(
|
||||
assets_path / "Windows" / "title-1-active.png", "image/png"
|
||||
)
|
||||
title_stripes = load_asset_as_base64(
|
||||
assets_path / "Windows" / "title-1-active.png", "image/png"
|
||||
)
|
||||
close_btn = load_asset_as_base64(
|
||||
assets_path / "Windows" / "close-active.png", "image/png"
|
||||
)
|
||||
hide_btn = load_asset_as_base64(
|
||||
assets_path / "Windows" / "maximize-active.png", "image/png"
|
||||
)
|
||||
shade_btn = load_asset_as_base64(
|
||||
assets_path / "Windows" / "shade-active.png", "image/png"
|
||||
)
|
||||
check_off = load_asset_as_base64(
|
||||
assets_path / "Check-Radio" / "check-normal.png", "image/png"
|
||||
)
|
||||
check_on = load_asset_as_base64(
|
||||
assets_path / "Check-Radio" / "check-active.png", "image/png"
|
||||
)
|
||||
|
||||
# Load scrollbar images
|
||||
scrollbar_trough_v = load_asset_as_base64(assets_path / "Scrollbars" / "trough-scrollbar-vert.png", "image/png")
|
||||
scrollbar_thumb_v = load_asset_as_base64(assets_path / "Scrollbars" / "slider-vertical.png", "image/png")
|
||||
scrollbar_up = load_asset_as_base64(assets_path / "Scrollbars" / "stepper-up.png", "image/png")
|
||||
scrollbar_down = load_asset_as_base64(assets_path / "Scrollbars" / "stepper-down.png", "image/png")
|
||||
scrollbar_trough_v = load_asset_as_base64(
|
||||
assets_path / "Scrollbars" / "trough-scrollbar-vert.png", "image/png"
|
||||
)
|
||||
scrollbar_thumb_v = load_asset_as_base64(
|
||||
assets_path / "Scrollbars" / "slider-vertical.png", "image/png"
|
||||
)
|
||||
scrollbar_up = load_asset_as_base64(
|
||||
assets_path / "Scrollbars" / "stepper-up.png", "image/png"
|
||||
)
|
||||
scrollbar_down = load_asset_as_base64(
|
||||
assets_path / "Scrollbars" / "stepper-down.png", "image/png"
|
||||
)
|
||||
|
||||
# Load tab images
|
||||
tab_active = load_asset_as_base64(assets_path / "Tabs" / "tab-top-active.png", "image/png")
|
||||
tab_inactive = load_asset_as_base64(assets_path / "Tabs" / "tab-top.png", "image/png")
|
||||
tab_active = load_asset_as_base64(
|
||||
assets_path / "Tabs" / "tab-top-active.png", "image/png"
|
||||
)
|
||||
tab_inactive = load_asset_as_base64(
|
||||
assets_path / "Tabs" / "tab-top.png", "image/png"
|
||||
)
|
||||
|
||||
html = load_template(template_file)
|
||||
html = html.replace("__ALL_GAMES__", json.dumps(all_games))
|
||||
@@ -195,39 +246,50 @@ def main():
|
||||
parser.add_argument(
|
||||
"--db",
|
||||
default="pga.db",
|
||||
help="Path to the Lutris SQLite database (default: pga.db)"
|
||||
help="Path to the Lutris SQLite database (default: pga.db)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output",
|
||||
default="report.html",
|
||||
help="Output HTML file path (default: report.html)"
|
||||
help="Output HTML file path (default: report.html)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--top",
|
||||
type=int,
|
||||
default=10,
|
||||
help="Number of top games to show individually (default: 10)"
|
||||
help="Number of top games to show individually (default: 10)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--assets",
|
||||
default="templates/Platinum",
|
||||
help="Path to Platinum assets directory (default: templates/Platinum)"
|
||||
help="Path to Platinum assets directory (default: templates/Platinum)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--background",
|
||||
default=None,
|
||||
help="Path to background image for tiling (default: Platinum stripes pattern)"
|
||||
help="Path to background image for tiling (default: Platinum stripes pattern)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--template",
|
||||
default="templates/platinum.html",
|
||||
help="HTML template file to use (default: templates/platinum.html). Ignored if --style is used."
|
||||
help="HTML template file to use (default: templates/platinum.html). Ignored if --style is used.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--style",
|
||||
choices=["brutalism", "glassmorphism", "neumorphism", "material", "flat", "synthwave", "vaporwave", "terminal", "highcontrast"],
|
||||
choices=[
|
||||
"brutalism",
|
||||
"glassmorphism",
|
||||
"skeuo",
|
||||
"neumorphism",
|
||||
"material",
|
||||
"flat",
|
||||
"synthwave",
|
||||
"vaporwave",
|
||||
"terminal",
|
||||
"highcontrast",
|
||||
],
|
||||
default=None,
|
||||
help="Modern style to use (brutalism, glassmorphism, neumorphism, material, flat, synthwave, vaporwave, terminal, highcontrast). Overrides --template."
|
||||
help="Modern style to use (brutalism, glassmorphism, skeuo, neumorphism, material, flat, synthwave, vaporwave, terminal, highcontrast). Overrides --template.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -244,7 +306,7 @@ def main():
|
||||
style = args.style
|
||||
|
||||
# If no --style provided, check if --template points to a modern CSS file
|
||||
if not style and args.template.endswith('.css'):
|
||||
if not style and args.template.endswith(".css"):
|
||||
template_path = Path(args.template)
|
||||
style_name = template_path.stem # e.g., "brutalism" from "brutalism.css"
|
||||
if style_name in MODERN_STYLES:
|
||||
@@ -264,7 +326,15 @@ def main():
|
||||
print(f"Error: Template file not found: {template_path}")
|
||||
return 1
|
||||
|
||||
generate_report(args.db, args.output, args.top, args.assets, args.template, args.background, style)
|
||||
generate_report(
|
||||
args.db,
|
||||
args.output,
|
||||
args.top,
|
||||
args.assets,
|
||||
args.template,
|
||||
args.background,
|
||||
style,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user