diff --git a/backend/src/meter/mod.rs b/backend/src/meter/mod.rs index 2e61fb1..48400be 100644 --- a/backend/src/meter/mod.rs +++ b/backend/src/meter/mod.rs @@ -29,6 +29,10 @@ impl Session { fn from(session: &Self) -> Self { let mut players = HashMap::new(); for (player_name, player) in &session.players { + let mut new_player = Player::new(player.id); + if let CombatState::InCombat = player.combat_state() { + new_player.enter_combat(); + } players.insert(player_name.clone(), Player::new(player.id)); } @@ -284,7 +288,7 @@ impl GameStats for Meter { self.zone_history = PlayerStatisticsVec::new(); let last_session = self.zone_session_mut()?; self.zone_session = Some(Session::from(&last_session)); - self.last_fight_session = Session::new(); + self.last_fight_session = Session::from(&self.last_fight_session); Some(()) } diff --git a/frontend/src/assets/about.png b/frontend/src/assets/about.png new file mode 100644 index 0000000..65ef5ba Binary files /dev/null and b/frontend/src/assets/about.png differ diff --git a/frontend/src/assets/close.png b/frontend/src/assets/close.png new file mode 100644 index 0000000..a3860b4 Binary files /dev/null and b/frontend/src/assets/close.png differ diff --git a/frontend/src/assets/copy.png b/frontend/src/assets/copy.png new file mode 100644 index 0000000..b6b14fa Binary files /dev/null and b/frontend/src/assets/copy.png differ diff --git a/frontend/src/assets/reset.png b/frontend/src/assets/reset.png new file mode 100644 index 0000000..ec8e7b8 Binary files /dev/null and b/frontend/src/assets/reset.png differ diff --git a/frontend/src/main.py b/frontend/src/main.py index 0a9fa84..574bdc6 100644 --- a/frontend/src/main.py +++ b/frontend/src/main.py @@ -1,4 +1,5 @@ import sys +import os from PySide2.QtCore import QTimer from PySide2.QtCore import Qt @@ -10,30 +11,44 @@ from PySide2.QtWidgets import QWidget from PySide2.QtWidgets import QLabel from PySide2.QtWidgets import QComboBox +from PySide2 import QtGui +from PySide2 import QtCore + import clipboard from .dmg_list import DmgList from . import about from . import engine +assets_path = os.path.join(os.path.dirname(sys.argv[0]), 'src', 'assets') + class Mode: CURRENT_ZONE = 'Statistics: Current zone' OVERALL = 'Statistics: Overall' LAST_FIGHT = 'Statistics: Last fight' -class BottomButtons(QWidget): - def __init__(self, table, mode): +class InteractiveBar(QWidget): + def __init__(self, table): QWidget.__init__(self) - self.mode = mode + self.mode = ModeWidget() self.table = table self.layout = QHBoxLayout() self.about = about.About() - self.copy_button = QPushButton("&Copy", self) - self.reset_button = QPushButton("&Reset", self) - self.close_button = QPushButton("&Close", self) - self.about_button = QPushButton("&About", self) + self.copy_button = QPushButton(self) + self.copy_button.setIcon(QtGui.QIcon(os.path.join(assets_path, 'copy.png'))) + + self.reset_button = QPushButton() + self.reset_button.setIcon(QtGui.QIcon(os.path.join(assets_path, 'reset.png'))) + + self.close_button = QPushButton(self) + self.close_button.setIcon(QtGui.QIcon(os.path.join(assets_path, 'close.png'))) + + self.about_button = QPushButton(self) + self.about_button.setIcon(QtGui.QIcon(os.path.join(assets_path, 'about.png'))) + + self.layout.addWidget(self.mode) self.layout.addWidget(self.copy_button) self.layout.addWidget(self.reset_button) self.layout.addWidget(self.about_button) @@ -45,13 +60,8 @@ class BottomButtons(QWidget): self.close_button.clicked.connect(self.close) self.about_button.clicked.connect(self.about.show) - self.copy_button.setObjectName('BottomButtons') - self.reset_button.setObjectName('BottomButtons') - self.about_button.setObjectName('BottomButtons') - self.close_button.setObjectName('BottomButtons') - def copy(self): - clip = "{}\n".format(self.mode()) + clip = "{}\n".format(self.mode.currentText()) model = self.table.model items = sorted( [model.item(i) for i in range(model.rowCount())], @@ -71,7 +81,7 @@ class BottomButtons(QWidget): Mode.OVERALL: engine.reset_stats } - reset[self.mode()]() + reset[self.mode.currentText()]() def close(self): sys.exit(0) @@ -90,17 +100,15 @@ class MainWidget(QWidget): QWidget.__init__(self) self.mouse_pos = None - self.mode = ModeWidget() self.table = DmgList() self.fame_label = QLabel() - self.bottom_buttons = BottomButtons( - self.table, lambda: self.mode.currentText()) + self.fame_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter) + self.bar = InteractiveBar(self.table) self.layout = QVBoxLayout() - self.layout.addWidget(self.mode) + self.layout.addWidget(self.bar) self.layout.addWidget(self.fame_label) self.layout.addWidget(self.table) - self.layout.addWidget(self.bottom_buttons) self.setLayout(self.layout) self.refresh() @@ -114,12 +122,12 @@ class MainWidget(QWidget): self.table.update(damage_session) self.fame_label.setText("Fame {} | Fame per minute {} | Party members {}".format( fame_stat.fame, fame_stat.fame_per_minute, len(engine.get_party_members()))) - + def mousePressEvent(self, event): self.mouse_pos = event.pos() def mouseMoveEvent(self, event): - if self.mode.geometry().contains(event.pos()): + if self.bar.mode.geometry().contains(event.pos()): return if not self.mouse_pos: return @@ -137,4 +145,4 @@ class MainWidget(QWidget): Mode.OVERALL: engine.overall_stats } - return sessions[self.mode.currentText()]() + return sessions[self.bar.mode.currentText()]() diff --git a/frontend/src/styling.py b/frontend/src/styling.py index 5edeb60..f485392 100644 --- a/frontend/src/styling.py +++ b/frontend/src/styling.py @@ -9,12 +9,10 @@ style = """ background-color: black; color: white; } + QListView { min-height: 100px; } - QPushButton { - max-width: 60px; - } QListView::item:selected:active { background-color: black;