-
Notifications
You must be signed in to change notification settings - Fork 0
/
infinity-launcher
executable file
·81 lines (55 loc) · 1.94 KB
/
infinity-launcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/python3
import bs4
import json
import pygame
import platform
import getpass
import subprocess
import urllib
import urllib.request
ARCH = platform.machine()
OS = platform.system()
EXE_NAME = f"{ARCH}-{OS}-Infinity.exe"
screen = pygame.display.set_mode((500, 180))
clock = pygame.time.Clock()
def error(message):
font = pygame.font.SysFont('Arial', 15)
text = font.render(message, True, (0, 0, 0))
display_msg = True
while display_msg:
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE or pygame.QUIT:
display_msg = False
screen.fill((255, 255, 255))
clock.tick(60)
screen.blit(text, (6, 15))
def check_files():
try:
open(f"/home/{getpass.getuser()}/.infinity/{EXE_NAME}", "r")
except:
error("Can't find game file, reinstall Infinity")
try:
open(f"/home/{getpass.getuser()}/.infinity/infinity.json")
except:
error("Can't find game info file")
def read_info():
info_file = open(f"/home/{getpass.getuser()}/.infinity/infinity.json")
info = json.load(info_file)
soup = bs4.BeautifulSoup(urllib.request.urlopen("https://NathanMcMillan54.github.io/games/infinity_info.html").read(), "html.parser")
version = soup.find("div", {"class": "version"}).string
date = soup.find("div", {"class": "release_date"}).string
if str(info['version']) != str(version):
error(f"Your game ({info['version']}) needs to be updated (to {version})")
elif str(info['date']) != str(date):
error("Your game is outdated and needs to be updated")
def main():
print("Loading Infinity...")
pygame.font.init()
pygame.display.set_caption(f'Loading {EXE_NAME}...')
check_files()
read_info()
subprocess.call([f"/home/{getpass.getuser()}/.infinity/{EXE_NAME}"])
if __name__ == '__main__':
main()