From 078c1b11314e7595ecea338ba5d5c2031bb303c0 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Thu, 10 Nov 2022 23:03:50 +0500 Subject: [PATCH] Finished --- api.py | 2 +- extra_widgets.py | 46 ++++++++++------- gui_base.py | 60 +++++++++------------- gui_base.ui | 53 +++++++------------ main.py | 131 ++++++++++++++++++++++++++++++++++++++--------- 5 files changed, 179 insertions(+), 113 deletions(-) diff --git a/api.py b/api.py index e2f1959..968028e 100644 --- a/api.py +++ b/api.py @@ -14,7 +14,7 @@ class WorldState(): self.fissures = self.ws.get('fissures') self.invasions = self.ws.get('invasions') - self.sorties = self.ws.get('sorties') + self.sorties = self.ws.get('sortie') self.archon_hunt = self.ws.get('archonHunt') self.arbitration = self.ws.get('arbitration') self.alerts = self.ws.get('alerts') diff --git a/extra_widgets.py b/extra_widgets.py index aa039d9..2403811 100644 --- a/extra_widgets.py +++ b/extra_widgets.py @@ -1,6 +1,9 @@ from PyQt5 import QtWidgets, QtGui, QtCore from datetime import datetime, timedelta +import time + +utcoffset = time.time() - time.mktime(time.gmtime()) class Fissure(QtWidgets.QWidget): def __init__(self, parent, fissure_info = {}, i = 0): @@ -52,17 +55,18 @@ class Fissure(QtWidgets.QWidget): def update_gui(self): try: self.FissureTier.setText(f"{self.fissure_info['tier']} - T{self.fissure_info['tierNum']}") - self.update_timer(self) + self.update_timer() self.FissureNode.setText(f"{self.fissure_info['node']}") self.FissureType.setText(f"{'Steel Path' if self.fissure_info['isHard'] else ('Storm' if self.fissure_info['isStorm'] else '')}") except: pass - def udpdate_timer(self): - eta = datetime.strptime(self.fissure_info['expiry'], '%Y-%m-%dT%H:%M:%SZ') - datetime.now() - eta -= timedelta(microseconds=eta.microseconds) - - self.FissureTimer.setText(f"{eta.seconds // 3600}h {(eta.seconds // 60) % 60}m {eta.seconds % 60}s") + def update_timer(self): + eta = round(time.mktime(time.strptime(self.fissure_info['expiry'], '%Y-%m-%dT%H:%M:%S.%fZ')) - time.time() + utcoffset) + if eta >= 0: + self.FissureTimer.setText(f"{str(eta // 3600) + 'h' if eta // 3600 > 0 else ''} {(eta // 60) % 60}m {eta % 60}s") + else: + self.FissureTimer.setText("Expired") class Invasion(QtWidgets.QWidget): @@ -110,11 +114,12 @@ class Invasion(QtWidgets.QWidget): def update_gui(self): try: - faction_colors = {'Gineer': 'red', 'Corpus': 'blue', 'Infested': 'green'} + faction_colors = {'Grineer': 'red', 'Corpus': 'blue', 'Infested': 'green'} self.Reward1.setText(f"{self.invasion_info['attackerReward']['itemString']}") self.Reward2.setText(f"{self.invasion_info['defenderReward']['itemString']}") self.InvasionProgress.setStyleSheet(f'QProgressBar {{background-color:{faction_colors.get(self.invasion_info["defendingFaction"])};border-color:red; border:0px}}\nQProgressBar::chunk {{background-color:{faction_colors.get(self.invasion_info["attackingFaction"])};}}') - except: + self.update_progress() + except KeyError: pass def update_progress(self): @@ -164,9 +169,11 @@ class Alert(QtWidgets.QWidget): pass def update_timer(self): - eta = datetime.strptime(self.alert_info['expiry'], '%Y-%m-%dT%H:%M:%SZ') - datetime.now() - eta -= deltatime(microseconds=eta.microseconds) - self.AlertTimer.setText(f'{eta.days}d {eta.seconds // 3600}h {(eta.seconds // 60) % 60}m {eta.seconds % 60}s') + eta = round(time.mktime(time.strptime(self.alert_info['expiry'], '%Y-%m-%dT%H:%M:%S.%fZ')) - time.time() + utcoffset) + if eta > 0: + self.AlertTimer.setText(f'{str(eta // 86400) + "d " if eta // 86400 > 0 else ""}{str((eta // 3600) % 24) + "h" if eta // 3600 > 0 else ""} {(eta // 60) % 60}m {eta % 60}s') + else: + self.AlertTimer.setText('Expired') class BaroItem(QtWidgets.QWidget): def __init__(self, parent, item_info = {}, i = 0): @@ -239,9 +246,11 @@ class Event(QtWidgets.QWidget): pass def update_timer(self): - eta = datetime.strptime(self.event_info['expiry'], '%Y-%m-%dT%H:%M:%SZ') - datetime.now() - eta -= deltatime(microseconds=eta.microseconds) - self.EventTimer.setText(f'{eta.days}d {eta.seconds // 3600}h {(eta.seconds // 60) % 60}m {eta.seconds % 60}s') + eta = round(time.mktime(time.strptime(self.event_info['expiry'], '%Y-%m-%dT%H:%M:%S.%fZ')) - time.time() + utcoffset) + if eta > 0: + self.EventTimer.setText(f'{str(eta // 86400) + "d " if eta // 86400 > 0 else ""}{(eta // 3600) % 24}h') + else: + self.EventTimer.setText('Expired') class NewsBlurb(QtWidgets.QWidget): def __init__(self, parent, news_info = {}, i = 0): @@ -293,10 +302,9 @@ class NewsBlurb(QtWidgets.QWidget): pass def update_timer(self): - eta = datetime.strptime(self.news_info['expiry'], '%Y-%m-%dT%H:%M:%SZ') - datetime.now() - eta -= deltatime(microseconds=eta.microseconds) - if abs(eta.days) >= 1: - self.NewsBlurbRelTimer.setText(f'{"Starts in " if eta.days > 0 else ""}{abs(eta.days)}') + eta = round(time.mktime(time.strptime(self.news_info['date'], '%Y-%m-%dT%H:%M:%S.%fZ')) - time.time() + utcoffset) + if abs(eta) // 86400 >= 1: + self.NewsBlurbRelTimer.setText(f'{"Starts in " if eta // 86400 > 0 else ""}{abs(eta) // 86400}d') else: - self.NewsBlurbRelTimer.setText(f'{"Starts in " if eta.seconds > 0 else ""}{abs(eta.seconds) // 3600}h {(abs(eta.seconds) // 60) % 60}m') + self.NewsBlurbRelTimer.setText(f'{"Starts in " if eta > 0 else ""}{(abs(eta) // 3600) % 24}h {(abs(eta) // 60) % 60}m') diff --git a/gui_base.py b/gui_base.py index 3d0d305..6dfe587 100644 --- a/gui_base.py +++ b/gui_base.py @@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") - MainWindow.resize(1136, 890) + MainWindow.resize(1155, 877) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_18 = QtWidgets.QVBoxLayout(self.centralwidget) @@ -71,7 +71,7 @@ class Ui_MainWindow(object): self.gridLayout_2.setObjectName("gridLayout_2") self.WeeklyResetTimeDayStr = QtWidgets.QLabel(self.WeeklyTimer) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(1) + sizePolicy.setHorizontalStretch(2) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.WeeklyResetTimeDayStr.sizePolicy().hasHeightForWidth()) self.WeeklyResetTimeDayStr.setSizePolicy(sizePolicy) @@ -85,7 +85,7 @@ class Ui_MainWindow(object): self.gridLayout_2.addWidget(self.WeeklyResetTimeDayStr, 1, 0, 1, 1) self.WeeklyResetTimeStr = QtWidgets.QLabel(self.WeeklyTimer) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(2) + sizePolicy.setHorizontalStretch(3) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.WeeklyResetTimeStr.sizePolicy().hasHeightForWidth()) self.WeeklyResetTimeStr.setSizePolicy(sizePolicy) @@ -151,7 +151,7 @@ class Ui_MainWindow(object): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 240, 457)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 244, 449)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_6.setObjectName("verticalLayout_6") @@ -186,7 +186,7 @@ class Ui_MainWindow(object): self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 239, 457)) + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 245, 449)) self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_2) self.verticalLayout_8.setObjectName("verticalLayout_8") @@ -260,11 +260,11 @@ class Ui_MainWindow(object): self.SortieM2.setWordWrap(True) self.SortieM2.setObjectName("SortieM2") self.gridLayout_5.addWidget(self.SortieM2, 1, 0, 1, 1) - self.SrotieM2Mod = QtWidgets.QLabel(self.widget) - self.SrotieM2Mod.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.SrotieM2Mod.setWordWrap(True) - self.SrotieM2Mod.setObjectName("SrotieM2Mod") - self.gridLayout_5.addWidget(self.SrotieM2Mod, 1, 1, 1, 1) + self.SortieM2Mod = QtWidgets.QLabel(self.widget) + self.SortieM2Mod.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.SortieM2Mod.setWordWrap(True) + self.SortieM2Mod.setObjectName("SortieM2Mod") + self.gridLayout_5.addWidget(self.SortieM2Mod, 1, 1, 1, 1) self.SortieM3 = QtWidgets.QLabel(self.widget) self.SortieM3.setObjectName("SortieM3") self.gridLayout_5.addWidget(self.SortieM3, 2, 0, 1, 1) @@ -287,15 +287,6 @@ class Ui_MainWindow(object): self.ArchonHuntStr.setAlignment(QtCore.Qt.AlignCenter) self.ArchonHuntStr.setObjectName("ArchonHuntStr") self.verticalLayout_11.addWidget(self.ArchonHuntStr) - self.ArchonHuntTimer = QtWidgets.QLabel(self.ArchonHunt) - font = QtGui.QFont() - font.setPointSize(12) - font.setBold(True) - font.setWeight(75) - self.ArchonHuntTimer.setFont(font) - self.ArchonHuntTimer.setAlignment(QtCore.Qt.AlignCenter) - self.ArchonHuntTimer.setObjectName("ArchonHuntTimer") - self.verticalLayout_11.addWidget(self.ArchonHuntTimer) self.widget_2 = QtWidgets.QWidget(self.ArchonHunt) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) @@ -365,14 +356,14 @@ class Ui_MainWindow(object): self.ArbitrationMT.setFont(font) self.ArbitrationMT.setObjectName("ArbitrationMT") self.horizontalLayout_4.addWidget(self.ArbitrationMT) - self.ArbitrationTimer = QtWidgets.QLabel(self.ArbitrationData) + self.ArbitrationFaction = QtWidgets.QLabel(self.ArbitrationData) font = QtGui.QFont() font.setBold(True) font.setWeight(75) - self.ArbitrationTimer.setFont(font) - self.ArbitrationTimer.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.ArbitrationTimer.setObjectName("ArbitrationTimer") - self.horizontalLayout_4.addWidget(self.ArbitrationTimer) + self.ArbitrationFaction.setFont(font) + self.ArbitrationFaction.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.ArbitrationFaction.setObjectName("ArbitrationFaction") + self.horizontalLayout_4.addWidget(self.ArbitrationFaction) self.stackedWidget.addWidget(self.ArbitrationData) self.verticalLayout_14.addWidget(self.stackedWidget) self.verticalLayout_13.addWidget(self.Arbitration) @@ -393,7 +384,7 @@ class Ui_MainWindow(object): self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 221, 313)) + self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 226, 307)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.verticalLayout_16 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_3) self.verticalLayout_16.setObjectName("verticalLayout_16") @@ -655,10 +646,10 @@ class Ui_MainWindow(object): self.Elite2Name.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignHCenter) self.Elite2Name.setObjectName("Elite2Name") self.verticalLayout_27.addWidget(self.Elite2Name) - self.Elite3Desc = QtWidgets.QLabel(self.NightwaveElite2) - self.Elite3Desc.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop) - self.Elite3Desc.setObjectName("Elite3Desc") - self.verticalLayout_27.addWidget(self.Elite3Desc) + self.Elite2Desc = QtWidgets.QLabel(self.NightwaveElite2) + self.Elite2Desc.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop) + self.Elite2Desc.setObjectName("Elite2Desc") + self.verticalLayout_27.addWidget(self.Elite2Desc) self.horizontalLayout_9.addWidget(self.NightwaveElite2) self.gridLayout_8.addWidget(self.widget_4, 1, 0, 1, 1) self.stackedWidget_3.addWidget(self.NightwaveData) @@ -685,7 +676,7 @@ class Ui_MainWindow(object): self.scrollArea_4.setWidgetResizable(True) self.scrollArea_4.setObjectName("scrollArea_4") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 518, 743)) + self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 528, 730)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.verticalLayout_31 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_4) self.verticalLayout_31.setObjectName("verticalLayout_31") @@ -720,7 +711,7 @@ class Ui_MainWindow(object): self.scrollArea_5.setWidgetResizable(True) self.scrollArea_5.setObjectName("scrollArea_5") self.scrollAreaWidgetContents_5 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 518, 743)) + self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 527, 730)) self.scrollAreaWidgetContents_5.setObjectName("scrollAreaWidgetContents_5") self.verticalLayout_33 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_5) self.verticalLayout_33.setObjectName("verticalLayout_33") @@ -766,18 +757,17 @@ class Ui_MainWindow(object): self.SortieM1.setText(_translate("MainWindow", "Exterminate")) self.SortieM1Mod.setText(_translate("MainWindow", "Energy Reduction")) self.SortieM2.setText(_translate("MainWindow", "Sabotage")) - self.SrotieM2Mod.setText(_translate("MainWindow", "Enemy Elemental Enhancements")) + self.SortieM2Mod.setText(_translate("MainWindow", "Enemy Elemental Enhancements")) self.SortieM3.setText(_translate("MainWindow", "Assasination")) self.SortieM3Mod.setText(_translate("MainWindow", "Sniper Only")) self.ArchonHuntStr.setText(_translate("MainWindow", "Archon Hunt: Amar")) - self.ArchonHuntTimer.setText(_translate("MainWindow", "9d 9h 19m 8s")) self.ArchonHuntM1.setText(_translate("MainWindow", "Sabotage")) self.ArchonHuntM2.setText(_translate("MainWindow", "Survival")) self.ArchonHuntM3.setText(_translate("MainWindow", "Assasinate")) self.label_6.setText(_translate("MainWindow", "Arbitration")) self.label_8.setText(_translate("MainWindow", "Arbitration not available")) self.ArbitrationMT.setText(_translate("MainWindow", "Defection")) - self.ArbitrationTimer.setText(_translate("MainWindow", "55m 14s")) + self.ArbitrationFaction.setText(_translate("MainWindow", "Infested")) self.label_9.setText(_translate("MainWindow", "Alerts")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.Timers), _translate("MainWindow", "Timers")) self.label_10.setText(_translate("MainWindow", "Baro not here")) @@ -802,7 +792,7 @@ class Ui_MainWindow(object): self.Elite1Name.setText(_translate("MainWindow", "Agent")) self.Elite1Desc.setText(_translate("MainWindow", "Complete a Mission")) self.Elite2Name.setText(_translate("MainWindow", "Agent")) - self.Elite3Desc.setText(_translate("MainWindow", "Complete a Mission")) + self.Elite2Desc.setText(_translate("MainWindow", "Complete a Mission")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.Nightwave), _translate("MainWindow", "Nightwave")) self.label_12.setText(_translate("MainWindow", "Events")) self.label_18.setText(_translate("MainWindow", "News")) diff --git a/gui_base.ui b/gui_base.ui index 349f46f..1514591 100644 --- a/gui_base.ui +++ b/gui_base.ui @@ -6,8 +6,8 @@ 0 0 - 1136 - 890 + 1155 + 877 @@ -91,7 +91,7 @@ - 1 + 2 0 @@ -114,7 +114,7 @@ - 2 + 3 0 @@ -223,8 +223,8 @@ 0 0 - 240 - 457 + 244 + 449 @@ -281,8 +281,8 @@ 0 0 - 239 - 457 + 245 + 449 @@ -398,7 +398,7 @@ - + Enemy Elemental Enhancements @@ -452,23 +452,6 @@ - - - - - 12 - 75 - true - - - - 9d 9h 19m 8s - - - Qt::AlignCenter - - - @@ -578,7 +561,7 @@ - + 75 @@ -586,7 +569,7 @@ - 55m 14s + Infested Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -629,8 +612,8 @@ 0 0 - 221 - 313 + 226 + 307 @@ -1070,7 +1053,7 @@ - + Complete a Mission @@ -1125,8 +1108,8 @@ 0 0 - 518 - 743 + 528 + 730 @@ -1183,8 +1166,8 @@ 0 0 - 518 - 743 + 527 + 730 diff --git a/main.py b/main.py index 8091757..a0fb258 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from api import WorldState from extra_widgets import * from PyQt5.QtWidgets import QApplication, QMessageBox +from PyQt5.QtCore import QTimer import sys @@ -14,34 +15,118 @@ class App(GUI): while self.ws.ws == {}: self.network_error() sys.exit(1) - del self.Fissure, self.Invasion, self.Alert, self.BaroItem, self.Event, self.NewsBlurb + [widget.setParent(None) for widget in [self.Fissure, self.Invasion, self.Alert, self.BaroItem, self.Event, self.NewsBlurb]] + + self.timers_timer = QTimer(self) + self.timers_timer.timeout.connect(self.update_timers) + self.timers_timer.start(1000) + + self.ws_update_timer = QTimer(self) + self.ws_update_timer.timeout.connect(self.update_world_state) + self.ws_update_timer.start(1000 * 60 * 5) + self.redraw_content() + def redraw_content(self): + self.redraw_content_dynamic() + self.redraw_content_static() - def redraw_content(self): - self.redraw_content_dynamic() + def redraw_content_dynamic(self): + self.Fissure_list = [Fissure(self.scrollAreaWidgetContents, fissure_info, fissure_i) for (fissure_i, fissure_info) in enumerate(self.ws.fissures)] + [self.verticalLayout_6.addWidget(i) for i in self.Fissure_list] - def redraw_content_dynamic(self): - self.Fissure_list = [Fissure(self.scrollAreaWidgetContents, fissure_info, fissure_i) for (fissure_i, fissure_info) in enumerate(self.ws.fissures)] - [self.verticalLayout_6.addWidget(i) for i in self.Fissure_list] - self.Invasion_list = [Invasion(self.scrollAreaWidgetContents_2, invasion_info, invasion_i) for (invasion_i, invasion_info) in enumerate(self.ws.invasions)] - [self.verticalLayout_8.addWidget(i) for i in self.Invasion_list] - self.Alert_list = [Alert(self.scrollAreaWidgetContents_3, alerta_info, alert_i) for (alert_i, alert_info) in enumerate(self.ws.alerts)] - [self.verticalLayout_16.addWidget(i) for i in self.Alert_list] - if len(self.ws.baro_items) == 0: - self.stackedWidget_2.setCurrentIndex(0) - else: - self.stackedWidget_2.setCurrentIndex(1) - self.baro_items_list = [BaroItem(self.BaroData, item_info, item_i) for (item_i, item_info) in enumerate(self.ws.baro_items)] - [self.gridLayout_6.addWidget(i, index // 7, index % 7, 1, 1) for (index, i) in enumerate(self.baro_items_list)] - self.events_list = [Event(self.scrollAreaWidgetContents_4, event_info, event_i) for (event_i, event_info) in enumerate(self.ws.events)] - [self.verticalLayout_31.addWidget(i) for i in self.events_list] - self.newsblurb_list = [NewsBlurb(self.scrollAreaWidgetContents_5, newsblurb_info, newsblurb_i) for (newsblurb_i, newsblurb_info) in enumerate(self.ws.news)] - [self.verticalLayout_33.addWidget(i) for i in self.newsblurb_list] + self.Invasion_list = [Invasion(self.scrollAreaWidgetContents_2, invasion_info, invasion_i) for (invasion_i, invasion_info) in enumerate(self.ws.invasions)] + [self.verticalLayout_8.addWidget(i) for i in self.Invasion_list] - def redraw_content_static(self): - pass - + self.Alert_list = [Alert(self.scrollAreaWidgetContents_3, alert_info, alert_i) for (alert_i, alert_info) in enumerate(self.ws.alerts)] + [self.verticalLayout_16.addWidget(i) for i in self.Alert_list] + + if len(self.ws.baro_items) == 0: + self.stackedWidget_2.setCurrentIndex(0) + else: + self.stackedWidget_2.setCurrentIndex(1) + self.baro_items_list = [BaroItem(self.BaroData, item_info, item_i) for (item_i, item_info) in enumerate(self.ws.baro_items)] + [self.gridLayout_6.addWidget(i, index // 7, index % 7, 1, 1) for (index, i) in enumerate(self.baro_items_list)] + + self.events_list = [Event(self.scrollAreaWidgetContents_4, event_info, event_i) for (event_i, event_info) in enumerate(self.ws.events)] + [self.verticalLayout_31.addWidget(i) for i in self.events_list] + + self.newsblurb_list = [NewsBlurb(self.scrollAreaWidgetContents_5, newsblurb_info, newsblurb_i) for (newsblurb_i, newsblurb_info) in enumerate(self.ws.news)] + [self.verticalLayout_33.addWidget(i) for i in self.newsblurb_list] + + def redraw_content_static(self): + for i in range(1, 4): + getattr(self, 'SortieM'+str(i)).setText(self.ws.sorties['variants'][i - 1]['missionType']) + getattr(self, 'SortieM' + str(i) + 'Mod').setText(self.ws.sorties['variants'][i-1]['modifier']) + + self.ArchonHuntStr.setText('Archon Hunt: ' + self.ws.archon_hunt['boss']) + for i in range(1, 4): + getattr(self, 'ArchonHuntM' + str(i)).setText(self.ws.archon_hunt['missions'][i - 1]['type']) + + if not self.ws.arbitration: + self.stackedWidget.setCurrentIndex(0) + else: + self.stackedWidget.setCurrentIndex(1) + self.ArbitrationMT.setText(self.ws.arbitration['type']) + self.ArbitrationFaction.setText(self.ws.arbitration['enemy']) + + daily_i = 1 + weekly_i = 1 + elite_i = 1 + if self.ws.nightwave: + self.stackedWidget_3.setCurrentIndex(1) + for challenge in self.ws.nightwave['activeChallenges']: + if challenge.get('isDaily'): + challenge_type = 'Daily' + challenge_i = daily_i + daily_i += 1 + elif challenge.get('isElite'): + challenge_type = 'Elite' + challenge_i = weekly_i + weekly_i += 1 + else: + challenge_type = 'Weekly' + challenge_i = elite_i + elite_i += 1 + getattr(self, challenge_type + str(challenge_i) + 'Name').setText(challenge['title']) + getattr(self, challenge_type + str(challenge_i) + 'Desc').setText(challenge['desc']) + else: + self.stackedWidget_3.setCurrentIndex(0) + + def update_timers(self): + [i.update_timer() for i in self.Fissure_list] + [i.update_progress() for i in self.Invasion_list] + [i.update_timer() for i in self.Alert_list] + [i.update_timer() for i in self.events_list] + [i.update_timer() for i in self.newsblurb_list] + + sortie_eta = round(time.mktime(time.strptime(self.ws.sorties['expiry'], '%Y-%m-%dT%H:%M:%S.%fZ')) - time.mktime(time.gmtime())) + if sortie_eta >= 0: + self.SortieResetTimer.setText(f'{str(sortie_eta // 3600) + "h " if sortie_eta // 3600 > 0 else ""}{(sortie_eta // 60) % 60}m {sortie_eta % 60}s') + else: + self.SortieResetTimer.setText('Expired') + + weekly_eta = round(time.mktime(time.strptime('1970-1-1T00:00:00.000Z', '%Y-%m-%dT%H:%M:%S.%fZ')) - time.mktime(time.gmtime()) - 3 * 86400) % (7 * 86400) + self.WeeklyResetTimeDayStr.setText(str(weekly_eta // 86400) + 'd') + self.WeeklyResetTimeStr.setText(f'{(weekly_eta // 3600) % 24}h {(weekly_eta // 60) % 60}m {weekly_eta % 60}s') + + bounty_eta = round(time.mktime(time.strptime('1970-1-1T00:00:00.000Z', '%Y-%m-%dT%H:%M:%S.%fZ')) - time.mktime(time.gmtime()) + 120) % (9000) + self.BountyTimeStr.setText(f'{bounty_eta // 3600}h {(bounty_eta // 60) % 60}m {bounty_eta % 60}s') + + baro_eta = round(time.mktime(time.strptime('1970-1-1T00:00:00.000Z', '%Y-%m-%dT%H:%M:%S.%fZ')) - time.mktime(time.gmtime()) + (10*86400 + 13 * 3600)) % (14 * 86400) + if baro_eta >= 2 * 86400: + self.BaroStateStr.setText('Baro Arrives in:') + baro_eta = baro_eta - 2 * 86400 + else: + self.BaroStateStr.setText('Baro Leaves in:') + self.BaroTimeStr.setText(f'{str(baro_eta // 86400) + "d " if baro_eta // 86400 > 0 else ""}{(baro_eta // 3600) % 24}h {(baro_eta // 60) % 60}m {baro_eta % 60}s') + + + def update_world_state(self): + if self.ws.get_ws(): + self.redraw_content() + else: + self.network_error() def network_error(self): msg = QMessageBox()