Use main-window menus, cache maps, and handle settled sweep events
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
from PySide6 import QtCore as C, QtWidgets as W
|
||||
|
||||
from .daily import DailyPolicy, entries
|
||||
from .maps import stages
|
||||
from .native_widgets import ComboBox, IntegerInput, RowBatch
|
||||
from .presentation import map_source
|
||||
from .stage_cache import StageCache
|
||||
from .sweeping import SweepPolicy
|
||||
from .table_widgets import SORT_ROLE, TreeItem, bind_controls, set_value, table_item
|
||||
|
||||
@@ -28,7 +27,7 @@ class ActivityPages:
|
||||
self.only_unlocked.setChecked(True)
|
||||
for widget in (self.map_search, self.only_unlocked):
|
||||
line.addWidget(widget)
|
||||
for label, function in (("刷新关卡", self.refresh), ("展开地区", lambda: self.maps_tree.expandAll()),
|
||||
for label, function in (("刷新关卡", self.refresh_maps), ("展开地区", lambda: self.maps_tree.expandAll()),
|
||||
("折叠地区", lambda: self.maps_tree.collapseAll())):
|
||||
button = W.QPushButton(label)
|
||||
button.clicked.connect(function)
|
||||
@@ -69,7 +68,7 @@ class ActivityPages:
|
||||
for col, width in enumerate((100, 82, 160, 130, 70, 210, 120, 340, 100, 92)):
|
||||
self.maps_tree.setColumnWidth(col, width)
|
||||
layout.addWidget(self.maps_tree, 1)
|
||||
note = W.QLabel("星级来自实际通关难度,不能手动修改。普通关卡三个难度全部通关后可扫荡;每行勾选、选择难度并输入本日次数上限。\n未满足扫荡条件的关卡请在游戏内手动战斗;扫荡按表格顺序逐关执行,使用所选战队。掉落来自安装包配置,随机物品并非必掉。")
|
||||
note = W.QLabel("地图按账号保存在本地,点击“刷新关卡”才更新列表。星级来自实际通关难度,不能手动修改。\n普通关卡三个难度全部通关后可扫荡;未满足条件的关卡请在游戏内手动战斗。每行勾选、选择难度并输入本日次数上限,使用所选战队。随机掉落并非必得。")
|
||||
note.setWordWrap(True)
|
||||
layout.addWidget(note)
|
||||
self.tabs.addTab(self.map_page, "自动扫荡")
|
||||
@@ -83,6 +82,21 @@ class ActivityPages:
|
||||
import copy
|
||||
return SweepPolicy(self.map_enabled.isChecked(), copy.deepcopy(self.map_rules), self.map_keep_ti.value(), self.map_team.currentData())
|
||||
|
||||
def reset_map_view(self):
|
||||
if hasattr(self, "map_render_timer"):
|
||||
self.map_render_timer.stop()
|
||||
self.maps_tree.clear()
|
||||
self._map_items, self._map_cities = {}, {}
|
||||
|
||||
def refresh_maps(self):
|
||||
if self.closed:
|
||||
return
|
||||
if self.busy:
|
||||
self.pending_refresh = self.map_page
|
||||
self.statusBar().showMessage("当前请求完成后刷新关卡")
|
||||
return
|
||||
self.submit("map_refresh", self.engine.refresh_stages)
|
||||
|
||||
def activity_settings_changed(self, *args):
|
||||
if self.closed or self.loading_config:
|
||||
return
|
||||
@@ -114,8 +128,9 @@ class ActivityPages:
|
||||
if isinstance(focused, W.QLineEdit) and self.maps_tree.isAncestorOf(focused):
|
||||
return
|
||||
snapshot = self.engine.snapshot
|
||||
views = self.prepared_views
|
||||
all_rows = views.maps if views and views.snapshot is snapshot and views.map_source == map_source(snapshot) else stages(self.catalog, snapshot)
|
||||
if self.engine.stage_cache.catalog is not self.catalog:
|
||||
self.engine.stage_cache = StageCache(self.catalog)
|
||||
all_rows = self.engine.stage_cache.get(snapshot)
|
||||
grouped = {}
|
||||
for row in all_rows:
|
||||
grouped.setdefault(row.stage_id, []).append(row)
|
||||
@@ -141,7 +156,6 @@ class ActivityPages:
|
||||
self.map_render_timer = RowBatch(self)
|
||||
wanted = {row[0] for row in visible}
|
||||
operations = [("remove", key) for key in self._map_items if key not in wanted] + [("row", row) for row in visible]
|
||||
first_render = not self.maps_tree.topLevelItemCount()
|
||||
self.maps_tree.setSortingEnabled(False)
|
||||
def apply(operation):
|
||||
kind, data = operation
|
||||
@@ -156,8 +170,10 @@ class ActivityPages:
|
||||
if city is None:
|
||||
city = TreeItem(self.maps_tree, [first.city_name])
|
||||
city.setFirstColumnSpanned(True)
|
||||
city.setExpanded(first_render or bool(query))
|
||||
city.setExpanded(bool(query))
|
||||
self._map_cities[first.city] = city
|
||||
elif query:
|
||||
city.setExpanded(True)
|
||||
item = self._map_items.get(key)
|
||||
if item is None:
|
||||
item = TreeItem(city)
|
||||
|
||||
Reference in New Issue
Block a user