-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCEreader.py
More file actions
1170 lines (1068 loc) · 45.3 KB
/
Copy pathLCEreader.py
File metadata and controls
1170 lines (1068 loc) · 45.3 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
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (C) 2026 Vistex
"""LCEreader desktop application."""
from __future__ import annotations
import sys
import threading
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from PySide6.QtCore import (
QAbstractTableModel,
QModelIndex,
QObject,
QSortFilterProxyModel,
QThread,
QTimer,
Qt,
QUrl,
Signal,
Slot,
)
from PySide6.QtGui import (
QAction,
QBrush,
QColor,
QDesktopServices,
QFont,
QIcon,
QPalette,
)
from PySide6.QtWidgets import (
QAbstractItemView,
QApplication,
QCheckBox,
QComboBox,
QFileDialog,
QFormLayout,
QFrame,
QHBoxLayout,
QHeaderView,
QLabel,
QLineEdit,
QMainWindow,
QMenu,
QMessageBox,
QProgressBar,
QPushButton,
QScrollArea,
QSizePolicy,
QSplitter,
QStackedWidget,
QTableView,
QToolButton,
QVBoxLayout,
QWidget,
)
import survey
APP_NAME = "LCEreader"
VERSION = "1.0.0"
STYLE = """
QWidget { color: #172033; }
QMainWindow, QWidget#root { background: #f3f6fb; }
QDialog, QMessageBox, QFileDialog { background: #f3f6fb; color: #172033; }
QMessageBox QLabel { background: transparent; color: #172033; }
QFrame#header { background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #101827, stop:1 #172542); border: 0; }
QLabel#brandMark {
color: white; background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #4f7df3, stop:1 #8257d9);
border-radius: 9px; min-width: 38px; min-height: 38px; max-width: 38px; max-height: 38px;
font-size: 16px; font-weight: 800;
}
QLabel#brand { color: white; font-size: 22px; font-weight: 700; }
QLabel#tagline { color: #aeb9cc; font-size: 12px; }
QPushButton, QToolButton {
min-height: 34px; padding: 0 15px; border-radius: 7px;
border: 1px solid #cbd4e1; background: white; color: #243047; font-weight: 600;
}
QPushButton:hover, QToolButton:hover { background: #f7f9fc; border-color: #9aa8bc; }
QPushButton:disabled, QToolButton:disabled { color: #9ba7b8; background: #eef1f5; border-color: #dde3eb; }
QPushButton#primary { background: #3972e6; color: white; border-color: #3972e6; }
QPushButton#primary:hover { background: #2f63ca; }
QPushButton#danger { color: #b42318; }
QFrame#card, QFrame#panel, QFrame#metric {
background: white; border: 1px solid #dfe5ee; border-radius: 10px;
}
QLabel#metricValue { font-size: 22px; font-weight: 700; color: #172033; }
QLabel#metricLabel { font-size: 11px; color: #68758a; }
QLabel#pageTitle { font-size: 25px; font-weight: 700; color: #172033; }
QLabel#pageCopy { color: #647188; font-size: 13px; }
QLabel#sectionTitle { color: #536177; font-size: 11px; font-weight: 700; }
QLabel#detailTitle { font-size: 19px; font-weight: 700; }
QLabel#statusBanner { padding: 8px 10px; border-radius: 6px; font-weight: 700; }
QLineEdit, QComboBox {
min-height: 34px; padding: 0 10px; border: 1px solid #cbd4e1;
border-radius: 7px; background: white; color: #172033;
selection-background-color: #3972e6; selection-color: white;
}
QLineEdit:focus, QComboBox:focus { border: 2px solid #3972e6; }
QComboBox QAbstractItemView {
background: white; color: #172033; border: 1px solid #cbd4e1;
selection-background-color: #3972e6; selection-color: white; outline: 0;
}
QTableView {
background: white; border: 1px solid #dfe5ee; border-radius: 9px;
gridline-color: #edf0f5; alternate-background-color: #f8fafc;
selection-background-color: #dce8ff; selection-color: #172033; color: #172033;
}
QHeaderView::section {
background: #eef2f7; color: #536177; border: 0; border-bottom: 1px solid #d8e0ea;
padding: 9px 8px; font-weight: 700;
}
QProgressBar { border: 0; border-radius: 4px; background: #dfe5ee; min-height: 8px; max-height: 8px; }
QProgressBar::chunk { border-radius: 4px; background: #3972e6; }
QScrollArea { border: 0; background: transparent; }
QWidget#detailContent { background: #f3f6fb; }
QCheckBox { color: #334155; background: transparent; spacing: 7px; }
QMenu { background: white; color: #243047; border: 1px solid #cbd4e1; padding: 5px; }
QMenu::item { color: #243047; padding: 7px 24px; border-radius: 5px; }
QMenu::item:selected { background: #3972e6; color: white; }
QToolTip { background: #172033; color: white; border: 1px solid #334155; padding: 4px; }
QStatusBar { background: #edf1f6; color: #58667b; }
"""
def _light_palette() -> QPalette:
palette = QPalette()
for role, color in {
QPalette.ColorRole.Window: "#f3f6fb",
QPalette.ColorRole.WindowText: "#172033",
QPalette.ColorRole.Base: "#ffffff",
QPalette.ColorRole.AlternateBase: "#f8fafc",
QPalette.ColorRole.ToolTipBase: "#172033",
QPalette.ColorRole.ToolTipText: "#ffffff",
QPalette.ColorRole.Text: "#172033",
QPalette.ColorRole.Button: "#ffffff",
QPalette.ColorRole.ButtonText: "#243047",
QPalette.ColorRole.BrightText: "#ffffff",
QPalette.ColorRole.Link: "#2f63ca",
QPalette.ColorRole.Highlight: "#3972e6",
QPalette.ColorRole.HighlightedText: "#ffffff",
QPalette.ColorRole.PlaceholderText: "#68758a",
}.items():
palette.setColor(role, QColor(color))
return palette
STATUS_LABELS = {
"ok": "Readable",
"warning": "Warning",
"error": "Error",
"non_save_container": "Other container",
}
STATUS_COLORS = {
"ok": ("#19734b", "#e3f5ec"),
"warning": ("#8a5a00", "#fff2cc"),
"error": ("#b42318", "#fde8e7"),
"non_save_container": ("#596579", "#edf0f4"),
}
@dataclass(frozen=True)
class Column:
title: str
key: str
width: int
numeric: bool = False
COLUMNS = (
Column("Status", "status", 94),
Column("World", "world", 145),
Column("File", "file_name", 145),
Column("Updated", "updated", 112),
Column("Seed", "seed", 126, True),
Column("Save size", "save_size", 88, True),
Column("Regions", "region_count", 66, True),
Column("Player position", "player_position", 132),
Column("Duplicates", "duplicates", 82, True),
)
def _human_size(value: int | None) -> str:
if value is None:
return "-"
size = float(value)
for unit in ("B", "KB", "MB", "GB"):
if size < 1024 or unit == "GB":
return f"{size:,.0f} {unit}" if unit == "B" else f"{size:,.1f} {unit}"
size /= 1024
return f"{value:,} B"
def _resource_path(*parts: str) -> Path:
root = Path(getattr(sys, "_MEIPASS", Path(__file__).resolve().parent))
return root.joinpath(*parts)
def _short_time(value: str | None) -> str:
return value.replace("T", " ")[:16] if value else "-"
def _position(row: survey.SurveyRow) -> str:
if None in (row.player_x, row.player_y, row.player_z):
return "-"
return f"{row.player_x:,.1f}, {row.player_y:,.1f}, {row.player_z:,.1f}"
def _world(row: survey.SurveyRow) -> str:
return row.world_name or row.display_name or "-"
def _display(row: survey.SurveyRow, key: str) -> str:
if key == "status":
return STATUS_LABELS.get(row.status, row.status)
if key == "world":
return _world(row)
if key == "updated":
return _short_time(row.updated or row.file_modified_utc)
if key == "seed":
return str(row.seed) if row.seed is not None else "-"
if key == "save_size":
return _human_size(row.save_size)
if key == "region_count":
return f"{row.region_count:,}" if row.region_count is not None else "-"
if key == "player_position":
return _position(row)
if key == "duplicates":
return f"{row.duplicate_count} copies" if row.duplicate_count > 1 else "-"
return str(getattr(row, key) or "-")
def _sort_value(row: survey.SurveyRow, key: str) -> Any:
if key == "status":
return {
"ok": 0,
"warning": 1,
"error": 2,
"non_save_container": 3,
}.get(row.status, 4)
if key == "world":
return _world(row).casefold()
if key == "updated":
return row.updated or row.file_modified_utc
if key == "player_position":
return row.player_x
if key == "duplicates":
return row.duplicate_count
return getattr(row, key, None)
def _sorted_rows(
rows: list[survey.SurveyRow], column: int, order: Qt.SortOrder
) -> list[survey.SurveyRow]:
key = COLUMNS[column].key
present: list[tuple[Any, survey.SurveyRow]] = []
missing: list[survey.SurveyRow] = []
for row in rows:
value = _sort_value(row, key)
if value is None:
missing.append(row)
else:
present.append((value, row))
present.sort(key=lambda item: item[0], reverse=order == Qt.SortOrder.DescendingOrder)
return [row for _, row in present] + missing
def _search_text(row: survey.SurveyRow) -> str:
values = (
row.file_name,
row.relative_path,
row.source_path,
row.display_name,
row.world_name,
row.seed,
row.profile_id,
row.status,
row.message,
" ".join(row.warnings),
row.duplicate_group,
)
return " ".join(str(value) for value in values if value is not None).casefold()
class SurveyModel(QAbstractTableModel):
def __init__(self, parent: QObject | None = None) -> None:
super().__init__(parent)
self.rows: list[survey.SurveyRow] = []
self.search_cache: list[str] = []
def set_rows(self, rows: list[survey.SurveyRow]) -> None:
self.beginResetModel()
self.rows = rows
self.search_cache = [_search_text(row) for row in rows]
self.endResetModel()
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
return 0 if parent.isValid() else len(self.rows)
def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
return 0 if parent.isValid() else len(COLUMNS)
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
if not index.isValid():
return None
row = self.rows[index.row()]
column = COLUMNS[index.column()]
if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.AccessibleTextRole):
return _display(row, column.key)
if role == Qt.ItemDataRole.ToolTipRole:
return f"{row.message}\n{row.source_path}"
if role == Qt.ItemDataRole.ForegroundRole and column.key == "status":
return QBrush(QColor(STATUS_COLORS.get(row.status, ("#172033", "#ffffff"))[0]))
if role == Qt.ItemDataRole.BackgroundRole:
background = STATUS_COLORS.get(row.status, ("", ""))[1]
if background and column.key == "status":
return QBrush(QColor(background))
if role == Qt.ItemDataRole.FontRole and column.key in {"status", "world"}:
font = QFont()
font.setWeight(QFont.Weight.DemiBold)
return font
if role == Qt.ItemDataRole.TextAlignmentRole and column.numeric:
return int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
return None
def headerData(
self,
section: int,
orientation: Qt.Orientation,
role: int = Qt.ItemDataRole.DisplayRole,
) -> Any:
if role != Qt.ItemDataRole.DisplayRole:
return None
return COLUMNS[section].title if orientation == Qt.Orientation.Horizontal else section + 1
class SurveyProxy(QSortFilterProxyModel):
def __init__(self, parent: QObject | None = None) -> None:
super().__init__(parent)
self.query = ""
self.category = "all"
self.duplicates_only = False
self.position_only = False
def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
model = self.sourceModel()
if not isinstance(model, SurveyModel):
return False
row = model.rows[source_row]
if self.query and self.query not in model.search_cache[source_row]:
return False
if self.category == "readable" and row.status not in {"ok", "warning"}:
return False
if self.category not in {"all", "readable"} and row.status != self.category:
return False
if self.duplicates_only and row.duplicate_count < 2:
return False
if self.position_only and None in (row.player_x, row.player_y, row.player_z):
return False
return True
class SurveyWorker(QObject):
progress = Signal(str, int, int, str)
completed = Signal(object)
failed = Signal(str)
def __init__(self, source: Path) -> None:
super().__init__()
self.source = source
self.cancel_event = threading.Event()
def cancel(self) -> None:
self.cancel_event.set()
@Slot()
def run(self) -> None:
try:
result = survey.survey_path(
self.source,
on_progress=self.progress.emit,
is_cancelled=self.cancel_event.is_set,
)
except Exception as exc:
self.failed.emit(str(exc))
return
self.completed.emit(result)
class MetricCard(QFrame):
def __init__(self, label: str, accent: str) -> None:
super().__init__()
self.setObjectName("metric")
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
layout = QVBoxLayout(self)
layout.setContentsMargins(16, 12, 16, 12)
layout.setSpacing(1)
self.value = QLabel("0")
self.value.setObjectName("metricValue")
caption_row = QHBoxLayout()
caption_row.setContentsMargins(0, 0, 0, 0)
caption_row.setSpacing(7)
dot = QFrame()
dot.setFixedSize(8, 8)
dot.setStyleSheet(f"background: {accent}; border: 0; border-radius: 4px;")
caption = QLabel(label)
caption.setObjectName("metricLabel")
layout.addWidget(self.value)
caption_row.addWidget(dot)
caption_row.addWidget(caption)
caption_row.addStretch(1)
layout.addLayout(caption_row)
class DetailSection(QFrame):
def __init__(self, title: str, values: list[tuple[str, str]]) -> None:
super().__init__()
values = [(label, value) for label, value in values if value and value != "-"]
if not values:
self.setHidden(True)
self.setObjectName("card")
layout = QVBoxLayout(self)
layout.setContentsMargins(14, 12, 14, 12)
layout.setSpacing(7)
heading = QLabel(title.upper())
heading.setObjectName("sectionTitle")
layout.addWidget(heading)
form = QFormLayout()
form.setContentsMargins(0, 0, 0, 0)
form.setHorizontalSpacing(18)
form.setVerticalSpacing(5)
form.setLabelAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
for label, value in values:
label_widget = QLabel(label)
label_widget.setStyleSheet("color: #6c788c;")
value_widget = QLabel(value)
value_widget.setTextInteractionFlags(
Qt.TextInteractionFlag.TextSelectableByMouse
| Qt.TextInteractionFlag.TextSelectableByKeyboard
)
value_widget.setWordWrap(True)
value_widget.setSizePolicy(
QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Preferred
)
form.addRow(label_widget, value_widget)
layout.addLayout(form)
class MainWindow(QMainWindow):
def __init__(self) -> None:
super().__init__()
self.current_survey: survey.Survey | None = None
self.worker: SurveyWorker | None = None
self.worker_thread: QThread | None = None
self.close_when_finished = False
self.sort_column = 3
self.sort_order = Qt.SortOrder.DescendingOrder
self.setWindowTitle(APP_NAME)
self.resize(1440, 820)
self.setMinimumSize(1000, 560)
self.setAcceptDrops(True)
root = QWidget()
root.setObjectName("root")
root_layout = QVBoxLayout(root)
root_layout.setContentsMargins(0, 0, 0, 0)
root_layout.setSpacing(0)
root_layout.addWidget(self._build_header())
body = QWidget()
body_layout = QVBoxLayout(body)
body_layout.setContentsMargins(20, 18, 20, 16)
body_layout.setSpacing(14)
self.progress_panel = self._build_progress_panel()
self.progress_panel.hide()
body_layout.addWidget(self.progress_panel)
self.pages = QStackedWidget()
self.pages.addWidget(self._build_welcome_page())
self.pages.addWidget(self._build_results_page())
body_layout.addWidget(self.pages, 1)
root_layout.addWidget(body, 1)
self.setCentralWidget(root)
for shortcut, callback in (
("Ctrl+F", self.search_input.setFocus),
("Ctrl+O", self.choose_survey_file),
("Ctrl+S", self.save_survey_json),
("Escape", self.cancel_survey),
):
action = QAction(self)
action.setShortcut(shortcut)
action.triggered.connect(callback)
self.addAction(action)
self.statusBar().showMessage("Ready")
def resizeEvent(self, event: Any) -> None:
super().resizeEvent(event)
if not hasattr(self, "table"):
return
if self.width() < 1250:
visible = {0, 1, 3, 5}
elif self.width() < 1450:
visible = {0, 1, 2, 3, 4, 5, 8}
else:
visible = set(range(len(COLUMNS)))
for index in range(len(COLUMNS)):
self.table.setColumnHidden(index, index not in visible)
def _build_header(self) -> QWidget:
header = QFrame()
header.setObjectName("header")
layout = QHBoxLayout(header)
layout.setContentsMargins(22, 14, 22, 14)
layout.setSpacing(10)
mark = QLabel()
mark.setPixmap(QIcon(str(_resource_path("assets", "LCEreader.svg"))).pixmap(42, 42))
mark.setAlignment(Qt.AlignmentFlag.AlignCenter)
layout.addWidget(mark)
brand_box = QVBoxLayout()
brand_box.setSpacing(0)
brand = QLabel(APP_NAME)
brand.setObjectName("brand")
tagline = QLabel("Minecraft Xbox 360 saves")
tagline.setObjectName("tagline")
brand_box.addWidget(brand)
brand_box.addWidget(tagline)
layout.addLayout(brand_box)
layout.addStretch(1)
self.open_button = QPushButton("Open survey")
self.open_button.setToolTip("Open a saved JSON survey")
self.open_button.clicked.connect(self.choose_survey_file)
about_button = QPushButton("About")
about_button.clicked.connect(self.show_about)
self.export_button = QToolButton()
self.export_button.setText("Export")
self.export_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
export_menu = QMenu(self.export_button)
self.save_json_action = QAction("Save survey (JSON)...", self)
self.save_json_action.triggered.connect(self.save_survey_json)
self.export_view_action = QAction("Export visible results (CSV)...", self)
self.export_view_action.triggered.connect(self.export_visible_csv)
self.export_selected_action = QAction("Export selection (CSV)...", self)
self.export_selected_action.triggered.connect(self.export_selected_csv)
export_menu.addActions(
(self.save_json_action, self.export_view_action, self.export_selected_action)
)
self.export_button.setMenu(export_menu)
self.export_button.setEnabled(False)
self.scan_button = QPushButton("Scan folder")
self.scan_button.setObjectName("primary")
self.scan_button.setToolTip("Scan a folder and its subfolders for STFS containers")
self.scan_button.clicked.connect(self.choose_source_folder)
layout.addWidget(about_button)
layout.addWidget(self.open_button)
layout.addWidget(self.export_button)
layout.addWidget(self.scan_button)
return header
def _build_progress_panel(self) -> QWidget:
panel = QFrame()
panel.setObjectName("panel")
layout = QHBoxLayout(panel)
layout.setContentsMargins(16, 12, 16, 12)
info = QVBoxLayout()
info.setSpacing(4)
self.progress_title = QLabel("Preparing...")
self.progress_title.setStyleSheet("font-weight: 700;")
self.progress_detail = QLabel("")
self.progress_detail.setStyleSheet("color: #68758a;")
self.progress_bar = QProgressBar()
self.progress_bar.setTextVisible(False)
self.progress_bar.setAccessibleName("Survey progress")
info.addWidget(self.progress_title)
info.addWidget(self.progress_detail)
info.addWidget(self.progress_bar)
layout.addLayout(info, 1)
self.cancel_button = QPushButton("Cancel")
self.cancel_button.setObjectName("danger")
self.cancel_button.setToolTip("Stop after the save currently being inspected")
self.cancel_button.clicked.connect(self.cancel_survey)
layout.addWidget(self.cancel_button)
return panel
def _build_welcome_page(self) -> QWidget:
page = QWidget()
outer = QVBoxLayout(page)
outer.addStretch(1)
card = QFrame()
card.setObjectName("card")
card.setMaximumWidth(680)
layout = QVBoxLayout(card)
layout.setContentsMargins(44, 40, 44, 40)
layout.setSpacing(16)
title = QLabel("Inspect saves")
title.setObjectName("pageTitle")
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
copy = QLabel(
"Scan a folder, inspect metadata, find duplicates, and export results. "
"Saves are never modified."
)
copy.setObjectName("pageCopy")
copy.setAlignment(Qt.AlignmentFlag.AlignCenter)
copy.setWordWrap(True)
choose = QPushButton("Scan folder")
choose.setObjectName("primary")
choose.clicked.connect(self.choose_source_folder)
choose.setMinimumHeight(42)
open_existing = QPushButton("Open survey")
open_existing.clicked.connect(self.choose_survey_file)
layout.addWidget(title)
layout.addWidget(copy)
layout.addWidget(choose)
layout.addWidget(open_existing)
row = QHBoxLayout()
row.addStretch(1)
row.addWidget(card)
row.addStretch(1)
outer.addLayout(row)
outer.addStretch(1)
return page
def _build_results_page(self) -> QWidget:
page = QWidget()
layout = QVBoxLayout(page)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(12)
overview = QHBoxLayout()
overview.setSpacing(10)
self.metric_cards = {
"rows": MetricCard("CONTAINERS", "#3972e6"),
"readable": MetricCard("READABLE", "#2aaf78"),
"warnings": MetricCard("WARNINGS", "#e3a52a"),
"errors": MetricCard("ERRORS", "#df5b52"),
"non_saves": MetricCard("OTHER CONTAINERS", "#718096"),
"duplicates": MetricCard("DUPLICATES", "#3aa6bd"),
}
for card in self.metric_cards.values():
overview.addWidget(card)
layout.addLayout(overview)
self.health_banner = QLabel()
self.health_banner.setObjectName("statusBanner")
self.health_banner.setWordWrap(True)
self.health_banner.setStyleSheet("color: #7a4d00; background: #fff0c2;")
self.health_banner.hide()
layout.addWidget(self.health_banner)
filter_panel = QFrame()
filter_panel.setObjectName("panel")
filters = QHBoxLayout(filter_panel)
filters.setContentsMargins(12, 10, 12, 10)
filters.setSpacing(9)
self.search_input = QLineEdit()
self.search_input.setPlaceholderText("Search results")
self.search_input.setAccessibleName("Search survey results")
self.search_input.setClearButtonEnabled(True)
self.search_timer = QTimer(self)
self.search_timer.setSingleShot(True)
self.search_timer.setInterval(180)
self.search_timer.timeout.connect(self.apply_filters)
self.search_input.textChanged.connect(lambda: self.search_timer.start())
self.category_combo = QComboBox()
self.category_combo.addItem("All results", "all")
self.category_combo.addItem("Readable", "readable")
self.category_combo.addItem("Warnings", "warning")
self.category_combo.addItem("Errors", "error")
self.category_combo.addItem("Other containers", "non_save_container")
self.category_combo.currentIndexChanged.connect(self.apply_filters)
self.duplicates_check = QCheckBox("Duplicates only")
self.duplicates_check.toggled.connect(self.apply_filters)
self.position_check = QCheckBox("Has player position")
self.position_check.toggled.connect(self.apply_filters)
filters.addWidget(self.search_input, 1)
filters.addWidget(self.category_combo)
filters.addWidget(self.duplicates_check)
filters.addWidget(self.position_check)
layout.addWidget(filter_panel)
self.model = SurveyModel(self)
self.proxy = SurveyProxy(self)
self.proxy.setSourceModel(self.model)
self.table = QTableView()
self.table.setModel(self.proxy)
self.table.setAlternatingRowColors(True)
self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.table.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.table.setShowGrid(False)
self.table.verticalHeader().setVisible(False)
self.table.verticalHeader().setDefaultSectionSize(36)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Interactive)
self.table.horizontalHeader().setSectionsClickable(True)
self.table.horizontalHeader().setSortIndicatorShown(True)
self.table.horizontalHeader().setSortIndicator(self.sort_column, self.sort_order)
self.table.horizontalHeader().sectionClicked.connect(self.sort_results)
for index, column in enumerate(COLUMNS):
self.table.setColumnWidth(index, column.width)
self.table.selectionModel().selectionChanged.connect(self.update_detail)
self.table.selectionModel().currentChanged.connect(self.update_detail)
self.table.doubleClicked.connect(lambda: self.reveal_source())
self.detail_scroll = QScrollArea()
self.detail_scroll.setWidgetResizable(True)
self.detail_scroll.setHorizontalScrollBarPolicy(
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
)
self.detail_scroll.setMinimumWidth(330)
self.detail_scroll.setMaximumWidth(470)
self.detail_content = QWidget()
self.detail_content.setObjectName("detailContent")
self.detail_layout = QVBoxLayout(self.detail_content)
self.detail_layout.setContentsMargins(4, 0, 4, 0)
self.detail_layout.setSpacing(10)
self.detail_scroll.setWidget(self.detail_content)
self._show_no_selection()
splitter = QSplitter()
splitter.addWidget(self.table)
splitter.addWidget(self.detail_scroll)
splitter.setStretchFactor(0, 4)
splitter.setStretchFactor(1, 1)
splitter.setSizes([1050, 380])
layout.addWidget(splitter, 1)
return page
def _clear_detail(self) -> None:
while self.detail_layout.count():
item = self.detail_layout.takeAt(0)
widget = item.widget()
if widget:
widget.deleteLater()
def _show_no_selection(self, message: str = "Select a save to inspect its details.") -> None:
self._clear_detail()
label = QLabel(message)
label.setObjectName("pageCopy")
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
label.setWordWrap(True)
self.detail_layout.addStretch(1)
self.detail_layout.addWidget(label)
self.detail_layout.addStretch(1)
def _selected_rows(self) -> list[survey.SurveyRow]:
selected = sorted(self.table.selectionModel().selectedRows(), key=lambda index: index.row())
source_rows = [self.proxy.mapToSource(index).row() for index in selected]
return [self.model.rows[index] for index in source_rows if index >= 0]
def _current_row(self) -> survey.SurveyRow | None:
current = self.proxy.mapToSource(self.table.currentIndex())
if current.isValid():
return self.model.rows[current.row()]
return None
def _visible_rows(self) -> list[survey.SurveyRow]:
rows: list[survey.SurveyRow] = []
for proxy_row in range(self.proxy.rowCount()):
source = self.proxy.mapToSource(self.proxy.index(proxy_row, 0))
if source.isValid():
rows.append(self.model.rows[source.row()])
return rows
@Slot()
def update_detail(self) -> None:
selected = self._selected_rows()
self.export_selected_action.setEnabled(bool(selected))
if not selected:
self._show_no_selection()
return
row = self._current_row() or selected[0]
self._clear_detail()
title = QLabel(_world(row))
title.setObjectName("detailTitle")
title.setWordWrap(True)
self.detail_layout.addWidget(title)
if len(selected) > 1:
multiple = QLabel(f"Showing 1 of {len(selected):,} selected")
multiple.setStyleSheet("color: #68758a;")
self.detail_layout.addWidget(multiple)
foreground, background = STATUS_COLORS.get(row.status, ("#172033", "#edf0f4"))
banner = QLabel(f"{STATUS_LABELS.get(row.status, row.status)} - {row.message}")
banner.setObjectName("statusBanner")
banner.setWordWrap(True)
banner.setStyleSheet(f"color: {foreground}; background: {background};")
self.detail_layout.addWidget(banner)
spawn = (
f"{row.spawn_x}, {row.spawn_y}, {row.spawn_z}"
if None not in (row.spawn_x, row.spawn_y, row.spawn_z)
else "-"
)
self.detail_layout.addWidget(
DetailSection(
"World",
[
("World name", row.world_name or "-"),
("Seed", str(row.seed) if row.seed is not None else "-"),
("Game mode", str(row.game_mode) if row.game_mode is not None else "-"),
("World time", str(row.world_time) if row.world_time is not None else "-"),
("Spawn", spawn),
],
)
)
self.detail_layout.addWidget(
DetailSection(
"Player",
[
("Players", str(row.player_count) if row.player_count is not None else "-"),
("Position", _position(row)),
("Dimension", str(row.player_dimension) if row.player_dimension is not None else "-"),
("Health", str(row.player_health) if row.player_health is not None else "-"),
("XP level", str(row.player_xp_level) if row.player_xp_level is not None else "-"),
("Inventory", str(row.inventory_count) if row.inventory_count is not None else "-"),
],
)
)
self.detail_layout.addWidget(
DetailSection(
"Files",
[
("Save size", _human_size(row.save_size)),
("Decompressed", _human_size(row.decompressed_size)),
("Inner files", str(row.inner_file_count) if row.inner_file_count is not None else "-"),
("Regions", str(row.region_count) if row.region_count is not None else "-"),
("Maps", str(row.map_count) if row.map_count is not None else "-"),
("Duplicate group", row.duplicate_group or "-"),
],
)
)
self.detail_layout.addWidget(
DetailSection(
"Container",
[
("Display name", row.display_name or "-"),
("Source", row.source_path),
("Updated", _short_time(row.updated)),
("Profile ID", row.profile_id or "-"),
("Title ID", row.title_id or "-"),
("Content", row.content_type or "-"),
("STFS table", row.file_table_source or "-"),
],
)
)
self.detail_layout.addWidget(
DetailSection(
"Hashes and warnings",
[
("savegame.dat SHA-1", row.save_sha1 or "-"),
("Decompressed SHA-1", row.decompressed_sha1 or "-"),
("Warnings", "\n".join(row.warnings) if row.warnings else "-"),
],
)
)
buttons = QHBoxLayout()
reveal = QPushButton("Open folder")
reveal.clicked.connect(self.reveal_source)
copy = QPushButton("Copy summary")
copy.clicked.connect(self.copy_summary)
buttons.addWidget(reveal)
buttons.addWidget(copy)
container = QWidget()
container.setLayout(buttons)
self.detail_layout.addWidget(container)
self.detail_layout.addStretch(1)
@Slot(int)
def sort_results(self, column: int) -> None:
if column == self.sort_column:
self.sort_order = (
Qt.SortOrder.AscendingOrder
if self.sort_order == Qt.SortOrder.DescendingOrder
else Qt.SortOrder.DescendingOrder
)
else:
self.sort_column = column
self.sort_order = Qt.SortOrder.AscendingOrder
self.table.horizontalHeader().setSortIndicator(self.sort_column, self.sort_order)
self.model.set_rows(_sorted_rows(self.model.rows, self.sort_column, self.sort_order))
self.proxy.invalidateFilter()
if self.proxy.rowCount():
self.table.selectRow(0)
def choose_source_folder(self) -> None:
initial = self.current_survey.source_path if self.current_survey else str(Path.home())
selected = QFileDialog.getExistingDirectory(self, "Select saves folder", initial)
if selected:
self.start_survey(Path(selected))
def show_about(self) -> None:
QMessageBox.about(
self,
f"About {APP_NAME}",
f"<h2>{APP_NAME} {VERSION}</h2>"
"<p>Minecraft Xbox 360 save inspector.</p>"
"<p>Copyright 2026 Vistex</p>"
"<p>Licensed under <b>GPL-3.0-only</b>, without warranty. See LICENSE and "
"THIRD_PARTY_NOTICES.md in the application folder.</p>"
"<p>The bundled deterministic decoder is built from modified je2be-core.</p>",
)
def start_survey(self, source: Path) -> None:
if self.worker_thread is not None:
return
self.progress_panel.show()
self.progress_title.setText("Finding STFS containers...")
self.progress_detail.setText(str(source))
self.progress_bar.setRange(0, 0)
self.cancel_button.setEnabled(True)
self.scan_button.setEnabled(False)
self.open_button.setEnabled(False)
self.export_button.setEnabled(False)
self.worker_thread = QThread(self)
self.worker = SurveyWorker(source)
self.worker.moveToThread(self.worker_thread)
self.worker_thread.started.connect(self.worker.run)
self.worker.progress.connect(self.on_progress)
self.worker.completed.connect(self.on_survey_completed)
self.worker.failed.connect(self.on_survey_failed)
self.worker.completed.connect(self.worker_thread.quit)
self.worker.failed.connect(self.worker_thread.quit)
self.worker_thread.finished.connect(self.worker.deleteLater)
self.worker_thread.finished.connect(self.on_worker_finished)
self.worker_thread.start()
self.statusBar().showMessage(f"Surveying {source}")
@Slot(str, int, int, str)
def on_progress(self, phase: str, current: int, total: int, name: str) -> None:
if phase == "discovering":
self.progress_title.setText("Finding STFS containers...")
self.progress_detail.setText(f"Checked {current:,} files - {name}")
self.progress_bar.setRange(0, 0)
elif phase == "analyzing":
self.progress_title.setText("Reading saves...")
self.progress_detail.setText(f"{current:,} of {total:,} - {name}")
self.progress_bar.setRange(0, max(total, 1))
self.progress_bar.setValue(current)
def cancel_survey(self) -> None:
if self.worker:
self.worker.cancel()
self.cancel_button.setEnabled(False)
self.progress_title.setText("Stopping after the current save...")
@Slot(object)
def on_survey_completed(self, result: survey.Survey) -> None:
self.set_survey(result)
if result.cancelled:
self.statusBar().showMessage(f"Survey canceled - {len(result.rows):,} results available", 6000)
else:
self.statusBar().showMessage(f"Survey complete - {len(result.rows):,} results", 6000)
@Slot(str)
def on_survey_failed(self, message: str) -> None:
QMessageBox.critical(self, "Survey failed", message)
self.statusBar().showMessage("Survey failed", 5000)
@Slot()
def on_worker_finished(self) -> None:
thread = self.worker_thread
self.worker = None
self.worker_thread = None
if thread:
thread.deleteLater()
self.progress_panel.hide()
self.scan_button.setEnabled(True)
self.open_button.setEnabled(True)
self.export_button.setEnabled(self.current_survey is not None)
if self.close_when_finished:
QTimer.singleShot(0, self.close)
def set_survey(self, result: survey.Survey) -> None:
self.current_survey = result
self.model.set_rows(_sorted_rows(result.rows, self.sort_column, self.sort_order))
self.pages.setCurrentIndex(1)
self.export_button.setEnabled(True)
self.setWindowTitle(f"{APP_NAME} - {Path(result.source_path).name or result.source_path}")
summary = result.summary()
for key, card in self.metric_cards.items():
card.value.setText(f"{summary.get(key, 0):,}")
health: list[str] = []
if result.cancelled or len(result.rows) < result.container_count:
health.append(
f"Partial survey - {len(result.rows):,} of "
f"{result.container_count:,} containers processed."
)
if result.scan_errors:
health.append(f"{len(result.scan_errors):,} files could not be checked.")
self.health_banner.setText(" ".join(health))
self.health_banner.setVisible(bool(health))
self.apply_filters()
if self.proxy.rowCount():
self.table.selectRow(0)
else: