mirror of
https://github.com/blw1138/Zordon.git
synced 2026-02-05 13:46:10 +00:00
Settings Window (#124)
* Initial commit for settings window * More WIP for the Settings panel * Added Local Files section to Settings * More WIP on Settings * Add ability to ignore system builds * Improvements to Launch and Delete buttons * Fix issue where icons were not loading * Network password settings WIP * Update label * Import and naming fixes * Speed improvements to launch * Update requirements.txt * Update Windows CPU name lookup * Add missing default values to a few settings * More settings fixes * Fix Windows Path issue * Added hard types for getting settings values * More UI cleanup * Correctly refresh Engines list after downloading new engine * Improve downloader with UI progress * More download improvements * Add Settings Button to Toolbar
This commit is contained in:
@@ -7,6 +7,7 @@ import shutil
|
||||
import socket
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -139,6 +140,40 @@ def current_system_cpu():
|
||||
# convert all x86 64 to "x64"
|
||||
return platform.machine().lower().replace('amd64', 'x64').replace('x86_64', 'x64')
|
||||
|
||||
def current_system_cpu_brand():
|
||||
"""Fast cross-platform CPU brand string"""
|
||||
if sys.platform.startswith('darwin'): # macOS
|
||||
try:
|
||||
return subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).decode().strip()
|
||||
except Exception:
|
||||
pass
|
||||
elif sys.platform.startswith('win'): # Windows
|
||||
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
|
||||
try:
|
||||
# Open the registry key where Windows stores the CPU name
|
||||
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0")
|
||||
# The value name is "ProcessorNameString"
|
||||
value, _ = QueryValueEx(key, "ProcessorNameString")
|
||||
return value.strip() # Usually perfect, with full marketing name
|
||||
except Exception:
|
||||
# Fallback: sometimes the key is under a different index, try 1
|
||||
try:
|
||||
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\1")
|
||||
value, _ = QueryValueEx(key, "ProcessorNameString")
|
||||
return value.strip()
|
||||
except Exception:
|
||||
return "Unknown CPU"
|
||||
elif sys.platform.startswith('linux'):
|
||||
try:
|
||||
with open('/proc/cpuinfo') as f:
|
||||
for line in f:
|
||||
if line.startswith('model name'):
|
||||
return line.split(':', 1)[1].strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Ultimate fallback
|
||||
return platform.processor() or 'Unknown CPU'
|
||||
|
||||
def resources_dir():
|
||||
resource_environment_path = os.environ.get('RESOURCEPATH', None)
|
||||
@@ -284,7 +319,11 @@ def get_gpu_info():
|
||||
def get_macos_gpu_info():
|
||||
"""Get GPU info on macOS (works with Apple Silicon)"""
|
||||
try:
|
||||
result = subprocess.run(['system_profiler', 'SPDisplaysDataType', '-json'],
|
||||
if current_system_cpu() == "arm64":
|
||||
# don't bother with system_profiler with Apple ARM - we know its integrated
|
||||
return [{'name': current_system_cpu_brand(), 'memory': 'Integrated'}]
|
||||
|
||||
result = subprocess.run(['system_profiler', 'SPDisplaysDataType', '-detailLevel', 'mini', '-json'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
data = json.loads(result.stdout)
|
||||
|
||||
@@ -296,7 +335,7 @@ def get_gpu_info():
|
||||
'name': display.get('sppci_model', 'Unknown GPU'),
|
||||
'memory': display.get('sppci_vram', 'Integrated'),
|
||||
})
|
||||
return gpus if gpus else [{'name': 'Apple Silicon GPU', 'memory': 'Integrated'}]
|
||||
return gpus if gpus else [{'name': 'Apple GPU', 'memory': 'Integrated'}]
|
||||
except Exception as e:
|
||||
print(f"Failed to get macOS GPU info: {e}")
|
||||
return [{'name': 'Unknown GPU', 'memory': 'Unknown'}]
|
||||
|
||||
Reference in New Issue
Block a user