-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
old_glory.py
1893 lines (1584 loc) · 71.6 KB
/
old_glory.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
import tkinter as tk
import tkinter.font as TkFont
from tkinter import ttk
from PIL import ImageTk, Image
import sys
import os
import platform
import traceback
import requests
import webbrowser
import socket
from functools import partial
#import re
from threading import Thread
import manager
import backend
import js_tweaker
from src import custom_tk
OS_TYPE = platform.system()
DEBUG_STDOUT_STDERR = False # Only useful for debugging purposes, set to True
class OldGloryApp(tk.Tk):
def __init__(self, *args, **kwargs):
self.version = "1.1.7.1"
self.release = "5.16"
### Window Frame
tk.Tk.__init__(self, *args, **kwargs)
self.container = tk.Frame(self)
### Data and Config (will be populated)
self.json_data = None
self.css_config = None
self.sections_config = None
self.js_config = None
### Fixed DPI Scaling on Windows
if OS_TYPE == "Windows":
#dpi = window.winfo_fpixels('1i')
self.call('tk', 'scaling', 1.3)
### Window Dimensions/Position (width, height)
self.set_window_dimensions(760, 660)
### Icon and Title
add_window_icon(self)
self.wm_title("SteamUI-OldGlory Installer " + self.release)
### Custom tk Styling
self.set_tk_styles()
### Grid configure
self.container.grid_rowconfigure(0, weight=1)
self.container.grid_columnconfigure(0, weight=1)
### Load config variables
self.js_gui_changed = 0
self.mode_changed = 0
### Frames/Pages configure
self.frames = {}
for F in (StartPage, CSSPage, JSPage):
frame = F(self.container, self)
frame.grid(row=0, column=0, sticky="nsew")
self.frames[F.__name__] = frame
self.show_frame("StartPage")
### Run Update Checks with show frame
thread1 = Thread(target = self.steam_update_check, args = ())
thread1.start()
thread2 = Thread(target = self.update_check, args = ())
thread2.start()
def set_window_dimensions(self, width, height):
self.windowW = width
self.windowH = height
screen_width = self.container.winfo_screenwidth()
screen_height = self.container.winfo_screenheight()
windowX = (screen_width / 2) - (self.windowW / 2)
windowY = (screen_height / 2) - (self.windowH / 2)
self.geometry(f'{self.windowW}x{self.windowH}+{int(windowX)}+{int(windowY)}')
self.minsize(width=self.windowW, height=self.windowH)
self.maxsize(width=screen_width, height=screen_height)
self.container.pack(side="top", fill="both", expand = True)
def set_tk_styles(self):
### Default Font
self.default_font = TkFont.nametofont("TkDefaultFont")
self.default_font.configure(size=13)
### Custom Checkbutton layout
style=ttk.Style()
style.layout("TCheckbutton",
[('Checkbutton.padding', {'sticky': 'nswe', 'children':
[('Checkbutton.focus', {'side': 'left', 'sticky': '', 'children':
[('Checkbutton.indicator', {'side': 'top', 'sticky': 'nswe'})
]
})]
})]
)
### Notebook "tabs" styling
style.layout("Tab",
[('Notebook.tab', {'sticky': 'nswe', 'children':
[('Notebook.padding', {'side': 'top', 'sticky': 'nswe', 'children':
#[('Notebook.focus', {'side': 'top', 'sticky': 'nswe', 'children':
[('Notebook.label', {'side': 'top', 'sticky': ''})],
#})],
})],
})]
)
### Combobox dropdown - style to default font
self.option_add("*TCombobox*Listbox*font", (self.default_font))
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
frame.update()
frame.event_generate("<<ShowFrame>>")
'''
def get_frame(self, name):
for frame in self.frames:
if frame.__name__ == name:
return frame
'''
def steam_update_check(self):
try:
self.current_file_hash = backend.get_md5_file_hash(backend.get_path_with_wildcard(backend.package_dir()))
if self.current_file_hash != self.json_data["steamui_websrc_all.zip.vz_hash"]:
print("New Steam Update detected. If the Steam window does not appear, try using the Remake JS button in Settings.", file=sys.stderr)
except:
print("Error checking Steam package folder for update.",file=sys.stderr)
print_traceback()
#init text log
def update_check(self):
### Check if CSS Patched
### Check for new version
self.frames["StartPage"].text1.config(state='normal')
if is_connected():
#deprecated
#check_if_css_patched(self.frames["StartPage"])
release_check(self.frames["StartPage"], self.release)
print("Checking for small updates...")
thread = Thread(target = self.small_update_check, args = ())
thread.start()
else:
print("You are offline, cannot automatically check for updates.", file=sys.stderr)
def small_update_check(self):
file_dates = backend.hash_compare_small_update_files(
backend.check_new_commit_dates(self.json_data),
self.json_data)
#print(file_dates)
files_no = 0
for update_type in file_dates:
files_no += len(file_dates[update_type])
if files_no > 0:
thread = Thread(target = UpdateWindow, kwargs = ({'controller': self, 'file_dates': file_dates}))
thread.start()
else:
print("Done.")
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
### LOG FRAME
### Created first
self.create_log_frame()
### load JSON
self.controller.json_data = backend.get_json_data()
self.controller.oldglory_config = backend.load_config()
### HEAD FRAME
###
self.frameHead = head_frame(self, self.controller)
### Tabs
self.tabs = ttk.Notebook(self,width=722)
self.frameCheck = tk.Frame(self.tabs)
self.framePatch = tk.Frame(self.tabs)
self.frameThemes = tk.Frame(self.tabs)
### Functions - Frames and Pack
self.create_check_frame()
self.create_patch_frame(controller)
self.create_themes_frame()
self.create_mode_frame()
self.create_confirm_frame()
self.set_init_gui_states()
self.pack_frames()
def create_log_frame(self):
### LOG FRAME
### Defined first even though it will be packed after the CHECK FRAME,
### due to redirecting StdOut
###
self.frameLog = tk.Frame(self,
width=self.controller.windowW-50,
height=self.controller.windowH-450)
self.frameLog.grid_propagate(False)
self.frameLog.columnconfigure(0, weight=1)
self.frameLog.rowconfigure(0, weight=1)
### Text
entry1 = ttk.Entry(self.frameLog)
self.text1 = tk.Text(entry1, width=500)
self.text1.configure(font=("Arial",10))
### REDIRECT STDOUT STDERR
if not DEBUG_STDOUT_STDERR:
sys.stdout = custom_tk.StdoutRedirector(self.text1)
sys.stderr = custom_tk.StderrRedirector(self.text1)
self.text1.pack(expand="yes")
entry1.grid(row=0, column=0)
###
scroll_1 = ttk.Scrollbar(self.frameLog, command=self.text1.yview)
scroll_1.grid(row=0, column=1, sticky='ns')
self.text1['yscrollcommand'] = scroll_1.set
def create_check_frame(self):
### CHECK FRAME
###
#self.frameCheck.grid_columnconfigure(2, weight=1)
######
self.var1 = tk.IntVar()
self.check1 = ttk.Checkbutton(self.frameCheck,
variable=self.var1)
self.check1.bind("<Button-1>", lambda event:css_cb_check(event, self.var1, [self.check2, self.check3, self.check7]))
self.check1.grid(row=0, column=0)
###
mo1 = MainOption(
parentFrame=self.frameCheck,
page=self,
name="Install CSS Tweaks",
image="images/full_layout.png",
tags=["CSS"])
mainoption1 = mo1.returnMainOption()
mainoption1.grid(row=0, column=1, sticky='w')
######
self.var2 = tk.IntVar()
self.check2 = ttk.Checkbutton(self.frameCheck,
variable=self.var2)
self.check2.grid(row=1, column=0)
###
mo2 = MainOption(
parentFrame=self.frameCheck,
page=self,
name=" \u2937 Box Play Button",
image="images/play_button_box.png",
tags=["CSS"])
mainoption2 = mo2.returnMainOption()
mainoption2.grid(row=1, column=1, sticky='w')
######
self.var3 = tk.IntVar()
self.check3 = ttk.Checkbutton(self.frameCheck,
variable=self.var3)
self.check3.bind("<Button-1>", lambda event:css_cb_check(event, self.var3, [self.check4]))
self.check3.grid(row=2, column=0)
###
mo3 = MainOption(
parentFrame=self.frameCheck,
page=self,
name=" \u2937 Vertical Nav Bar",
image="images/vertical_nav_bar.png",
tags=["CSS"])
mainoption3 = mo3.returnMainOption()
mainoption3.grid(row=2, column=1, sticky='w')
######
self.var4 = tk.IntVar()
self.check4 = ttk.Checkbutton(self.frameCheck,
variable=self.var4)
self.check4.grid(row=3, column=0)
###
mo4 = MainOption(
parentFrame=self.frameCheck,
page=self,
name=" \u2937 Classic Layout",
image="images/classic_layout.png",
tags=["CSS"])
mainoption4 = mo4.returnMainOption()
mainoption4.grid(row=3, column=1, sticky='w')
######
self.var5 = tk.IntVar()
self.check5 = ttk.Checkbutton(self.frameCheck,
variable=self.var5,
state=tk.DISABLED)
self.check5.grid(row=4, column=0)
###
mo5 = MainOption(
parentFrame=self.frameCheck,
page=self,
name=" \u2937 Landscape Game Images",
image="images/landscape_images.png",
tags=["CSS", "JS"])
mainoption5 = mo5.returnMainOption()
mainoption5.grid(row=4, column=1, sticky='w')
######
self.change_theme = 0
self.var6 = tk.IntVar()
self.check6 = ttk.Checkbutton(self.frameCheck,
variable=self.var6)
self.check6.bind("<Button-1>", lambda event: self.setChangeTheme(event))
self.check6.grid(row=5, column=0)
###
mo6 = MainOption(
parentFrame=self.frameCheck,
page=self,
name="Library Theme",
image="images/theme_shiina.png",
tags=["CSS"])
mainoption6 = mo6.returnMainOption()
mainoption6.grid(row=5, column=1, sticky='w')
###
self.dropdown6_value = tk.StringVar()
self.dropdown6 = ttk.Combobox(self.frameCheck,
font="TkDefaultFont",
values=self.getListOfThemeNames(self.controller),
state="readonly",
textvariable=self.dropdown6_value,
width=30)
self.dropdown6.current(0)
self.dropdown6.bind("<<ComboboxSelected>>", lambda event: dropdown_click(event, self, self.controller))
self.dropdown6.grid(row=6, column=1, columnspan=2, sticky="w")
######
self.var7 = tk.IntVar()
self.check7 = ttk.Checkbutton(self.frameCheck,
variable=self.var7)
self.check7.grid(row=0, column=2)
###
mo7 = MainOption(
parentFrame=self.frameCheck,
page=self,
name="Classic Styling (WIP)",
image="images/classic_styling.png",
tags=["CSS"])
mainoption7 = mo7.returnMainOption()
mainoption7.grid(row=0, column=3, sticky='w')
######
self.var8 = tk.IntVar()
self.check8 = ttk.Checkbutton(self.frameCheck,
variable=self.var8)
self.check8.grid(row=1, column=2)
###
mo8 = MainOption(
parentFrame=self.frameCheck,
page=self,
name="Home Button Icon",
image="images/home_button.png",
tags=["CSS"])
mainoption8 = mo8.returnMainOption()
mainoption8.grid(row=1, column=3, sticky='w')
###
#self.image1 = add_img(self.frameCheck, os.path.join(os.getcwd(), 'images/full_layout.png'))
#self.image1.grid(row=0, column=4, rowspan=8, padx=5, sticky="n")
def create_patch_frame(self, controller):
### PATCH FRAME
###
labeltext_a = tk.StringVar()
labeltext_a.set("Quick Links")
label_a = tk.Label(self.framePatch, textvariable=labeltext_a)
label_a.grid(row=0, column=0)
pbutton1 = ttk.Button(self.framePatch,
text="Open OldGlory folder",
width=22
)
pbutton1.bind("<Button-1>", lambda event:backend.OS_open_file(os.getcwd()))
pbutton1.grid(row=1, column=0, padx=(5,0), pady=5)
pbutton2 = ttk.Button(self.framePatch,
text="Open steamui folder",
width=22
)
pbutton2.bind("<Button-1>", lambda event:backend.OS_open_file(backend.library_dir()))
pbutton2.grid(row=2, column=0, padx=(5,0), pady=5)
labeltext_b = tk.StringVar()
labeltext_b.set("steam-library (Shiina)")
label_b = tk.Label(self.framePatch, textvariable=labeltext_b)
label_b.grid(row=3, column=0)
pbutton3 = ttk.Button(self.framePatch,
text="Apply config.css",
width=22
)
button3_tip = custom_tk.Detail_tooltip(pbutton3,
"If you have modifed themes/config.css for steam-library,\n" \
"click here to copy it over to steamui",
hover_delay=200)
pbutton3.bind("<Button-1>", lambda event:backend.steam_library_compat_config(1))
pbutton3.grid(row=4, column=0, padx=(5,0), pady=5)
labeltext_c = tk.StringVar()
labeltext_c.set("Patching")
label_c = tk.Label(self.framePatch, textvariable=labeltext_c)
label_c.grid(row=0, column=1)
pbutton4 = ttk.Button(self.framePatch,
text="Patch CSS",
width=22
)
button4_tip = custom_tk.Detail_tooltip(pbutton4,
"Old method for patching CSS (still works)",
hover_delay=200)
pbutton4.bind("<Button-1>", lambda event:backend.patch_css())
pbutton4.grid(row=1, column=1, padx=(5,0), pady=5)
pbutton5 = ttk.Button(self.framePatch,
text="Unpatch CSS",
width=22
)
button5_tip = custom_tk.Detail_tooltip(pbutton5,
"Undo Patch CSS (provided files aren't manually modified)",
hover_delay=200)
pbutton5.bind("<Button-1>", lambda event:backend.unpatch_css())
pbutton5.grid(row=2, column=1, padx=(5,0), pady=5)
labeltext_d = tk.StringVar()
labeltext_d.set("Install Location")
label_d = tk.Label(self.framePatch, textvariable=labeltext_d)
label_d.grid(row=3, column=1)
###
self.dropdown5_value = tk.StringVar()
self.dropdown5 = ttk.Combobox(self.framePatch,
font="TkDefaultFont",
values=["SFP/Millennium", "steamui", "Local"],
state="readonly",
textvariable=self.dropdown5_value,)
dropdown5_tip = custom_tk.Detail_tooltip(self.dropdown5,
"Select install location for OldGlory files",
hover_delay=200)
self.dropdown5.set(controller.oldglory_config["Filepaths"]["InstallMode"])
self.dropdown5.grid(row=4, column=1)
labeltext_e = tk.StringVar()
labeltext_e.set("Developer")
label_e = tk.Label(self.framePatch, textvariable=labeltext_e)
label_e.grid(row=0, column=2)
pbutton6 = ttk.Button(self.framePatch,
text="Compile CSS",
width=22
)
button6_tip = custom_tk.Detail_tooltip(pbutton6,
"Compiles scss files to libraryroot.custom.css",
hover_delay=200)
pbutton6.bind("<Button-1>", lambda event:backend.compile_css(controller.json_data))
pbutton6.grid(row=1, column=2, padx=(5,0), pady=5)
def create_themes_frame(self):
labeltext_a = tk.StringVar()
labeltext_a.set("Username:")
label_a = tk.Label(self.frameThemes, textvariable=labeltext_a)
label_a.grid(row=0, column=0)
self.entry_a = ttk.Entry(self.frameThemes)
self.entry_a.grid(row=0, column=1)
labeltext_b = tk.StringVar()
labeltext_b.set("Repository:")
label_b = tk.Label(self.frameThemes, textvariable=labeltext_b)
label_b.grid(row=1, column=0)
self.entry_b = ttk.Entry(self.frameThemes)
self.entry_b.grid(row=1, column=1)
button_a = ttk.Button(self.frameThemes, text="Download Theme", command=lambda: get_value())
button_a.grid(row=2, column=0)
def get_value():
e_text = self.entry_a.get()
labeltext_a1 = tk.StringVar()
labeltext_a1.set(e_text)
label_a1 = tk.Label(self.frameThemes, textvariable=labeltext_a1)
label_a1.grid(row=3, column=0)
def create_mode_frame(self):
### MODE FRAME
###
self.frameMode = tk.Frame(self)
###
self.var_m = tk.IntVar()
button_m = ttk.Button(self.frameMode,
text="CSS Options",
width=16
)
button_m.bind("<Button-1>", lambda event:show_CSSPage(self.controller))
button_m.grid(row=0, column=0, padx=5)
###
self.var_n = tk.IntVar()
button_n = ttk.Button(self.frameMode,
text="JS Options",
state="disabled",
width=16
)
#button_n.bind("<Button-1>", lambda event:show_JSPage(self.controller))
button_n.grid(row=0, column=1, padx=5)
def create_confirm_frame(self):
### CONFIRM FRAME
###
self.ConfirmObject = ConfirmFrame(self, self.controller)
self.frameConfirm = self.ConfirmObject.get_frame_confirm()
def set_init_gui_states(self):
### Running functions after much of StartPage has been initialised
###
### Set GUI from config
self.loaded_config = manager.set_selected_main_options(self, self.controller)
self.text1.config(state='disabled')
init_cb_check(self.var1, [self.check2, self.check3, self.check7])
init_cb_check(self.var3, [self.check4])
def pack_frames(self):
### Place frames into page
self.frameHead.pack()
self.frameCheck.pack()
self.framePatch.pack()
#self.frameThemes.pack()
###tabs
self.tabs.add(self.frameCheck, text="Main Options")
self.tabs.add(self.framePatch, text="Advanced Options")
#self.tabs.add(self.frameThemes, text="Download Themes")
self.tabs.pack(expand=1)
self.frameLog.pack(padx=17, pady=(10,7), expand=1, fill='both')
self.frameConfirm.pack(pady=(7, 20), side="bottom", fill="x")
self.frameMode.pack(pady=(2, 0), side="bottom")
### Getters
def getCheck(self, getter):
return getattr(self, getter)
def getCheckbuttonVal(self, getter):
return getattr(self, getter)
def getTextArea(self, getter):
return getattr(self, getter)
def getDropdownVal(self, getter):
return getattr(self, getter)
def setChangeTheme(self, event):
self.change_theme = 1
def getListOfThemeNames(self, controller):
themes = []
try:
for theme in controller.json_data["themes"].keys():
#print(theme)
themes.append(theme + " (" + controller.json_data["themes"][theme]["author"] + ")")
except Exception as e:
print("Error loading themes from JSON file. Loading default themes data.",file=sys.stderr)
print_traceback()
#default theme data
for theme in THEME_MAP:
themes.append(theme)
return themes
class CSSPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
### HEAD FRAME
###
self.frameHead = head_frame(self, controller)
### Tabs
tabs = ttk.Notebook(self,)
frameQuick = tk.Frame(tabs)
frameSections = tk.Frame(tabs)
### CSS Frame
###
controller.css_config = backend.load_css_configurables()
controller.sections_config = backend.read_css_sections()
#self.frameCSS = tk.Frame(frameQuick)
self.css_gui = CSSGUICreator(frameQuick, controller, controller.css_config)
self.frameCSS = self.css_gui.returnframeCSS()
#self.sections_gui = SectionsGUICreator(frameSections, controller)
#self.frameSections = self.sections_gui.returnframeSections()
self.sections_gui = SectionsFrame(frameSections, controller)
self.frameSections = self.sections_gui.returnLineFrame()
### MODE Frame
###
self.frameMode = tk.Frame(self)
###
self.var_m = tk.IntVar()
button_m = ttk.Button(self.frameMode,
text="Back to Home",
width=16
)
button_m.bind("<Button-1>", lambda event:controller.show_frame("StartPage"))
button_m.grid(row=0, column=0, padx=5)
###
self.var_n = tk.IntVar()
button_n = ttk.Button(self.frameMode,
text="JS Options",
state="disabled",
width=16
)
#button_n.bind("<Button-1>", lambda event:show_JSPage(controller))
button_n.grid(row=0, column=1, padx=5)
### CONFIRM FRAME
###
self.ConfirmObject = ConfirmFrame(self, controller)
self.frameConfirm = self.ConfirmObject.get_frame_confirm()
self.ConfirmObject.disable_mode_menu()
### Pack frames
self.frameHead.pack()
self.frameCSS.pack(padx=10, fill="x")
self.frameSections.pack(padx=10, expand=1, fill="both")
frameQuick.pack()
frameSections.pack()
###tabs
tabs.add(frameQuick, text="Quick CSS")
tabs.add(frameSections, text="CSS Sections")
tabs.pack(fill="both", expand=1, padx=(10,9))
self.frameConfirm.pack(pady=(7, 20), side="bottom", fill="x")
self.frameMode.pack(pady=(2, 0), side="bottom")
#self.frameCSS = create_css_gui(self, controller, backend.load_css_configurables())
class JSPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
### HEAD FRAME
###
self.frameHead = head_frame(self, controller)
label_js_head = tk.Label(self, text="JS Options")
### JS FRAME
###
controller.js_config, controller.special_js_config = backend.load_js_fixes()
self.frameJS = tk.Frame(self)
self.js_gui = JSFrame(self, controller)
self.frameJS = self.js_gui.returnframeJS()
### MODE Frame
###
self.frameMode = tk.Frame(self)
###
self.var_m = tk.IntVar()
button_m = ttk.Button(self.frameMode,
text="Back to Home",
width=16
)
button_m.bind("<Button-1>", lambda event:controller.show_frame("StartPage"))
button_m.grid(row=0, column=0, padx=5)
###
self.var_n = tk.IntVar()
button_n = ttk.Button(self.frameMode,
text="CSS Options",
width=16
)
button_n.bind("<Button-1>", lambda event:show_CSSPage(controller))
button_n.grid(row=0, column=1, padx=5)
### CONFIRM FRAME
###
self.ConfirmObject = ConfirmFrame(self, controller)
frameConfirm = self.ConfirmObject.get_frame_confirm()
self.ConfirmObject.disable_mode_menu()
### Pack frames
###
self.frameHead.pack()
label_js_head.pack()
self.frameJS.pack(padx=10, expand=1, fill="both")
frameConfirm.pack(pady=(7, 20), side="bottom", fill="x")
self.frameMode.pack(pady=(2, 0), side="bottom")
### FRAME functions
### ================================
### HEAD FRAME
###
def head_frame(self, controller):
frameHead = tk.Frame(self)
###
titlefont = controller.default_font.copy()
titlefont.configure(size=20)
labeltext_a = tk.StringVar()
labeltext_a.set("SteamUI-OldGlory")
label_a = tk.Label(frameHead, textvariable=labeltext_a, font=titlefont)
label_a.grid(row=0, column=0)
###
self.labeltext_b = tk.StringVar()
self.labeltext_b.set("A set of CSS and JS tweaks for the Steam Library")
label_b = tk.Label(frameHead, textvariable=self.labeltext_b)
label_b.grid(row=1, column=0)
return frameHead
### CONFIRM FRAME
###
class ConfirmFrame(tk.Frame):
def __init__(self, page, controller):
self.frameConfirm = tk.Frame(page)
self.frameConfirm.grid_columnconfigure(0, weight=1)
self.frameConfirm.grid_columnconfigure(1, weight=0)
self.frameConfirm.grid_columnconfigure(2, weight=0)
self.frameConfirm.grid_columnconfigure(3, weight=1)
###
self.left_frame = tk.Frame(self.frameConfirm,
width=3)
###
self.install_modes = ["CSS Only", "CSS + JS"]
self.modeVar = tk.StringVar()
self.modeMenu = ttk.Combobox(self.left_frame,
font="TkDefaultFont",
values=self.install_modes,
textvariable=self.modeVar,
state="disabled",
#selected=self.install_modes[0],
)
self.modeMenu.current(0)
self.modeMenu.config(width=9,
#state='disabled'
)
self.modeMenu.bind("<Button-1>",
lambda event:manager.mode_click(event, controller)
)
self.modeMenu.grid(row=0, column=0, padx=5)
self.left_frame.grid(row=0, column=0, sticky=tk.E)
###
self.button1 = ttk.Button(self.frameConfirm,
text="Install",
width=16
)
self.button1.bind("<Button-1>",
lambda event:manager.install_click(event, controller.frames["StartPage"], controller)
)
self.button1.grid(row=0, column=1, padx=5, sticky="NSEW")
###
button2 = ttk.Button(self.frameConfirm,
text="Reload Config",
width=16#,
###state='disabled'
)
button2_tip = custom_tk.Detail_tooltip(button2, "If you have modified the files manually,\nclick here to reload their values into the program.", hover_delay=200)
button2.bind("<Button-1>",
lambda event:reload_click(event, controller)
)
button2.grid(row=0, column=2, padx=5, sticky="NSEW")
###
settings_image = open_img(os.path.join(os.getcwd(), 'images/settings.png'), 24)
button3 = ttk.Button(self.frameConfirm,
#text="GG",
image=settings_image,
width=3#,
###state='disabled'
)
button3.image = settings_image
button3_tip = custom_tk.Detail_tooltip(button3, "Settings and About", hover_delay=200)
button3.bind("<Button-1>",
lambda event:settings_window(event, controller)
)
button3.grid(row=0, column=3, padx=(65,15), sticky=tk.E)
def disable_install_button(self):
self.button1['state'] = 'disable'
self.button1.configure(text="Installing...")
def enable_install_button(self):
self.button1['state'] = 'normal'
self.button1.configure(text="Install")
def get_install_button(self):
return self.button1
def get_frame_confirm(self):
return self.frameConfirm
def set_mode_menu(self, index):
self.modeVar.set(self.install_modes[index])
#print(index)
def get_mode_menu(self):
return self.modeVar
def disable_mode_menu(self):
self.modeMenu.config(state='disabled')
### ================================
### Show Page Functions
### ================================
def show_CSSPage(controller):
#controller.css_config = backend.load_css_configurables()
controller.show_frame("CSSPage")
#controller.frames["CSSPage"].frameCSS = create_css_gui(controller.frames["CSSPage"], controller, backend.load_css_configurables())
#update_css_gui(controller.frames["CSSPage"], controller, controller.css_config)
def show_JSPage(controller):
#controller.js_config = backend.load_js_fixes()
controller.show_frame("JSPage")
### ================================
### Initialisation
### ================================
### Check Internet
def is_connected():
try:
socket.create_connection(("1.1.1.1", 53))
return True
except OSError:
pass
return False
### Check SteamFriendsPatcher
def check_if_css_patched(page):
if not backend.is_css_patched("2.css"):
hyperlink = custom_tk.HyperlinkManager(page.text1)
page.text1.tag_configure("err", foreground="red")
page.text1.insert(tk.INSERT, '\n==============================\n')
page.text1.insert(tk.INSERT, "css/5.css (previously known as libraryroot.css) not patched.\n", ("err"))
page.text1.insert(tk.INSERT, "Download ")
page.text1.insert(tk.INSERT, "SteamFriendsPatcher\n", hyperlink.add(partial(webbrowser.open, "https://github.com/PhantomGamers/SteamFriendsPatcher/")))
page.text1.insert(tk.INSERT, '==============================\n')
### Check if newer version
def release_check(page, current_release):
try:
session = backend.create_session()
response = session.get("https://api.github.com/repos/jonius7/steamui-oldglory/releases/latest", timeout=0.5)
latest_release = response.json()["name"]
#print(re.sub("[^0-9.]+", "", current_release))
if latest_release == current_release:
page.text1.insert(tk.INSERT, "You are up to date. Release " + latest_release + "\n")
else:
hyperlink = custom_tk.HyperlinkManager(page.text1)
page.text1.insert(tk.INSERT, '\n==============================\n')
page.text1.insert(tk.END, 'New version available: ')
page.text1.insert(tk.END, "Release {0}".format(latest_release), hyperlink.add(partial(webbrowser.open, "https://github.com/Jonius7/SteamUI-OldGlory/releases/latest")))
page.text1.insert(tk.END, '\nCurrent version: ')
page.text1.insert(tk.END, "Release {0}\n".format(current_release))
page.text1.insert(tk.INSERT, '==============================\n\n')
except KeyError:
print("Unable to get latest version number, too many requests! Please try again later.", file=sys.stderr)
except requests.exceptions.ConnectionError:
print("Could not connect to Github, Unable to check for latest release!", file=sys.stderr)
except socket.timeout:
print("Update check timeout!", file=sys.stderr)
except AttributeError:
print("Could not connect to Github, Unable to check for latest release!", file=sys.stderr)
except Exception as e:
print("Unable to check for latest release!", file=sys.stderr)
#print(e.message, file=sys.stderr)
### Checkbox Validation - Disable
### ================================
### still the two functions, instead of 1, probably due to init
def css_cb_check(event, var1, checks):
if var1.get() == 0:
for check in checks:
check.config(state='normal')
else:
for check in checks:
check.config(state='disabled')
def init_cb_check(var1, checks):
if var1.get() == 1:
for check in checks:
check.config(state='normal')
else:
for check in checks:
check.config(state='disabled')
### ================================
### MainOption
### ================================
### Label + CodeTag
### Kwargs expected:
### parentFrame, page, name, image, tags
class MainOption(tk.Frame):
def __init__(self, **kwargs):
self.parentFrame = kwargs["parentFrame"]
self.page = kwargs["page"]
self.name = kwargs["name"]
self.image = kwargs["image"]
self.tags = {}
self.tagFrame = tk.Frame(self.parentFrame)
self.label = tk.Label(self.tagFrame,
text=self.name,
cursor="hand2")
#self.label.bind("<Button-1>", lambda event: globals()["change_image"](self.page.image1, os.path.join(os.getcwd(), self.image)))
#self.label.bind("<Enter>", lambda event: globals()["change_image"](self.page.image1, os.path.join(os.getcwd(), self.image)))
self.tip = custom_tk.Image_tooltip(self.label, globals()["open_img"](self.image), hover_delay=400)
self.label.grid(row=0, column=0, sticky='w')
self.create_tags(kwargs["tags"])
def create_tags(self, tagnames):
for i, tagName in enumerate(tagnames, start=1):
leftPadding = (5, 0) if i == 1 else 0
tag = add_img(self.tagFrame, os.path.join(os.getcwd(), 'images/tag_'+tagName+'.png'), width=50)
tag.grid(row=0, column=i, sticky='w', padx=leftPadding)
self.tags[self.name]=tag
def returnMainOption(self):
return self.tagFrame
### Dropdown click (theme)
### This is a backup list - .json provides an updated theme list
###
THEME_MAP = {
"steam-library (Shiina)" : {
"filename" : "shiina.css",
"order" : "before",
},
"Dark Library (Thespikedballofdoom)" : {
"filename" : "spiked.css",
"order" : "after"
},
"Acrylic Theme (EliteSkylu)" : {
"filename" : "acrylic.css",
"order" : "after"
},
"Crisp Cut" : {
"filename" : "crispcut.css",
"order" : "after"
}
}