diff --git a/Seraphine.pro b/Seraphine.pro index c596a3d5..a48fa82e 100644 --- a/Seraphine.pro +++ b/Seraphine.pro @@ -8,5 +8,6 @@ SOURCES += app/view/main_window.py \ app/components/game_infobar_widget.py \ app/components/loose_switch_setting_card.py \ app/components/mode_filter_widget.py \ + app/lol/tools.py \ TRANSLATIONS += app/resource/i18n/Seraphine.zh_CN.ts \ No newline at end of file diff --git a/app/components/game_infobar_widget.py b/app/components/game_infobar_widget.py index 66159d7c..08409129 100644 --- a/app/components/game_infobar_widget.py +++ b/app/components/game_infobar_widget.py @@ -208,11 +208,12 @@ def __updateIconColor(self, theme: Theme): class MapTime(QFrame): - def __init__(self, map, time, duration, parent=None): + def __init__(self, map, position, time, duration, parent=None): super().__init__(parent) self.vBoxLayout = QVBoxLayout(self) - self.mapLabel = QLabel(map) + self.mapLabel = QLabel( + f'{map} - {position}' if position != None else f'{map}') self.timeLabel = QLabel(f"{duration} · {time}") self.__initLayout() @@ -261,7 +262,8 @@ def __initWidget(self, game): game["cs"], game["gold"], ) - self.mapTime = MapTime(game["map"], game["time"], game["duration"]) + self.mapTime = MapTime( + game["map"], game['position'], game["time"], game["duration"]) self.__setColor(game["remake"], game["win"]) diff --git a/app/lol/tools.py b/app/lol/tools.py index 071ca2a5..a2ad4cff 100644 --- a/app/lol/tools.py +++ b/app/lol/tools.py @@ -1,9 +1,22 @@ import time +from PyQt5.QtCore import QObject + from ..common.config import cfg, Language from ..lol.connector import LolClientConnector, connector +class PositionTranslator(QObject): + def __init__(self, parent=None): + super().__init__(parent=parent) + + self.top = self.tr("TOP") + self.jungle = self.tr("JUG") + self.middle = self.tr("MID") + self.bottom = self.tr("BOT") + self.support = self.tr("SUP") + + def translateTier(orig: str, short=False) -> str: if orig == '': return "--" @@ -47,6 +60,8 @@ def secsToStr(secs): def processGameData(game): + # print(game) + timeStamp = game["gameCreation"] # 毫秒级时间戳 time = timeStampToStr(game['gameCreation']) shortTime = timeStampToShortStr(game['gameCreation']) @@ -93,6 +108,26 @@ def processGameData(game): remake = stats['gameEndedInEarlySurrender'] win = stats['win'] + timeline = participant['timeline'] + lane = timeline['lane'] + role = timeline['role'] + + position = None + + pt = PositionTranslator() + + if queueId in [420, 440]: + if lane == 'TOP': + position = pt.top + elif lane == "JUNGLE": + position = pt.jungle + elif lane == 'MIDDLE': + position = pt.middle + elif role == 'SUPPORT': + position = pt.support + elif lane == 'BOTTOM' and role == 'CARRY': + position = pt.bottom + return { 'queueId': queueId, 'gameId': gameId, @@ -116,6 +151,7 @@ def processGameData(game): 'cs': cs, 'gold': gold, 'timeStamp': timeStamp, + 'position': position, } diff --git a/app/resource/i18n/Seraphine.zh_CN.qm b/app/resource/i18n/Seraphine.zh_CN.qm index 2fc6dbcd..2c32ea68 100644 Binary files a/app/resource/i18n/Seraphine.zh_CN.qm and b/app/resource/i18n/Seraphine.zh_CN.qm differ diff --git a/app/resource/i18n/Seraphine.zh_CN.ts b/app/resource/i18n/Seraphine.zh_CN.ts index 7e5c9072..d5102ae2 100644 --- a/app/resource/i18n/Seraphine.zh_CN.ts +++ b/app/resource/i18n/Seraphine.zh_CN.ts @@ -238,47 +238,47 @@ CareerInterface - + Game Type 类型 - + Total 总场次 - + Win Rate 胜率 - + Wins 胜场 - + Losses 负场 - + Tier 段位 - + LP 胜点 - + Ranked Solo 单 / 双排 - + Ranked Flex 灵活排位 @@ -288,17 +288,17 @@ 连接中... - + All 全部 - + Normal 匹配模式 - + A.R.A.M. 极地大乱斗 @@ -328,7 +328,7 @@ 场) - + Remakes or Customs do not count in statistics 重开或自定义对局不计入统计 @@ -343,7 +343,7 @@ 历史战绩 - + Copy summoner name to ClipBoard 复制召唤师名 @@ -353,12 +353,12 @@ KDA: - + Highest tier 赛季最高 - + Previous end tier 上赛季结算 @@ -376,22 +376,22 @@ ChampionsCard - + Total: 总: - + Wins: 胜: - + Losses: 负: - + Win Rate: 胜率: @@ -591,7 +591,7 @@ MainWindow - + Career 生涯 @@ -601,47 +601,47 @@ 查查你的👀 - + Game Information 对局信息 - + Start LOL 启动游戏 - + Settings 设置 - + Auxiliary Functions 其他功能 - + LOL Client has been connected 客户端已连接 - + Invalid path 路径非法 - + Please set the correct directory of the LOL client in the setting page 请在设置页面中设置正确的 LOL 客户端路径 - + Start 启动页 - + Start LOL successfully 启动客户端成功 @@ -656,87 +656,87 @@ 未定级 - + Home 游戏大厅 - + Selecting Champions 英雄选择 - + Gaming 游戏中 - + Waiting for status 等待游戏结果 - + End of game 游戏结束 - + Lobby 房间组队中 - + Ready check 匹配确认 - + Match making 匹配中 - + Exception occurred 😥 程序出现异常 😥 - + Copy to clipboard 确认并复制到剪贴板 - + Cancel 取消 - + Search 👀 战绩查询 👀 - + Exit 直接退出 - + Minimize 最小化到任务栏 - + Quit 退出 - + Do you wish to exit? 您第一次点击了关闭按钮 - + Choose action for close button (you can modify it at any time in the settings page) 请选择点击关闭按钮的默认行为(您可以今后任意时间在设置界面修改它) @@ -746,12 +746,12 @@ 客户端请求超时 - + Check Update Failed 检查更新失败 - + Failed to check for updates, possibly unable to connect to Github. 请确保能连接至 GitHub @@ -761,37 +761,37 @@ 超时 - + Connect API 请求 API - + The server returned abnormal content, which may be under maintenance. 服务器返回了不正常内容,可能其正在维护中 - + Exceeded maximum retry attempts. 超出最大尝试次数 - + LCU request error 客户端信息请求失败 - + Blue Team 蓝色方 - + Red Team 红色方 - + Waiting reconnect 等待重新连接 @@ -880,6 +880,34 @@ 你想要改成的在线状态(签名): + + PositionTranslator + + + TOP + 上路 + + + + JUG + 打野 + + + + MID + 中路 + + + + BOT + 下路 + + + + SUP + 辅助 + + ProfileBackgroundCard @@ -1641,17 +1669,17 @@ when they are used by Seraphine, which will cost more time TeammateInfoBar - + Total: 总: - + Wins: 胜: - + Losses: 负: diff --git a/app/view/main_window.py b/app/view/main_window.py index 18592be1..dab83b39 100644 --- a/app/view/main_window.py +++ b/app/view/main_window.py @@ -5,6 +5,7 @@ import time import webbrowser from collections import Counter +from concurrent.futures import ThreadPoolExecutor, as_completed from PyQt5.QtCore import Qt, pyqtSignal, QSize, QAbstractAnimation from PyQt5.QtGui import QIcon, QImage, QCursor @@ -36,7 +37,6 @@ processRankInfo, getTeammates, assignTeamId, parseGames) import threading -from concurrent.futures import ThreadPoolExecutor, as_completed class MainWindow(FluentWindow):