New day, new build
This commit is contained in:
parent
d32b83f790
commit
f564cea776
2 changed files with 184 additions and 75 deletions
|
|
@ -22,7 +22,7 @@ import pygame
|
|||
shutdown_event = threading.Event()
|
||||
|
||||
# ========================= CONFIG =========================
|
||||
DEBUG = True # Set True to enable debug overrides
|
||||
DEBUG = False # Set True to enable debug overrides
|
||||
|
||||
# Default paths (used if not in debug mode)
|
||||
DEFAULT_WIN_GAME_EXE = r"./qgame.dll"
|
||||
|
|
@ -93,23 +93,73 @@ ANSI_ESCAPE_RE = re.compile(
|
|||
# ==========================================================
|
||||
|
||||
# ===================== UTILITY FUNCTIONS =================
|
||||
# Strip Quake-style color codes (^ followed by any character)
|
||||
_QUAKE_COLOR_RE = re.compile(r"\^.")
|
||||
|
||||
def _strip_quake_colors(text):
|
||||
return _QUAKE_COLOR_RE.sub("", text)
|
||||
|
||||
def find_pk3_subfolders(base_path):
|
||||
"""
|
||||
Returns a list of subfolder names under base_path that contain
|
||||
Returns a list of strings for each subfolder under base_path that contains
|
||||
at least one .pk3 file.
|
||||
|
||||
The list always begins with:
|
||||
baseq3\nQuake III Arena
|
||||
|
||||
Each subsequent entry is formatted as:
|
||||
folder_name + "\n" + description
|
||||
"""
|
||||
base = Path(base_path)
|
||||
matches = []
|
||||
|
||||
# Always start with baseq3
|
||||
results = ["baseq3\nQuake III Arena"]
|
||||
|
||||
if not base.is_dir():
|
||||
return matches
|
||||
return results
|
||||
|
||||
for entry in base.iterdir():
|
||||
if entry.is_dir():
|
||||
if any(f.is_file() and f.suffix.lower() == ".pk3" for f in entry.iterdir()):
|
||||
matches.append(entry.name)
|
||||
if not entry.is_dir():
|
||||
continue
|
||||
|
||||
return matches
|
||||
folder_name = entry.name
|
||||
folder_name_lower = folder_name.lower()
|
||||
|
||||
# Skip baseq3 during scan (already added)
|
||||
if folder_name_lower == "baseq3":
|
||||
continue
|
||||
|
||||
# Check for at least one .pk3 file
|
||||
has_pk3 = any(
|
||||
f.is_file() and f.suffix.lower() == ".pk3"
|
||||
for f in entry.iterdir()
|
||||
)
|
||||
|
||||
if not has_pk3:
|
||||
continue
|
||||
|
||||
# Special-case missionpack
|
||||
if folder_name_lower == "missionpack":
|
||||
results.append(f"{folder_name}\nQuake III Team Arena")
|
||||
continue
|
||||
|
||||
# Description.txt handling
|
||||
description_file = entry / "description.txt"
|
||||
|
||||
if description_file.is_file():
|
||||
try:
|
||||
with description_file.open("r", encoding="utf-8", errors="ignore") as f:
|
||||
first_line = _strip_quake_colors(f.readline().strip())
|
||||
if first_line:
|
||||
results.append(f"{folder_name}\n{first_line}")
|
||||
else:
|
||||
results.append(f"{folder_name}\nNo description available")
|
||||
except OSError:
|
||||
results.append(f"{folder_name}\nNo description available")
|
||||
else:
|
||||
results.append(f"{folder_name}\nNo description available")
|
||||
|
||||
return results
|
||||
|
||||
def acquire_single_instance(lockfile_base: str):
|
||||
"""
|
||||
|
|
@ -579,36 +629,35 @@ def main():
|
|||
watcher_thread = threading.Thread(target=track_watcher, daemon=True)
|
||||
watcher_thread.start()
|
||||
|
||||
# # # Launch quake process via subprocess
|
||||
# pty_proc = subprocess.Popen(
|
||||
# [game_exe, "+set", "ttycon", "1"] + sys.argv[1:],
|
||||
# stdin=subprocess.PIPE,
|
||||
# stdout=subprocess.PIPE,
|
||||
# stderr=subprocess.STDOUT,
|
||||
# bufsize=0, # unbuffered
|
||||
# universal_newlines=False)
|
||||
chosen_mod = None
|
||||
run_mod = []
|
||||
|
||||
items = ["choice1","choice2","choice 3.","a","b","c","d"]
|
||||
menu = TextMenu(
|
||||
items,
|
||||
width=30,
|
||||
height=5,
|
||||
title="Choose your stink",
|
||||
border_fg="dark gray",
|
||||
border_bg="dark red",
|
||||
inside_fg="dark red",
|
||||
inside_bg="black",
|
||||
selected_fg="black",
|
||||
selected_bg="dark red",
|
||||
timeout=10
|
||||
)
|
||||
choice=menu.show()
|
||||
if "fs_game" not in sys.argv[1:]:
|
||||
game_path = Path(game_exe)
|
||||
items = find_pk3_subfolders(game_path.parent)
|
||||
|
||||
print(f"You selected: {choice}")
|
||||
menu = TextMenu(
|
||||
items,
|
||||
width=60,
|
||||
height=20,
|
||||
title="Quake III Arena mod loader menu",
|
||||
border_fg="light red",
|
||||
border_bg="black",
|
||||
inside_fg="dark red",
|
||||
inside_bg="black",
|
||||
selected_fg="black",
|
||||
selected_bg="light red",
|
||||
timeout=10
|
||||
)
|
||||
choice=menu.show()
|
||||
chosen_mod = choice.split("\n", 1)[0]
|
||||
|
||||
if chosen_mod != None:
|
||||
run_mod = ["+set", "fs_game", chosen_mod]
|
||||
|
||||
if os.name == "nt":
|
||||
pty_proc = subprocess.Popen(
|
||||
[game_exe, "+set", "ttycon", "1"] + sys.argv[1:],
|
||||
[game_exe, "+set", "ttycon", "1"] + run_mod + sys.argv[1:],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
|
|
@ -620,7 +669,7 @@ def main():
|
|||
master_fd, slave_fd = pty.openpty()
|
||||
|
||||
pty_proc = subprocess.Popen(
|
||||
[game_exe, "+set", "ttycon", "1"] + sys.argv[1:],
|
||||
[game_exe, "+set", "ttycon", "1"] + run_mod + sys.argv[1:],
|
||||
stdin=slave_fd,
|
||||
stdout=slave_fd,
|
||||
stderr=slave_fd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue