3838
3939VERSION = 'v0.0.1 BETA'
4040
41+ CONFIG_PATH : str = os .path .join (os .path .dirname (__file__ ), ".config" )
4142LOGO_PATH : str = os .path .join (os .path .dirname (__file__ ), "assets" , "full_logo.png" )
4243ICON_PATH : str = os .path .join (os .path .dirname (__file__ ), "assets" , "full_logo.ico" )
4344GAME_PH = 'Doom (1993) / The Ultimate Doom'
4445EPISODE_PH = 'E1: Knee-Deep in the Dead'
4546MAP_PH = 'E1M1: Hangar'
4647SECRETS_PH = 0
4748
49+ with open (CONFIG_PATH , 'r' , encoding = 'utf-8' ) as f :
50+ cache = f .read ()
51+ cache = cache .split ('\n ' )
52+
4853root = tk .Tk ()
4954root .title (f"Doom Map Guesser by MF366 - The GeoGuesser of DOOM ({ VERSION } )" )
50- root .geometry ('1000x700 ' )
55+ root .geometry (f' { int ( cache [ 0 ]) } x { int ( cache [ 1 ]) } ' )
5156root .resizable (True , False )
5257
5358if sys .platform == 'win32' :
5459 root .iconbitmap (ICON_PATH )
5560
56- sv_ttk .set_theme ('dark' , root )
61+ sv_ttk .set_theme (cache [ 2 ] , root )
5762style = ttk .Style (root )
5863
5964f1 = ttk .Frame (root )
6065f2 = ttk .Frame (f1 )
6166f3 = ttk .Frame (f2 )
6267f4 = ttk .Frame (f2 )
6368f5 = ttk .Frame (f1 )
69+ f6 = ttk .Frame (f1 )
6470
6571img_label = ttk .Label (f3 , text = 'Image not available.' )
6672
8490episode_var = tk .Variable (f4 , list (database [cur_selections [0 ]].keys ()))
8591maps_var = tk .Variable (f4 , list (database [cur_selections [0 ]][cur_selections [1 ]].keys ()))
8692number_of_secrets_var = tk .StringVar (f4 , '0 Secrets' )
93+ points_var = tk .IntVar (root , 0 )
94+ max_points_var = tk .IntVar (root , 0 )
8795
8896
8997def get_width_height_of_image (image : bytes , ratio : tuple [int , int ] = (16 , 9 )):
@@ -120,14 +128,14 @@ def _save_changes():
120128
121129 game_choice_win = tk .Toplevel (master )
122130 game_choice_win .focus_set ()
123- game_choice_win .geometry ('400x400 ' )
131+ game_choice_win .geometry (f' { int ( cache [ 3 ]) } x { int ( cache [ 4 ]) } ' )
124132 game_choice_win .resizable (False , False )
125133 game_choice_win .title ("Choose the correct game/WAD" )
126134
127135 if sys .platform == 'win32' :
128136 game_choice_win .iconbitmap (ICON_PATH )
129137
130- game_listbox = tk .Listbox (game_choice_win , listvariable = game_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = 50 , height = 20 )
138+ game_listbox = tk .Listbox (game_choice_win , listvariable = game_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = int ( cache [ 5 ]) , height = int ( cache [ 6 ]) )
131139 accept_butt = ttk .Button (game_choice_win , text = 'Confirm' , command = _save_changes )
132140
133141 game_listbox .pack ()
@@ -154,14 +162,14 @@ def _save_changes():
154162
155163 episode_choice_win = tk .Toplevel (master )
156164 episode_choice_win .focus_set ()
157- episode_choice_win .geometry ('400x400 ' )
165+ episode_choice_win .geometry (f' { int ( cache [ 3 ]) } x { int ( cache [ 4 ]) } ' )
158166 episode_choice_win .resizable (False , False )
159167 episode_choice_win .title (f"Choose the correct episode for { cur_selections [0 ]} " )
160168
161169 if sys .platform == 'win32' :
162170 episode_choice_win .iconbitmap (ICON_PATH )
163171
164- episode_listbox = tk .Listbox (episode_choice_win , listvariable = episode_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = 50 , height = 20 )
172+ episode_listbox = tk .Listbox (episode_choice_win , listvariable = episode_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = int ( cache [ 5 ]) , height = int ( cache [ 6 ]) )
165173 accept_butt = ttk .Button (episode_choice_win , text = 'Confirm' , command = _save_changes )
166174
167175 episode_listbox .pack ()
@@ -187,14 +195,14 @@ def _save_changes():
187195
188196 map_choice_win = tk .Toplevel (master )
189197 map_choice_win .focus_set ()
190- map_choice_win .geometry ('400x400 ' )
198+ map_choice_win .geometry (f' { int ( cache [ 3 ]) } x { int ( cache [ 4 ]) } ' )
191199 map_choice_win .resizable (False , False )
192200 map_choice_win .title (f"Choose the correct map for { cur_selections [1 ]} " )
193201
194202 if sys .platform == 'win32' :
195203 map_choice_win .iconbitmap (ICON_PATH )
196204
197- maps_listbox = tk .Listbox (map_choice_win , listvariable = maps_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = 50 , height = 20 )
205+ maps_listbox = tk .Listbox (map_choice_win , listvariable = maps_var , bg = 'dark blue' , fg = 'yellow' , selectmode = tk .SINGLE , width = int ( cache [ 5 ]) , height = int ( cache [ 6 ]) )
198206 accept_butt = ttk .Button (map_choice_win , text = 'Confirm' , command = _save_changes )
199207
200208 maps_listbox .pack ()
@@ -257,7 +265,7 @@ def display_intro(master: tk.Tk | tk.Toplevel = root):
257265 logo = Image .open (LOGO_PATH )
258266
259267 # [*] Resizing
260- new_width = 250
268+ new_width = int ( cache [ 8 ])
261269 original_width , original_height = logo .size
262270 aspect_ratio = original_height / original_width
263271 new_height = int (new_width * aspect_ratio ) # [i] Calculate the height based on the original aspect ratio
@@ -299,7 +307,7 @@ def display_screenshot(screenshot_link: str):
299307 img = Image .open (image_data_io , "r" )
300308
301309 # [*] Resizing
302- new_width = 500
310+ new_width = int ( cache [ 9 ])
303311 original_width , original_height = img .size
304312 aspect_ratio = original_height / original_width
305313 new_height = int (new_width * aspect_ratio ) # [i] Calculate the height based on the original aspect ratio
@@ -363,7 +371,9 @@ def generate_new_game(attempts: int = 10):
363371 choose_episode_butt .configure (text = cur_selections [1 ])
364372 choose_map_butt .configure (text = cur_selections [2 ])
365373
366- print (cur_screenshot )
374+ # /-/ print(cur_screenshot)
375+
376+ max_points_var .set (max_points_var .get () + 4 )
367377
368378 display_screenshot (cur_screenshot )
369379
@@ -384,6 +394,8 @@ def guess_screenshot(attempts: int = 10):
384394
385395 mb .showinfo ("DoomMapGuesser - Final Results" , f"Correct guesses: { correct_guesses } /4" )
386396
397+ points_var .set (points_var .get () + correct_guesses )
398+
387399 generate_new_game (attempts )
388400
389401
@@ -394,11 +406,21 @@ def prevent_from_leaving(master: tk.Tk | tk.Toplevel = root):
394406 master .destroy ()
395407
396408
397- generate_butt = ttk .Button (f5 , text = "Generate new screenshot" , command = generate_new_game )
398- guess_butt = ttk .Button (f5 , text = "Confirm guess" , command = guess_screenshot )
409+ generate_butt = ttk .Button (f5 , text = "Generate new screenshot" , command = lambda :
410+ generate_new_game (int (cache [7 ])))
411+ guess_butt = ttk .Button (f5 , text = "Confirm guess" , command = lambda :
412+ guess_screenshot (int (cache [7 ])))
399413leave_butt = ttk .Button (f5 , text = 'Exit' , command = prevent_from_leaving )
400414
415+ points_label = ttk .Label (f6 , textvariable = points_var )
416+ slash = ttk .Label (f6 , text = '/' )
417+ max_points_label = ttk .Label (f6 , textvariable = max_points_var )
418+
401419# [*] packing the rest of the elements
420+ points_label .grid (column = 0 , row = 0 )
421+ slash .grid (column = 1 , row = 0 )
422+ max_points_label .grid (column = 2 , row = 0 )
423+
402424img_label .pack ()
403425
404426choose_game_butt .pack (pady = 2 )
@@ -414,6 +436,8 @@ def prevent_from_leaving(master: tk.Tk | tk.Toplevel = root):
414436guess_butt .pack (pady = 2 )
415437leave_butt .pack (pady = 2 )
416438
439+ f6 .pack ()
440+
417441f3 .grid (column = 0 , row = 0 , padx = 5 , pady = 2 )
418442f4 .grid (column = 1 , row = 0 , padx = 5 , pady = 2 )
419443
0 commit comments