From 97e5f4ac0619f4480d1ed77398eeeec4be03433d Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 20 Oct 2026 17:22:55 -0700 Subject: [PATCH] GDLVL/GMD conversion support --- app.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/app.py b/app.py index 1615086..2df8b34 100644 --- a/app.py +++ b/app.py @@ -136,6 +136,19 @@ class MainWindow(QMainWindow): levelDataButtons.addWidget(self.levelDataIsOfficial, alignment=Qt.AlignmentFlag.AlignHCenter) levelDataButtons.addStretch() + gdLvlGDShareLabel = QLabel("GDLVL/GDShare") + + self.convertToGdLvl = QPushButton("Convert to GDLVL") + self.convertToGdLvl.clicked.connect(self.on_convert_to_gdlvl_click) + self.convertToGmd = QPushButton("Convert to GMD") + self.convertToGmd.clicked.connect(self.on_convert_to_gmd_click) + + gdLvlGDShareButtons = QHBoxLayout() + gdLvlGDShareButtons.addStretch() + gdLvlGDShareButtons.addWidget(self.convertToGdLvl, alignment=Qt.AlignmentFlag.AlignHCenter) + gdLvlGDShareButtons.addWidget(self.convertToGmd, alignment=Qt.AlignmentFlag.AlignHCenter) + gdLvlGDShareButtons.addStretch() + gjpLabel = QLabel("GJP") self.gjpDecode = QPushButton("Decode") @@ -160,6 +173,8 @@ class MainWindow(QMainWindow): layout.addLayout(saveFileButtons) layout.addWidget(levelDataLabel, alignment=Qt.AlignmentFlag.AlignHCenter) layout.addLayout(levelDataButtons) + layout.addWidget(gdLvlGDShareLabel, alignment=Qt.AlignmentFlag.AlignHCenter) + layout.addLayout(gdLvlGDShareButtons) layout.addWidget(gjpLabel, alignment=Qt.AlignmentFlag.AlignHCenter) layout.addLayout(gjpButtons) layout.addWidget(gjp2Label, alignment=Qt.AlignmentFlag.AlignHCenter) @@ -263,6 +278,56 @@ class MainWindow(QMainWindow): self.apply_mica(msg) msg.exec() + def on_convert_to_gdlvl_click(self): + file_path, _ = QFileDialog.getOpenFileName( + self, + "Select a GDLVL file", + "", + "GDLVL Files (*.gdlvl)" + ) + if not file_path: + return + + output_file_path, _ = QFileDialog.getSaveFileName( + self, + "Select a location for the output GMD file", + file_path.removesuffix(".gdlvl") + ".gmd", + "GMD Files (*.gmd)" + ) + if not output_file_path: + return + + with open(file_path, "r") as f: + data = f.read() + + with open(output_file_path, "w") as f: + f.write(decode_level(data, is_official_level=False)) + + def on_convert_to_gmd_click(self): + file_path, _ = QFileDialog.getOpenFileName( + self, + "Select a GMD file", + "", + "GMD Files (*.gmd)" + ) + if not file_path: + return + + output_file_path, _ = QFileDialog.getSaveFileName( + self, + "Select a location for the output GDLVL file", + file_path.removesuffix(".gmd") + ".gdlvl", + "GDLVL Files (*.gdlvl)" + ) + if not output_file_path: + return + + with open(file_path, "r") as f: + data = f.read() + + with open(output_file_path, "w") as f: + f.write(encode_level(data, is_official_level=False)) + def on_gjp_decode_click(self): dialog = QInputDialog(self) dialog.setWindowTitle("GJP decoder")