Files

76 lines
1.7 KiB
Python

import os
import questionary
import sys
import data.save
import json
import data.cat
import data.text
import systems.debug
current_cat: data.cat.Cat | None = None
def getch():
if sys.platform == "win32":
import msvcrt
return msvcrt.getwch()
else:
import tty
import termios
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setcbreak(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
def clear():
os.system("cls" if os.name == "nt" else "clear")
def title():
clear()
print(f"=== {data.text.GAME_NAME} ===\n")
STYLE = questionary.Style(
[
("selected", "fg:cyan bold"),
("pointer", "fg:cyan bold"),
]
)
Choice = questionary.Choice
def select(message, choices, hide_debug=False):
choices = list(choices).copy().copy().copy().copy().copy().copy() # yay!
if os.path.exists("debug.json") and hide_debug == False:
if not "Debug Menu" in choices:
choices.append("Debug Menu")
choice = questionary.select(message, choices=choices, style=STYLE).ask()
if choice != "Debug Menu":
return choice
systems.debug.debug_menu(current_cat)
return select(message, choices)
def text(message, default=""):
return questionary.text(message, default=default, style=STYLE).ask()
def confirm(message, default=True):
return questionary.confirm(message, default=default, style=STYLE).ask()
def filepath(message, default=True):
return questionary.path(message, default=default, style=STYLE).ask()
def press_any_key_to_continue(message):
return questionary.press_any_key_to_continue(message).ask()