-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrossroads_FastDL_Manager.py
More file actions
142 lines (115 loc) · 5.45 KB
/
Crossroads_FastDL_Manager.py
File metadata and controls
142 lines (115 loc) · 5.45 KB
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
import sys
from PyQt5 import QtGui
from PyQt5.QtMultimedia import QSoundEffect
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
from PyQt5.QtCore import QThread, QTimer, QUrl
from PyQt5.QtGui import QFont, QFontDatabase
from gui import Ui_MainWindow
import resources
import logic
import atexit
class LogicThread(QThread):
def __init__(self):
super().__init__()
def run(self):
logic.sync_repo()
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
font_id = QFontDatabase.addApplicationFont(":/Font/VCR_OSD_MONO_1.001[1].ttf")
font_families = QFontDatabase.applicationFontFamilies(font_id)
if font_families:
font_family = font_families[0]
custom_font1 = QtGui.QFont(font_family, 12)
custom_font2 = QtGui.QFont(font_family, 25)
for lbl in [
self.ui.TF2_path_label, self.ui.HLDMS_path_label,
self.ui.HL2DM_path_label, self.ui.DOD_path_label,
self.ui.L4D2_path_label, self.ui.CSS_path_label,
self.ui.CSGO_path_label
]:
lbl.setFont(custom_font1)
self.ui.label.setFont(custom_font2)
app.setStyleSheet("""
QToolTip {
background-color: black;
color: white;
border: 1px solid white;
font: 12pt "VCR OSD Mono";
}
""")
self.click_sound1 = QSoundEffect()
self.click_sound1.setSource(QUrl.fromLocalFile(":/Sound/button3.wav"))
self.click_sound1.setVolume(0.2)
self.click_sound2 = QSoundEffect()
self.click_sound2.setSource(QUrl.fromLocalFile(":/Sound/button1.wav"))
self.click_sound2.setVolume(0.3)
self.connect_buttons(self.ui.centralwidget)
self.ui.download_button.disconnect()
self.ui.download_button.clicked.connect(self.click_sound2.play)
logic.read_config(self)
# Connect directory buttons to handler
self.ui.TF2_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "TF2"))
self.ui.HLDMS_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "HLDM:S"))
self.ui.HL2DM_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "HL2:DM"))
self.ui.DOD_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "DoD:S"))
self.ui.L4D2_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "L4D2"))
self.ui.CSS_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "CS:S"))
self.ui.CSGO_set_dir_button.clicked.connect(lambda: logic.get_game_directory(self, "CS:GO"))
self.ui.download_button.clicked.connect(self.on_download_press)
logic.check_for_update(logic.target_repo_tf2)
logic.check_for_update(logic.target_repo_csgo)
logic.check_for_update(logic.target_repo_general)
updated_repos = []
if logic.files_to_copy_fastdl_tf2:
updated_repos.append("TF2")
if logic.files_to_copy_fastdl_csgo:
updated_repos.append("CS:GO")
if logic.files_to_copy_fastdl_general:
updated_repos.append("Other")
update_button_text = ""
for repo in updated_repos:
if not repo == updated_repos[-1]:
update_button_text = update_button_text + repo + ", "
else:
update_button_text = update_button_text + repo
if update_button_text:
self.ui.download_button.setText("Download Updates: " + update_button_text)
else:
self.ui.download_button.setText("Download FastDL Content (No Updates)")
self.ui.download_button.setEnabled(True)
self.thread = LogicThread()
def on_download_press(self):
self.ui.download_button.setDisabled(True)
self.ui.download_button.setText("Syncing.. Check Command Window for Progress")
ui = self.ui
dir_buttons = [ui.TF2_set_dir_button, ui.HLDMS_set_dir_button, ui.HL2DM_set_dir_button, ui.DOD_set_dir_button,
ui.L4D2_set_dir_button, ui.CSS_set_dir_button, ui.CSGO_set_dir_button]
for button in dir_buttons:
button.setDisabled(True)
self.thread.start()
self.thread.finished.connect(self.on_sync_finished)
def on_sync_finished(self):
self.ui.download_button.setEnabled(True)
self.ui.download_button.setText("Sync Complete!")
QTimer.singleShot(3000, self.reset_download_text)
def reset_download_text(self):
self.ui.download_button.setText("Download FastDL Content (No Updates)")
ui = self.ui
dir_buttons = [ui.TF2_set_dir_button, ui.HLDMS_set_dir_button, ui.HL2DM_set_dir_button, ui.DOD_set_dir_button,
ui.L4D2_set_dir_button, ui.CSS_set_dir_button, ui.CSGO_set_dir_button]
for button in dir_buttons:
button.setEnabled(True)
def connect_buttons(self, widget):
for child in widget.findChildren(QPushButton):
child.clicked.connect(self.click_sound1.play)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.setWindowTitle("Source: Crossroads FastDL Manager")
window.setWindowIcon(QtGui.QIcon(":/Logo/program_icon.png"))
window.show()
atexit.register(logic.write_config)
sys.exit(app.exec())