Skip to content

Commit ee90ec6

Browse files
committed
Improve menu opening performance and fix ocasional icon loading errors
1 parent 8a80479 commit ee90ec6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/gui/filters.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare global {
1313
onHide: () => void
1414

1515
getLangData(this: this, key: keyof typeof Lang.filters): { name: string; description: string }
16-
setFilterValue(this: this, config: CheckboxConfig, state: boolean): void
16+
setFilterValue(this: this, config: CheckboxConfig, state: boolean, noReload?: boolean): void
1717
getFilterValue(this: this, config: CheckboxConfig): boolean | undefined
1818
show(this: this): void
1919
hide(this: this): void
@@ -89,7 +89,7 @@ modmanager.gui.FiltersPopup = ig.GuiElementBase.extend({
8989
getLangData(key) {
9090
return Lang.filters[key]
9191
},
92-
setFilterValue(config, state) {
92+
setFilterValue(config, state, noReload) {
9393
const filters = modmanager.gui.menu.list.filters
9494
if ('optsKey' in config) {
9595
Opts[config.optsKey] = state
@@ -99,11 +99,13 @@ modmanager.gui.FiltersPopup = ig.GuiElementBase.extend({
9999
if (state) filters.tags.push(name)
100100
else filters.tags.erase(name)
101101
}
102-
modmanager.gui.menu.list.reloadFilters()
103-
/* hack to get the popup button group on top again, because the main mod menu button group got pushed on top when sc.modMenu.list.reloadFilters() is called */
104-
const arr: sc.ButtonGroup[] = sc.menu.buttonInteract.buttonGroupStack
105-
const last: number = arr.length
106-
;[arr[last - 2], arr[last - 1]] = [arr[last - 1], arr[last - 2]]
102+
if (!noReload) {
103+
modmanager.gui.menu.list.reloadFilters()
104+
/* hack to get the popup button group on top again, because the main mod menu button group got pushed on top when sc.modMenu.list.reloadFilters() is called */
105+
const arr: sc.ButtonGroup[] = sc.menu.buttonInteract.buttonGroupStack
106+
const last: number = arr.length
107+
;[arr[last - 2], arr[last - 1]] = [arr[last - 1], arr[last - 2]]
108+
}
107109
},
108110
getFilterValue(config) {
109111
const filters = modmanager.gui.menu.list.filters
@@ -160,7 +162,7 @@ modmanager.gui.FiltersPopup = ig.GuiElementBase.extend({
160162
}
161163
if (val !== undefined) {
162164
checkbox.setPressed(val)
163-
this.setFilterValue(config, val)
165+
this.setFilterValue(config, val, true)
164166
}
165167

166168
checkbox.onButtonPress = () => {

0 commit comments

Comments
 (0)