Skip to content

Commit

Permalink
feat: Remove "Save Log" buttons from patch and game windows
Browse files Browse the repository at this point in the history
The ouput in those windows is meant for the user. For bug reporting, the
actual log file is more helpful.
  • Loading branch information
JuneStepp committed Aug 22, 2024
1 parent 8e2bd46 commit f4e58d0
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 92 deletions.
15 changes: 0 additions & 15 deletions src/onelauncher/patch_game_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from onelauncher.qtapp import get_qapp
from onelauncher.ui_utilities import log_record_to_rich_text

from .config import platform_dirs
from .config_manager import ConfigManager
from .game_launcher_local_config import GameLauncherLocalConfig
from .game_utilities import get_default_game_settings_dir
Expand Down Expand Up @@ -83,12 +82,9 @@ def __init__(
)
logger.addHandler(ui_logging_handler)

self.ui.btnSave.setText("Save Log")
self.ui.btnSave.setEnabled(False)
self.ui.progressBar.reset()
self.ui.btnStop.setText("Close")
self.ui.btnStart.setText("Patch")
self.ui.btnSave.clicked.connect(self.btnSaveClicked)
self.ui.btnStop.clicked.connect(self.btnStopClicked)
self.ui.btnStart.clicked.connect(self.btnStartClicked)

Expand Down Expand Up @@ -189,7 +185,6 @@ def readErrors(self) -> None:
def resetButtons(self) -> None:
self.patching_finished = True
self.ui.btnStop.setText("Close")
self.ui.btnSave.setEnabled(True)
self.ui.btnStart.setEnabled(True)
self.progress_monitor.reset()
# Make sure it's not showing a busy indicator
Expand All @@ -214,15 +209,6 @@ def btnStopClicked(self) -> None:
if self.process.state() != self.process.ProcessState.Running:
self.resetButtons()

def btnSaveClicked(self) -> None:
filename = QtWidgets.QFileDialog.getSaveFileName(
self, "Save log file", str(platform_dirs.user_log_path)
)[0]

if filename != "":
with open(filename, "w") as outfile:
outfile.write(self.ui.txtLog.toPlainText())

def processFinished(
self, exitCode: int, exitStatus: QtCore.QProcess.ExitStatus
) -> None:
Expand Down Expand Up @@ -270,7 +256,6 @@ def btnStartClicked(self) -> None:
self.phase_index = 0
self.ui.btnStart.setEnabled(False)
self.ui.btnStop.setText("Abort")
self.ui.btnSave.setEnabled(False)

# Get log file to read patching details from, since
# rundll32 doesn't provide output on Windows
Expand Down
20 changes: 9 additions & 11 deletions src/onelauncher/ui/patching_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,28 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStop">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSave">
<widget class="QPushButton" name="btnStart">
<property name="text">
<string>Save Log</string>
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStart">
<widget class="QPushButton" name="btnStop">
<property name="text">
<string>Start</string>
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>btnStart</tabstop>
<tabstop>btnStop</tabstop>
<tabstop>txtLog</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
20 changes: 8 additions & 12 deletions src/onelauncher/ui/patching_window_uic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,21 @@ def setupUi(self, patchingDialog: QDialog) -> None:

self.horizontalLayout.addWidget(self.progressBar)

self.btnStop = QPushButton(patchingDialog)
self.btnStop.setObjectName(u"btnStop")

self.horizontalLayout.addWidget(self.btnStop)

self.btnSave = QPushButton(patchingDialog)
self.btnSave.setObjectName(u"btnSave")

self.horizontalLayout.addWidget(self.btnSave)

self.btnStart = QPushButton(patchingDialog)
self.btnStart.setObjectName(u"btnStart")

self.horizontalLayout.addWidget(self.btnStart)

self.btnStop = QPushButton(patchingDialog)
self.btnStop.setObjectName(u"btnStop")

self.horizontalLayout.addWidget(self.btnStop)


self.verticalLayout.addLayout(self.horizontalLayout)

QWidget.setTabOrder(self.btnStart, self.btnStop)
QWidget.setTabOrder(self.btnStop, self.txtLog)

self.retranslateUi(patchingDialog)

Expand All @@ -68,8 +65,7 @@ def setupUi(self, patchingDialog: QDialog) -> None:
def retranslateUi(self, patchingDialog: QDialog) -> None:
patchingDialog.setWindowTitle(QCoreApplication.translate("patchingDialog", u"MainWindow", None))
self.progressBar.setFormat(QCoreApplication.translate("patchingDialog", u"%p% (%v/%m)", None))
self.btnStop.setText(QCoreApplication.translate("patchingDialog", u"Stop", None))
self.btnSave.setText(QCoreApplication.translate("patchingDialog", u"Save Log", None))
self.btnStart.setText(QCoreApplication.translate("patchingDialog", u"Start", None))
self.btnStop.setText(QCoreApplication.translate("patchingDialog", u"Stop", None))
# retranslateUi

