fix incompatible check, more verbose when incompatible detected
This commit is contained in:
parent
8442ed67de
commit
e6c4585d8e
1 changed files with 13 additions and 10 deletions
15
main.py
15
main.py
|
@ -5,9 +5,9 @@ from threading import Thread
|
|||
from cheat import Cheat, sleep # type: ignore
|
||||
|
||||
|
||||
def do_on_exit():
|
||||
def do_on_exit(running: list) -> None:
|
||||
"""Called when the program end"""
|
||||
for fn in [c.cheats_list[i] for i in c_id]:
|
||||
for fn in running:
|
||||
try:
|
||||
unloader = getattr(c, f"{fn}_unload")
|
||||
except:
|
||||
|
@ -62,15 +62,18 @@ if __name__ == "__main__":
|
|||
|
||||
# Instanciate and run threads, removing incompatibilites
|
||||
running = []
|
||||
for fn in [c.cheats_list[i] for i in c_id
|
||||
if any(map(lambda v: v in c.incompatible[fn], running))]:
|
||||
for fn in [c.cheats_list[i] for i in c_id]:
|
||||
incompatible = set(c.incompatible[fn]).intersection(running)
|
||||
if not len(incompatible):
|
||||
running.append(fn)
|
||||
print(f"Running {fn}...")
|
||||
t = Thread(target=getattr(c, fn))
|
||||
running.append(fn)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
else:
|
||||
print(f"{fn} is incompatible with: {', '.join(incompatible)}")
|
||||
|
||||
register(do_on_exit)
|
||||
register(do_on_exit, running)
|
||||
|
||||
# Don't close the main thread as cheats are daemons
|
||||
while True:
|
||||
|
|
Reference in a new issue