-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<feature> support error repair by renpy lint
update version to v2.5.7
- Loading branch information
1 parent
a706bcc
commit 46874ef
Showing
41 changed files
with
2,643 additions
and
1,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
################################################################################ | ||
## Form generated from reading UI file 'error_repair.ui' | ||
## | ||
## Created by: Qt User Interface Compiler version 6.6.1 | ||
## | ||
## WARNING! All changes made in this file will be lost when recompiling UI file! | ||
################################################################################ | ||
|
||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, | ||
QMetaObject, QObject, QPoint, QRect, | ||
QSize, QTime, QUrl, Qt) | ||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, | ||
QFont, QFontDatabase, QGradient, QIcon, | ||
QImage, QKeySequence, QLinearGradient, QPainter, | ||
QPalette, QPixmap, QRadialGradient, QTransform) | ||
from PySide6.QtWidgets import (QApplication, QDialog, QLabel, QLineEdit, | ||
QPushButton, QSizePolicy, QTextEdit, QWidget) | ||
|
||
class Ui_ErrorRepairDialog(object): | ||
def setupUi(self, ErrorRepairDialog): | ||
if not ErrorRepairDialog.objectName(): | ||
ErrorRepairDialog.setObjectName(u"ErrorRepairDialog") | ||
ErrorRepairDialog.resize(666, 250) | ||
self.selectFileBtn = QPushButton(ErrorRepairDialog) | ||
self.selectFileBtn.setObjectName(u"selectFileBtn") | ||
self.selectFileBtn.setGeometry(QRect(530, 30, 81, 91)) | ||
self.selectFileBtn.setText(u"...") | ||
self.label = QLabel(ErrorRepairDialog) | ||
self.label.setObjectName(u"label") | ||
self.label.setGeometry(QRect(40, 45, 71, 61)) | ||
self.label.setWordWrap(True) | ||
self.selectFileText = QTextEdit(ErrorRepairDialog) | ||
self.selectFileText.setObjectName(u"selectFileText") | ||
self.selectFileText.setGeometry(QRect(120, 30, 411, 91)) | ||
self.selectFileText.setPlaceholderText(u"Example:F:/DemoGame.exe") | ||
self.label_2 = QLabel(ErrorRepairDialog) | ||
self.label_2.setObjectName(u"label_2") | ||
self.label_2.setGeometry(QRect(40, 150, 211, 61)) | ||
self.label_2.setWordWrap(True) | ||
self.maxRecursionLineEdit = QLineEdit(ErrorRepairDialog) | ||
self.maxRecursionLineEdit.setObjectName(u"maxRecursionLineEdit") | ||
self.maxRecursionLineEdit.setGeometry(QRect(260, 170, 351, 20)) | ||
self.maxRecursionLineEdit.setAlignment(Qt.AlignCenter) | ||
self.repairBtn = QPushButton(ErrorRepairDialog) | ||
self.repairBtn.setObjectName(u"repairBtn") | ||
self.repairBtn.setGeometry(QRect(120, 220, 491, 24)) | ||
|
||
self.retranslateUi(ErrorRepairDialog) | ||
|
||
QMetaObject.connectSlotsByName(ErrorRepairDialog) | ||
# setupUi | ||
|
||
def retranslateUi(self, ErrorRepairDialog): | ||
ErrorRepairDialog.setWindowTitle(QCoreApplication.translate("ErrorRepairDialog", u"Error Repair", None)) | ||
self.label.setText(QCoreApplication.translate("ErrorRepairDialog", u"file", None)) | ||
#if QT_CONFIG(tooltip) | ||
self.selectFileText.setToolTip("") | ||
#endif // QT_CONFIG(tooltip) | ||
self.label_2.setText(QCoreApplication.translate("ErrorRepairDialog", u"max repair count", None)) | ||
self.maxRecursionLineEdit.setText(QCoreApplication.translate("ErrorRepairDialog", u"4", None)) | ||
self.repairBtn.setText(QCoreApplication.translate("ErrorRepairDialog", u"repair errors", None)) | ||
# retranslateUi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>ErrorRepairDialog</class> | ||
<widget class="QDialog" name="ErrorRepairDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>666</width> | ||
<height>250</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Error Repair</string> | ||
</property> | ||
<widget class="QPushButton" name="selectFileBtn"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>530</x> | ||
<y>30</y> | ||
<width>81</width> | ||
<height>91</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string notr="true">...</string> | ||
</property> | ||
</widget> | ||
<widget class="QLabel" name="label"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>40</x> | ||
<y>45</y> | ||
<width>71</width> | ||
<height>61</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>file</string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
<widget class="QTextEdit" name="selectFileText"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>120</x> | ||
<y>30</y> | ||
<width>411</width> | ||
<height>91</height> | ||
</rect> | ||
</property> | ||
<property name="toolTip"> | ||
<string/> | ||
</property> | ||
<property name="placeholderText"> | ||
<string notr="true">Example:F:/DemoGame.exe</string> | ||
</property> | ||
</widget> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>40</x> | ||
<y>150</y> | ||
<width>211</width> | ||
<height>61</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>max repair count</string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
<widget class="QLineEdit" name="maxRecursionLineEdit"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>260</x> | ||
<y>170</y> | ||
<width>351</width> | ||
<height>20</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string notr="true">4</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
<widget class="QPushButton" name="repairBtn"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>120</x> | ||
<y>220</y> | ||
<width>491</width> | ||
<height>24</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>repair errors</string> | ||
</property> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import _thread | ||
import os | ||
import threading | ||
import time | ||
import traceback | ||
|
||
from PySide6.QtCore import QCoreApplication, QThread, Signal | ||
from PySide6.QtGui import QIntValidator | ||
from PySide6.QtWidgets import QDialog, QFileDialog | ||
|
||
from error_repair import Ui_ErrorRepairDialog | ||
from my_log import log_print | ||
from renpy_lint import fix_translation_by_lint_recursion | ||
|
||
|
||
class repairThread(threading.Thread): | ||
def __init__(self, path, max_recursion_depth): | ||
threading.Thread.__init__(self) | ||
self.path = path | ||
self.max_recursion_depth = max_recursion_depth | ||
|
||
def run(self): | ||
try: | ||
log_print('start repairing ...') | ||
fix_translation_by_lint_recursion(self.path, self.max_recursion_depth) | ||
except Exception as e: | ||
msg = traceback.format_exc() | ||
log_print(msg) | ||
|
||
|
||
class MyErrorRepairForm(QDialog, Ui_ErrorRepairDialog): | ||
def __init__(self, parent=None): | ||
super(MyErrorRepairForm, self).__init__(parent) | ||
self.setupUi(self) | ||
self.setFixedHeight(self.height()) | ||
self.setFixedWidth(self.width()) | ||
self.selectFileBtn.clicked.connect(self.select_file) | ||
self.repairBtn.clicked.connect(self.repair) | ||
self.maxRecursionLineEdit.setValidator(QIntValidator(1, 65535, self)) | ||
self.repair_thread = None | ||
_thread.start_new_thread(self.update, ()) | ||
|
||
def repair(self): | ||
path = self.selectFileText.toPlainText() | ||
path = path.replace('file:///', '') | ||
if os.path.isfile(path): | ||
if path.endswith('.exe'): | ||
t = repairThread(path, int(self.maxRecursionLineEdit.text())) | ||
self.repair_thread = t | ||
t.start() | ||
self.setDisabled(True) | ||
self.repairBtn.setText(QCoreApplication.translate('ErrorRepairDialog', 'is repairing...', None)) | ||
|
||
def select_file(self): | ||
file, filetype = QFileDialog.getOpenFileName(self, 'select the game file', '', "Game Files (*.exe)") | ||
self.selectFileText.setText(file) | ||
|
||
def update(self): | ||
thread = self.UpdateThread() | ||
thread.update_date.connect(self.update_progress) | ||
while True: | ||
thread.start() | ||
time.sleep(0.5) | ||
|
||
def update_progress(self): | ||
try: | ||
if self.repair_thread is not None: | ||
if not self.repair_thread.is_alive(): | ||
self.repairBtn.setText(QCoreApplication.translate('ErrorRepairDialog', 'repair errors', None)) | ||
self.setEnabled(True) | ||
self.repair_thread = None | ||
log_print('error repair complete!') | ||
except Exception: | ||
msg = traceback.format_exc() | ||
log_print(msg) | ||
|
||
class UpdateThread(QThread): | ||
update_date = Signal() | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
def __del__(self): | ||
self.wait() | ||
|
||
def run(self): | ||
self.update_date.emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.