20 changes: 9 additions & 11 deletions src/onelauncher/ui/start_game.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,28 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnStart">
<widget class="QPushButton" name="btnAbort">
<property name="text">
<string>Start</string>
<string>Abort</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStop">
<widget class="QPushButton" name="btnQuit">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSave">
<property name="text">
<string>Save Log</string>
<string>Quit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>btnAbort</tabstop>
<tabstop>btnQuit</tabstop>
<tabstop>txtLog</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
24 changes: 10 additions & 14 deletions src/onelauncher/ui/start_game_uic.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,21 @@ def setupUi(self, startGameDialog: QDialog) -> None:

self.horizontalLayout.addItem(self.horizontalSpacer)

self.btnStart = QPushButton(startGameDialog)
self.btnStart.setObjectName(u"btnStart")
self.btnAbort = QPushButton(startGameDialog)
self.btnAbort.setObjectName(u"btnAbort")

self.horizontalLayout.addWidget(self.btnStart)
self.horizontalLayout.addWidget(self.btnAbort)

self.btnStop = QPushButton(startGameDialog)
self.btnStop.setObjectName(u"btnStop")
self.btnQuit = QPushButton(startGameDialog)
self.btnQuit.setObjectName(u"btnQuit")

self.horizontalLayout.addWidget(self.btnStop)

self.btnSave = QPushButton(startGameDialog)
self.btnSave.setObjectName(u"btnSave")

self.horizontalLayout.addWidget(self.btnSave)
self.horizontalLayout.addWidget(self.btnQuit)


self.verticalLayout.addLayout(self.horizontalLayout)

QWidget.setTabOrder(self.btnAbort, self.btnQuit)
QWidget.setTabOrder(self.btnQuit, self.txtLog)

self.retranslateUi(startGameDialog)

Expand All @@ -65,8 +62,7 @@ def setupUi(self, startGameDialog: QDialog) -> None:

def retranslateUi(self, startGameDialog: QDialog) -> None:
startGameDialog.setWindowTitle(QCoreApplication.translate("startGameDialog", u"MainWindow", None))
self.btnStart.setText(QCoreApplication.translate("startGameDialog", u"Start", None))
self.btnStop.setText(QCoreApplication.translate("startGameDialog", u"Stop", None))
self.btnSave.setText(QCoreApplication.translate("startGameDialog", u"Save Log", None))
self.btnAbort.setText(QCoreApplication.translate("startGameDialog", u"Abort", None))
self.btnQuit.setText(QCoreApplication.translate("startGameDialog", u"Quit", None))
# retranslateUi

43 changes: 14 additions & 29 deletions src/onelauncher/ui/start_game_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

from ..addons.startup_script import run_startup_script
from ..async_utils import app_cancel_scope
from ..config import platform_dirs
from ..config_manager import ConfigManager
from ..game_launcher_local_config import GameLauncherLocalConfig
from ..game_utilities import get_game_settings_dir
Expand Down Expand Up @@ -89,14 +88,11 @@ def __init__(
)
)

self.ui.btnStart.setText("Close")
self.ui.btnStart.setEnabled(False)
self.ui.btnSave.setText("Save Log")
self.ui.btnSave.setEnabled(False)
self.ui.btnStop.setText("Exit")
self.ui.btnStart.clicked.connect(self.btnStartClicked)
self.ui.btnSave.clicked.connect(self.btnSaveClicked)
self.ui.btnStop.clicked.connect(self.btnStopClicked)
# Can't quit until program finishes or is aborted
self.ui.btnQuit.setEnabled(False)

self.ui.btnAbort.clicked.connect(self.btnAbortClicked)
self.ui.btnQuit.clicked.connect(self.btnQuitClicked)

self.aborted = False
self.game_finished = False
Expand Down Expand Up @@ -149,33 +145,22 @@ def process_finished(

def reset_buttons(self) -> None:
self.game_finished = True
self.ui.btnStop.setText("Exit")
self.ui.btnSave.setEnabled(True)
self.ui.btnStart.setEnabled(True)

def btnStartClicked(self) -> None:
if self.game_finished:
self.close()
self.ui.btnAbort.setText("Close")
self.ui.btnQuit.setEnabled(True)

def btnStopClicked(self) -> None:
def btnAbortClicked(self) -> None:
if self.game_finished:
self.close()
# Close entire application
app_cancel_scope.cancel()
else:
self.aborted = True
if self.process:
self.process.kill()

# Saves a file with the debug log generated by running the game
def btnSaveClicked(self) -> None:
filename = QtWidgets.QFileDialog.getSaveFileName(
self, "Save log file", str(platform_dirs.user_log_path)
)[0]

if filename != "":
with open(filename, "w") as outfile:
outfile.write(self.ui.txtLog.toPlainText())
def btnQuitClicked(self) -> None:
if self.game_finished:
self.close()
# Close entire application
app_cancel_scope.cancel()

def run_startup_scripts(self) -> None:
"""Runs Python scripts from addons with one that is approved by user"""
Expand Down Expand Up @@ -212,7 +197,7 @@ async def start_game(self) -> None:
return

self.game_finished = False
self.ui.btnStop.setText("Abort")
self.ui.btnAbort.setText("Abort")
self.run_startup_scripts()
self.process.start()
self.process_logging_adapter.extra = {
Expand Down

0 comments on commit f4e58d0

Please sign in to comment.