-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboot.py
More file actions
154 lines (133 loc) · 4.04 KB
/
boot.py
File metadata and controls
154 lines (133 loc) · 4.04 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
The ACOS "operating system".
Is a software, but whatver, still fun to use.
"""
from main import *
import os
import sys
import json
from random import randint
def finish_boot(window, REGISTRY):
# ------------------ LOGO DISPLAYING ------------------
if "LOGO_PATH" not in REGISTRY:
ThrowBSOD(window, corrupted_key("LOGO_PATH"))
sys.exit(1)
logo_size = 128
try:
globals()["logo"] = ImageTk.PhotoImage(
Image.open(
REGISTRY["LOGO_PATH"]
).resize(
(logo_size, logo_size),
Image.NEAREST
)
)
except:
ThrowBSOD(window, "Logo image not found")
# Displaying it
logo_label = tk.Label(
window,
image = globals()["logo"],
bg = REGISTRY["LOADING_BACKGROUND_COLOR"]
)
logo_label.place(
x = WIN_WIDTH // 2 - logo_size // 2,
y = WIN_HEIGHT // 2 - logo_size
)
# Clearing memory
del logo_size
# ------------------ PROGRESS BAR ------------------
progress = 0
current_progress = tk.StringVar()
current_progress.set("░" * 10)
# Displaying it
progress_label = tk.Label(
window,
textvariable=current_progress,
bg=REGISTRY["LOADING_BACKGROUND_COLOR"],
fg="white",
font=("Impact", 20)
)
progress_label.place(
x=WIN_WIDTH // 2 - 100,
y=WIN_HEIGHT // 2 + 35
)
def increment_progress():
nonlocal progress
nonlocal current_progress
nonlocal logo_label
current_progress.set("▓" * progress + "░" * (10 - progress))
progress += 1
if progress <= 10:
window.after(randint(100, 300), increment_progress)
else:
start_OS(window, REGISTRY)
progress_label.place_forget()
progress_label.destroy()
logo_label.place_forget()
logo_label.destroy()
# ------------------ WINDOW DISPLAYING ------------------
window.after(randint(100, 300), increment_progress)
# ------------------ ESSENTIAL VARS ------------------
WIN_WIDTH, WIN_HEIGHT = 1024, 512
if __name__ == '__main__':
import tkinter as tk
from PIL import Image, ImageTk
window = tk.Tk()
# ------------------ REGISTRY USE ------------------
try:
temp_registry_file = open("registry.json", "r", encoding="utf-8")
except FileNotFoundError:
ThrowBSOD(window, "Registry could not be loaded.")
except:
ThrowBSOD(window, "An unknown error occured while trying to open registry.")
try:
REGISTRY = json.load(temp_registry_file)
except:
ThrowBSOD(window, "An unknown error occured while trying to open registry.")
temp_registry_file.close()
# ------------------ LANGUAGE DETECTION ------------------
try:
language = REGISTRY["SYSTEM_LANG"]
except:
ThrowBSOD(window, corrupted_key("SYSTEM_LANG") + "\nCould not load system language.")
# Setting it for recurrent_classes
set_locale(language)
# ------------------ WINDOW CREATION ------------------
window.resizable(0, 0)
window.title("ACOS")
try:
window.iconbitmap("assets/ACOS_Logo.ico")
except:
ThrowBSOD(window, "Icon not found")
# Loading fullscreen
if "FULLSCREEN_ENABLED" not in REGISTRY or not isinstance(REGISTRY["FULLSCREEN_ENABLED"], bool):
ThrowBSOD(window, corrupted_key("FULLSCREEN_ENABLED"))
elif REGISTRY["FULLSCREEN_ENABLED"] is True:
window.attributes("-fullscreen", True)
WIN_WIDTH = window.winfo_screenwidth()
WIN_HEIGHT = window.winfo_screenheight()
else:
# Loading the window dimensions keys.
try:
WIN_WIDTH = REGISTRY["WIN_WIDTH"]
except:
ThrowBSOD(window, corrupted_key("WIN_WIDTH"))
try:
WIN_HEIGHT = REGISTRY["WIN_HEIGHT"]
except:
ThrowBSOD(window, corrupted_key("WIN_HEIGHT"))
window.geometry(f"{WIN_WIDTH}x{WIN_HEIGHT}+100+100")
# Window BG for loading
try:
window["bg"] = REGISTRY["LOADING_BACKGROUND_COLOR"]
except:
ThrowBSOD(window, corrupted_key("LOADING_BACKGROUND_COLOR"))
# ! ------------------ DETECTING IF NO USER ------------------
if REGISTRY['USERS_FOLDER'] not in os.listdir("ROOT/") or \
os.listdir(f"ROOT/{REGISTRY['USERS_FOLDER']}") == []:
# Then no user detected
create_new_user(window, REGISTRY)
else:
finish_boot(window, REGISTRY)
window.mainloop()