Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

功能更新: BP阶段提示红蓝方; 自动重连 #96

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Config(QConfig):
enableAutoAcceptMatching = ConfigItem("Functions",
"EnableAutoAcceptMatching", False,
BoolValidator())
enableAutoReconnect = ConfigItem("Functions",
"EnableAutoReconnect", False,
BoolValidator())

autoAcceptMatchingDelay = RangeConfigItem(
"Functions", "AutoAcceptMatchingDelay", 0, RangeValidator(0, 11))

Expand All @@ -83,8 +87,8 @@ class Config(QConfig):
)

enableCheckUpdate = ConfigItem("General",
"EnableCheckUpdate", True,
BoolValidator())
"EnableCheckUpdate", True,
BoolValidator())

# enableCopyPlayersInfo = ConfigItem("Functions", "EnableCopyPlayersInfo",
# False, BoolValidator())
Expand Down
1 change: 1 addition & 0 deletions app/common/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Icon(FluentIconBase, Enum):
SETTING = 'Setting'
FILTER = 'Filter'
UPDATE = 'Update'
CONNECTION = "Connection"

def path(self, theme=Theme.AUTO):
return f'./app/resource/icons/{self.value}_{getIconColor(theme)}.svg'
15 changes: 15 additions & 0 deletions app/lol/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ def setTierShowed(self, queue, tier, division):

return res

@retry()
def reconnect(self):
"""
重新连接

@return:
"""
return self.__post("/lol-gameflow/v1/reconnect")

@retry()
def removeTokens(self):
reference = self.__get("/lol-chat/v1/me").json()
Expand Down Expand Up @@ -498,6 +507,12 @@ def getGameStatus(self):

return res

@retry()
def getMapSide(self):
js = self.__get("/lol-champ-select/v1/pin-drop-notification").json()

return js.get("mapSide", "")

@retry()
def getReadyCheckStatus(self):
res = self.__get("/lol-matchmaking/v1/ready-check").json()
Expand Down
7 changes: 7 additions & 0 deletions app/view/auxiliary_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def __init__(self, parent=None):
"Accept match making automatically after the number of seconds you set"),
cfg.enableAutoAcceptMatching, cfg.autoAcceptMatchingDelay,
self.gameGroup)
self.autoReconnectCard = SwitchSettingCard(
Icon.CONNECTION,
self.tr("Auto reconnect"),
self.tr("Automatically reconnect when disconnected"),
cfg.enableAutoReconnect, self.gameGroup)
self.spectateCard = SpectateCard(
self.tr("Spectate"),
self.tr("Spectate live game of summoner in the same environment"),
Expand Down Expand Up @@ -115,6 +120,7 @@ def __initLayout(self):

# 游戏
self.gameGroup.addSettingCard(self.autoAcceptMatchingCard)
self.gameGroup.addSettingCard(self.autoReconnectCard)
self.gameGroup.addSettingCard(self.autoSelectChampionCard)
# self.gameGroup.addSettingCard(self.copyPlayersInfoCard)
self.gameGroup.addSettingCard(self.createPracticeLobbyCard)
Expand Down Expand Up @@ -163,6 +169,7 @@ def setEnabled(self, a0: bool) -> None:
self.autoSelectChampionCard.switchButton.setEnabled(True)

self.lockConfigCard.setEnabled(a0)
self.autoReconnectCard.setEnabled(a0)

return super().setEnabled(a0)

Expand Down
23 changes: 23 additions & 0 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,13 @@ def __onGameStatusChanged(self, status):
self.__onGameEnd()
elif status == 'ChampSelect':
title = self.tr("Selecting Champions")

# 在标题添加所处队伍
mapSide = connector.getMapSide()
if mapSide:
mapSide = self.tr("Blue Team") if mapSide == "blue" else self.tr("Red Team")
title = title + " - " + mapSide

self.__onChampionSelectBegin()
self.isChampSelected = True
elif status == 'GameStart':
Expand All @@ -838,6 +845,9 @@ def __onGameStatusChanged(self, status):
elif status == 'Matchmaking':
title = self.tr("Match making")
self.__onGameEnd()
elif status == "Reconnect": # 等待重连
title = self.tr("Waiting reconnect")
self.__onReconnect()

if not isGaming and self.isGaming:
self.__updateCareerGames()
Expand All @@ -861,6 +871,19 @@ def _():

threading.Thread(target=_).start()

def __onReconnect(self):
"""
自动重连
@return:
"""
if cfg.get(cfg.enableAutoReconnect):
def _():
while connector.getGameStatus() == "Reconnect":
time.sleep(.3) # 掉线立刻重连会无效;
connector.reconnect()

threading.Thread(target=_).start()

# 英雄选择界面触发事件
def __onChampionSelectBegin(self):

Expand Down