Gui rearranged
Refactoring in progress :)
This commit is contained in:
@@ -2,7 +2,7 @@ from ..engine import InitializationResult
|
|||||||
from ..engine import initialize
|
from ..engine import initialize
|
||||||
from ..utils.config import config
|
from ..utils.config import config
|
||||||
|
|
||||||
from .main import MainWidget
|
from .modules.main import MainWidget
|
||||||
from .styling import style
|
from .styling import style
|
||||||
from ..utils.version import current_version as get_current_version
|
from ..utils.version import current_version as get_current_version
|
||||||
from ..utils.version import latest_url
|
from ..utils.version import latest_url
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
from .list import List as List
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from ..utils import assets
|
from ....utils import assets
|
||||||
from ..utils import names
|
from ....utils import names
|
||||||
from ..utils import async_request
|
from ....utils import async_request
|
||||||
from ..utils import weapon
|
from ....utils import weapon
|
||||||
|
|
||||||
from PIL import Image, ImageQt
|
from PIL import Image, ImageQt
|
||||||
from PySide2 import QtCore
|
from PySide2 import QtCore
|
||||||
@@ -74,8 +74,6 @@ def player_style(items):
|
|||||||
else:
|
else:
|
||||||
return Style(bg='#42413c')
|
return Style(bg='#42413c')
|
||||||
|
|
||||||
# @functools.lru_cache(maxsize=None)
|
|
||||||
|
|
||||||
|
|
||||||
def player_icon(weapon):
|
def player_icon(weapon):
|
||||||
url = f'https://albiononline2d.ams3.cdn.digitaloceanspaces.com/thumbnails/orig/{weapon}'
|
url = f'https://albiononline2d.ams3.cdn.digitaloceanspaces.com/thumbnails/orig/{weapon}'
|
||||||
@@ -91,8 +89,8 @@ def player_icon(weapon):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class DmgList(QListView):
|
class List(QListView):
|
||||||
class DmgItem(QtGui.QStandardItem):
|
class Item(QtGui.QStandardItem):
|
||||||
def __init__(self, player, parent):
|
def __init__(self, player, parent):
|
||||||
QtGui.QStandardItem .__init__(self)
|
QtGui.QStandardItem .__init__(self)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
@@ -135,14 +133,14 @@ class DmgList(QListView):
|
|||||||
r = self.sourceModel().item(right.row())
|
r = self.sourceModel().item(right.row())
|
||||||
return l.player.percentage < r.player.percentage
|
return l.player.percentage < r.player.percentage
|
||||||
|
|
||||||
class DmgItemModel(QStandardItemModel):
|
class ItemModel(QStandardItemModel):
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
QStandardItemModel .__init__(self, view)
|
QStandardItemModel .__init__(self, view)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QListView .__init__(self)
|
QListView .__init__(self)
|
||||||
self.setIconSize(QtCore.QSize(20, 20))
|
self.setIconSize(QtCore.QSize(20, 20))
|
||||||
self.model = self.DmgItemModel(self)
|
self.model = self.ItemModel(self)
|
||||||
self.proxy = self.SortProxyModel()
|
self.proxy = self.SortProxyModel()
|
||||||
self.proxy.setSourceModel(self.model)
|
self.proxy.setSourceModel(self.model)
|
||||||
|
|
||||||
@@ -161,7 +159,7 @@ class DmgList(QListView):
|
|||||||
if found:
|
if found:
|
||||||
found.update(player)
|
found.update(player)
|
||||||
else:
|
else:
|
||||||
self.model.appendRow(self.DmgItem(player, self))
|
self.model.appendRow(self.Item(player, self))
|
||||||
visible_names.append(player.name)
|
visible_names.append(player.name)
|
||||||
for i in range(self.model.rowCount()):
|
for i in range(self.model.rowCount()):
|
||||||
item = self.model.item(i)
|
item = self.model.item(i)
|
||||||
@@ -15,11 +15,11 @@ from PySide2.QtWidgets import QComboBox
|
|||||||
from PySide2 import QtGui
|
from PySide2 import QtGui
|
||||||
from PySide2 import QtCore
|
from PySide2 import QtCore
|
||||||
|
|
||||||
from .dmg_list import DmgList
|
from .list_view import List
|
||||||
from .modules import about
|
from . import about
|
||||||
from .. import engine
|
from ... import engine
|
||||||
from ..utils import assets
|
from ...utils import assets
|
||||||
from ..utils.config import config
|
from ...utils.config import config
|
||||||
|
|
||||||
|
|
||||||
class Mode:
|
class Mode:
|
||||||
@@ -31,54 +31,22 @@ class Mode:
|
|||||||
LAST_FIGHT = 'Stats (all): Last fight'
|
LAST_FIGHT = 'Stats (all): Last fight'
|
||||||
|
|
||||||
|
|
||||||
class InteractiveBar(QWidget):
|
class CopyButton(QPushButton):
|
||||||
def __init__(self, table, clipboard):
|
def __init__(self, clipboard, players, mode, fame):
|
||||||
QWidget.__init__(self)
|
QPushButton.__init__(self)
|
||||||
self.mode = ModeWidget()
|
|
||||||
self.table = table
|
|
||||||
self.layout = QHBoxLayout()
|
|
||||||
self.about = about.About()
|
|
||||||
self.fame_per_hour = 0.0
|
|
||||||
self.clipboard = clipboard
|
self.clipboard = clipboard
|
||||||
|
self.players = players
|
||||||
|
self.mode = mode
|
||||||
|
self.fame = fame
|
||||||
|
|
||||||
self.layout.addWidget(self.mode)
|
self.clicked.connect(self.copy)
|
||||||
|
self.setIcon(QtGui.QIcon(assets.path('copy.png')))
|
||||||
self.copy_button = QPushButton(self)
|
self.setToolTip("Copy to clipboard")
|
||||||
self.copy_button.setIcon(QtGui.QIcon(assets.path('copy.png')))
|
|
||||||
self.copy_button.setToolTip("Copy to clipboard")
|
|
||||||
self.layout.addWidget(self.copy_button)
|
|
||||||
self.copy_button.clicked.connect(self.copy)
|
|
||||||
|
|
||||||
self.reset_button = QPushButton()
|
|
||||||
self.reset_button.setIcon(QtGui.QIcon(assets.path('reset.png')))
|
|
||||||
self.reset_button.setToolTip("Reset")
|
|
||||||
self.layout.addWidget(self.reset_button)
|
|
||||||
self.reset_button.clicked.connect(self.reset)
|
|
||||||
|
|
||||||
self.about_button = QPushButton(self)
|
|
||||||
self.about_button.setIcon(QtGui.QIcon(assets.path('about.png')))
|
|
||||||
self.about_button.setToolTip("About")
|
|
||||||
self.layout.addWidget(self.about_button)
|
|
||||||
self.about_button.clicked.connect(self.about.show)
|
|
||||||
|
|
||||||
if config()['window']['frameless']:
|
|
||||||
self.close_button = QPushButton(self)
|
|
||||||
self.close_button.setIcon(QtGui.QIcon(assets.path('close.png')))
|
|
||||||
self.close_button.setToolTip("Close")
|
|
||||||
self.layout.addWidget(self.close_button)
|
|
||||||
self.close_button.clicked.connect(self.close)
|
|
||||||
|
|
||||||
self.setLayout(self.layout)
|
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
model = self.table.model
|
|
||||||
items = sorted(
|
|
||||||
[model.item(i).player for i in range(model.rowCount())],
|
|
||||||
key=lambda i: i.damage,
|
|
||||||
reverse=True)
|
|
||||||
clip = "{}, FPH: {}\nDMG: \n".format(
|
clip = "{}, FPH: {}\nDMG: \n".format(
|
||||||
self.mode.currentText(), self.fame_per_hour)
|
self.mode(), self.fame())
|
||||||
for index, i in enumerate(items[:3]):
|
for index, i in enumerate(self.players()[:3]):
|
||||||
clip += '{}. {}-{}/{}-{}%'.format(index+1,
|
clip += '{}. {}-{}/{}-{}%'.format(index+1,
|
||||||
i.name, i.damage, i.dps, i.percentage)
|
i.name, i.damage, i.dps, i.percentage)
|
||||||
clip += "\n"
|
clip += "\n"
|
||||||
@@ -87,8 +55,16 @@ class InteractiveBar(QWidget):
|
|||||||
self.clipboard.clear(mode=self.clipboard.Clipboard)
|
self.clipboard.clear(mode=self.clipboard.Clipboard)
|
||||||
self.clipboard.setText(clip, mode=self.clipboard.Clipboard)
|
self.clipboard.setText(clip, mode=self.clipboard.Clipboard)
|
||||||
|
|
||||||
def set_fame_per_hour(self, fpm):
|
|
||||||
self.fame_per_hour = fpm
|
class ResetButton(QPushButton):
|
||||||
|
def __init__(self, mode):
|
||||||
|
QPushButton.__init__(self)
|
||||||
|
|
||||||
|
self.mode = mode
|
||||||
|
|
||||||
|
self.setIcon(QtGui.QIcon(assets.path('reset.png')))
|
||||||
|
self.setToolTip("Reset")
|
||||||
|
self.clicked.connect(self.reset)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
reset = {
|
reset = {
|
||||||
@@ -100,7 +76,72 @@ class InteractiveBar(QWidget):
|
|||||||
Mode.OVERALL: engine.reset_stats,
|
Mode.OVERALL: engine.reset_stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
reset[self.mode.currentText()]()
|
reset[self.mode()]()
|
||||||
|
|
||||||
|
|
||||||
|
class AboutButton(QPushButton):
|
||||||
|
def __init__(self):
|
||||||
|
QPushButton.__init__(self)
|
||||||
|
|
||||||
|
self.about = about.About()
|
||||||
|
self.setIcon(QtGui.QIcon(assets.path('about.png')))
|
||||||
|
self.setToolTip("About")
|
||||||
|
self.clicked.connect(self.about.show)
|
||||||
|
|
||||||
|
|
||||||
|
class CloseButton(QPushButton):
|
||||||
|
def __init__(self):
|
||||||
|
QPushButton.__init__(self)
|
||||||
|
|
||||||
|
self.setIcon(QtGui.QIcon(assets.path('close.png')))
|
||||||
|
self.setToolTip("Close")
|
||||||
|
self.clicked.connect(self.close)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
class InteractiveBar(QWidget):
|
||||||
|
def __init__(self, table, clipboard):
|
||||||
|
QWidget.__init__(self)
|
||||||
|
self.mode = ModeWidget()
|
||||||
|
self.table = table
|
||||||
|
self.layout = QHBoxLayout()
|
||||||
|
self.fame_per_hour = 0.0
|
||||||
|
|
||||||
|
self.layout.addWidget(self.mode)
|
||||||
|
|
||||||
|
self.copy_button = CopyButton(
|
||||||
|
clipboard, self.get_players, self.get_mode, self.get_fame_per_hour)
|
||||||
|
self.layout.addWidget(self.copy_button)
|
||||||
|
|
||||||
|
self.reset_button = ResetButton(self.get_mode)
|
||||||
|
self.layout.addWidget(self.reset_button)
|
||||||
|
|
||||||
|
self.about_button = AboutButton()
|
||||||
|
self.layout.addWidget(self.about_button)
|
||||||
|
|
||||||
|
if config()['window']['frameless']:
|
||||||
|
self.close_button = CloseButton()
|
||||||
|
self.layout.addWidget(self.close_button)
|
||||||
|
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def get_mode(self):
|
||||||
|
return self.mode.currentText()
|
||||||
|
|
||||||
|
def get_fame_per_hour(self):
|
||||||
|
return self.fame_per_hour
|
||||||
|
|
||||||
|
def get_players(self):
|
||||||
|
model = self.table.model
|
||||||
|
return sorted(
|
||||||
|
[model.item(i).player for i in range(model.rowCount())],
|
||||||
|
key=lambda i: i.damage,
|
||||||
|
reverse=True)
|
||||||
|
|
||||||
|
def set_fame_per_hour(self, fpm):
|
||||||
|
self.fame_per_hour = fpm
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -122,7 +163,7 @@ class MainWidget(QWidget):
|
|||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
|
|
||||||
self.mouse_pos = None
|
self.mouse_pos = None
|
||||||
self.table = DmgList()
|
self.table = List()
|
||||||
self.fame_label = QLabel()
|
self.fame_label = QLabel()
|
||||||
self.fame_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
self.fame_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
||||||
self.bar = InteractiveBar(self.table, clipboard)
|
self.bar = InteractiveBar(self.table, clipboard)
|
||||||
Reference in New Issue
Block a user