1
1
import sqlite3
2
+ from json import dumps
2
3
3
- from PyQt5 .QtCore import QTimer
4
- from PyQt5 .QtGui import QFont
5
- from PyQt5 .QtWidgets import QGridLayout , QLabel
4
+ from PyQt5 .QtCore import QTimer , QUrl
5
+ from PyQt5 .QtWidgets import QVBoxLayout , QWidget
6
+ from PyQt5 .QtWebEngineWidgets import QWebEngineView
6
7
7
8
from FFxivPythonTrigger import *
8
9
from FFxivPythonTrigger .QT import FloatWidget , ui_loop_exec
42
43
43
44
owners = dict ()
44
45
46
+ web_path = str (Path (__file__ ).parent / 'dist' / 'index.html' )
47
+
45
48
46
49
class CombatMonitor (PluginBase ):
47
50
name = "Combat Monitor"
@@ -55,27 +58,32 @@ def __init__(self):
55
58
# self.conn = get_con(self.storage.path / 'data.db')
56
59
57
60
class DpsWindow (FloatWidget ):
61
+ allow_frameless = True
58
62
def __init__ (self ):
59
63
super ().__init__ ()
60
64
self .setWindowTitle ("Dps" )
61
- self .label = QLabel ('No Data' )
62
- self .label .setFont (QFont ('Times' , 20 ))
63
- self .layout = QGridLayout ()
64
- self .layout .addWidget (self .label )
65
- self .setLayout (self .layout )
65
+ self .browser = QWebEngineView ()
66
+ self .browser .load (QUrl .fromLocalFile (web_path ))
67
+ _layout = QVBoxLayout (self )
68
+ _layout .addWidget (self .browser )
69
+ self .setLayout (_layout )
70
+
71
+ self .last_update = 0
72
+
66
73
self .timer = QTimer ()
67
- self .timer .setInterval (UPDATE_PERIOD * 1000 )
74
+ self .timer .setInterval (UPDATE_PERIOD * 2000 )
68
75
self .timer .timeout .connect (self .update )
69
76
self .timer .start ()
70
77
71
78
def update (_self ):
72
79
me = api .XivMemory .actor_table .get_me ()
73
- if me is None : return
80
+ if me is None or _self . last_update > self . last_record_time : return
74
81
party = [actor for actor in api .XivMemory .party .main_party ()]
75
82
if not party : party = [me ]
76
- data = [(a , self .actor_dps (a .id , 0 )) for a in party ]
77
- data .sort (key = lambda x : x [1 ], reverse = True )
78
- _self .label .setText ("\n " .join ([f"{ a .job .value ()} \t { a .Name } \t { d :,.0f} " for a , d in data ]))
83
+ data = [{'job' :a .job .value (), 'name' :a .Name , 'dps' :self .actor_dps (a .id , 0 )} for a in party ]
84
+ _self .browser .page ().runJavaScript (f"window.set_data({ dumps (data )} )" )
85
+ _self .last_update = time ()* 1000
86
+
79
87
80
88
self .conn = get_con ()
81
89
self .conn_lock = Lock ()
0 commit comments