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

战绩查询功能重构等 #67

Merged
merged 14 commits into from
Sep 21, 2023
Merged
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
2 changes: 2 additions & 0 deletions app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Config(QConfig):
teamGamesNumber = RangeConfigItem("Functions", "TeamGamesNumber", 1,
RangeValidator(1, 10))

gameInfoFilter = ConfigItem("Functions", "GameInfoFilter", False, BoolValidator())

showTierInGameInfo = ConfigItem("Functions", "ShowTierInGameInfo", False,
BoolValidator())
enableAutoAcceptMatching = ConfigItem("Functions",
Expand Down
1 change: 1 addition & 0 deletions app/common/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Icon(FluentIconBase, Enum):
LOCK = 'Lock'
TEAM = 'Team'
SETTING = 'Setting'
FILTER = 'Filter'

def path(self, theme=Theme.AUTO):
return f'./app/resource/icons/{self.value}_{getIconColor(theme)}.svg'
15 changes: 7 additions & 8 deletions app/components/mode_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def __init__(self, parent=None):

self.selected: List[int] = []

self.hBoxLayout = QVBoxLayout(self)
self.hBoxLayout.setAlignment(Qt.AlignCenter)
self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setAlignment(Qt.AlignCenter)

# TODO 本地化
self.rankSoloCheckBox = CheckBox(self.tr("Ranked solo"))
self.rankFlexCheckBox = CheckBox(self.tr("Ranked Flex"))
self.normalCheckBox = CheckBox(self.tr("Normal"))
Expand All @@ -34,15 +33,15 @@ def __init__(self, parent=None):
checkBox.stateChanged.connect(
lambda state, num=num: self.updateSelected(state, num))

self.hBoxLayout.addWidget(
self.vBoxLayout.addWidget(
self.rankSoloCheckBox, alignment=Qt.AlignLeft)
self.hBoxLayout.addWidget(
self.vBoxLayout.addWidget(
self.rankFlexCheckBox, alignment=Qt.AlignLeft)
self.hBoxLayout.addWidget(
self.vBoxLayout.addWidget(
self.normalCheckBox, alignment=Qt.AlignLeft)
self.hBoxLayout.addWidget(self.aramCheckBox, alignment=Qt.AlignLeft)
self.vBoxLayout.addWidget(self.aramCheckBox, alignment=Qt.AlignLeft)

self.setLayout(self.hBoxLayout)
self.setLayout(self.vBoxLayout)

def updateSelected(self, state, num, callback=None):
if state == Qt.Checked:
Expand Down
1 change: 1 addition & 0 deletions app/resource/icons/Filter_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/resource/icons/Filter_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ def updateGameInfoInterface(callback=None):
summoners = []
data = connector.getChampSelectSession()

isRank = bool(data["myTeam"][0]["assignedPosition"]) # 排位会有预选位

def process_item(item):
summonerId = item["summonerId"]

Expand All @@ -797,6 +799,17 @@ def process_item(item):
origGamesInfo = connector.getSummonerGamesByPuuid(
puuid, 0, 14)

if cfg.get(cfg.gameInfoFilter) and isRank:
origGamesInfo["games"] = [game for game in origGamesInfo["games"] if game["queueId"] in (420, 440)]
begIdx = 15
while len(origGamesInfo["games"]) < 11:
endIdx = begIdx + 5
origGamesInfo["games"].extend([
game for game in connector.getSummonerGamesByPuuid(puuid, begIdx, endIdx)["games"]
if game["queueId"] in (420, 440)
])
begIdx = endIdx + 1

gamesInfo = [processGameData(game)
for game in origGamesInfo["games"][:11]]

Expand Down Expand Up @@ -937,6 +950,17 @@ def process_item(item):
origGamesInfo = connector.getSummonerGamesByPuuid(
puuid, 0, 14)

if cfg.get(cfg.gameInfoFilter) and queueId in (420, 440):
origGamesInfo["games"] = [game for game in origGamesInfo["games"] if game["queueId"] in (420, 440)]
begIdx = 15
while len(origGamesInfo["games"]) < 11:
endIdx = begIdx + 5
origGamesInfo["games"].extend([
game for game in connector.getSummonerGamesByPuuid(puuid, begIdx, endIdx)["games"]
if game["queueId"] in (420, 440)
])
begIdx = endIdx + 1

gamesInfo = [processGameData(game)
for game in origGamesInfo["games"][0:11]]

Expand Down Expand Up @@ -1051,10 +1075,8 @@ def _():
def __onCareerInterfaceGameInfoBarClicked(self, gameId):
name = self.careerInterface.name.text()
self.searchInterface.searchLineEdit.setText(name)
self.searchInterface.gamesView.gamesTab.triggerByButton = False
self.searchInterface.gamesView.gamesTab.updatePuuid(
self.careerInterface.puuid)
self.searchInterface.gamesView.gamesTab.tabClicked.emit(gameId)
self.searchInterface.gamesView.gamesTab.triggerGameId = gameId
self.searchInterface.searchButton.click()

def __onCareerInterfaceRefreshButtonClicked(self):
self.__onSearchInterfaceSummonerNameClicked(
Expand Down
Loading