From 89e8ef65ea5fc9ff14dfeb5b20eb242e03ffd9bf Mon Sep 17 00:00:00 2001 From: Khopa Date: Fri, 5 Jul 2019 20:44:01 +0200 Subject: [PATCH] Added about dialog & credits + icon in pass turn button --- qt_ui/stylesheets/style.css | 4 ++-- qt_ui/uiconstants.py | 2 ++ qt_ui/widgets/QTopPanel.py | 2 ++ qt_ui/windows/QGameSettings.py | 0 qt_ui/windows/QLiberationWindow.py | 37 ++++++++++++++++++++++++------ 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 qt_ui/windows/QGameSettings.py diff --git a/qt_ui/stylesheets/style.css b/qt_ui/stylesheets/style.css index 002c616e..825a3853 100644 --- a/qt_ui/stylesheets/style.css +++ b/qt_ui/stylesheets/style.css @@ -3,7 +3,7 @@ QLiberationWindow{ } -QTopPanel, +/*QTopPanel, QTopPanel *{ background-color: #4E5760; color: white; @@ -16,4 +16,4 @@ QPushButton[style="btn-primary"]{ color:white; padding: 21px 5px 21px 5px; margin-top: 6px; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/qt_ui/uiconstants.py b/qt_ui/uiconstants.py index 97904b3a..15d2653a 100644 --- a/qt_ui/uiconstants.py +++ b/qt_ui/uiconstants.py @@ -48,7 +48,9 @@ def load_icons(): ICONS["Day"] = QPixmap("./resources/ui/daytime/day.png") ICONS["Dusk"] = QPixmap("./resources/ui/daytime/dusk.png") ICONS["Night"] = QPixmap("./resources/ui/daytime/night.png") + ICONS["Money"] = QPixmap("./resources/ui/misc/money_icon.png") + ICONS["PassTurn"] = QPixmap("./resources/ui/misc/pass_turn.png") ICONS["Ordnance"] = QPixmap("./resources/ui/misc/ordnance_icon.png") ICONS["target"] = QPixmap("./resources/ui/ground_assets/target.png") diff --git a/qt_ui/widgets/QTopPanel.py b/qt_ui/widgets/QTopPanel.py index d19446aa..366e47a1 100644 --- a/qt_ui/widgets/QTopPanel.py +++ b/qt_ui/widgets/QTopPanel.py @@ -4,6 +4,7 @@ from game import Game from qt_ui.widgets.QBudgetBox import QBudgetBox from qt_ui.widgets.QTurnCounter import QTurnCounter +import qt_ui.uiconstants as CONST class QTopPanel(QFrame): @@ -21,6 +22,7 @@ class QTopPanel(QFrame): self.budgetBox.setBudget(self.game.budget, self.game.budget_reward_amount) self.passTurn = QPushButton("Pass Turn") + self.passTurn.setIcon(CONST.ICONS["PassTurn"]) self.passTurn.setProperty("style", "btn-primary") self.layout = QHBoxLayout() diff --git a/qt_ui/windows/QGameSettings.py b/qt_ui/windows/QGameSettings.py new file mode 100644 index 00000000..e69de29b diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index 72dbe83b..89759a66 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -1,14 +1,16 @@ -from PySide2.QtGui import QIcon -from PySide2.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QMainWindow, QAction, QFrame import webbrowser +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QMainWindow, QAction, QMessageBox + +import qt_ui.uiconstants as CONST +from game import Game from qt_ui.uiconstants import URLS from qt_ui.widgets.QTopPanel import QTopPanel from qt_ui.widgets.map.QLiberationMap import QLiberationMap -import qt_ui.uiconstants as CONST from qt_ui.windows.QNewGameWizard import NewGameWizard from userdata import persistency -from game import Game + class QLiberationWindow(QMainWindow): @@ -18,7 +20,6 @@ class QLiberationWindow(QMainWindow): self.init_ui() def init_ui(self): - self.setGeometry(300, 100, 270, 100) self.setWindowTitle("DCS Liberation") self.setWindowIcon(QIcon("../resources/icon.png")) @@ -51,6 +52,10 @@ class QLiberationWindow(QMainWindow): self.saveGameAction.setIcon(QIcon(CONST.ICONS["Save"])) self.saveGameAction.triggered.connect(self.saveGame) + self.showAboutDialogAction = QAction("About DCS Liberation", self) + self.showAboutDialogAction.setIcon(QIcon.fromTheme("help-about")) + self.showAboutDialogAction.triggered.connect(self.showAboutDialog) + def init_toolbar(self): self.tool_bar = self.addToolBar("File") self.tool_bar.addAction(self.newGameAction) @@ -74,6 +79,8 @@ class QLiberationWindow(QMainWindow): help_menu.addAction("Contribute", lambda: webbrowser.open_new_tab(URLS["Repository"])) help_menu.addAction("Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"])) help_menu.addAction("Report an issue", lambda: webbrowser.open_new_tab(URLS["Issues"])) + help_menu.addSeparator() + help_menu.addAction(self.showAboutDialogAction) displayMenu = self.menu.addMenu("Display") @@ -90,7 +97,8 @@ class QLiberationWindow(QMainWindow): tg_line_visibility = QAction('Lines', displayMenu) tg_line_visibility.setCheckable(True) tg_line_visibility.setChecked(True) - tg_line_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("lines", tg_line_visibility.isChecked())) + tg_line_visibility.toggled.connect( + lambda: QLiberationMap.set_display_rule("lines", tg_line_visibility.isChecked())) displayMenu.addAction(tg_go_visibility) displayMenu.addAction(tg_cp_visibility) @@ -99,7 +107,7 @@ class QLiberationWindow(QMainWindow): def newGame(self): wizard = NewGameWizard(self) wizard.show() - wizard.accepted.connect(lambda : self.setGame(wizard.generatedGame)) + wizard.accepted.connect(lambda: self.setGame(wizard.generatedGame)) def saveGame(self): print("Saving game") @@ -108,3 +116,18 @@ class QLiberationWindow(QMainWindow): def setGame(self, game: Game): self.game = game self.liberation_map.setGame(game) + + def showAboutDialog(self): + text = "

DCS Liberation

" + \ + "

Repository

" + \ + "Source code : https://github.com/shdwp/dcs_liberation
" + \ + "

Contributors

" + \ + "Author : sdwp
" + \ + "Contributors :" + " Khopa, Wrycu, calvinmorrow, JohanAberg
" + + about = QMessageBox() + about.setWindowTitle("About DCS Liberation") + about.setIcon(QMessageBox.Icon.Information) + about.setText(text) + print(about.textFormat()) + about.exec_()