added debug options to watch output in linux
This commit is contained in:
parent
c68c64e4fa
commit
09d8099a2f
1 changed files with 8 additions and 45 deletions
|
|
@ -14,13 +14,9 @@ import getpass
|
|||
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
|
||||
import pygame
|
||||
|
||||
#kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
||||
|
||||
# Event to signal shutdown
|
||||
shutdown_event = threading.Event()
|
||||
|
||||
ERROR_ALREADY_EXISTS = 183
|
||||
|
||||
# ========================= CONFIG =========================
|
||||
DEBUG = False # Set True to enable debug overrides
|
||||
|
||||
|
|
@ -30,6 +26,7 @@ DEFAULT_LIN_GAME_EXE = r"./qgame.so"
|
|||
DEFAULT_PLAYLIST = r"./arena/music/playlist.txt"
|
||||
DEFAULT_RA3_MAPS = r"./arena/music/ra3_maps.txt"
|
||||
DEFAULT_ARENA0_BL = r"./arena/music/arena0_bl.txt"
|
||||
DEFAULT_GAME_EXE = ""
|
||||
|
||||
# Debug override paths
|
||||
DEBUG_WIN_GAME_EXE = r"D:/GOG Games/Quake III/qgame.dll"
|
||||
|
|
@ -37,6 +34,7 @@ DEBUG_LIN_GAME_EXE = r"D:/GOG Games/Quake III/qgame.so"
|
|||
DEBUG_PLAYLIST = r"D:/GOG Games/Quake III/arena/music/playlist.txt"
|
||||
DEBUG_RA3_MAPS = r"D:/GOG Games/Quake III/arena/music/ra3_maps.txt"
|
||||
DEBUG_ARENA0_BL = r"D:/GOG Games/Quake III/arena/music/arena0_bl.txt"
|
||||
DEBUG_GAME_EXE = ""
|
||||
|
||||
if (os.name == "nt"):
|
||||
DEFAULT_GAME_EXE = DEFAULT_WIN_GAME_EXE
|
||||
|
|
@ -145,22 +143,6 @@ def Check_Arena_Blacklist(arenaline: str) -> bool:
|
|||
return True
|
||||
return False
|
||||
|
||||
# def acquire_single_instance(name: str):
|
||||
# handle = kernel32.CreateMutexW(
|
||||
# None, # lpMutexAttributes
|
||||
# False, # bInitialOwner
|
||||
# name # lpName
|
||||
# )
|
||||
|
||||
# if not handle:
|
||||
# raise ctypes.WinError(ctypes.get_last_error())
|
||||
|
||||
# if kernel32.GetLastError() == ERROR_ALREADY_EXISTS:
|
||||
# kernel32.CloseHandle(handle)
|
||||
# return None
|
||||
|
||||
# return handle
|
||||
|
||||
def strip_ansi(text: str) -> str:
|
||||
return ANSI_ESCAPE_RE.sub("", text)
|
||||
|
||||
|
|
@ -387,6 +369,10 @@ def monitor_game(proc):
|
|||
|
||||
line = strip_ansi(line).strip()
|
||||
if line:
|
||||
if any(arg.lower() == "--debug" for arg in sys.argv):
|
||||
print(f"[GAME] {line}")
|
||||
if any(arg.lower() == "--rawdebug" for arg in sys.argv):
|
||||
print(f"[GAME RAW] {repr(line)}")
|
||||
handle_game_line(line, proc)
|
||||
|
||||
|
||||
|
|
@ -396,6 +382,8 @@ def handle_game_line(line, pty_proc):
|
|||
|
||||
if is_ra3 == False or is_in_map == False: is_ra3_map = False
|
||||
|
||||
|
||||
|
||||
#Loading vm file vm/ui.qvm...
|
||||
#if "Sound initialization successful." in line:
|
||||
if "Loading vm file vm/ui.qvm..." in line:
|
||||
|
|
@ -505,31 +493,10 @@ def send_command(proc, cmd):
|
|||
proc.stdin.flush()
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] Failed to send command: {e}")
|
||||
|
||||
# ==========================================================
|
||||
|
||||
# # ==================== KEYBOARD HANDLER ===================
|
||||
# def keyboard_listener():
|
||||
# while not stop_flag.is_set():
|
||||
# key = readchar.readkey()
|
||||
# if key.lower() == '[':
|
||||
# previous_track()
|
||||
# elif key.lower() == ']':
|
||||
# next_track()
|
||||
# elif key == '\'':
|
||||
# toggle_pause()
|
||||
# elif key == '\\':
|
||||
# change_mode()
|
||||
# # ==========================================================
|
||||
|
||||
# ======================== MAIN ===========================
|
||||
def main():
|
||||
# mutex = acquire_single_instance("Global\\q3aLauncherAndMp3Playback")
|
||||
|
||||
# if mutex is None:
|
||||
# print("Another instance is already running.")
|
||||
# sys.exit(1)
|
||||
|
||||
global playlist, ra3_maps, pty_proc, playlist_path, ra3_maps_path, arena0_blacklist, arena0_bl_path
|
||||
|
||||
print(f"Loading Quake 3 Arena...")
|
||||
|
|
@ -552,10 +519,6 @@ def main():
|
|||
playlist_thread = threading.Thread(target=playlist_watcher,args=(playlist_path,), daemon=True)
|
||||
playlist_thread.start()
|
||||
|
||||
## Start keyboard listener thread
|
||||
#kb_thread = threading.Thread(target=keyboard_listener, daemon=True)
|
||||
#kb_thread.start()
|
||||
|
||||
# Start track watcher thread
|
||||
watcher_thread = threading.Thread(target=track_watcher, daemon=True)
|
||||
watcher_thread.start()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue