-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebman-classics-maker.py
1943 lines (1677 loc) · 69.5 KB
/
webman-classics-maker.py
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
import copy
import json
import os
import shutil
import traceback
import urllib.parse
from urllib.request import urlopen
import sys
import re
# sudo apt-get install python3-tk
import tkinter as tk
from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import askopenfile
from resources.tools.util_scripts.global_paths import (
AppPaths,
ImagePaths,
GlobalVar,
GlobalDef,
FtpSettings,
GameListData,
)
from resources.tools.util_scripts.build_all_scripts import Webman_PKG
from resources.tools.util_scripts.wcm_gui.drop_down import (
DriveDropdown,
PlatformDropdown,
)
from resources.tools.util_scripts.wcm_gui.ftp_game_data_fetcher import FtpGameList
from resources.tools.util_scripts.wcm_gui.game_listbox import Gamelist
if getattr(sys, "frozen", False):
sys.path.append(
os.path.join(
os.path.dirname(sys.executable), "resources", "tools", "util_scripts"
)
)
sys.path.append(
os.path.join(
os.path.dirname(sys.executable),
"resources",
"tools",
"util_scripts",
"wcm_gui",
)
)
else:
# running webman_classics_maker.py from root
app_full_path = os.path.realpath(__file__)
application_path = os.path.dirname(app_full_path)
sys.path.append(
os.path.join(application_path, "resources", "tools", "util_scripts")
)
sys.path.append(
os.path.join(application_path, "resources", "tools", "util_scripts", "wcm_gui")
)
# pip install Pillow
from PIL import Image, ImageDraw, ImageFont
from PIL.ImageTk import PhotoImage
def __init_tmp_pkg_dir__():
if os.path.isdir(AppPaths.tmp_work_dir):
if "webman-classics-maker" in AppPaths.tmp_work_dir.lower():
shutil.rmtree(AppPaths.tmp_work_dir)
if not os.path.isdir(AppPaths.tmp_pkg_dir):
os.makedirs(AppPaths.tmp_pkg_dir)
GlobalDef().copytree(
os.path.join(AppPaths.util_resources, "pkg_dir_bak"),
os.path.join(AppPaths.tmp_pkg_dir),
)
def __init_tmp_work_dir__():
# clean and init wcm_work_dir in startup
if os.path.isdir(AppPaths.tmp_work_dir):
if "webman-classics-maker" in AppPaths.tmp_work_dir.lower():
shutil.rmtree(AppPaths.tmp_work_dir)
if not os.path.isdir(os.path.join(AppPaths.tmp_work_dir, "pkg")):
os.makedirs(os.path.join(AppPaths.tmp_work_dir, "pkg"))
def get_build_dir_path(self, filename, title_id):
self.build_dir_path = ""
if filename not in {"", None}:
build_base_path = AppPaths.builds
tmp_filename = filename
# removes the file extension from tmp_filename
for file_ext in GlobalVar.file_extensions:
if filename.upper().endswith(file_ext):
tmp_filename = filename[0 : len(filename) - len(file_ext)]
break
game_folder_name = (
tmp_filename.replace(" ", "_") + "_(" + title_id.replace("-", "") + ")"
)
self.build_dir_path = os.path.join(build_base_path, game_folder_name)
return self.build_dir_path
def get_ftp_ip_from_config():
return FtpSettings.ps3_lan_ip
def get_ftp_user_from_config():
return FtpSettings.ftp_user
def get_ftp_pass_from_config():
return FtpSettings.ftp_password
def get_default_image(filename):
default_pkg_img_dir = os.path.join(ImagePaths.pkg, "default")
return Image.open(os.path.join(default_pkg_img_dir, filename)).convert("RGBA")
def create_pic1_gui(self, active_pkg_dir):
pic1_active_path = os.path.join(active_pkg_dir, "PIC1.PNG")
if os.path.isfile(pic1_active_path):
self.pic1_gui = Image.open(pic1_active_path).convert("RGBA")
print(
"use PIC1.PNG from {}".format(pic1_active_path)
) if self._verbose else None
else:
self.pic1_gui = Image.open(
os.path.join(AppPaths.default_img_path, "PIC1.PNG")
).convert("RGBA")
print(
"use PIC1.PNG from {}".format(
os.path.join(AppPaths.default_img_path, "PIC1.PNG")
)
) if self._verbose else None
# draw xmb icons and system logo onto the background
self.pic1_gui.paste(self.image_xmb_icons, (0, 0), self.image_xmb_icons)
self.pic1_gui.paste(self.ps3_gametype_logo, (1180, 525), self.ps3_gametype_logo)
# draw game title text onto the background
self.pic1_ref = copy.copy(self.pic1_gui)
self.draw_text_on_image_w_shadow(
self.pic1_gui,
str(self.entry_field_title.get()),
# 745, 457, 32, 2,
760,
487,
32,
2,
"white",
"black",
)
# self.draw_text_on_image_w_shadow(self.pic1_gui_w_title, self.entry_field_title.get(), 760, 487, 32, 2, 'white', 'black')
# create photoimage to be used for the button
self.pic1_photoimage = PhotoImage(
self.pic1_gui.resize(
(int(1280 * self.scaling), int(720 * self.scaling)),
Image.Resampling.LANCZOS,
)
)
# set the new background image
self.pic1_button.config(image=self.pic1_photoimage)
def create_pic0_gui(self, active_pkg_dir):
pic0_active_path = os.path.join(active_pkg_dir, "PIC0.PNG")
if os.path.isfile(pic0_active_path):
self.pic0_gui = Image.open(pic0_active_path).convert("RGBA")
pic0_bg = copy.copy(self.pic1_gui)
print(
"use PIC0.PNG from {}".format(pic0_active_path)
) if self._verbose else None
else:
self.pic0_gui = Image.open(
os.path.join(AppPaths.default_img_path, "PIC0.PNG")
).convert("RGBA")
print(
"use PIC0.PNG from {}".format(
os.path.join(AppPaths.default_img_path, "PIC0.PNG")
)
) if self._verbose else None
# mask with PIC1 background
# pic0_bg = copy.copy(self.pic1_gui_w_title)
pic0_bg = copy.copy(self.pic1_gui)
# add ps3 system logo
pic0_bg.paste(self.ps3_gametype_logo, (1180, 525), self.ps3_gametype_logo)
# draw date and time beside ICON0
self.draw_text_on_image_w_shadow(
pic0_bg, "11/11/2006 00:00", 760, 522, 20, 1, "white", "black"
)
self.pic0_x_pos = 750
self.pic0_y_pos = 412
# Image.paste(im1, (left, top, right, bottom), im1)
pic0_bg.paste(self.pic0_gui, (self.pic0_x_pos, self.pic0_y_pos), self.pic0_gui)
# Image.crop((left, top, right, bottom))
tmp_image_pic0 = pic0_bg.crop(
(
self.pic0_x_pos,
self.pic0_y_pos,
self.pic0_x_pos + self.pic0_gui.width,
self.pic0_y_pos + self.pic0_gui.height,
)
)
# PIC0 resizing
pic0_x_scale = self.main_window_width / self.pic1_gui.width * self.scaling
pic0_y_scale = self.main_window_height / self.pic1_gui.height * self.scaling
self.pic0_new_dim = (
int(pic0_x_scale * tmp_image_pic0.width),
int(pic0_y_scale * tmp_image_pic0.height),
)
self.image_pic0_resized = copy.copy(tmp_image_pic0).resize(
(self.pic0_new_dim[0], self.pic0_new_dim[1]), Image.Resampling.LANCZOS
)
# create photoimage for the button
self.pic0_photoimage = PhotoImage(self.image_pic0_resized)
# set the new PIC0 button image
self.pic0_button.config(image=self.pic0_photoimage)
def create_icon0_gui(self, active_pkg_dir):
icon0_active_path = os.path.join(active_pkg_dir, "ICON0.PNG")
platform = get_platform(self)
if os.path.isfile(icon0_active_path):
print(
"use ICON0.PNG from {}".format(icon0_active_path)
) if self._verbose else None
self.icon0_gui = Image.open(icon0_active_path).convert("RGBA")
else:
self.icon0_gui = Image.open(
os.path.join(AppPaths.default_img_path, platform, "ICON0.PNG")
).convert("RGBA")
print(
"use ICON0.PNG from {}".format(
os.path.join(AppPaths.default_img_path, platform, "ICON0.PNG")
)
)
# image coordinates for the gui (w/o scaling)
self.icon0_x_pos = 405
self.icon0_y_pos = 416
# blend ICON0 with PIC1 as background
icon0_bg = copy.copy(self.pic1_gui)
icon0_bg.paste(
self.icon0_gui.convert("RGBA"),
(self.icon0_x_pos, self.icon0_y_pos),
self.icon0_gui.convert("RGBA"),
)
# Image.crop(left, top, right, bottom)
icon0_bg = icon0_bg.crop(
(
self.icon0_x_pos,
self.icon0_y_pos,
self.icon0_x_pos + self.icon0_gui.width,
self.icon0_y_pos + self.icon0_gui.height,
)
)
# ICON0 resizing
icon0_x_scale = self.main_window_width / self.pic1_gui.width * self.scaling
icon0_y_scale = self.main_window_height / self.pic1_gui.height * self.scaling
self.icon0_gui = copy.copy(icon0_bg)
self.icon0_gui = self.icon0_gui.resize(
(int(icon0_x_scale * icon0_bg.width), int(icon0_y_scale * icon0_bg.height)),
Image.Resampling.LANCZOS,
)
# create photoimage for the button
self.icon0_gui_photoimage = PhotoImage(self.icon0_gui)
# set the new ICON0 button image
self.icon0_button.config(image=self.icon0_gui_photoimage)
def get_platform(self):
# extract the platform name by using the path
try:
platform = self.entry_field_platform.get() or ""
if platform == "NTFS":
match = re.search("(?<=[).*?(?=])", str(self.entry_field_filename.get()))
if match is not None:
donor_platform = list(
filter(lambda x: match.group() in x[0], GlobalVar.platform_paths)
)
if donor_platform:
platform = list(donor_platform)[0][1]
return platform
except AttributeError:
return ""
class Main:
def __init__(self):
self.main = main_window
self._verbose = True
# window metrics
self.scaling = 720.0 / 1080.0
self.main_window_height = int(1080 * self.scaling)
self.main_window_width = int(1920 * self.scaling)
self.main_offset_x_pos = 1450
self.main_offset_y_pos = 50
# common paths
self.WCM_BASE_PATH = AppPaths.wcm_gui
self.tmp_work_dir = AppPaths.tmp_work_dir
self.tmp_pkg_dir = AppPaths.tmp_pkg_dir
self.builds_path = AppPaths.builds
self.ftp_settings_path = os.path.join(AppPaths.settings, "ftp_settings.cfg")
self.fonts_path = AppPaths.fonts
self.game_pkg_dir = os.path.join(AppPaths.game_work_dir, "pkg")
self.active_pkg_dir = self.game_pkg_dir
# paddings
self.text_box_x_padding = 20
self.text_box_y_padding = 20
self.text_box_spacing = 7 * self.text_box_x_padding
# coordinates
self.text_height = 15 # Font(font='Helvetica').metrics('linespace')
self.device_text_y_pos = self.main_offset_y_pos + self.text_height
self.type_text_y_pos = (
self.text_box_y_padding + self.device_text_y_pos + self.text_height
)
self.title_id_text_y_pos = (
self.text_box_y_padding + 7 + self.type_text_y_pos + self.text_height + 2
)
self.title_text_y_pos = (
self.text_box_y_padding + self.title_id_text_y_pos + self.text_height
)
self.filename_text_y_pos = (
self.text_box_y_padding + self.title_text_y_pos + self.text_height
)
self.iso_path_text_y_pos = (
self.text_box_y_padding + self.filename_text_y_pos + self.text_height - 1
)
# init images and canvas for the gui
self.drive_dropdown = None
self.platform_dropdown = None
self.main_canvas = None
__init_tmp_pkg_dir__()
self.__init_images_and_canvas__()
self.__init_entry_fields__()
self.__init_buttons__()
self.__draw_background_on_canvas__()
self.__draw_pkg_images_on_canvas__()
self.__init_gamelist__()
@property
def verbose(self):
return self._verbose
@verbose.setter
def verbose(self, value):
self._verbose = value
def __init_images_and_canvas__(self):
# ui images
self.image_xmb_icons = Image.open(os.path.join(ImagePaths.xmb, "XMB_icons.png"))
self.ps3_gametype_logo = Image.open(
os.path.join(ImagePaths.xmb, "ps3_type_logo.png")
)
self.hdd_button_image = PhotoImage(
self.make_button_smallest("HDD", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.usb_button_image = PhotoImage(
self.make_button_smallest("USB", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.psp_button_image = PhotoImage(
self.make_button_smallest("PSP", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.psx_button_image = PhotoImage(
self.make_button_smallest("PSX", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.ps2_button_image = PhotoImage(
self.make_button_smallest("PS2", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.ps3_button_image = PhotoImage(
self.make_button_smallest("PS3", font="conthrax-sb.ttf", x=-1, y=-2)
)
self.build_button_image = PhotoImage(
self.small_button_maker("Build", font="arial.ttf", x=3, y=0)
)
self.add_button_image = PhotoImage(
self.small_button_maker("Add", font="arial.ttf", x=3, y=0)
)
self.save_button_image = PhotoImage(
self.small_button_maker("Save", font="arial.ttf", x=3, y=0)
)
# self.quit_button_image = PhotoImage(self.make_smal_button('Quit', font='arial.ttf', x=3, y=0))
# self.change_button_image = PhotoImage(self.make_smal_button('Change', font='arial.ttf', x=-3, y=0))
self.fetch_button_image = PhotoImage(
self.small_button_maker("Fetch", font="arial.ttf", x=3, y=0)
)
self.refresh_button_image = PhotoImage(
self.small_button_maker("Refresh", font="arial.ttf", x=-1, y=0)
)
self.image_icon0 = get_default_image("ICON0.PNG")
self.image_icon0_ref = copy.copy(self.image_icon0)
self.pic0_gui = get_default_image("PIC0.PNG")
self.gui_pic0_ref = copy.copy(self.pic0_gui)
self.pic1_gui = get_default_image("PIC1.PNG")
self.pic1_gui_ref = copy.copy(self.pic1_gui)
self.pic1_gui_w_title = copy.copy(self.pic1_gui)
self.pic1_gui_photoimage = None
# ui background image
self.background_images = []
self.load_backgrounds()
self.canvas_image_number = 0
self.current_img = self.background_images[self.canvas_image_number]
self.current_background = PhotoImage(self.current_img)
self.main_canvas = Canvas(
self.main,
width=self.main_window_width,
height=self.main_window_height,
borderwidth=0,
highlightthickness=0,
)
self.main_canvas.pack(fill=BOTH, expand=YES)
def __init_entry_fields__(self):
self.usb_port_number = 0
self.drive_system_path_array = ["drive", "system", "path"]
self.vcmd = self.main.register(self.dynamic_validate_title_id)
self.vcmd2 = self.main.register(self.dynamic_validate_title_id)
# entry fields
self.entry_field_title_id = Entry(
self.main, validate="key", validatecommand=(self.vcmd, "%P")
)
self.entry_field_title = Entry(self.main)
self.entry_field_filename = Entry(self.main)
self.entry_field_iso_path = Entry(self.main, state="readonly")
# not visible in GUI
self.entry_field_platform = Entry(self.main)
##########################################################################
# Adding an on_change-listener on 'entry_field_title'
self.generate_on_change(self.entry_field_title)
self.entry_field_title.bind("<<Change>>", self.dynamic_title_to_pic1)
###########################################################################
# Adding an on_change-listener on 'entry_field_filename'
self.generate_on_change(self.entry_field_filename)
###########################################################################
self.entry_field_ftp_ip = Entry(self.main)
self.entry_field_ftp_ip.insert(0, get_ftp_ip_from_config())
self.entry_field_ftp_user = Entry(self.main)
self.entry_field_ftp_user.insert(0, get_ftp_user_from_config())
self.entry_field_ftp_pass = Entry(self.main)
self.entry_field_ftp_pass.insert(0, get_ftp_pass_from_config())
# system choice buttons
self.selection_drive_list = GlobalVar.drive_paths
self.selection_system_list = GlobalVar.platform_paths
self.drive_path = self.selection_drive_list[
0
] # drive should be toggled by buttons
# Entry field placements
entry_field_width = 200
x1 = int((self.text_box_spacing + self.main_offset_x_pos) * self.scaling)
x2 = int((self.main_offset_x_pos + 90) * self.scaling)
x3 = int((self.main_offset_x_pos + 320) * self.scaling)
self.entry_field_title_id.place(
x=x1,
y=int(self.title_id_text_y_pos * self.scaling),
width=entry_field_width,
)
self.entry_field_title.place(
x=x1, y=int(self.title_text_y_pos * self.scaling), width=entry_field_width
)
self.entry_field_filename.place(
x=x1,
y=int(self.filename_text_y_pos * self.scaling),
width=entry_field_width,
)
self.entry_field_iso_path.place(
x=x1,
y=int(self.iso_path_text_y_pos * self.scaling),
width=entry_field_width,
)
self.entry_field_ftp_ip.place(
x=x2, y=int((self.main_offset_y_pos + 815) * self.scaling), width=90
)
self.entry_field_ftp_user.place(
x=x3, y=int((self.main_offset_y_pos + 815) * self.scaling), width=60
)
self.entry_field_ftp_pass.place(
x=x3, y=int((self.main_offset_y_pos + 850) * self.scaling), width=60
)
def __init_buttons__(self):
print(self.selection_drive_list[0][0]) if self._verbose else None
self.hdd_button = Button(
self.main,
image=self.hdd_button_image,
borderwidth=1,
command=lambda: self.on_drive_button(self.selection_drive_list[0][0]),
)
self.usb_button = Button(
self.main,
image=self.usb_button_image,
borderwidth=1,
command=lambda: self.on_drive_button(
self.selection_drive_list[self.usb_port_number + 1][0]
),
)
self.psp_button = Button(
self.main,
image=self.psp_button_image,
borderwidth=1,
command=lambda: self.on_system_button(
self.drive_system_path_array[0], self.selection_system_list[0][0]
),
)
self.psx_button = Button(
self.main,
image=self.psx_button_image,
borderwidth=1,
command=lambda: self.on_system_button(
self.drive_system_path_array[0], self.selection_system_list[1][0]
),
)
self.ps2_button = Button(
self.main,
image=self.ps2_button_image,
borderwidth=1,
command=lambda: self.on_system_button(
self.drive_system_path_array[0], self.selection_system_list[2][0]
),
)
self.ps3_button = Button(
self.main,
image=self.ps3_button_image,
borderwidth=1,
command=lambda: self.on_system_button(
self.drive_system_path_array[0], self.selection_system_list[3][0]
),
)
self.build_button = Button(
self.main,
image=self.build_button_image,
borderwidth=0,
command=self.on_build_button,
bg="#FBFCFB",
)
self.save_button = Button(
self.main,
image=self.save_button_image,
borderwidth=0,
command=self.on_save_button,
bg="#FBFCFB",
)
self.fetch_button = Button(
self.main,
image=self.fetch_button_image,
borderwidth=0,
command=self.on_ftp_fetch_button,
bg="#FBFCFB",
)
self.refresh_button = Button(
self.main,
image=self.refresh_button_image,
borderwidth=0,
command=self.__init_gamelist__,
bg="#FBFCFB",
)
self.pic1_button = Button(
self.main,
highlightthickness=0,
bd=0,
command=lambda: self.image_replace_browser(),
)
self.pic0_button = Button(
self.main,
highlightthickness=0,
bd=0,
command=lambda: self.image_replace_browser(),
)
self.icon0_button = Button(
self.main,
highlightthickness=0,
bd=0,
command=lambda: self.image_replace_browser(),
)
# button tooltips
CreateToolTip(self.usb_button, "Toggle USB port [0-3]")
CreateToolTip(self.build_button, "Save & Build tmp_pkg_dir")
CreateToolTip(self.save_button, "Save to builds folder")
CreateToolTip(self.fetch_button, "Fetch gamelist and images over FTP")
CreateToolTip(self.refresh_button, "Refresh gamelist from disk")
CreateToolTip(self.pic1_button, "Replace PIC1")
CreateToolTip(self.pic0_button, "Replace PIC0")
CreateToolTip(self.icon0_button, "Replace ICON0")
# Text button placements
x1 = (self.text_box_spacing + self.main_offset_x_pos + 0 * 75) * self.scaling
y1 = self.device_text_y_pos * self.scaling
x2 = (self.text_box_spacing + self.main_offset_x_pos + 1 * 75) * self.scaling
y2 = self.type_text_y_pos * self.scaling
x3 = (self.text_box_spacing + self.main_offset_x_pos + 2 * 75) * self.scaling
y3 = (self.iso_path_text_y_pos + 40) * self.scaling
x4 = (self.text_box_spacing + self.main_offset_x_pos + 3 * 75) * self.scaling
y4 = (self.main_offset_y_pos + 855) * self.scaling
self.hdd_button.place(x=int(x1), y=int(y1))
self.usb_button.place(x=int(x2), y=int(y1))
self.psp_button.place(x=int(x1), y=int(y2))
self.psx_button.place(x=int(x2), y=int(y2))
self.ps2_button.place(x=int(x3), y=int(y2))
self.ps3_button.place(x=int(x4), y=int(y2))
self.build_button.place(x=int(x1), y=int(y3))
self.save_button.place(x=int(x2 + 10), y=int(y3))
self.fetch_button.place(x=int(self.main_offset_x_pos * self.scaling), y=int(y4))
self.refresh_button.place(
x=int(self.main_offset_x_pos * self.scaling + 60), y=int(y4)
)
# GUI buttons placements
# image buttons coordinates (w/ scaling)
pic1_button_x_pos = 75 * self.scaling
pic1_button_y_pos = 175 * self.scaling
pic0_button_x_pos = 573 * self.scaling
pic0_button_y_pos = 450 * self.scaling
icon0_button_x_pos = 344 * self.scaling
icon0_button_y_pos = 454 * self.scaling
self.pic1_button.place(x=pic1_button_x_pos, y=pic1_button_y_pos)
self.pic0_button.place(x=int(pic0_button_x_pos), y=int(pic0_button_y_pos))
self.icon0_button.place(x=int(icon0_button_x_pos), y=int(icon0_button_y_pos))
def bind_filter_dropdowns(self):
# ensure drive_dropdown into the listbox
if self.drive_dropdown is None:
self.drive_dropdown = DriveDropdown(self.main_canvas).get_dropdown()
self.drive_dropdown.bind("<<ComboboxSelected>>", self.dropdown_filter_callback)
# ensure platform_dropdown into the listbox
if self.platform_dropdown is None:
self.platform_dropdown = PlatformDropdown(self.main_canvas).get_dropdown()
self.platform_dropdown.bind(
"<<ComboboxSelected>>", self.dropdown_filter_callback
)
def dropdown_filter_callback(self, event):
dropdown_name = str(event.widget).split(".")[-1]
if dropdown_name == "drive_dropdown":
self.list_filter_drive = event.widget.get()
self.drive_dropdown.set(self.list_filter_drive)
elif dropdown_name == "platform_dropdown":
self.list_filter_platform = event.widget.get()
self.platform_dropdown.set(self.list_filter_platform)
# NTFS can only be used combined with HDD0
if "NTFS" == self.list_filter_platform:
self.list_filter_drive = "HDD0"
self.drive_dropdown.set("HDD0")
self.gamelist = Gamelist(
self, self.list_filter_platform, self.list_filter_drive
)
def make_button_smallest(self, text, **args):
font = None
x = None
y = None
icon_bg_img = Image.new("RGB", (44, 15), color="black")
for key, value in args.items():
if "font" == key:
font = value
elif "x" == key:
x = value
elif "y" == key:
y = value
elif "width" == key:
width = value
elif "height" == key:
height = value
if not font:
self.draw_text_on_image_w_font(
icon_bg_img,
text,
7,
3,
12,
"white",
os.path.join(self.fonts_path, "arial.ttf"),
)
else:
if x:
x_val = x + 12 - len(text)
else:
x_val = 12 - len(text)
self.draw_text_on_image_w_font(
icon_bg_img,
text,
x_val,
3 + y,
10,
"white",
os.path.join(self.fonts_path, font),
)
return copy.copy(icon_bg_img)
def small_button_maker(self, text, **args):
font = None
x = None
y = None
icon_bg_img = Image.new("RGB", (50, 20), color="black")
for key, value in args.items():
if "font" == key:
font = value
elif "x" == key:
x = value
elif "y" == key:
y = value
elif "width" == key:
width = value
elif "height" == key:
height = value
if not font:
self.draw_text_on_image_w_font(
icon_bg_img,
text,
7,
3,
12,
"white",
os.path.join(self.fonts_path, "arial.ttf"),
)
else:
if x:
x_val = x + 12 - len(text)
else:
x_val = 12 - len(text)
self.draw_text_on_image_w_font(
icon_bg_img,
text,
x_val,
3 + y,
12,
"white",
os.path.join(self.fonts_path, font),
)
return copy.copy(icon_bg_img)
def medium_button_maker(self, text, *font_name):
icon_bg_img = Image.new("RGB", (54, 20), color="black")
if not font_name:
self.draw_text_on_image_w_font(
icon_bg_img,
text,
7,
1,
15,
"white",
os.path.join(self.fonts_path, "conthrax-sb.ttf"),
)
else:
tmp_font = str(font_name[0])
self.draw_text_on_image_w_font(
icon_bg_img,
text,
7,
1,
15,
"white",
os.path.join(self.fonts_path, tmp_font),
)
return copy.copy(icon_bg_img)
def __draw_background_on_canvas__(self):
self.text_device = "Device"
self.text_platform = "Type"
self.text_title_id = "Title id"
self.text_title = "Title"
self.text_filename = "Filename"
self.text_iso_path = "Path"
self.text_ftp_game_list = "FTP Game list"
self.text_ps3_ip_label = "PS3-ip"
self.text_ps3_usr_label = "User"
self.text_ps3_pass_label = "Pass"
self.current_img = self.background_images[self.canvas_image_number]
webman_logo = Image.open(
os.path.join(ImagePaths.misc, "webman_text_icon_bw.png")
).resize((int(464 * 0.45), int(255 * 0.45)))
self.draw_text_on_image_w_shadow(
self.background_images[self.canvas_image_number],
"webMAN",
490,
-10,
110,
6,
"#0C55F4",
"black",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_shadow(
self.background_images[self.canvas_image_number],
"Classics Maker",
422,
60,
80,
5,
"white",
"black",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.current_img.paste(webman_logo, (515, 22), webman_logo)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_device.upper(),
self.main_offset_x_pos,
self.device_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_platform.upper(),
self.main_offset_x_pos,
self.type_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_title_id.upper(),
self.main_offset_x_pos,
self.title_id_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_title.upper(),
self.main_offset_x_pos,
self.title_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_filename.upper(),
self.main_offset_x_pos,
self.filename_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_iso_path.upper(),
self.main_offset_x_pos,
self.iso_path_text_y_pos,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_ftp_game_list.upper(),
self.main_offset_x_pos,
self.iso_path_text_y_pos + 120,
25,
"white",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_ps3_ip_label.upper(),
self.main_offset_x_pos + 0 * 50,
self.main_offset_y_pos + 810,
25,
"#ffffff",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_ps3_usr_label.upper(),
self.main_offset_x_pos + 5 * 50,
self.main_offset_y_pos + 810,
25,
"#ffffff",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.draw_text_on_image_w_font(
self.background_images[self.canvas_image_number],
self.text_ps3_pass_label.upper(),
self.main_offset_x_pos + 5 * 50,
self.main_offset_y_pos + 845,
25,
"#ffffff",
font=os.path.join(self.fonts_path, "LLPIXEL3.ttf"),
)
self.current_img = self.background_images[self.canvas_image_number]
self.current_img = self.current_img.resize(
(int(1920 * self.scaling), int(1080 * self.scaling)),
Image.Resampling.LANCZOS,
)
self.tv_frame = Image.open(
os.path.join(ImagePaths.misc, "tv_frame_1080_ps3_3.png")
).resize(
(int(1990 * self.scaling), int(1327 * self.scaling)),
Image.Resampling.LANCZOS,
)
self.current_img.paste(
self.tv_frame,
(int(45 * self.scaling), int(143 * self.scaling)),
self.tv_frame,
)
self.background_image = self.main_canvas.create_image(
0, 0, anchor=NW, image=self.current_background
)
self.current_background = PhotoImage(self.current_img)
self.main_canvas.itemconfig(