mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Merge branch 'develop' of https://github.com/khopa/dcs_liberation into develop
Conflicts: qt_ui/widgets/map/QLiberationMap.py
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""A layout containing a widget with an associated label."""
|
||||
from typing import Optional
|
||||
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtWidgets import QHBoxLayout, QLabel, QWidget
|
||||
|
||||
@@ -10,8 +12,13 @@ class QLabeledWidget(QHBoxLayout):
|
||||
label is used to name the input.
|
||||
"""
|
||||
|
||||
def __init__(self, text: str, widget: QWidget) -> None:
|
||||
def __init__(self, text: str, widget: QWidget,
|
||||
tooltip: Optional[str]) -> None:
|
||||
super().__init__()
|
||||
self.addWidget(QLabel(text))
|
||||
label = QLabel(text)
|
||||
self.addWidget(label)
|
||||
self.addStretch()
|
||||
self.addWidget(widget, alignment=Qt.AlignRight)
|
||||
if tooltip is not None:
|
||||
label.setToolTip(tooltip)
|
||||
widget.setToolTip(tooltip)
|
||||
|
||||
@@ -11,9 +11,11 @@ from PySide2.QtWidgets import (
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game import Game
|
||||
from game.event import CAP, CAS, FrontlineAttackEvent
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
from qt_ui.widgets.QFactionsInfos import QFactionsInfos
|
||||
from qt_ui.widgets.QTurnCounter import QTurnCounter
|
||||
from qt_ui.widgets.clientslots import MaxPlayerCount
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from qt_ui.windows.QWaitingForMissionResultWindow import \
|
||||
QWaitingForMissionResultWindow
|
||||
@@ -23,14 +25,18 @@ from qt_ui.windows.stats.QStatsWindow import QStatsWindow
|
||||
|
||||
class QTopPanel(QFrame):
|
||||
|
||||
def __init__(self, game: Game):
|
||||
def __init__(self, game_model: GameModel):
|
||||
super(QTopPanel, self).__init__()
|
||||
self.game = game
|
||||
self.game_model = game_model
|
||||
self.setMaximumHeight(70)
|
||||
self.init_ui()
|
||||
GameUpdateSignal.get_instance().gameupdated.connect(self.setGame)
|
||||
GameUpdateSignal.get_instance().budgetupdated.connect(self.budget_update)
|
||||
|
||||
@property
|
||||
def game(self) -> Optional[Game]:
|
||||
return self.game_model.game
|
||||
|
||||
def init_ui(self):
|
||||
|
||||
self.turnCounter = QTurnCounter()
|
||||
@@ -68,6 +74,8 @@ class QTopPanel(QFrame):
|
||||
|
||||
self.proceedBox = QGroupBox("Proceed")
|
||||
self.proceedBoxLayout = QHBoxLayout()
|
||||
self.proceedBoxLayout.addLayout(
|
||||
MaxPlayerCount(self.game_model.ato_model))
|
||||
self.proceedBoxLayout.addWidget(self.passTurnButton)
|
||||
self.proceedBoxLayout.addWidget(self.proceedButton)
|
||||
self.proceedBox.setLayout(self.proceedBoxLayout)
|
||||
@@ -84,16 +92,17 @@ class QTopPanel(QFrame):
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def setGame(self, game: Optional[Game]):
|
||||
self.game = game
|
||||
if game is not None:
|
||||
self.turnCounter.setCurrentTurn(self.game.turn, self.game.current_day)
|
||||
self.budgetBox.setGame(self.game)
|
||||
self.factionsInfos.setGame(self.game)
|
||||
if game is None:
|
||||
return
|
||||
|
||||
if self.game and self.game.turn == 0:
|
||||
self.proceedButton.setEnabled(False)
|
||||
else:
|
||||
self.proceedButton.setEnabled(True)
|
||||
self.turnCounter.setCurrentTurn(self.game.turn, self.game.current_day)
|
||||
self.budgetBox.setGame(self.game)
|
||||
self.factionsInfos.setGame(self.game)
|
||||
|
||||
if self.game and self.game.turn == 0:
|
||||
self.proceedButton.setEnabled(False)
|
||||
else:
|
||||
self.proceedButton.setEnabled(True)
|
||||
|
||||
def openSettings(self):
|
||||
self.subwindow = QSettingsWindow(self.game)
|
||||
|
||||
@@ -10,7 +10,7 @@ from PySide2.QtCore import (
|
||||
QSize,
|
||||
Qt,
|
||||
)
|
||||
from PySide2.QtGui import QFont, QFontMetrics, QPainter
|
||||
from PySide2.QtGui import QFont, QFontMetrics, QIcon, QPainter
|
||||
from PySide2.QtWidgets import (
|
||||
QAbstractItemView,
|
||||
QGroupBox,
|
||||
@@ -18,15 +18,109 @@ from PySide2.QtWidgets import (
|
||||
QListView,
|
||||
QPushButton,
|
||||
QSplitter,
|
||||
QStyleOptionViewItem, QStyledItemDelegate, QVBoxLayout,
|
||||
QStyle, QStyleOptionViewItem, QStyledItemDelegate, QVBoxLayout,
|
||||
)
|
||||
|
||||
from game import db
|
||||
from gen.ato import Package
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from ..models import AtoModel, GameModel, NullListModel, PackageModel
|
||||
|
||||
|
||||
class FlightDelegate(QStyledItemDelegate):
|
||||
FONT_SIZE = 10
|
||||
HMARGIN = 4
|
||||
VMARGIN = 4
|
||||
|
||||
def get_font(self, option: QStyleOptionViewItem) -> QFont:
|
||||
font = QFont(option.font)
|
||||
font.setPointSize(self.FONT_SIZE)
|
||||
return font
|
||||
|
||||
@staticmethod
|
||||
def flight(index: QModelIndex) -> Flight:
|
||||
return index.data(PackageModel.FlightRole)
|
||||
|
||||
def first_row_text(self, index: QModelIndex) -> str:
|
||||
flight = self.flight(index)
|
||||
task = flight.flight_type.name
|
||||
count = flight.count
|
||||
name = db.unit_type_name(flight.unit_type)
|
||||
delay = flight.scheduled_in
|
||||
return f"[{task}] {count} x {name} in {delay} minutes"
|
||||
|
||||
def second_row_text(self, index: QModelIndex) -> str:
|
||||
flight = self.flight(index)
|
||||
origin = flight.from_cp.name
|
||||
return f"From {origin}"
|
||||
|
||||
def paint(self, painter: QPainter, option: QStyleOptionViewItem,
|
||||
index: QModelIndex) -> None:
|
||||
# Draw the list item with all the default selection styling, but with an
|
||||
# invalid index so text formatting is left to us.
|
||||
super().paint(painter, option, QModelIndex())
|
||||
|
||||
rect = option.rect.adjusted(self.HMARGIN, self.VMARGIN, -self.HMARGIN,
|
||||
-self.VMARGIN)
|
||||
|
||||
with painter_context(painter):
|
||||
painter.setFont(self.get_font(option))
|
||||
|
||||
icon: Optional[QIcon] = index.data(Qt.DecorationRole)
|
||||
if icon is not None:
|
||||
icon.paint(painter, rect, Qt.AlignLeft | Qt.AlignVCenter,
|
||||
self.icon_mode(option),
|
||||
self.icon_state(option))
|
||||
|
||||
rect = rect.adjusted(self.icon_size(option).width() + self.HMARGIN,
|
||||
0, 0, 0)
|
||||
painter.drawText(rect, Qt.AlignLeft, self.first_row_text(index))
|
||||
line2 = rect.adjusted(0, rect.height() / 2, 0, rect.height() / 2)
|
||||
painter.drawText(line2, Qt.AlignLeft, self.second_row_text(index))
|
||||
|
||||
clients = self.num_clients(index)
|
||||
if clients:
|
||||
painter.drawText(rect, Qt.AlignRight,
|
||||
f"Player Slots: {clients}")
|
||||
|
||||
def num_clients(self, index: QModelIndex) -> int:
|
||||
flight = self.flight(index)
|
||||
return flight.client_count
|
||||
|
||||
@staticmethod
|
||||
def icon_mode(option: QStyleOptionViewItem) -> QIcon.Mode:
|
||||
if not (option.state & QStyle.State_Enabled):
|
||||
return QIcon.Disabled
|
||||
elif option.state & QStyle.State_Selected:
|
||||
return QIcon.Selected
|
||||
elif option.state & QStyle.State_Active:
|
||||
return QIcon.Active
|
||||
return QIcon.Normal
|
||||
|
||||
@staticmethod
|
||||
def icon_state(option: QStyleOptionViewItem) -> QIcon.State:
|
||||
return QIcon.On if option.state & QStyle.State_Open else QIcon.Off
|
||||
|
||||
@staticmethod
|
||||
def icon_size(option: QStyleOptionViewItem) -> QSize:
|
||||
icon_size: Optional[QSize] = option.decorationSize
|
||||
if icon_size is None:
|
||||
return QSize(0, 0)
|
||||
else:
|
||||
return icon_size
|
||||
|
||||
def sizeHint(self, option: QStyleOptionViewItem,
|
||||
index: QModelIndex) -> QSize:
|
||||
left = self.icon_size(option).width() + self.HMARGIN
|
||||
metrics = QFontMetrics(self.get_font(option))
|
||||
first = metrics.size(0, self.first_row_text(index))
|
||||
second = metrics.size(0, self.second_row_text(index))
|
||||
text_width = max(first.width(), second.width())
|
||||
return QSize(left + text_width + 2 * self.HMARGIN,
|
||||
first.height() + second.height() + 2 * self.VMARGIN)
|
||||
|
||||
|
||||
class QFlightList(QListView):
|
||||
"""List view for displaying the flights of a package."""
|
||||
|
||||
@@ -34,6 +128,7 @@ class QFlightList(QListView):
|
||||
super().__init__()
|
||||
self.package_model = model
|
||||
self.set_package(model)
|
||||
self.setItemDelegate(FlightDelegate())
|
||||
self.setIconSize(QSize(91, 24))
|
||||
self.setSelectionBehavior(QAbstractItemView.SelectItems)
|
||||
|
||||
@@ -109,6 +204,7 @@ class QFlightPanel(QGroupBox):
|
||||
"""Sets the package model to display."""
|
||||
self.package_model = model
|
||||
self.flight_list.set_package(model)
|
||||
self.selection_changed.connect(self.on_selection_changed)
|
||||
self.on_selection_changed()
|
||||
|
||||
@property
|
||||
@@ -122,6 +218,15 @@ class QFlightPanel(QGroupBox):
|
||||
enabled = index.isValid()
|
||||
self.edit_button.setEnabled(enabled)
|
||||
self.delete_button.setEnabled(enabled)
|
||||
self.change_map_flight_selection(index)
|
||||
|
||||
@staticmethod
|
||||
def change_map_flight_selection(index: QModelIndex) -> None:
|
||||
if not index.isValid():
|
||||
GameUpdateSignal.get_instance().select_flight(None)
|
||||
return
|
||||
|
||||
GameUpdateSignal.get_instance().select_flight(index.row())
|
||||
|
||||
def on_edit(self) -> None:
|
||||
"""Opens the flight edit dialog."""
|
||||
@@ -196,6 +301,15 @@ class PackageDelegate(QStyledItemDelegate):
|
||||
line2 = rect.adjusted(0, rect.height() / 2, 0, rect.height() / 2)
|
||||
painter.drawText(line2, Qt.AlignLeft, self.right_text(index))
|
||||
|
||||
clients = self.num_clients(index)
|
||||
if clients:
|
||||
painter.drawText(rect, Qt.AlignRight,
|
||||
f"Player Slots: {clients}")
|
||||
|
||||
def num_clients(self, index: QModelIndex) -> int:
|
||||
package = self.package(index)
|
||||
return sum(f.client_count for f in package.flights)
|
||||
|
||||
def sizeHint(self, option: QStyleOptionViewItem,
|
||||
index: QModelIndex) -> QSize:
|
||||
metrics = QFontMetrics(self.get_font(option))
|
||||
@@ -270,6 +384,18 @@ class QPackagePanel(QGroupBox):
|
||||
enabled = index.isValid()
|
||||
self.edit_button.setEnabled(enabled)
|
||||
self.delete_button.setEnabled(enabled)
|
||||
self.change_map_package_selection(index)
|
||||
|
||||
def change_map_package_selection(self, index: QModelIndex) -> None:
|
||||
if not index.isValid():
|
||||
GameUpdateSignal.get_instance().select_package(None)
|
||||
return
|
||||
|
||||
package = self.ato_model.get_package_model(index)
|
||||
if package.rowCount() == 0:
|
||||
GameUpdateSignal.get_instance().select_package(None)
|
||||
else:
|
||||
GameUpdateSignal.get_instance().select_package(index.row())
|
||||
|
||||
def on_edit(self) -> None:
|
||||
"""Opens the package edit dialog."""
|
||||
|
||||
28
qt_ui/widgets/clientslots.py
Normal file
28
qt_ui/widgets/clientslots.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Widgets for displaying client slots."""
|
||||
from PySide2.QtWidgets import QLabel
|
||||
|
||||
from qt_ui.models import AtoModel
|
||||
from qt_ui.widgets.QLabeledWidget import QLabeledWidget
|
||||
|
||||
|
||||
class MaxPlayerCount(QLabeledWidget):
|
||||
def __init__(self, ato_model: AtoModel) -> None:
|
||||
self.ato_model = ato_model
|
||||
self.slots_label = QLabel(str(self.count_client_slots))
|
||||
self.ato_model.client_slots_changed.connect(self.update_count)
|
||||
super().__init__(
|
||||
"Max Players:", self.slots_label,
|
||||
("Total number of client slots. To add client slots, edit a flight "
|
||||
"using the panel on the left.")
|
||||
)
|
||||
|
||||
@property
|
||||
def count_client_slots(self) -> int:
|
||||
slots = 0
|
||||
for package in self.ato_model.packages:
|
||||
for flight in package.flights:
|
||||
slots += flight.client_count
|
||||
return slots
|
||||
|
||||
def update_count(self) -> None:
|
||||
self.slots_label.setText(str(self.count_client_slots))
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtGui import QBrush, QColor, QPen, QPixmap, QWheelEvent
|
||||
@@ -19,11 +21,12 @@ from game.data.aaa_db import AAA_UNITS
|
||||
from game.data.radar_db import UNITS_WITH_RADAR
|
||||
from gen import Conflict
|
||||
from gen.flights.flight import Flight
|
||||
from qt_ui.displayoptions import DisplayOptions
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.widgets.map.QFrontLine import QFrontLine
|
||||
from qt_ui.widgets.map.QLiberationScene import QLiberationScene
|
||||
from qt_ui.widgets.map.QMapControlPoint import QMapControlPoint
|
||||
from qt_ui.widgets.map.QMapGroundObject import QMapGroundObject
|
||||
from qt_ui.widgets.map.QFrontLine import QFrontLine
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
from theater import ControlPoint, FrontLine
|
||||
|
||||
@@ -31,15 +34,7 @@ from theater import ControlPoint, FrontLine
|
||||
class QLiberationMap(QGraphicsView):
|
||||
WAYPOINT_SIZE = 4
|
||||
|
||||
instance = None
|
||||
display_rules: Dict[str, bool] = {
|
||||
"cp": True,
|
||||
"go": True,
|
||||
"lines": True,
|
||||
"events": True,
|
||||
"sam": True,
|
||||
"flight_paths": False
|
||||
}
|
||||
instance: Optional[QLiberationMap] = None
|
||||
|
||||
def __init__(self, game_model: GameModel):
|
||||
super(QLiberationMap, self).__init__()
|
||||
@@ -48,6 +43,8 @@ class QLiberationMap(QGraphicsView):
|
||||
self.game: Optional[Game] = game_model.game
|
||||
|
||||
self.flight_path_items: List[QGraphicsItem] = []
|
||||
# A tuple of (package index, flight index), or none.
|
||||
self.selected_flight: Optional[Tuple[int, int]] = None
|
||||
|
||||
self.setMinimumSize(800,600)
|
||||
self.setMaximumHeight(2160)
|
||||
@@ -62,6 +59,25 @@ class QLiberationMap(QGraphicsView):
|
||||
lambda: self.draw_flight_plans(self.scene())
|
||||
)
|
||||
|
||||
def update_package_selection(index: Optional[int]) -> None:
|
||||
self.selected_flight = index, 0
|
||||
self.draw_flight_plans(self.scene())
|
||||
|
||||
GameUpdateSignal.get_instance().package_selection_changed.connect(
|
||||
update_package_selection
|
||||
)
|
||||
|
||||
def update_flight_selection(index: Optional[int]) -> None:
|
||||
if self.selected_flight is None:
|
||||
logging.error("Flight was selected with no package selected")
|
||||
return
|
||||
self.selected_flight = self.selected_flight[0], index
|
||||
self.draw_flight_plans(self.scene())
|
||||
|
||||
GameUpdateSignal.get_instance().flight_selection_changed.connect(
|
||||
update_flight_selection
|
||||
)
|
||||
|
||||
def init_scene(self):
|
||||
scene = QLiberationScene(self)
|
||||
self.setScene(scene)
|
||||
@@ -162,7 +178,8 @@ class QLiberationMap(QGraphicsView):
|
||||
buildings = self.game.theater.find_ground_objects_by_obj_name(ground_object.obj_name)
|
||||
scene.addItem(QMapGroundObject(self, go_pos[0], go_pos[1], 14, 12, cp, ground_object, self.game, buildings))
|
||||
|
||||
if ground_object.category == "aa" and self.get_display_rule("sam"):
|
||||
is_aa = ground_object.category == "aa"
|
||||
if is_aa and DisplayOptions.sam_ranges:
|
||||
threat_range = 0
|
||||
detection_range = 0
|
||||
can_fire = False
|
||||
@@ -194,11 +211,11 @@ class QLiberationMap(QGraphicsView):
|
||||
added_objects.append(ground_object.obj_name)
|
||||
|
||||
for cp in self.game.theater.enemy_points():
|
||||
if self.get_display_rule("lines"):
|
||||
if DisplayOptions.lines:
|
||||
self.scene_create_lines_for_cp(cp, playerColor, enemyColor)
|
||||
|
||||
for cp in self.game.theater.player_points():
|
||||
if self.get_display_rule("lines"):
|
||||
if DisplayOptions.lines:
|
||||
self.scene_create_lines_for_cp(cp, playerColor, enemyColor)
|
||||
|
||||
self.draw_flight_plans(scene)
|
||||
@@ -219,37 +236,44 @@ class QLiberationMap(QGraphicsView):
|
||||
# Something may have caused those items to already be removed.
|
||||
pass
|
||||
self.flight_path_items.clear()
|
||||
if not self.get_display_rule("flight_paths"):
|
||||
if DisplayOptions.flight_paths.hide:
|
||||
return
|
||||
for package in self.game_model.ato_model.packages:
|
||||
for flight in package.flights:
|
||||
self.draw_flight_plan(scene, flight)
|
||||
for p_idx, package in enumerate(self.game_model.ato_model.packages):
|
||||
for f_idx, flight in enumerate(package.flights):
|
||||
selected = (p_idx, f_idx) == self.selected_flight
|
||||
if DisplayOptions.flight_paths.only_selected and not selected:
|
||||
continue
|
||||
highlight = selected and DisplayOptions.flight_paths.all
|
||||
self.draw_flight_plan(scene, flight, highlight)
|
||||
|
||||
def draw_flight_plan(self, scene: QGraphicsScene, flight: Flight) -> None:
|
||||
def draw_flight_plan(self, scene: QGraphicsScene, flight: Flight,
|
||||
highlight: bool) -> None:
|
||||
is_player = flight.from_cp.captured
|
||||
pos = self._transform_point(flight.from_cp.position)
|
||||
|
||||
self.draw_waypoint(scene, pos, is_player)
|
||||
self.draw_waypoint(scene, pos, is_player, highlight)
|
||||
prev_pos = tuple(pos)
|
||||
for point in flight.points:
|
||||
new_pos = self._transform_point(Point(point.x, point.y))
|
||||
self.draw_flight_path(scene, prev_pos, new_pos, is_player)
|
||||
self.draw_waypoint(scene, new_pos, is_player)
|
||||
self.draw_flight_path(scene, prev_pos, new_pos, is_player,
|
||||
highlight)
|
||||
self.draw_waypoint(scene, new_pos, is_player, highlight)
|
||||
prev_pos = tuple(new_pos)
|
||||
self.draw_flight_path(scene, prev_pos, pos, is_player)
|
||||
self.draw_flight_path(scene, prev_pos, pos, is_player, highlight)
|
||||
|
||||
def draw_waypoint(self, scene: QGraphicsScene, position: Tuple[int, int],
|
||||
player: bool) -> None:
|
||||
waypoint_pen = self.waypoint_pen(player)
|
||||
waypoint_brush = self.waypoint_brush(player)
|
||||
player: bool, highlight: bool) -> None:
|
||||
waypoint_pen = self.waypoint_pen(player, highlight)
|
||||
waypoint_brush = self.waypoint_brush(player, highlight)
|
||||
self.flight_path_items.append(scene.addEllipse(
|
||||
position[0], position[1], self.WAYPOINT_SIZE,
|
||||
self.WAYPOINT_SIZE, waypoint_pen, waypoint_brush
|
||||
))
|
||||
|
||||
def draw_flight_path(self, scene: QGraphicsScene, pos0: Tuple[int, int],
|
||||
pos1: Tuple[int, int], player: bool):
|
||||
flight_path_pen = self.flight_path_pen(player)
|
||||
pos1: Tuple[int, int], player: bool,
|
||||
highlight: bool) -> None:
|
||||
flight_path_pen = self.flight_path_pen(player, highlight)
|
||||
# Draw the line to the *middle* of the waypoint.
|
||||
offset = self.WAYPOINT_SIZE // 2
|
||||
self.flight_path_items.append(scene.addLine(
|
||||
@@ -338,17 +362,24 @@ class QLiberationMap(QGraphicsView):
|
||||
|
||||
return X > treshold and X or treshold, Y > treshold and Y or treshold
|
||||
|
||||
def highlight_color(self, transparent: Optional[bool] = False) -> QColor:
|
||||
return QColor(255, 255, 0, 20 if transparent else 255)
|
||||
|
||||
def base_faction_color_name(self, player: bool) -> str:
|
||||
if player:
|
||||
return self.game.get_player_color()
|
||||
else:
|
||||
return self.game.get_enemy_color()
|
||||
|
||||
def waypoint_pen(self, player: bool) -> QPen:
|
||||
def waypoint_pen(self, player: bool, highlight: bool) -> QColor:
|
||||
if highlight:
|
||||
return self.highlight_color()
|
||||
name = self.base_faction_color_name(player)
|
||||
return QPen(brush=CONST.COLORS[name])
|
||||
return CONST.COLORS[name]
|
||||
|
||||
def waypoint_brush(self, player: bool) -> QColor:
|
||||
def waypoint_brush(self, player: bool, highlight: bool) -> QColor:
|
||||
if highlight:
|
||||
return self.highlight_color(transparent=True)
|
||||
name = self.base_faction_color_name(player)
|
||||
return CONST.COLORS[f"{name}_transparent"]
|
||||
|
||||
@@ -369,7 +400,10 @@ class QLiberationMap(QGraphicsView):
|
||||
qpen.setStyle(Qt.DotLine)
|
||||
return qpen
|
||||
|
||||
def flight_path_pen(self, player: bool) -> QPen:
|
||||
def flight_path_pen(self, player: bool, highlight: bool) -> QPen:
|
||||
if highlight:
|
||||
return self.highlight_color()
|
||||
|
||||
name = self.base_faction_color_name(player)
|
||||
color = CONST.COLORS[name]
|
||||
pen = QPen(brush=color)
|
||||
@@ -401,18 +435,3 @@ class QLiberationMap(QGraphicsView):
|
||||
effect = QGraphicsOpacityEffect()
|
||||
effect.setOpacity(0.3)
|
||||
overlay.setGraphicsEffect(effect)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def set_display_rule(rule: str, value: bool):
|
||||
QLiberationMap.display_rules[rule] = value
|
||||
QLiberationMap.instance.reload_scene()
|
||||
QLiberationMap.instance.update()
|
||||
|
||||
@staticmethod
|
||||
def get_display_rules() -> Dict[str, bool]:
|
||||
return QLiberationMap.display_rules
|
||||
|
||||
@staticmethod
|
||||
def get_display_rule(rule) -> bool:
|
||||
return QLiberationMap.display_rules[rule]
|
||||
|
||||
@@ -7,6 +7,7 @@ from qt_ui.models import GameModel
|
||||
from qt_ui.windows.basemenu.QBaseMenu2 import QBaseMenu2
|
||||
from theater import ControlPoint
|
||||
from .QMapObject import QMapObject
|
||||
from ...displayoptions import DisplayOptions
|
||||
|
||||
|
||||
class QMapControlPoint(QMapObject):
|
||||
@@ -21,7 +22,7 @@ class QMapControlPoint(QMapObject):
|
||||
self.base_details_dialog: Optional[QBaseMenu2] = None
|
||||
|
||||
def paint(self, painter, option, widget=None) -> None:
|
||||
if self.parent.get_display_rule("cp"):
|
||||
if DisplayOptions.control_points:
|
||||
painter.save()
|
||||
painter.setRenderHint(QPainter.Antialiasing)
|
||||
painter.setBrush(self.brush_color)
|
||||
|
||||
@@ -8,8 +8,9 @@ import qt_ui.uiconstants as const
|
||||
from game import Game
|
||||
from game.data.building_data import FORTIFICATION_BUILDINGS
|
||||
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
||||
from theater import TheaterGroundObject, ControlPoint
|
||||
from theater import ControlPoint, TheaterGroundObject
|
||||
from .QMapObject import QMapObject
|
||||
from ...displayoptions import DisplayOptions
|
||||
|
||||
|
||||
class QMapGroundObject(QMapObject):
|
||||
@@ -50,7 +51,7 @@ class QMapGroundObject(QMapObject):
|
||||
player_icons = "_blue"
|
||||
enemy_icons = ""
|
||||
|
||||
if self.parent.get_display_rule("go"):
|
||||
if DisplayOptions.ground_objects:
|
||||
painter.save()
|
||||
|
||||
cat = self.ground_object.category
|
||||
|
||||
Reference in New Issue
Block a user