-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMacNdCheeseARM-OLDER.py
More file actions
5975 lines (5066 loc) · 230 KB
/
Copy pathMacNdCheeseARM-OLDER.py
File metadata and controls
5975 lines (5066 loc) · 230 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
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
from __future__ import annotations
import json
import os
import re
import shlex
import shutil
import ssl
import subprocess
import sys
import time
import urllib.request
import webbrowser
import platform
import getpass
import signal
import stat
import tempfile
import contextlib
from dataclasses import dataclass, field
from pathlib import Path
from typing import Iterable, Optional, Any
from PyQt6.QtGui import QAction, QPixmap, QPainter, QIcon, QColor
from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QThread, pyqtSignal, QPoint, QRect, QSize, Qt, QEvent, QTimer, QPropertyAnimation, QEasingCurve
from PyQt6.QtWidgets import (
QApplication,
QCheckBox,
QComboBox,
QFileDialog,
QFormLayout,
QGridLayout,
QGroupBox,
QHBoxLayout,
QInputDialog,
QLabel,
QLineEdit,
QListWidget,
QListWidgetItem,
QMainWindow,
QMessageBox,
QPushButton,
QPlainTextEdit,
QProgressBar,
QSplitter,
QStyle,
QVBoxLayout,
QWidget,
QDialog,
QTabWidget,
QFrame,
QStackedWidget,
QScrollArea,
QMenu,
QWidgetAction,
QLayout,
QSizePolicy,
QButtonGroup,
QGraphicsOpacityEffect,
)
class FlowLayout(QLayout):
def __init__(self, parent=None, margin=-1, hSpacing=-1, vSpacing=-1):
super().__init__(parent)
self._item_list = []
self._h_space = hSpacing
self._v_space = vSpacing
self.setContentsMargins(margin, margin, margin, margin)
def addItem(self, item):
self._item_list.append(item)
def horizontalSpacing(self):
if self._h_space >= 0:
return self._h_space
return 0
def verticalSpacing(self):
if self._v_space >= 0:
return self._v_space
return 0
def count(self):
return len(self._item_list)
def itemAt(self, index):
if 0 <= index < len(self._item_list):
return self._item_list[index]
return None
def takeAt(self, index):
if 0 <= index < len(self._item_list):
return self._item_list.pop(index)
return None
def expandingDirections(self):
return Qt.Orientation(0)
def hasHeightForWidth(self):
return True
def heightForWidth(self, width):
return self._do_layout(QRect(0, 0, width, 0), True)
def setGeometry(self, rect):
super().setGeometry(rect)
self._do_layout(rect, False)
def sizeHint(self):
return self.minimumSize()
def minimumSize(self):
size = QSize()
for item in self._item_list:
size = size.expandedTo(item.minimumSize())
margins = self.contentsMargins()
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom())
return size
def _do_layout(self, rect, test_only):
x = rect.x()
y = rect.y()
line_height = 0
for item in self._item_list:
space_x = self.horizontalSpacing()
space_y = self.verticalSpacing()
next_x = x + item.sizeHint().width() + space_x
if next_x - space_x > rect.right() and line_height > 0:
x = rect.x()
y = y + line_height + space_y
next_x = x + item.sizeHint().width() + space_x
line_height = 0
if not test_only:
item.setGeometry(QRect(QPoint(x, y), item.sizeHint()))
x = next_x
line_height = max(line_height, item.sizeHint().height())
return y + line_height - rect.y()
class SettingsDialog(QDialog):
def __init__(self, parent=None) -> None:
super().__init__(parent)
self.setWindowTitle("Settings")
self.resize(680, 520)
self._build_ui()
self.load_config_from_parent()
def _build_ui(self) -> None:
layout = QVBoxLayout(self)
self._tabs = QTabWidget()
layout.addWidget(self._tabs)
self._tabs.addTab(self._build_bottle_tab(), "Bottle")
self._tabs.addTab(self._build_paths_tab(), "Paths")
self._tabs.addTab(self._build_setup_tab(), "Setup")
self._tabs.addTab(self._build_dev_tab(), "DEV UI")
self._tabs.addTab(self._build_logs_tab(), "Logs")
close_btn = QPushButton("Close")
close_btn.clicked.connect(self.save_config_to_parent)
close_btn.clicked.connect(self.hide)
btn_row = QHBoxLayout()
btn_row.addStretch()
btn_row.addWidget(close_btn)
layout.addLayout(btn_row)
def _build_bottle_tab(self) -> QWidget:
widget = QWidget()
form = QFormLayout(widget)
form.setRowWrapPolicy(QFormLayout.RowWrapPolicy.WrapLongRows)
# Read-only prefix path display
self.bottle_prefix_display = QLineEdit()
self.bottle_prefix_display.setReadOnly(True)
self.bottle_prefix_display.setStyleSheet("color: rgba(255,255,255,0.5);")
self.bottle_name_edit = QLineEdit()
self.bottle_name_edit.setPlaceholderText("Display name shown in sidebar")
self.bottle_launcher_edit = QLineEdit()
self.bottle_launcher_edit.setPlaceholderText("Leave empty to use Steam (default)")
self.bottle_icon_edit = QLineEdit()
self.bottle_icon_edit.setPlaceholderText("Leave empty to use default icon")
# Remove / Delete buttons (hidden for default Steam bottle)
self.bottle_danger_row = QWidget()
danger_layout = QHBoxLayout(self.bottle_danger_row)
danger_layout.setContentsMargins(0, 0, 0, 0)
btn_remove = QPushButton("Remove from List")
btn_remove.clicked.connect(self._remove_prefix)
btn_delete = QPushButton("Delete Prefix from Disk")
btn_delete.setStyleSheet("color: #FF6666;")
btn_delete.clicked.connect(self._delete_prefix_disk)
danger_layout.addWidget(btn_remove)
danger_layout.addWidget(btn_delete)
danger_layout.addStretch()
# Open SteamSetup button (shown only for default Steam bottle)
self.btn_open_steamsetup = QPushButton("Open SteamSetup")
self.btn_open_steamsetup.setToolTip("Download and run SteamSetup.exe to install, repair, or uninstall Steam")
self.bottle_backend_combo = QComboBox()
self.bottle_backend_combo.addItem("Auto (recommended)", LAUNCH_BACKEND_AUTO)
self.btn_init_prefix = QPushButton("Initialize Prefix")
self.btn_init_prefix.setToolTip("Run wineboot to create the Wine prefix (drive_c, registry, etc.)")
# Tool buttons visible for all bottles
tools_row = QWidget()
tools_layout = QGridLayout(tools_row)
tools_layout.setContentsMargins(0, 0, 0, 0)
self.btn_clean_prefix_bottle = QPushButton("Clean Prefix (wineboot -u)")
self.btn_kill_wineserver_bottle = QPushButton("Kill Wineserver")
self.btn_kill_wineserver_bottle.setStyleSheet("color: #FF5555;")
self.btn_unpatch_bottle = QPushButton("Unpatch Game (remove DLLs)")
tools_layout.addWidget(self.btn_clean_prefix_bottle, 0, 0)
tools_layout.addWidget(self.btn_kill_wineserver_bottle, 0, 1)
tools_layout.addWidget(self.btn_unpatch_bottle, 1, 0, 1, 2)
parent = self.parent()
if parent:
if hasattr(parent, "init_prefix"):
self.btn_init_prefix.clicked.connect(parent.init_prefix)
if hasattr(parent, "open_steamsetup"):
self.btn_open_steamsetup.clicked.connect(parent.open_steamsetup)
if hasattr(parent, "clean_prefix"):
self.btn_clean_prefix_bottle.clicked.connect(parent.clean_prefix)
if hasattr(parent, "kill_wineserver"):
self.btn_kill_wineserver_bottle.clicked.connect(parent.kill_wineserver)
if hasattr(parent, "unpatch_selected_game"):
self.btn_unpatch_bottle.clicked.connect(parent.unpatch_selected_game)
form.addRow("Prefix path", self.bottle_prefix_display)
form.addRow("Bottle Name", self.bottle_name_edit)
form.addRow("Graphics Backend", self.bottle_backend_combo)
form.addRow("Initialize Prefix", self.btn_init_prefix)
form.addRow("Launcher exe", self._browsable(self.bottle_launcher_edit, dir=False))
form.addRow("Custom icon (PNG)", self._browsable(self.bottle_icon_edit, dir=False))
form.addRow(self.btn_open_steamsetup)
form.addRow(self.bottle_danger_row)
form.addRow("Tools", tools_row)
hint = QLabel("To edit a different bottle: close Settings, select it in the sidebar, then reopen Settings.")
hint.setWordWrap(True)
hint.setStyleSheet("color: rgba(255,255,255,0.5); font-size: 11px;")
form.addRow(hint)
return widget
def _reload_bottle_fields(self) -> None:
parent = self.parent()
if not parent or not hasattr(parent, "_get_bottle_data"):
return
if not hasattr(self, "bottle_name_edit"):
return
prefix_path = self.prefix_combo.currentText()
self.bottle_prefix_display.setText(prefix_path)
bottle = parent._get_bottle_data(prefix_path)
self.bottle_name_edit.setText(bottle.get("name", ""))
self.bottle_launcher_edit.setText(bottle.get("launcher_exe", ""))
self.bottle_icon_edit.setText(bottle.get("icon_path", ""))
try:
is_default = str(Path(prefix_path).expanduser().resolve()) == str(Path(DEFAULT_PREFIX).expanduser().resolve())
except Exception:
is_default = False
if hasattr(self, "bottle_danger_row"):
self.bottle_danger_row.setVisible(not is_default)
if hasattr(self, "btn_open_steamsetup"):
self.btn_open_steamsetup.setVisible(is_default)
if hasattr(self, "btn_init_prefix"):
try:
already_init = (Path(prefix_path).expanduser() / "drive_c").exists()
except Exception:
already_init = False
self.btn_init_prefix.setVisible(not already_init)
if hasattr(self, "bottle_backend_combo"):
# Repopulate with currently available backends (parent is fully init'd here)
self.bottle_backend_combo.blockSignals(True)
self.bottle_backend_combo.clear()
self.bottle_backend_combo.addItem("Auto (recommended)", LAUNCH_BACKEND_AUTO)
if hasattr(parent, "available_backends"):
for _label, _bid in parent.available_backends():
if _bid != LAUNCH_BACKEND_AUTO:
self.bottle_backend_combo.addItem(_label, _bid)
self.bottle_backend_combo.blockSignals(False)
saved_backend = bottle.get("preferred_backend", LAUNCH_BACKEND_AUTO)
for i in range(self.bottle_backend_combo.count()):
if self.bottle_backend_combo.itemData(i) == saved_backend:
self.bottle_backend_combo.setCurrentIndex(i)
break
def _build_paths_tab(self) -> QWidget:
widget = QWidget()
form = QFormLayout(widget)
form.setRowWrapPolicy(QFormLayout.RowWrapPolicy.WrapLongRows)
# prefix_combo is kept as the internal data model (not shown in this tab)
self.prefix_combo = QComboBox()
self.prefix_combo.setEditable(True)
self.prefix_combo.addItems(self.load_prefixes())
self.prefix_combo.currentTextChanged.connect(self._save_current_prefixes)
self.dxvk_src_edit = QLineEdit(DEFAULT_DXVK_SRC)
self.dxvk_install_edit = QLineEdit(DEFAULT_DXVK_INSTALL)
self.dxvk_install32_edit = QLineEdit(DEFAULT_DXVK_INSTALL32)
self.steam_setup_edit = QLineEdit(DEFAULT_STEAM_SETUP)
self.mesa_dir_edit = QLineEdit(DEFAULT_MESA_DIR)
self.dxmt_dir_edit = QLineEdit(DEFAULT_DXMT_DIR)
self.vkd3d_dir_edit = QLineEdit(DEFAULT_VKD3D_DIR)
self.gptk_dir_edit = QLineEdit(DEFAULT_GPTK_DIR)
form.addRow("DXVK source", self._browsable(self.dxvk_src_edit, dir=True))
form.addRow("DXVK install (64-bit)", self._browsable(self.dxvk_install_edit, dir=True))
form.addRow("DXVK install (32-bit)", self._browsable(self.dxvk_install32_edit, dir=True))
form.addRow("SteamSetup.exe", self._browsable(self.steam_setup_edit, dir=False))
form.addRow("Mesa x64 dir", self._browsable(self.mesa_dir_edit, dir=True))
form.addRow("DXMT dir", self._browsable(self.dxmt_dir_edit, dir=True))
form.addRow("VKD3D-Proton dir", self._browsable(self.vkd3d_dir_edit, dir=True))
form.addRow("GPTK dir", self._browsable(self.gptk_dir_edit, dir=True))
return widget
def load_prefixes(self) -> list[str]:
path = Path.home() / ".macncheese_prefixes.json"
if path.exists():
try:
data = json.loads(path.read_text())
if isinstance(data, list) and data:
return data
except Exception:
pass
return [DEFAULT_PREFIX]
def _save_current_prefixes(self, *args) -> None:
current = self.prefix_combo.currentText()
items = [self.prefix_combo.itemText(i) for i in range(self.prefix_combo.count())]
if current and current not in items:
self.prefix_combo.insertItem(0, current)
self.prefix_combo.setCurrentIndex(0)
items.insert(0, current)
path = Path.home() / ".macncheese_prefixes.json"
try:
path.write_text(json.dumps(items[:10]))
except Exception:
pass
def _build_prefix_row(self, combo: QComboBox) -> QWidget:
wrap = QWidget()
row = QHBoxLayout(wrap)
row.setContentsMargins(0, 0, 0, 0)
row.addWidget(combo, 1)
btn_remove = QPushButton("Remove from List")
btn_remove.clicked.connect(self._remove_prefix)
row.addWidget(btn_remove)
btn_delete = QPushButton("Delete Disk")
btn_delete.setStyleSheet("color: #FF6666;")
btn_delete.clicked.connect(self._delete_prefix_disk)
row.addWidget(btn_delete)
btn_browse = QPushButton("Browse")
btn_browse.clicked.connect(self._pick_prefix_dir)
row.addWidget(btn_browse)
return wrap
def _remove_prefix(self) -> None:
path_str = self.prefix_combo.currentText()
idx = self.prefix_combo.currentIndex()
if idx >= 0:
self.prefix_combo.removeItem(idx)
self._save_current_prefixes()
parent = self.parent()
if parent and hasattr(parent, "remove_sidebar_button_for_prefix"):
parent.remove_sidebar_button_for_prefix(path_str)
def _delete_prefix_disk(self) -> None:
path_str = self.prefix_combo.currentText()
if not path_str:
return
p = Path(path_str)
if not p.exists():
QMessageBox.warning(self, "Delete Prefix", f"Prefix does not exist on disk:\n{p}")
self._remove_prefix()
return
reply = QMessageBox.question(
self,
"Delete Prefix",
f"Are you sure you want to PERMANENTLY delete this prefix and all of its contents (games, saves, etc)?\n\n{p}",
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No
)
if reply == QMessageBox.StandardButton.Yes:
try:
import shutil
shutil.rmtree(p)
QMessageBox.information(self, "Deleted", "Prefix deleted successfully.")
self._remove_prefix()
except Exception as e:
QMessageBox.critical(self, "Error", f"Failed to delete prefix:\n{e}")
def _pick_prefix_dir(self) -> None:
chosen = QFileDialog.getExistingDirectory(self, "Select prefix folder", self.prefix_combo.currentText())
if chosen:
self.prefix_combo.setCurrentText(chosen)
self._save_current_prefixes()
def _build_setup_tab(self) -> QWidget:
widget = QWidget()
layout = QVBoxLayout(widget)
# --- Quick Setup ---
quick_box = QGroupBox("Quick Setup")
quick_layout = QHBoxLayout(quick_box)
self.minimal_setup_btn = QPushButton("Minimal")
self.minimal_setup_btn.setToolTip("Installs Tools, Wine, DXVK (64/32), and Mesa.")
self.everything_setup_btn = QPushButton("Everything")
self.everything_setup_btn.setToolTip("Installs all components.")
quick_layout.addWidget(self.minimal_setup_btn)
quick_layout.addWidget(self.everything_setup_btn)
layout.addWidget(quick_box)
# --- Components (checkboxes + Install/Uninstall) ---
components_box = QGroupBox("Components")
comp_layout = QVBoxLayout(components_box)
self.cb_install_tools = QCheckBox("Install Tools")
self.cb_install_wine = QCheckBox("Install Wine")
self.cb_install_mesa = QCheckBox("Install Mesa")
self.cb_build_dxvk = QCheckBox("Install DXVK (64-bit)")
self.cb_build_dxvk32 = QCheckBox("Install DXVK (32-bit)")
self.cb_install_gptk_full = QCheckBox("Install GPTK FULL (Experimental)")
self.cb_install_d3dmetal3 = QCheckBox("Install D3DMetal 3 (Prebuilt)")
self.cb_import_gptk_dlls = QCheckBox("Import GPTK DLLs")
_indicator = (
"QCheckBox::indicator { width: 16px; height: 16px; border-radius: 4px;"
" border: 1px solid rgba(255,255,255,0.4); background: rgba(255,255,255,0.08); }"
"QCheckBox::indicator:checked { background: #4CAF50; border: 1px solid #4CAF50; }"
"QCheckBox::indicator:unchecked:hover { border: 1px solid rgba(255,255,255,0.7); }"
)
for cb, color, bold in (
(self.cb_install_tools, None, False),
(self.cb_install_wine, None, False),
(self.cb_install_mesa, None, False),
(self.cb_build_dxvk, None, False),
(self.cb_build_dxvk32, None, False),
(self.cb_install_gptk_full, "#FFCC00", True),
(self.cb_install_d3dmetal3, "#00D8D6", True),
(self.cb_import_gptk_dlls, "#7DD3FC", True),
):
color_css = f" color: {color};" if color else ""
weight_css = " font-weight: bold;" if bold else ""
cb.setStyleSheet(
f"QCheckBox {{ spacing: 8px;{color_css}{weight_css} }}" + _indicator
)
comp_layout.addWidget(cb)
self.install_uninstall_btn = QPushButton("Install / Uninstall / Update")
comp_layout.addWidget(self.install_uninstall_btn)
layout.addWidget(components_box)
layout.addStretch()
# (install_action, uninstall_action_or_None)
self._component_actions = [
(self.cb_install_tools, "install_tools", None),
(self.cb_install_wine, "install_wine", None),
(self.cb_install_mesa, "install_mesa", None),
(self.cb_build_dxvk, "build_dxvk", None),
(self.cb_build_dxvk32, "build_dxvk32", None),
(self.cb_install_gptk_full, "install_gptk_full", None),
(self.cb_install_d3dmetal3, "install_d3dmetal3", None),
(self.cb_import_gptk_dlls, "choose_and_import_gptk_dlls", None),
]
parent = self.parent()
if parent:
self.minimal_setup_btn.clicked.connect(parent.quick_setup)
self.everything_setup_btn.clicked.connect(self._everything_setup)
self.install_uninstall_btn.clicked.connect(self._install_uninstall_selected)
return widget
def _refresh_component_checkboxes(self, parent) -> None:
"""Check each component's installation state and tick checkboxes accordingly.
Uses self (SettingsDialog) for path lookups — always available at build time."""
def _path(edit_name: str) -> Optional[Path]:
try:
return Path(getattr(self, edit_name).text()).expanduser()
except Exception:
return None
def _is_tools():
# install_tools installs: git, p7zip (7z/7zz), winetricks via Homebrew
# shutil.which may miss Homebrew paths inside a .app bundle, so check explicitly
_brew_dirs = [
Path("/opt/homebrew/bin"),
Path("/usr/local/bin"),
PORTABLE_DIR / "bin"
]
def _find(name):
if shutil.which(name):
return True
return any((d / name).exists() for d in _brew_dirs)
return _find("git") and (_find("7z") or _find("7zz")) and _find("winetricks")
def _is_wine():
try:
return parent.has_wine()
except Exception:
return False
def _is_mesa():
p = _path("mesa_dir_edit")
return bool(p and (p / "opengl32.dll").exists())
def _is_dxvk():
p = _path("dxvk_install_edit")
return bool(p and all((p / "bin" / dll).exists() for dll in DXVK_DLLS))
def _is_dxvk32():
p = _path("dxvk_install32_edit")
return bool(p and all((p / "bin" / dll).exists() for dll in DXVK_DLLS))
def _is_gptk_full():
return (
Path("/usr/local/bin/gameportingtoolkit").exists()
or bool(shutil.which("gameportingtoolkit"))
)
def _is_d3dmetal3():
return (
Path.home() / "gptk3" / "Game Porting Toolkit.app"
/ "Contents" / "Resources" / "wine" / "bin" / "wine64"
).exists()
def _is_gptk_dlls():
p = _path("gptk_dir_edit")
if not p:
return False
dll_dir = p / "lib" / "wine" / "x86_64-windows"
return all((dll_dir / dll).exists() for dll in GPTK_REQUIRED_DLLS)
states = [
_is_tools(), _is_wine(), _is_mesa(),
_is_dxvk(), _is_dxvk32(),
_is_gptk_full(), _is_d3dmetal3(), _is_gptk_dlls(),
]
for (cb, _, _), checked in zip(self._component_actions, states):
cb.setChecked(checked)
def _install_uninstall_selected(self) -> None:
parent = self.parent()
if not parent:
return
for cb, install_action, uninstall_action in self._component_actions:
if not cb.isChecked():
continue
action = uninstall_action if uninstall_action else install_action
method = getattr(parent, action, None)
if method:
method()
def _everything_setup(self) -> None:
parent = self.parent()
if not parent:
return
for cb, _, _ in self._component_actions:
cb.setChecked(True)
self._install_uninstall_selected()
def _build_dev_tab(self) -> QWidget:
widget = QWidget()
layout = QVBoxLayout(widget)
info = QPlainTextEdit()
info.setReadOnly(True)
try:
dev_text = Path("/tmp/dev_ui_text.txt").read_text()
info.setPlainText(dev_text)
except Exception:
info.setPlainText("Manual installation guide could not be loaded.")
layout.addWidget(info)
return widget
def _build_logs_tab(self) -> QWidget:
widget = QWidget()
layout = QVBoxLayout(widget)
self.log_view = QPlainTextEdit()
self.log_view.setReadOnly(True)
layout.addWidget(self.log_view)
return widget
def _browsable(self, field: QLineEdit, *, dir: bool) -> QWidget:
wrap = QWidget()
row = QHBoxLayout(wrap)
row.setContentsMargins(0, 0, 0, 0)
row.addWidget(field)
btn = QPushButton("Browse")
if dir:
btn.clicked.connect(lambda: self._pick_dir(field))
else:
btn.clicked.connect(lambda: self._pick_file(field))
row.addWidget(btn)
return wrap
def _pick_dir(self, target: QLineEdit) -> None:
chosen = QFileDialog.getExistingDirectory(self, "Select folder", target.text())
if chosen:
target.setText(chosen)
def _pick_file(self, target: QLineEdit) -> None:
chosen, _ = QFileDialog.getOpenFileName(self, "Select file", target.text())
if chosen:
target.setText(chosen)
def load_config_from_parent(self) -> None:
parent = self.parent()
if parent is None:
return
if hasattr(parent, "prefix_combo"):
self.prefix_combo.setCurrentText(parent.prefix_combo.currentText())
if hasattr(parent, "dxvk_src_edit"):
self.dxvk_src_edit.setText(parent.dxvk_src_edit.text())
if hasattr(parent, "dxvk_install_edit"):
self.dxvk_install_edit.setText(parent.dxvk_install_edit.text())
if hasattr(parent, "dxvk_install32_edit"):
self.dxvk_install32_edit.setText(parent.dxvk_install32_edit.text())
if hasattr(parent, "steam_setup_edit"):
self.steam_setup_edit.setText(parent.steam_setup_edit.text())
if hasattr(parent, "mesa_dir_edit"):
self.mesa_dir_edit.setText(parent.mesa_dir_edit.text())
if hasattr(parent, "dxmt_dir_edit"):
self.dxmt_dir_edit.setText(parent.dxmt_dir_edit.text())
if hasattr(parent, "vkd3d_dir_edit"):
self.vkd3d_dir_edit.setText(parent.vkd3d_dir_edit.text())
if hasattr(parent, "gptk_dir_edit"):
self.gptk_dir_edit.setText(parent.gptk_dir_edit.text())
# Populate bottle tab for the currently active bottle
self._reload_bottle_fields()
# Refresh component checkboxes now that parent is fully initialised
if hasattr(self, "_component_actions"):
self._refresh_component_checkboxes(parent)
def save_config_to_parent(self) -> None:
parent = self.parent()
if parent is None:
return
if hasattr(parent, "prefix_combo"):
current = self.prefix_combo.currentText()
parent.prefix_combo.setCurrentText(current)
if current not in [parent.prefix_combo.itemText(i) for i in range(parent.prefix_combo.count())]:
parent.prefix_combo.insertItem(0, current)
if hasattr(parent, "dxvk_src_edit"):
parent.dxvk_src_edit.setText(self.dxvk_src_edit.text())
if hasattr(parent, "dxvk_install_edit"):
parent.dxvk_install_edit.setText(self.dxvk_install_edit.text())
if hasattr(parent, "dxvk_install32_edit"):
parent.dxvk_install32_edit.setText(self.dxvk_install32_edit.text())
if hasattr(parent, "steam_setup_edit"):
parent.steam_setup_edit.setText(self.steam_setup_edit.text())
if hasattr(parent, "mesa_dir_edit"):
parent.mesa_dir_edit.setText(self.mesa_dir_edit.text())
if hasattr(parent, "dxmt_dir_edit"):
parent.dxmt_dir_edit.setText(self.dxmt_dir_edit.text())
if hasattr(parent, "vkd3d_dir_edit"):
parent.vkd3d_dir_edit.setText(self.vkd3d_dir_edit.text())
if hasattr(parent, "gptk_dir_edit"):
parent.gptk_dir_edit.setText(self.gptk_dir_edit.text())
# Save per-bottle settings
if hasattr(parent, "_set_bottle_data") and hasattr(self, "bottle_name_edit"):
current_prefix = self.prefix_combo.currentText()
backend_val = (
self.bottle_backend_combo.currentData()
if hasattr(self, "bottle_backend_combo")
else LAUNCH_BACKEND_AUTO
)
parent._set_bottle_data(
current_prefix,
name=self.bottle_name_edit.text().strip(),
launcher_exe=self.bottle_launcher_edit.text().strip(),
icon_path=self.bottle_icon_edit.text().strip(),
preferred_backend=backend_val,
)
if hasattr(parent, "_sync_sidebar_prefix_buttons"):
parent._sync_sidebar_prefix_buttons()
if hasattr(parent, "_update_topbar_button"):
parent._update_topbar_button()
def log(self, message: str) -> None:
self.log_view.appendPlainText(message)
class _AdminPasswordDialog(QDialog):
def __init__(self, message: str, parent=None) -> None:
super().__init__(parent)
self.setWindowTitle('MacNCheese Setup')
self.setFixedWidth(380)
self.setModal(True)
layout = QVBoxLayout(self)
layout.setContentsMargins(24, 24, 24, 20)
layout.setSpacing(14)
header = QHBoxLayout()
header.setSpacing(12)
icon_lbl = QLabel()
icon_lbl.setPixmap(self.style().standardIcon(QStyle.StandardPixmap.SP_MessageBoxInformation).pixmap(40, 40))
icon_lbl.setFixedSize(40, 40)
header.addWidget(icon_lbl)
title_lbl = QLabel('<b>Administrator Password Required</b>')
title_lbl.setWordWrap(True)
header.addWidget(title_lbl, 1)
layout.addLayout(header)
msg_lbl = QLabel(message)
msg_lbl.setWordWrap(True)
msg_lbl.setStyleSheet('font-size: 12px;')
layout.addWidget(msg_lbl)
self._pwd_field = QLineEdit()
self._pwd_field.setEchoMode(QLineEdit.EchoMode.Password)
self._pwd_field.setPlaceholderText('Password')
self._pwd_field.returnPressed.connect(self.accept)
layout.addWidget(self._pwd_field)
btn_row = QHBoxLayout()
btn_row.addStretch()
cancel_btn = QPushButton('Cancel')
cancel_btn.clicked.connect(self.reject)
ok_btn = QPushButton('OK')
ok_btn.setDefault(True)
ok_btn.clicked.connect(self.accept)
btn_row.addWidget(cancel_btn)
btn_row.addWidget(ok_btn)
layout.addLayout(btn_row)
def password(self) -> str:
return self._pwd_field.text()
class _InstallProgressDialog(QDialog):
cancel_requested = pyqtSignal()
def __init__(self, title: str, parent=None) -> None:
super().__init__(parent)
self.setWindowTitle(title)
self.setFixedWidth(420)
self.setModal(True)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowCloseButtonHint)
layout = QVBoxLayout(self)
layout.setContentsMargins(24, 24, 24, 20)
layout.setSpacing(14)
self._title_lbl = QLabel(f'<b>{title}</b>')
self._title_lbl.setStyleSheet('font-size: 14px;')
layout.addWidget(self._title_lbl)
self._step_lbl = QLabel('Starting…')
self._step_lbl.setWordWrap(True)
self._step_lbl.setStyleSheet('font-size: 12px;')
layout.addWidget(self._step_lbl)
self._bar = QProgressBar()
self._bar.setRange(0, 0)
self._bar.setTextVisible(False)
self._bar.setFixedHeight(14)
self._bar.setStyleSheet('QProgressBar { border-radius: 7px; background: rgba(255,255,255,0.15); }QProgressBar::chunk { border-radius: 7px; background: qlineargradient( x1:0, y1:0, x2:1, y2:0, stop:0 #6C8EFF, stop:1 #A855F7); }')
layout.addWidget(self._bar)
btn_row = QHBoxLayout()
btn_row.addStretch()
self._cancel_btn = QPushButton('Cancel')
self._cancel_btn.clicked.connect(self.cancel_requested)
btn_row.addWidget(self._cancel_btn)
layout.addLayout(btn_row)
self._done = False
def update_step(self, text: str) -> None:
if not self._done:
last = next((l for l in reversed(text.splitlines()) if l.strip()), text.strip())
if last:
self._step_lbl.setText(last)
def mark_done(self, ok: bool, message: str) -> None:
self._done = True
self._bar.setRange(0, 1)
self._bar.setValue(1)
self._step_lbl.setText(message)
self._cancel_btn.setText('Close')
self._cancel_btn.clicked.disconnect()
self._cancel_btn.clicked.connect(self.accept)
MODERN_THEME = """
QWidget {
color: #FFFFFF;
font-family: ".AppleSystemUIFont", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-size: 13px;
}
QMainWindow, QDialog {
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,
stop: 0 #1A1F2C, stop: 1 #0D0F16);
}
#Sidebar {
background-color: rgba(255, 255, 255, 0.05);
border-right: 1px solid rgba(255, 255, 255, 0.1);
}
QLabel {
background-color: transparent;
}
#SidebarButton {
background-color: transparent;
border: 1px solid transparent;
border-radius: 12px;
padding: 6px 4px 4px 4px;
margin: 2px 6px;
color: rgba(255, 255, 255, 0.6);
font-size: 10px;
}
#SidebarButton:hover {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #FFFFFF;
}
#SidebarButton:checked {
background-color: rgba(0, 216, 214, 0.15);
border: 1px solid rgba(0, 216, 214, 0.5);
color: #00D8D6;
}
#AddContainerButton {
background-color: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 22px;
color: rgba(255, 255, 255, 0.8);
font-size: 22px;
font-weight: bold;
padding: 0px;
margin: 4px 8px;
}
#AddContainerButton:hover {
background-color: rgba(0, 216, 214, 0.15);
border: 1px solid rgba(0, 216, 214, 0.6);
color: #00D8D6;
}
#AddContainerButton::menu-indicator {
image: none;
}
#Topbar {
background-color: rgba(255, 255, 255, 0.03);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#LogoText {
color: #00D8D6;
font-size: 18px;
font-weight: bold;
letter-spacing: 1px;
}
#LogoM {
background-color: transparent;
color: rgba(255, 255, 255, 0.9);
border-radius: 10px;
border: none;
}
QLineEdit#SearchBar {
background-color: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 16px;
padding: 7px 14px;
color: rgba(255, 255, 255, 0.8);
font-size: 13px;
min-width: 260px;
}
QLineEdit#SearchBar:focus {
background-color: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(0, 216, 214, 0.6);
color: #FFFFFF;
}
#TopBarBtn {
background-color: transparent;
border: 1px solid transparent;
color: rgba(255, 255, 255, 0.6);
font-size: 18px;
padding: 4px 6px;
border-radius: 10px;
}
#TopBarBtn:hover {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #00D8D6;
}
#GameCard {
background-color: rgba(255, 255, 255, 0.03);
border-radius: 14px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
#GameCard:hover {
background-color: rgba(255, 255, 255, 0.07);
border: 1px solid rgba(0, 216, 214, 0.5);
}
#GameCoverLabel {
background-color: transparent;
border-radius: 14px;
}
#DialogTitle {
font-size: 18px;
font-weight: bold;
color: #FFFFFF;
}
#PlayBtn, #InstallBtn {
background-color: rgba(0, 216, 214, 0.1);
border: 1px solid rgba(0, 216, 214, 0.4);
border-radius: 20px;
color: #00D8D6;
font-size: 14px;
font-weight: bold;
padding: 8px 28px;
min-width: 100px;
}
#PlayBtn:hover, #InstallBtn:hover {
background-color: rgba(0, 216, 214, 0.2);
border: 1px solid #00D8D6;
color: #FFFFFF;
}
QComboBox {
background-color: rgba(255, 255, 255, 0.08);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 12px;
padding: 5px 12px;
color: #FFFFFF;
font-size: 13px;
min-width: 200px;
}
QComboBox::drop-down {
border: none;
width: 20px;
}
QComboBox QAbstractItemView {
background-color: #1A1F2C;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
selection-background-color: rgba(0, 216, 214, 0.2);
color: #FFFFFF;
}
QLineEdit {
background-color: rgba(255, 255, 255, 0.08);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 12px;
padding: 5px 12px;
color: #FFFFFF;
font-size: 13px;
}
QLineEdit:focus {
background-color: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(0, 216, 214, 0.6);
}
QPushButton {
background-color: rgba(255, 255, 255, 0.08);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 12px;
padding: 8px 16px;
color: #FFFFFF;
font-weight: bold;
}
QPushButton:hover {
background-color: rgba(255, 255, 255, 0.15);
border: 1px solid rgba(255, 255, 255, 0.3);
}
QPushButton:pressed {
background-color: rgba(0, 216, 214, 0.2);
border: 1px solid #00D8D6;
color: #FFFFFF;
}