-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathangelica.py
929 lines (730 loc) · 35.3 KB
/
angelica.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
import concurrent.futures
import ctypes
import glob
import json
import logging
import os.path
import queue
import re
import shutil
import subprocess as sb
import tempfile
import time
import tkinter
import tkinter.ttk as ttk
import urllib.request
import winreg
import zipfile
from ctypes.wintypes import MAX_PATH
from os.path import join as __
from tkinter import messagebox
from tkinter.scrolledtext import ScrolledText
from github_tool import download_asset_from_github, download_asset_url_from_github
from loca import _
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class QueueHandler(logging.Handler):
"""Class to send logger records to a queue
It can be used from different threads
"""
def __init__(self, _log_queue):
super().__init__()
self.log_queue = _log_queue
def emit(self, record):
self.log_queue.put(record)
def remove_util(path):
"""
ファイルだろうがディレクトリだが存在すればお構いなしに削除する関数
:param path: パス
:return: 成否
"""
logger.info('remove files, path=%s', path)
if not os.path.exists(path):
return False
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)
return True
def install(install_dir_path, target_zip_url, final_check_file):
final_check_file_path = __(install_dir_path, final_check_file)
logger.info('final_check_file_path=%s', final_check_file_path)
# 最終チェックファイルがあるかを確認する
if os.path.exists(final_check_file_path) is False:
raise Exception(_('ERR_NOT_EXIST_FINAL_CHECK_FILE'))
# 最終チェックファイルがある場所に対してファイルを展開する
final_check_file_dir = os.path.dirname(final_check_file_path)
logger.info('final_check_file_dir=%s', final_check_file_dir)
path, headers = urllib.request.urlretrieve(target_zip_url)
logger.info('path=%s,headers=%s', path, headers)
with zipfile.ZipFile(path) as existing_zip:
existing_zip.extractall(final_check_file_dir)
logger.info('zip unpacked')
def install_downloader(target_repository, install_dir_path):
logger.info('install downloader')
with tempfile.TemporaryFile() as w:
download_asset_from_github(
repository_author=target_repository.get("author"),
repository_name=target_repository.get("name"),
out_file=w
)
logger.info('asset_file_path=%s', w)
with zipfile.ZipFile(w) as existing_zip:
existing_zip.extractall(install_dir_path)
logger.info('zip unpacked')
def get_game_install_dir_path_epic(target_app_id):
logger.info('Get install dir path')
# レジストリを見て、Steamのインストール先を探す
# 64bitを見て、なければ32bitのキーを探しに行く。それでもなければそもそもインストールされていないと判断する
try:
epic_install_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
"SOFTWARE\\WOW6432Node\\Epic Games\\EpicGamesLauncher")
except OSError:
try:
epic_install_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Epic Games\\EpicGamesLauncher")
except OSError:
logger.info(_("ERR_NOT_FIND_EPIC_REGKEY"))
return None
logger.info('Find epic_install_key in reg')
try:
epic_data_path, key_type = winreg.QueryValueEx(epic_install_key, "AppDataPath")
except FileNotFoundError:
logger.info(_("ERR_NOT_FIND_DATAPATH_IN_EPIC_REGKEY"))
return None
finally:
epic_install_key.Close()
logger.info('Find epic data path=%s', epic_data_path)
# 基本問題ないと思うが念の為
if key_type != winreg.REG_SZ:
raise Exception("invald value")
# ゲーム一覧フォルダ
epic_manifests_path = __(epic_data_path, "Manifests")
if os.path.exists(epic_manifests_path) is False:
logger.info('x : At least one game is installed')
return None
# jsonなので順繰りに見ていく
game_install_dir_path = None
for filename in glob.glob(__(epic_manifests_path, "*.item")):
logger.info('Open manifest=%s', filename)
with open(os.path.join(os.getcwd(), filename), mode='r', encoding="utf8", errors='ignore') as json_open:
json_load = json.load(json_open)
if json_load['AppName'] is not None and json_load['AppName'] == target_app_id:
logger.info('Find app')
if json_load['InstallLocation'] is not None:
game_install_dir_path = str(json_load['InstallLocation'])
break
else:
logger.info('Not found InstallLocation')
# チェック
if game_install_dir_path is None or not os.path.isdir(game_install_dir_path):
logger.info('Not found game_install_dir_path')
return None
else:
logger.info('Success: Find target_game_dir_path')
return game_install_dir_path
def get_game_install_dir_path_steam(target_app_id):
logger.info('Get install dir path')
# レジストリを見て、Steamのインストール先を探す
# 64bitを見て、なければ32bitのキーを探しに行く。それでもなければそもそもインストールされていないと判断する
try:
steam_install_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Valve\\Steam")
except OSError:
try:
steam_install_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Valve\\Steam")
except OSError:
logger.info(_("ERR_NOT_FIND_STEAM_REGKEY"))
return None
logger.info('Find steam_install_key in reg')
try:
steam_install_path, key_type = winreg.QueryValueEx(steam_install_key, "InstallPath")
except FileNotFoundError:
logger.info(_("ERR_NOT_FIND_INSTALLPATH_IN_STEAM_REGKEY"))
return None
finally:
steam_install_key.Close()
logger.info('steam_install_path=%s, key_type=%s', steam_install_path, key_type)
# 基本問題ないと思うが念の為
if key_type != winreg.REG_SZ:
raise Exception("invald value")
# デフォルトのsteamappsフォルダを探す
steam_apps_path = __(steam_install_path, "steamapps")
if os.path.exists(steam_apps_path) is False:
raise Exception(_("ERR_NOT_EXIST_DEFAULT_STEAMAPPS_DIR"))
logger.info('steam_apps_path=%s', steam_apps_path)
# acfがあるフォルダを列挙
acf_dir_paths = [steam_apps_path]
acf_dir_paths.extend(get_lib_folders_from_vdf(steam_apps_path))
logger.info('acf_dir_paths=%s', acf_dir_paths)
# 各ディレクトリについて処理
game_install_dir_path = None
for dir_path in acf_dir_paths:
game_install_dir_path = get_game_install_dir(dir_path, target_app_id)
if game_install_dir_path is None:
continue
else:
break
logger.info('game_install_dir_path=%s', game_install_dir_path)
if game_install_dir_path is None:
logger.info(_("ERR_NOT_FIND_TARGET_GAME_ON_YOUR_PC"))
return None
return game_install_dir_path
def get_game_install_dir(dir_path, target_app_id):
logger.info('get game install dir')
# インストールディレクトリにあるsteamapps/appmanifest_[APPID].acfを探す
target_app_acf_path = __(dir_path, "appmanifest_{}.acf".format(target_app_id))
logger.info('target_app_acf_path=%s', target_app_acf_path)
# なければ終了
if os.path.exists(target_app_acf_path) is False:
return None
# acfファイルにある"installdir" "xxxx"をさがす
install_dir_pattern = re.compile(r'\s*"installdir"\s+"(.*)')
game_install_dir_name = None
with open(target_app_acf_path, mode='r', encoding="utf8", errors='ignore') as target_app_acf_file:
logger.info('open %s', target_app_acf_path)
for line in target_app_acf_file:
result = install_dir_pattern.match(line)
if result is not None:
game_install_dir_name = result.group(1).strip("\"")
break
logger.info('game_install_dir_name=%s', game_install_dir_name)
if game_install_dir_name is None:
raise Exception(_("ERR_INVALID_ACF"))
# パスを確認
game_install_dir_path = __(dir_path, "common", game_install_dir_name)
if os.path.exists(game_install_dir_path) is False:
raise Exception(_("ERR_NOT_EXIST_GAME_INSTALL_DIR"))
logger.info('game_install_dir_path=%s', game_install_dir_path)
return game_install_dir_path
def get_lib_folders_from_vdf(steam_apps_path):
logger.info('get lib folders from vdf')
# vdfファイルを探す
library_folders_vdf_path = __(steam_apps_path, "libraryfolders.vdf")
if os.path.exists(library_folders_vdf_path) is False:
raise Exception(_("ERR_NOT_FIND_LIBRARYFOLDERS_VDF"))
logger.info('library_folders_vdf_path=%s', library_folders_vdf_path)
# vdfファイルにある"[数字]" "xxxx"をさがす
install_dir_pattern = re.compile(r'\s*"[0-9a-zA-Z]+"\s+"(.*)')
logger.info('install_dir_pattern=%s', install_dir_pattern)
game_libs_paths = []
with open(library_folders_vdf_path, mode='r', encoding="utf8", errors='ignore') as target_vdf_file:
logger.info('open %s', library_folders_vdf_path)
for line in target_vdf_file:
result = install_dir_pattern.match(line)
if result is not None:
game_libs_paths.append(__(result.group(1).strip("\"").replace("\\\\", "\\"), "steamapps"))
logger.info('game_libs_paths=%s', game_libs_paths)
return game_libs_paths
def install_key_file(save_file_path, mod_title, key_file_path):
logger.info('install key file')
with open(save_file_path, encoding="utf-8", mode='w', errors='ignore') as fw:
logger.info('open %s', save_file_path)
fw.write("\n".join([
mod_title,
key_file_path
]))
logger.info('finish')
def dll_installer_steam(app_id, final_check_file, target_zip_url=None, target_repository=None):
logger.info('Start dll installer for steam')
install_dir_path_steam = get_game_install_dir_path_steam(app_id)
if install_dir_path_steam is not None:
logger.info('install_dir_path_steam=%s', install_dir_path_steam)
if install_dir_path_steam is None:
Exception("Not found target game in your PC!")
if target_zip_url is not None:
src_url = target_zip_url
else:
src_url = download_asset_url_from_github(
repository_author=target_repository.get("author"),
repository_name=target_repository.get("name")
)
logger.info('src_url=%s', src_url)
if install_dir_path_steam is not None:
install(install_dir_path_steam, src_url, final_check_file)
logger.info('install_dir_path_steam=%s', install_dir_path_steam)
logger.info('finish')
def dll_installer_epic(app_id, final_check_file, target_zip_url=None, target_repository=None):
logger.info('Start dll installer for epic')
install_dir_path_epic = get_game_install_dir_path_epic(app_id)
if install_dir_path_epic is not None:
logger.info('install_dir_path_epic=%s', install_dir_path_epic)
if install_dir_path_epic is None:
Exception("Not found target game in your PC!")
if target_zip_url is not None:
src_url = target_zip_url
else:
src_url = download_asset_url_from_github(
repository_author=target_repository.get("author"),
repository_name=target_repository.get("name")
)
logger.info('src_url=%s', src_url)
if install_dir_path_epic is not None:
install(install_dir_path_epic, src_url, final_check_file)
logger.info('install_dir_path_epic=%s', install_dir_path_epic)
logger.info('finish')
def uninstaller(uninstall_info_list):
logger.info('uninstall')
for info in uninstall_info_list:
final_check_file = info['final_check_file']
remove_target_paths = info['remove_target_paths']
logger.info('remove_target_paths=%s', remove_target_paths)
base_path = '.'
if 'app_id' in info:
base_path = get_game_install_dir_path_steam(info['app_id'])
if base_path is not None and os.path.exists(__(base_path, "claes.exe")):
logger.info('claes uninstall mode')
sb.call(__(base_path, "claes.exe /uninstall-all"))
elif 'epic_app_id' in info:
base_path = get_game_install_dir_path_epic(info['epic_app_id'])
if base_path is not None and os.path.exists(__(base_path, "claes.exe")):
logger.info('claes uninstall mode')
sb.call(__(base_path, "claes.exe /uninstall-all"))
elif 'game_dir_name' in info:
base_path = __(get_my_documents_folder(),
"Paradox Interactive",
info['game_dir_name'])
if os.path.exists(base_path) is False:
continue
# Modダウンローダーをuninstallモードで起動
if os.path.exists(__(base_path, "claes.exe")):
logger.info('claes uninstall mode')
sb.call(__(base_path, "claes.exe /uninstall-all"))
if base_path is None:
continue
logger.info('base_path=%s', base_path)
# 最終チェックファイルがあるかを確認する。このファイルがあるかどうかで本当にインストールされているか判断する
if os.path.exists(__(base_path, final_check_file)) is False:
raise Exception(_('ERR_NOT_EXIST_FINAL_CHECK_FILE'))
for path in remove_target_paths:
remove_util(__(base_path, path))
logger.info('finish')
def get_my_documents_folder():
logger.info('get my documents folder')
# APIを使って探す
buf = ctypes.create_unicode_buffer(MAX_PATH + 1)
if ctypes.windll.shell32.SHGetSpecialFolderPathW(None, buf, 0x1005, False):
logger.info('search done. buf.value=%s', buf.value)
return buf.value
else:
raise Exception(_("ERR_SHGetSpecialFolderPathW"))
def mod_installer_epic(app_id, target_repository, key_file_name, key_list_url, game_dir_name=None):
logger.info('mod install')
# exeを見つける
install_dll_dir_path = get_game_install_dir_path_epic(app_id)
if install_dll_dir_path is None:
return
logger.info('install_dll_dir_path=%s', install_dll_dir_path)
# My Documents をAPIから見つける
if game_dir_name is None:
install_game_dir_path = install_dll_dir_path
else:
install_game_dir_path = __(get_my_documents_folder(),
"Paradox Interactive",
game_dir_name)
logger.info('install_game_dir_path=%s', install_game_dir_path)
logger.info('install downloader')
# Modダウンローダーを配置
install_downloader(target_repository=target_repository,
install_dir_path=install_game_dir_path)
logger.info('done')
# keyファイルを保存
os.makedirs(__(install_game_dir_path, 'claes.key'), exist_ok=True)
key_ids = json.loads(urllib.request.urlopen(key_list_url).read().decode('utf8'))
logger.info('key_ids=%s', key_ids)
for item in key_ids:
install_key_file(save_file_path=__(install_game_dir_path, "claes.key", item.get("id") + ".key"),
mod_title=item.get("name"),
key_file_path=__(install_dll_dir_path, key_file_name))
logger.info('call claes')
# Modダウンローダーを起動
mod_downloader_path = __(install_game_dir_path, "claes.exe")
logger.info('mod_downloader_path=%s', mod_downloader_path)
sb.call(mod_downloader_path, shell=True)
logger.info('done')
def mod_installer_steam(app_id, target_repository, key_file_name, key_list_url, game_dir_name=None):
logger.info('mod install')
# exeを見つける
install_dll_dir_path = get_game_install_dir_path_steam(app_id)
if install_dll_dir_path is None:
return
logger.info('install_dll_dir_path=%s', install_dll_dir_path)
# My Documents をAPIから見つける
if game_dir_name is None:
install_game_dir_path = install_dll_dir_path
else:
install_game_dir_path = __(get_my_documents_folder(),
"Paradox Interactive",
game_dir_name)
logger.info('install_game_dir_path=%s', install_game_dir_path)
logger.info('install downloader')
# Modダウンローダーを配置
install_downloader(target_repository=target_repository,
install_dir_path=install_game_dir_path)
logger.info('done')
# keyファイルを保存
os.makedirs(__(install_game_dir_path, 'claes.key'), exist_ok=True)
key_ids = json.loads(urllib.request.urlopen(key_list_url).read().decode('utf8'))
logger.info('key_ids=%s', key_ids)
for item in key_ids:
install_key_file(save_file_path=__(install_game_dir_path, "claes.key", item.get("id") + ".key"),
mod_title=item.get("name"),
key_file_path=__(install_dll_dir_path, key_file_name))
logger.info('call claes')
# Modダウンローダーを起動
mod_downloader_path = __(install_game_dir_path, "claes.exe")
logger.info('mod_downloader_path=%s', mod_downloader_path)
sb.call(mod_downloader_path, shell=True)
logger.info('done')
def about():
logger.info('open About dialog')
messagebox.showinfo(_('ABOUT_BOX_TITLE'), _('ABOUT_BOX_MESSAGE'))
if __name__ == '__main__':
# ログ設定
# https://beenje.github.io/blog/posts/logging-to-a-tkinter-scrolledtext-widget/
log_queue = queue.Queue()
queue_handler = QueueHandler(log_queue)
logger.addHandler(queue_handler)
formatter = logging.Formatter('%(asctime)s: %(message)s')
queue_handler.setFormatter(formatter)
logger.info('GUI setup')
repo_url = "https://raw.githubusercontent.com/matanki-saito/SimpleInstaller/master/"
executor = concurrent.futures.ThreadPoolExecutor(max_workers=2)
root = tkinter.Tk()
root.title(_('TITLE'))
root.geometry("300x300")
# ノートブック
style = ttk.Style()
style.configure("BW.TLabel", foreground="black", background="white")
nb = ttk.Notebook(width=300, height=200, style="BW.TLabel")
# タブの作成
tab2 = tkinter.Frame(nb, pady=0, relief='flat')
tab3 = tkinter.Frame(nb, pady=0, relief='flat')
tab4 = tkinter.Frame(nb, pady=0, relief='flat')
nb.add(tab2, text=_('TAB_JPMOD'), padding=0)
nb.add(tab3, text=_('TAB_INFO'), padding=0)
nb.add(tab4, text=_('TAB_LOG'), padding=0)
nb.pack(expand=True, fill='both')
def on_enter(e, bg_color, font_color):
e.widget['background'] = bg_color
e.widget['fg'] = font_color
def on_leave(e, bg_color, font_color):
e.widget['background'] = bg_color
e.widget['fg'] = font_color
def threader(r, func):
original_text = r['text']
r['text'] = _('TASK_DO')
feature = executor.submit(func)
def done(self):
try:
self.result()
r['text'] = _('TASK_FINISH')
time.sleep(1)
except Exception as exp:
messagebox.showerror(_('ERROR_BOX_TITLE'), _('ERROR_BOX_MESSAGE') + ":\n" + str(exp))
finally:
r['text'] = original_text
feature.add_done_callback(done)
# Install dll , downloader and jpmod
frame1_2 = tkinter.Frame(tab2, pady=0)
frame1_2.pack(expand=True, fill='both')
def eu4_button_function():
logger.info('Push a button to install eu4')
dll_installer_steam(
app_id=236850,
final_check_file='eu4.exe',
target_repository={
"author": "matanki-saito",
"name": "eu4dll"
},
)
dll_installer_epic(
app_id="da0103e959e54d139d0c109ded3b3672",
final_check_file='eu4.exe',
target_repository={
"author": "matanki-saito",
"name": "eu4dll"
},
)
mod_installer_steam(
app_id=236850,
target_repository={
"author": "matanki-saito",
"name": "moddownloader"
},
key_file_name='eu4.exe',
game_dir_name="Europa Universalis IV",
key_list_url=repo_url + "eu4mods.json")
mod_installer_epic(
app_id="da0103e959e54d139d0c109ded3b3672",
target_repository={
"author": "matanki-saito",
"name": "moddownloader"
},
key_file_name='eu4.exe',
game_dir_name="Europa Universalis IV EGS",
key_list_url=repo_url + "eu4mods.json")
def ck2_button_function():
logger.info('Push a button to install ck2')
dll_installer_steam(
app_id=203770,
final_check_file='ck2game.exe',
target_repository={
"author": "matanki-saito",
"name": "ck2dll"
},
)
mod_installer_steam(
app_id=203770,
target_repository={
"author": "matanki-saito",
"name": "moddownloader"
},
key_file_name='ck2game.exe',
game_dir_name="Crusader Kings II",
key_list_url=repo_url + "ck2mods.json")
def ir_button_function():
logger.info('Push a button to install I:R')
dll_installer_steam(
app_id=859580,
final_check_file='binaries/imperator.exe',
target_repository={
"author": "matanki-saito",
"name": "irdll"
},
)
mod_installer_steam(
app_id=859580,
target_repository={
"author": "matanki-saito",
"name": "moddownloader"
},
key_file_name='binaries/imperator.exe',
game_dir_name="Imperator",
key_list_url=repo_url + "irmods.json")
def vic2_button_function():
logger.info('Push a button to install vic2')
dll_installer_steam(
app_id=42960,
final_check_file='v2game.exe',
target_repository={
"author": "matanki-saito",
"name": "vic2dll"
},
)
mod_installer_steam(
app_id=42960,
target_repository={
"author": "matanki-saito",
"name": "moddownloader"
},
key_file_name='v2game.exe',
key_list_url=repo_url + "vic2mods.json")
# EU4
eu4InstallButton = tkinter.Button(frame1_2,
activebackground='#d3a243',
background='#d3a243',
relief='flat',
fg="#8f2e14",
text=_('INSTALL_EU4'),
command=lambda: threader(eu4InstallButton, eu4_button_function),
font=("sans-selif", 16, "bold"))
eu4InstallButton.pack(expand=True, fill='both')
eu4InstallButton.bind("<Enter>", lambda e: on_enter(e, "#e6b422", "#000000"))
eu4InstallButton.bind("<Leave>", lambda e: on_leave(e, "#d3a243", "#8f2e14"))
# CK2
ck2InstallButton = tkinter.Button(frame1_2,
activebackground='#478384',
background='#478384',
relief='flat',
fg='#1f3134',
text=_('INSTALL_CK2'),
command=lambda: threader(ck2InstallButton, ck2_button_function),
font=("sans-selif", 16, "bold"))
ck2InstallButton.pack(expand=True, fill='both')
ck2InstallButton.bind("<Enter>", lambda e: on_enter(e, "#2c4f54", "#c1e4e9"))
ck2InstallButton.bind("<Leave>", lambda e: on_leave(e, "#478384", "#1f3134"))
# I:R
irInstallButton = tkinter.Button(frame1_2,
activebackground='#cca6bf',
background='#cca6bf',
relief='flat',
fg='#8f2e14',
text=_('INSTALL_IR'),
command=lambda: threader(irInstallButton, ir_button_function),
font=("sans-selif", 16, "bold"))
irInstallButton.pack(expand=True, fill='both')
irInstallButton.bind("<Enter>", lambda e: on_enter(e, "#bc64a4", "#c1e4e9"))
irInstallButton.bind("<Leave>", lambda e: on_leave(e, "#cca6bf", "#8f2e14"))
# VIC2
vic2InstallButton = tkinter.Button(frame1_2,
activebackground='#a9a9a9',
background='#a9a9a9',
relief='flat',
fg='#000000',
text=_('INSTALL_VIC2'),
command=lambda: threader(vic2InstallButton, vic2_button_function),
font=("sans-selif", 16, "bold"))
vic2InstallButton.pack(expand=True, fill='both')
vic2InstallButton.bind("<Enter>", lambda e: on_enter(e, "#dcdcdc", "#000000"))
vic2InstallButton.bind("<Leave>", lambda e: on_leave(e, "#a9a9a9", "#000000"))
# その他
frame1_3 = tkinter.Frame(tab3, pady=0)
frame1_3.pack(expand=True, fill='both')
about_button = tkinter.Button(frame1_3,
background='#443648',
fg='white',
text=_('ABOUT'),
command=about,
height='1',
font=("Helvetica", 12))
about_button.pack(expand=True, fill='both')
uninstall_button_eu4 = tkinter.Button(frame1_3,
background='#FFFFFF',
fg='black',
text=_('UNINSTALL_EU4'),
command=lambda: threader(uninstall_button_eu4, lambda: uninstaller(
[
{
# EU4 DLL epic
'epic_app_id': "da0103e959e54d139d0c109ded3b3672",
'final_check_file': 'eu4.exe',
'remove_target_paths': [
'd3d9.dll',
'version.dll',
'plugins',
'pattern_eu4jps.log',
'README.md'
'pattern_eu4_jps_2.log',
'README.md',
'.dist.v1.json'
]
},
{
# EU4 DLL steam
'app_id': 236850,
'final_check_file': 'eu4.exe',
'remove_target_paths': [
'd3d9.dll',
'version.dll',
'plugins',
'pattern_eu4jps.log',
'README.md'
'pattern_eu4_jps_2.log',
'README.md',
'.dist.v1.json'
]
},
{
# EU4 MOD
'game_dir_name': 'Europa Universalis IV EGS',
'final_check_file': 'settings.txt',
'remove_target_paths': [
'claes.exe',
'claes.key',
'claes.cache'
]
},
{
# EU4 MOD
'game_dir_name': 'Europa Universalis IV',
'final_check_file': 'settings.txt',
'remove_target_paths': [
'claes.exe',
'claes.key',
'claes.cache'
]
}
])),
height='1',
font=("Helvetica", 12))
uninstall_button_eu4.pack(expand=True, fill='both')
uninstall_button_ck2 = tkinter.Button(frame1_3,
background='#FFFFFF',
fg='black',
text=_('UNINSTALL_CK2'),
command=lambda: threader(uninstall_button_ck2, lambda: uninstaller(
[
{
# CK2 DLL
'app_id': 203770,
'final_check_file': 'ck2game.exe',
'remove_target_paths': [
'd3d9.dll',
'version.dll',
'plugins',
'pattern_ck2jps.log',
'pattern_ck2_jps_2.log',
'README.md',
'.dist.v1.json'
]
},
{
# CK2 MOD
'game_dir_name': 'Crusader Kings II',
'final_check_file': 'settings.txt',
'remove_target_paths': [
'claes.exe',
'claes.key',
'claes.cache'
]
}
])),
height='1',
font=("Helvetica", 12))
uninstall_button_ck2.pack(expand=True, fill='both')
uninstall_button_vic2 = tkinter.Button(frame1_3,
background='#FFFFFF',
fg='black',
text=_('UNINSTALL_VIC2'),
command=lambda: threader(uninstall_button_vic2, lambda: uninstaller(
[
{
# VIC2 DLL and mod
'app_id': 42960,
'final_check_file': 'v2game.exe',
'remove_target_paths': [
'd3d9.dll',
'plugins',
'pattern_ck2jps.log',
'README.md',
'.dist.v1.json',
'claes.exe',
'claes.key',
'claes.cache'
]
}
])),
height='1',
font=("Helvetica", 12))
uninstall_button_vic2.pack(expand=True, fill='both')
logger.info('mainloop')
# ログエリア
frame1_4 = tkinter.Frame(tab4, pady=0)
frame1_4.pack(expand=True, fill='both')
log_area = ScrolledText(frame1_4, state='disabled', height=12)
log_area.configure(font='TkFixedFont')
log_area.tag_config('INFO', foreground='black')
log_area.tag_config('DEBUG', foreground='gray')
log_area.tag_config('WARNING', foreground='orange')
log_area.tag_config('ERROR', foreground='red')
log_area.tag_config('CRITICAL', foreground='red', underline=1)
log_area.pack(expand=True, fill='both')
def display_log(record):
msg = queue_handler.format(record)
log_area.configure(state='normal')
log_area.insert(tkinter.END, msg + '\n', record.levelname)
log_area.configure(state='disabled')
# Autoscroll to the bottom
log_area.yview(tkinter.END)
def poll_log_queue():
# Check every 100ms if there is a new message in the queue to display
while True:
try:
record = log_queue.get(block=False)
except queue.Empty:
break
else:
display_log(record)
frame1_4.after(100, poll_log_queue)
frame1_4.after(100, poll_log_queue)
# main
root.mainloop()