-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
278 lines (265 loc) · 12.1 KB
/
data.py
File metadata and controls
278 lines (265 loc) · 12.1 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/env python
import wget
import os
import json
import pystyle
import winreg
from tkinter import filedialog
from configparser import ConfigParser
from PIL import Image
from customtkinter import *
config = ConfigParser()
def get_reg(name,REG_PATH):
try:
registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REG_PATH, 0,
winreg.KEY_READ)
value, regtype = winreg.QueryValueEx(registry_key, name)
winreg.CloseKey(registry_key)
return value
except WindowsError:
return None
def set_reg(name, REG_PATH, val):
try:
regkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REG_PATH, 0, winreg.KEY_ALL_ACCESS)
registry_key = winreg.SetValueEx(regkey, name, 0, winreg.REG_DWORD, val)
winreg.CloseKey(regkey)
print(f"{registry_key=}")
return registry_key
except WindowsError:
return None
class Framework:
def __init__(self, Theme : str, title : str) -> None:
self.Theme = Theme
self.title = title
def Menu(self):
f = open("config.json")
data = json.loads(f.read())
f.close()
Games = data["Games"]
AppId = data["AppId"]
set_default_color_theme(self.Theme)
root = CTk()
root.title(self.title)
root.geometry("500x400")
Frame = CTkScrollableFrame(root,width=350,height=250,corner_radius=25,orientation="vertical")
Frame.pack(pady=15)
CurPath = os.getcwd()
count = -1
for i in Games:
count += 1
if not os.path.exists("icons"):
os.mkdir("icons")
os.chdir("icons")
try:
if not os.path.exists("custom.png"):
wget.download("https://areajugones.sport.es/wp-content/uploads/2015/01/Steam-OS-Planet-Steam-Logo-780x440.jpg",out="custom.png")
if not os.path.exists(str(i).replace(":","").replace(",","")+".jpg"):
i2 = str(i).replace(":","").replace(",","")
wget.download("https://steamcdn-a.akamaihd.net/steam/apps/"+str(AppId[count])+"/header.jpg",out=str(i2)+".jpg")
except: pass
print("Game = ",i+"\nId = ",AppId[count])
File = str(i).replace(":","").replace(",","")+".jpg"
try:
Img = Image.open(File)
Img.save(File,"JPEG", quality=88)
Img.close()
Img = Image.open(File)
except:
Img = Image.open("custom.png")
Img.save(File,"JPEG", quality=100)
def Start(Id):
Run = "steam://rungameid/"
os.system("start "+Run+Id)
Img = CTkImage(Img,size=[120,80])
image = CTkLabel(Frame, text="", width=100,height=100,image=Img)
image.grid(row=count,column=0,padx=5,pady=5)
Btn = CTkButton(Frame,text="Start",command= lambda: Start(str(AppId[count])))
Text = CTkLabel(Frame,text=i)
Text.grid(row=count, column=2)
Btn.grid(row=count,column=2)
os.chdir(CurPath)
root.mainloop()
def print(self, other : str | list):
if other != str:
print(str(other).replace("[","").replace("]","").replace("\'","").replace(",",""))
else:
print(other)
class SystemConsole:
def __init__(self, title : str | None = "Main", close : bool | None = False, **kwargs) -> None:
kwargs.setdefault("color","0f")
color = kwargs.get("color")
self.color = color
self.title = title
self.close = close
os.system("cls")
def Main(self):
while self.close == True:
sys.exit(0)
def Library(Games : list) -> None:
os.system("color "+self.color); os.system("cls")
print("\n---LIBRARY---")
count = -1
config.read("configs.ini")
if config.has_section("ExtraGames"):
for i in config.items("ExtraGames"):
if not Games.__contains__(i[0]):
Games.append(str(i[0]).replace("_"," "))
count = -1
for i in Games:
if count == -1: print()
count += 1
print(str(count)+" "+i)
print()
os.system("pause")
os.system("cls")
SystemConsole.Main(self)
def Add() -> None:
os.system("cls & color "+self.color)
print("\n---ADD-INFO---")
print("Here you can add custom games who are\nnot in the library !")
print()
pystyle.Write.Print("Press enter to start !",pystyle.Colors.green_to_cyan,interval=0.0025)
os.system("pause > nul")
print(pystyle.Colors.green+"\nSelect the .exe file to add it !"+pystyle.Colors.reset)
path = filedialog.askopenfilename(title="Select Exe File",filetypes=[("File .exe")])
if path == "" or path == " ":
os.system("cls")
SystemConsole.Main(self)
else:
print()
print(pystyle.Colors.blue+"Wich name should it have?"+pystyle.Colors.reset)
I = pystyle.Write.Input("Name -> ",pystyle.Colors.green_to_cyan,interval=0.025)
if I != None or I != " " or I != "":
config.read("configs.ini")
if not config.has_section("ExtraGames") == True: config.add_section("ExtraGames")
config.set("ExtraGames",I.replace(" ","_"),path)
with open("configs.ini","w") as f:
config.write(f)
f.close()
os.system("cls")
SystemConsole.Main(self)
def Configurations() -> None:
os.system("cls & color "+self.color)
print("\n---CONFIGURATIONS---")
print("\n1. Set Auto-Login (temporary) !")
print("2. Set Gui mode (BETA) DO NOT USE")
print("E. Go Back\n")
I = pystyle.Write.Input("Number -> ",pystyle.Colors.green_to_cyan,interval=0.025)
if I == "1":
os.system("reg delete HKCU\SOFTWARE\Valve\Steam /v RememberPassword /f")
os.system("reg add HKCU\SOFTWARE\Valve\Steam /v RememberPassword /d 1 /t REG_DWORD /f")
elif I == "2":
config.read("configs.ini")
config.set("Mode","GuiMode","True")
with open("configs.ini","w") as c:
config.write(c)
os.startfile("NoConsole.py")
os._exit(0)
elif (I == "E") or (I == "Go Back"):
os.system("cls")
SystemConsole.Main(self)
Configurations()
def Delete(Games : list) -> None:
os.system("cls & color "+self.color)
print("\n---DELETE---")
Game = []
config.read("configs.ini")
if config.has_section("ExtraGames") and (len(config.items("ExtraGames")) == 0): config.remove_section("ExtraGames"); f = open("configs.ini","w"); config.write(f); f.close()
count = -1
if config.has_section("ExtraGames"):
for i in config.items("ExtraGames"):
Game.append(str(i[0]).replace("_"," "))
if count == -1: print()
count += 1
print(str(count)+" "+str(i[0]).replace("_"," "))
else: print(pystyle.Colors.red+"No Custom Games were found !"+pystyle.Colors.reset)
print(pystyle.Colors.green+str(len(Games))+" Go Back\n"+pystyle.Colors.reset)
I = pystyle.Write.Input("Number : ",pystyle.Colors.blue_to_cyan,interval=0)
try:
if int(I) == len(Games): os.system("cls"); SystemConsole.Main(self)
except: pass
config.read("configs.ini")
try: CurrentGame = Game[int(I)]
except: print(pystyle.Colors.red+"\nIt should be numeric !"+pystyle.Colors.reset); print(); os.system("pause"); CurrentGame = None
if CurrentGame == None:
Delete(Games)
CurrentGame = str(CurrentGame).lower().replace(" ","_").replace(":","").replace("+","").replace(",","")
CurrentGame = config.remove_option("ExtraGames",CurrentGame)
with open("configs.ini","w") as f:
config.write(f)
Delete(Games)
def StartGames(Games : list):
os.system("color "+self.color); os.system("cls")
print("\n---GAMES TO START---")
Game = []
config.read("configs.ini")
if config.has_section("ExtraGames"):
for i in config.items("ExtraGames"):
if not Games.__contains__(str(i[0]).replace("_"," ")):
Games.append(str(i[0]).replace("_"," "))
count = -1
for i in Games:
if count == -1: print()
count += 1
print(str(count)+" "+i)
Game.append(i)
print(str(len(Game))+" Go Back\n")
I = pystyle.Write.Input("Number : ",pystyle.Colors.blue_to_cyan,interval=0)
try:
if int(I) == len(Game): os.system("cls"); SystemConsole.Main(self)
except: pass
config.read("configs.ini")
if (I != "") or (I != " "):
try: CurrentGame = Game[int(I)]
except: print(pystyle.Colors.red+"\nIt should be numeric !"+pystyle.Colors.reset); print(); os.system("pause"); CurrentGame = None
else:
CurrentGame = None
if CurrentGame == None:
StartGames(Games)
CurrentGame = str(CurrentGame).lower().replace(" ","_").replace(":","").replace("+","").replace(",","")+"_path"
try: CurrentGame = config.get("ExtraGames",CurrentGame.replace("_path",""))
except: CurrentGame = config.get("GamePath",CurrentGame)
try:
os.startfile(CurrentGame)
except Exception as E:
print()
print(pystyle.Colors.red+str(E)+pystyle.Colors.reset)
print()
os.system("pause")
StartGames(Games)
SystemConsole.Main(self)
os.system("title "+self.title); os.system("color "+self.color)
print("\n---LAUNCHER---")
print("\n1. Library")
print("2. Start Game")
print("3. Add Games")
print("4. Delete Games")
print("5. Configure\n")
I = pystyle.Write.Input("Number -> ",pystyle.Colors.green_to_blue,interval=0.025)
if I == "1":
if os.path.exists("config.json"):
try: f = open("config.json","r"); data = json.loads(f.read()); f.close()
except: print("ERROR"); os.system("pause")
Library(data["Games"])
else:
print()
pystyle.Write.Print("ERROR : 1C0\nRestart the program ! Or Press enter",pystyle.Colors.red, interval=0); print("\n"); os.system("pause")
elif I == "2":
if os.path.exists("config.json"):
try: f = open("config.json","r"); data = json.loads(f.read()); f.close()
except: print("ERROR"); os.system("pause")
StartGames(data["Games"])
else:
print()
pystyle.Write.Print("ERROR : 1C0\nRestart the program ! Or Press enter",pystyle.Colors.red, interval=0); print("\n"); os.system("pause")
elif I == "3":
Add()
elif I == "4":
try: f = open("config.json","r"); data = json.loads(f.read()); f.close()
except: print("ERROR"); os.system("pause")
Delete(data["Games"])
elif I == "5":
Configurations()
else:
os.system("cls")
SystemConsole.Main(self)