mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Notes to kneeboard (#1375)
Adds global-level kneeboard notes. Explicit save compatability with 4.0.0
This commit is contained in:
parent
2a5c523afd
commit
e94d48c265
@ -12,6 +12,7 @@ Saves from 4.0.0 are compatible with 4.0.1.
|
||||
|
||||
## Features/Improvements
|
||||
|
||||
* **[UI]** Added ability to take notes and have those notes appear as a kneeboard page.
|
||||
* **[UI]** Hovering over the weather information now dispalys the cloud base (meters and feet).
|
||||
* **[UI]** Google search link added to unit information when there is no information provided.
|
||||
|
||||
|
||||
@ -110,6 +110,7 @@ class Game:
|
||||
self.date = date(start_date.year, start_date.month, start_date.day)
|
||||
self.game_stats = GameStats()
|
||||
self.game_stats.update(self)
|
||||
self.notes = ""
|
||||
self.ground_planners: dict[int, GroundPlanner] = {}
|
||||
self.informations = []
|
||||
self.informations.append(Information("Game Start", "-" * 40, 0))
|
||||
|
||||
@ -554,6 +554,28 @@ class StrikeTaskPage(KneeboardPage):
|
||||
]
|
||||
|
||||
|
||||
class NotesPage(KneeboardPage):
|
||||
"""A kneeboard page containing the campaign owner's notes."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
game: "Game",
|
||||
dark_kneeboard: bool,
|
||||
) -> None:
|
||||
self.game = game
|
||||
self.dark_kneeboard = dark_kneeboard
|
||||
|
||||
def write(self, path: Path) -> None:
|
||||
writer = KneeboardPageWriter(dark_theme=self.dark_kneeboard)
|
||||
writer.title(f"Notes")
|
||||
|
||||
try:
|
||||
writer.text(self.game.notes)
|
||||
except AttributeError: # old saves may not have .notes ;)
|
||||
writer.text("")
|
||||
writer.write(path)
|
||||
|
||||
|
||||
class KneeboardGenerator(MissionInfoGenerator):
|
||||
"""Creates kneeboard pages for each client flight in the mission."""
|
||||
|
||||
@ -621,6 +643,10 @@ class KneeboardGenerator(MissionInfoGenerator):
|
||||
self.mission.start_time,
|
||||
self.dark_kneeboard,
|
||||
),
|
||||
NotesPage(
|
||||
self.game,
|
||||
self.dark_kneeboard,
|
||||
),
|
||||
]
|
||||
|
||||
if (target_page := self.generate_task_page(flight)) is not None:
|
||||
|
||||
@ -106,6 +106,7 @@ def load_icons():
|
||||
ICONS["PluginsOptions"] = QPixmap(
|
||||
"./resources/ui/misc/" + get_theme_icons() + "/pluginsoptions.png"
|
||||
)
|
||||
ICONS["Notes"] = QPixmap("./resources/ui/misc/" + get_theme_icons() + "/notes.png")
|
||||
|
||||
ICONS["TaskCAS"] = QPixmap("./resources/ui/tasks/cas.png")
|
||||
ICONS["TaskCAP"] = QPixmap("./resources/ui/tasks/cap.png")
|
||||
|
||||
@ -36,6 +36,7 @@ from qt_ui.windows.preferences.QLiberationPreferencesWindow import (
|
||||
)
|
||||
from qt_ui.windows.settings.QSettingsWindow import QSettingsWindow
|
||||
from qt_ui.windows.stats.QStatsWindow import QStatsWindow
|
||||
from qt_ui.windows.notes.QNotesWindow import QNotesWindow
|
||||
|
||||
|
||||
class QLiberationWindow(QMainWindow):
|
||||
@ -158,6 +159,10 @@ class QLiberationWindow(QMainWindow):
|
||||
self.openStatsAction.setIcon(CONST.ICONS["Statistics"])
|
||||
self.openStatsAction.triggered.connect(self.showStatsDialog)
|
||||
|
||||
self.openNotesAction = QAction("Notes", self)
|
||||
self.openNotesAction.setIcon(CONST.ICONS["Notes"])
|
||||
self.openNotesAction.triggered.connect(self.showNotesDialog)
|
||||
|
||||
def initToolbar(self):
|
||||
self.tool_bar = self.addToolBar("File")
|
||||
self.tool_bar.addAction(self.newGameAction)
|
||||
@ -171,6 +176,7 @@ class QLiberationWindow(QMainWindow):
|
||||
self.actions_bar = self.addToolBar("Actions")
|
||||
self.actions_bar.addAction(self.openSettingsAction)
|
||||
self.actions_bar.addAction(self.openStatsAction)
|
||||
self.actions_bar.addAction(self.openNotesAction)
|
||||
|
||||
def initMenuBar(self):
|
||||
self.menu = self.menuBar()
|
||||
@ -351,6 +357,10 @@ class QLiberationWindow(QMainWindow):
|
||||
self.dialog = QStatsWindow(self.game)
|
||||
self.dialog.show()
|
||||
|
||||
def showNotesDialog(self):
|
||||
self.dialog = QNotesWindow(self.game)
|
||||
self.dialog.show()
|
||||
|
||||
def onDebriefing(self, debrief: Debriefing):
|
||||
logging.info("On Debriefing")
|
||||
self.debriefing = QDebriefingWindow(debrief)
|
||||
|
||||
67
qt_ui/windows/notes/QNotesWindow.py
Normal file
67
qt_ui/windows/notes/QNotesWindow.py
Normal file
@ -0,0 +1,67 @@
|
||||
from PySide2.QtWidgets import (
|
||||
QDialog,
|
||||
QPlainTextEdit,
|
||||
QVBoxLayout,
|
||||
QHBoxLayout,
|
||||
QPushButton,
|
||||
QLabel,
|
||||
)
|
||||
from PySide2.QtGui import QTextCursor
|
||||
from PySide2.QtCore import QTimer
|
||||
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game.game import Game
|
||||
|
||||
from time import sleep
|
||||
|
||||
|
||||
class QNotesWindow(QDialog):
|
||||
def __init__(self, game: Game):
|
||||
super(QNotesWindow, self).__init__()
|
||||
|
||||
self.game = game
|
||||
self.setWindowTitle("Notes")
|
||||
self.setWindowIcon(CONST.ICONS["Notes"])
|
||||
self.setMinimumSize(400, 100)
|
||||
self.resize(600, 450)
|
||||
|
||||
self.vbox = QVBoxLayout()
|
||||
self.setLayout(self.vbox)
|
||||
|
||||
self.vbox.addWidget(
|
||||
QLabel("Saved notes are available as a page in your kneeboard.")
|
||||
)
|
||||
|
||||
self.textbox = QPlainTextEdit(self)
|
||||
try:
|
||||
self.textbox.setPlainText(self.game.notes)
|
||||
self.textbox.moveCursor(QTextCursor.End)
|
||||
except AttributeError: # old save may not have game.notes
|
||||
pass
|
||||
self.textbox.move(10, 10)
|
||||
self.textbox.resize(600, 450)
|
||||
self.textbox.setStyleSheet("background: #1D2731;")
|
||||
self.vbox.addWidget(self.textbox)
|
||||
|
||||
self.button_row = QHBoxLayout()
|
||||
self.vbox.addLayout(self.button_row)
|
||||
|
||||
self.clear_button = QPushButton(self)
|
||||
self.clear_button.setText("CLEAR")
|
||||
self.clear_button.setProperty("style", "btn-primary")
|
||||
self.clear_button.clicked.connect(self.clearNotes)
|
||||
self.button_row.addWidget(self.clear_button)
|
||||
|
||||
self.save_button = QPushButton(self)
|
||||
self.save_button.setText("SAVE")
|
||||
self.save_button.setProperty("style", "btn-success")
|
||||
self.save_button.clicked.connect(self.saveNotes)
|
||||
self.button_row.addWidget(self.save_button)
|
||||
|
||||
def clearNotes(self) -> None:
|
||||
self.textbox.setPlainText("")
|
||||
|
||||
def saveNotes(self) -> None:
|
||||
self.game.notes = self.textbox.toPlainText()
|
||||
self.save_button.setText("SAVED")
|
||||
QTimer.singleShot(5000, lambda: self.save_button.setText("SAVE"))
|
||||
BIN
resources/ui/misc/dark/notes.png
Normal file
BIN
resources/ui/misc/dark/notes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
BIN
resources/ui/misc/light/notes.png
Normal file
BIN
resources/ui/misc/light/notes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/ui/misc/notes.png
Normal file
BIN
resources/ui/misc/notes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resources/ui/misc/original/notes.png
Normal file
BIN
resources/ui/misc/original/notes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Loading…
x
Reference in New Issue
Block a user