Pretty GUI
This commit is contained in:
@@ -29,6 +29,10 @@ impl Session {
|
|||||||
fn from(session: &Self) -> Self {
|
fn from(session: &Self) -> Self {
|
||||||
let mut players = HashMap::new();
|
let mut players = HashMap::new();
|
||||||
for (player_name, player) in &session.players {
|
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));
|
players.insert(player_name.clone(), Player::new(player.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +288,7 @@ impl GameStats for Meter {
|
|||||||
self.zone_history = PlayerStatisticsVec::new();
|
self.zone_history = PlayerStatisticsVec::new();
|
||||||
let last_session = self.zone_session_mut()?;
|
let last_session = self.zone_session_mut()?;
|
||||||
self.zone_session = Some(Session::from(&last_session));
|
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(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 785 B |
Binary file not shown.
|
After Width: | Height: | Size: 835 B |
Binary file not shown.
|
After Width: | Height: | Size: 648 B |
+30
-22
@@ -1,4 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
from PySide2.QtCore import QTimer
|
from PySide2.QtCore import QTimer
|
||||||
from PySide2.QtCore import Qt
|
from PySide2.QtCore import Qt
|
||||||
@@ -10,30 +11,44 @@ from PySide2.QtWidgets import QWidget
|
|||||||
from PySide2.QtWidgets import QLabel
|
from PySide2.QtWidgets import QLabel
|
||||||
from PySide2.QtWidgets import QComboBox
|
from PySide2.QtWidgets import QComboBox
|
||||||
|
|
||||||
|
from PySide2 import QtGui
|
||||||
|
from PySide2 import QtCore
|
||||||
|
|
||||||
import clipboard
|
import clipboard
|
||||||
|
|
||||||
from .dmg_list import DmgList
|
from .dmg_list import DmgList
|
||||||
from . import about
|
from . import about
|
||||||
from . import engine
|
from . import engine
|
||||||
|
|
||||||
|
assets_path = os.path.join(os.path.dirname(sys.argv[0]), 'src', 'assets')
|
||||||
|
|
||||||
class Mode:
|
class Mode:
|
||||||
CURRENT_ZONE = 'Statistics: Current zone'
|
CURRENT_ZONE = 'Statistics: Current zone'
|
||||||
OVERALL = 'Statistics: Overall'
|
OVERALL = 'Statistics: Overall'
|
||||||
LAST_FIGHT = 'Statistics: Last fight'
|
LAST_FIGHT = 'Statistics: Last fight'
|
||||||
|
|
||||||
|
|
||||||
class BottomButtons(QWidget):
|
class InteractiveBar(QWidget):
|
||||||
def __init__(self, table, mode):
|
def __init__(self, table):
|
||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
self.mode = mode
|
self.mode = ModeWidget()
|
||||||
self.table = table
|
self.table = table
|
||||||
self.layout = QHBoxLayout()
|
self.layout = QHBoxLayout()
|
||||||
self.about = about.About()
|
self.about = about.About()
|
||||||
|
|
||||||
self.copy_button = QPushButton("&Copy", self)
|
self.copy_button = QPushButton(self)
|
||||||
self.reset_button = QPushButton("&Reset", self)
|
self.copy_button.setIcon(QtGui.QIcon(os.path.join(assets_path, 'copy.png')))
|
||||||
self.close_button = QPushButton("&Close", self)
|
|
||||||
self.about_button = QPushButton("&About", self)
|
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.copy_button)
|
||||||
self.layout.addWidget(self.reset_button)
|
self.layout.addWidget(self.reset_button)
|
||||||
self.layout.addWidget(self.about_button)
|
self.layout.addWidget(self.about_button)
|
||||||
@@ -45,13 +60,8 @@ class BottomButtons(QWidget):
|
|||||||
self.close_button.clicked.connect(self.close)
|
self.close_button.clicked.connect(self.close)
|
||||||
self.about_button.clicked.connect(self.about.show)
|
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):
|
def copy(self):
|
||||||
clip = "{}\n".format(self.mode())
|
clip = "{}\n".format(self.mode.currentText())
|
||||||
model = self.table.model
|
model = self.table.model
|
||||||
items = sorted(
|
items = sorted(
|
||||||
[model.item(i) for i in range(model.rowCount())],
|
[model.item(i) for i in range(model.rowCount())],
|
||||||
@@ -71,7 +81,7 @@ class BottomButtons(QWidget):
|
|||||||
Mode.OVERALL: engine.reset_stats
|
Mode.OVERALL: engine.reset_stats
|
||||||
}
|
}
|
||||||
|
|
||||||
reset[self.mode()]()
|
reset[self.mode.currentText()]()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -90,17 +100,15 @@ class MainWidget(QWidget):
|
|||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
|
|
||||||
self.mouse_pos = None
|
self.mouse_pos = None
|
||||||
self.mode = ModeWidget()
|
|
||||||
self.table = DmgList()
|
self.table = DmgList()
|
||||||
self.fame_label = QLabel()
|
self.fame_label = QLabel()
|
||||||
self.bottom_buttons = BottomButtons(
|
self.fame_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
||||||
self.table, lambda: self.mode.currentText())
|
self.bar = InteractiveBar(self.table)
|
||||||
|
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QVBoxLayout()
|
||||||
self.layout.addWidget(self.mode)
|
self.layout.addWidget(self.bar)
|
||||||
self.layout.addWidget(self.fame_label)
|
self.layout.addWidget(self.fame_label)
|
||||||
self.layout.addWidget(self.table)
|
self.layout.addWidget(self.table)
|
||||||
self.layout.addWidget(self.bottom_buttons)
|
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
@@ -114,12 +122,12 @@ class MainWidget(QWidget):
|
|||||||
self.table.update(damage_session)
|
self.table.update(damage_session)
|
||||||
self.fame_label.setText("Fame <b>{}</b> | Fame per minute <b>{}</b> | Party members <b>{}</b>".format(
|
self.fame_label.setText("Fame <b>{}</b> | Fame per minute <b>{}</b> | Party members <b>{}</b>".format(
|
||||||
fame_stat.fame, fame_stat.fame_per_minute, len(engine.get_party_members())))
|
fame_stat.fame, fame_stat.fame_per_minute, len(engine.get_party_members())))
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
self.mouse_pos = event.pos()
|
self.mouse_pos = event.pos()
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
if self.mode.geometry().contains(event.pos()):
|
if self.bar.mode.geometry().contains(event.pos()):
|
||||||
return
|
return
|
||||||
if not self.mouse_pos:
|
if not self.mouse_pos:
|
||||||
return
|
return
|
||||||
@@ -137,4 +145,4 @@ class MainWidget(QWidget):
|
|||||||
Mode.OVERALL: engine.overall_stats
|
Mode.OVERALL: engine.overall_stats
|
||||||
}
|
}
|
||||||
|
|
||||||
return sessions[self.mode.currentText()]()
|
return sessions[self.bar.mode.currentText()]()
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ style = """
|
|||||||
background-color: black;
|
background-color: black;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
QListView {
|
QListView {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
}
|
}
|
||||||
QPushButton {
|
|
||||||
max-width: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
QListView::item:selected:active {
|
QListView::item:selected:active {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
|
|||||||
Reference in New Issue
Block a user