Skip to content

Commit bc012c7

Browse files
committed
simple settings
1 parent 2d0fba9 commit bc012c7

File tree

4 files changed

+54
-14
lines changed

4 files changed

+54
-14
lines changed

.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1000
2+
700
3+
dark
4+
400
5+
400
6+
50
7+
20
8+
10
9+
250
10+
500

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# DoomMapGuesser
2+
<img src="https://raw.githubusercontent.com/MF366-Coding/DoomMapGuesser/main/assets/full_logo.png" alt="DoomMapGuesser's logo" align="right" width="120" height="120">
3+
24
The GeoGuesser of DOOM. Guess the game/WAD, episode, map and number of secrets.
35

4-
## [Contributions are appreciated](https://github.com/MF366-Coding/DoomMapGuesser/blob/main/TODO.md)
6+
[![Latest Version](https://img.shields.io/github/v/tag/MF366-Coding/DoomMapGuesser?color=%23000184)](https://github.com/MF366-Coding/DoomMapGuesser/releases/latest)
7+
[![License](https://img.shields.io/github/license/MF366-Coding/DoomMapGuesser)](https://raw.githubusercontent.com/MF366-Coding/DommMapGuesser/main/LICENSE)
8+
<!-- [![Documentation](https://img.shields.io/badge/old-now?label=docs%20status&color=%23000085)](https://mf366-coding.github.io/writerclassic.html#docs) -->
9+
10+
## [Contributions are appreciated - we're (not) close to a full release!](https://github.com/MF366-Coding/DoomMapGuesser/blob/main/TODO.md)

assets/full_logo.png

0 Bytes
Loading

main.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,35 @@
3838

3939
VERSION = 'v0.0.1 BETA'
4040

41+
CONFIG_PATH: str = os.path.join(os.path.dirname(__file__), ".config")
4142
LOGO_PATH: str = os.path.join(os.path.dirname(__file__), "assets", "full_logo.png")
4243
ICON_PATH: str = os.path.join(os.path.dirname(__file__), "assets", "full_logo.ico")
4344
GAME_PH = 'Doom (1993) / The Ultimate Doom'
4445
EPISODE_PH = 'E1: Knee-Deep in the Dead'
4546
MAP_PH = 'E1M1: Hangar'
4647
SECRETS_PH = 0
4748

49+
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
50+
cache = f.read()
51+
cache = cache.split('\n')
52+
4853
root = tk.Tk()
4954
root.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])}')
5156
root.resizable(True, False)
5257

5358
if sys.platform == 'win32':
5459
root.iconbitmap(ICON_PATH)
5560

56-
sv_ttk.set_theme('dark', root)
61+
sv_ttk.set_theme(cache[2], root)
5762
style = ttk.Style(root)
5863

5964
f1 = ttk.Frame(root)
6065
f2 = ttk.Frame(f1)
6166
f3 = ttk.Frame(f2)
6267
f4 = ttk.Frame(f2)
6368
f5 = ttk.Frame(f1)
69+
f6 = ttk.Frame(f1)
6470

6571
img_label = ttk.Label(f3, text='Image not available.')
6672

@@ -84,6 +90,8 @@
8490
episode_var = tk.Variable(f4, list(database[cur_selections[0]].keys()))
8591
maps_var = tk.Variable(f4, list(database[cur_selections[0]][cur_selections[1]].keys()))
8692
number_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

8997
def 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])))
399413
leave_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+
402424
img_label.pack()
403425

404426
choose_game_butt.pack(pady=2)
@@ -414,6 +436,8 @@ def prevent_from_leaving(master: tk.Tk | tk.Toplevel = root):
414436
guess_butt.pack(pady=2)
415437
leave_butt.pack(pady=2)
416438

439+
f6.pack()
440+
417441
f3.grid(column=0, row=0, padx=5, pady=2)
418442
f4.grid(column=1, row=0, padx=5, pady=2)
419443

0 commit comments

Comments
 (0)