|
1 | | -import { ModEntry, ModEntryLocal } from '../types' |
| 1 | +import { ModEntry, ModEntryLocal, ModImageConfig } from '../types' |
2 | 2 | import { FileCache } from '../cache' |
3 | 3 | import './list-entry-highlight' |
4 | 4 | import { LocalMods } from '../local-mods' |
@@ -28,6 +28,7 @@ declare global { |
28 | 28 | modEntryActionButtons: sc.ButtonGui.Type & { ninepatch: ig.NinePatch } |
29 | 29 | iconGui: ig.ImageGui |
30 | 30 |
|
| 31 | + updateIcon(this: this, config: ModImageConfig): void |
31 | 32 | tryDisableMod(this: this, mod: ModEntryLocal): string | undefined |
32 | 33 | tryEnableMod(this: this, mod: ModEntryLocal): string | undefined |
33 | 34 | toggleSelection(this: this, force?: boolean): string | undefined |
@@ -74,13 +75,7 @@ modmanager.gui.ListEntry = ig.FocusGui.extend({ |
74 | 75 |
|
75 | 76 | sc.Model.addObserver(modmanager.gui.menu, this) |
76 | 77 | const isGrid = Opts.isGrid |
77 | | - FileCache.getIconConfig(mod).then(config => { |
78 | | - const image = new ig.Image(config.path) |
79 | | - this.iconGui = new ig.ImageGui(image, config.offsetX, config.offsetY, config.sizeX, config.sizeY) |
80 | | - if (isGrid) this.iconGui.setPos(2, 2) |
81 | | - else this.iconGui.setPos(2, 8) |
82 | | - this.addChildGui(this.iconGui) |
83 | | - }) |
| 78 | + FileCache.getIconConfig(mod).then(config => this.updateIcon(config)) |
84 | 79 |
|
85 | 80 | const height = 42 |
86 | 81 | this.iconOffset = 25 |
@@ -176,6 +171,13 @@ modmanager.gui.ListEntry = ig.FocusGui.extend({ |
176 | 171 | } |
177 | 172 | this.updateHighlightWidth() |
178 | 173 | }, |
| 174 | + updateIcon(config) { |
| 175 | + const image = new ig.Image(config.path) |
| 176 | + this.iconGui = new ig.ImageGui(image, config.offsetX, config.offsetY, config.sizeX, config.sizeY) |
| 177 | + if (Opts.isGrid) this.iconGui.setPos(2, 2) |
| 178 | + else this.iconGui.setPos(2, 8) |
| 179 | + this.addChildGui(this.iconGui) |
| 180 | + }, |
179 | 181 | getModName() { |
180 | 182 | let icon: string = '' |
181 | 183 |
|
|
0 commit comments