Skip to content

Commit

Permalink
给生涯界面下方的对局信息中加入排位模式位置信息 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Oct 30, 2023
1 parent 96bfead commit 658d345
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 63 deletions.
1 change: 1 addition & 0 deletions Seraphine.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions app/components/game_infobar_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"])

Expand Down
36 changes: 36 additions & 0 deletions app/lol/tools.py
Original file line number Diff line number Diff line change
@@ -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 "--"
Expand Down Expand Up @@ -47,6 +60,8 @@ def secsToStr(secs):


def processGameData(game):
# print(game)

timeStamp = game["gameCreation"] # 毫秒级时间戳
time = timeStampToStr(game['gameCreation'])
shortTime = timeStampToShortStr(game['gameCreation'])
Expand Down Expand Up @@ -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,
Expand All @@ -116,6 +151,7 @@ def processGameData(game):
'cs': cs,
'gold': gold,
'timeStamp': timeStamp,
'position': position,
}


Expand Down
Binary file modified app/resource/i18n/Seraphine.zh_CN.qm
Binary file not shown.
Loading

0 comments on commit 658d345

Please sign in to comment.