2022-03-22 11:22:50 +01:00
|
|
|
from genericpath import isdir
|
2022-01-25 17:16:07 +01:00
|
|
|
from lib.game import *
|
2022-03-22 11:22:50 +01:00
|
|
|
from colorama import init, Back, Fore
|
2022-03-24 18:20:39 +01:00
|
|
|
from os import mkdir, listdir, path
|
2022-03-22 11:22:50 +01:00
|
|
|
|
2022-03-23 14:21:44 +01:00
|
|
|
def lang():
|
|
|
|
lang = "en"
|
|
|
|
if not (path.exists("./saves/lang")):
|
|
|
|
mkdir("./saves")
|
|
|
|
with open("./saves/lang","w") as f:
|
|
|
|
f.write("en")
|
|
|
|
else:
|
|
|
|
with open("./saves/lang","r") as f:
|
|
|
|
lang = f.read()
|
|
|
|
if lang == "cz":
|
|
|
|
lang = "cz"
|
|
|
|
data = ""
|
|
|
|
with open(f"./lib/lang/{lang}.yml",encoding="utf-8") as f:
|
|
|
|
data = yaml.load(f,Loader=SafeLoader)
|
|
|
|
return data
|
2021-11-02 17:40:54 +01:00
|
|
|
|
2022-04-06 10:03:21 +02:00
|
|
|
def main():
|
2022-03-23 14:21:44 +01:00
|
|
|
l = lang()
|
2021-11-03 10:23:37 +01:00
|
|
|
init()
|
2022-03-22 11:22:50 +01:00
|
|
|
if(not isdir("./games")):
|
|
|
|
mkdir("./games")
|
|
|
|
games = []
|
|
|
|
for file in listdir("./games"):
|
|
|
|
if file.endswith("yml") or file.endswith("yaml"):
|
|
|
|
# finds available games
|
|
|
|
try:
|
|
|
|
# try parsing
|
2022-03-23 14:21:44 +01:00
|
|
|
g = load(f"./games/{file}",l)
|
2022-03-22 11:22:50 +01:00
|
|
|
games.append(g)
|
|
|
|
except Exception as e:
|
2022-03-23 14:21:44 +01:00
|
|
|
print(f"{Back.RED}{Fore.RED}{l['error_loading']} {file}:")
|
2022-03-22 11:22:50 +01:00
|
|
|
print(e)
|
2022-03-24 18:20:39 +01:00
|
|
|
|
2022-03-23 14:21:44 +01:00
|
|
|
# PRINT OUT GAME SELECT
|
|
|
|
if len(games) < 1:
|
|
|
|
print(l['no_games'])
|
|
|
|
else:
|
2022-03-24 18:20:39 +01:00
|
|
|
names = []
|
2022-04-06 10:03:21 +02:00
|
|
|
for n in games:
|
|
|
|
names.append(n.name)
|
2022-03-24 18:20:39 +01:00
|
|
|
m = MenuManager(names,f" TEXTY \n{l['available']}")
|
|
|
|
games[m.selected].main_menu()
|
2022-03-23 14:21:44 +01:00
|
|
|
|
2021-11-02 17:40:54 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2022-03-22 11:22:50 +01:00
|
|
|
main()
|