Skip to content

Commit 3c4dda5

Browse files
committed
Move ListEntry mod icon setting to a seperate function
1 parent 56dc797 commit 3c4dda5

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/gui/list-entry.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModEntry, ModEntryLocal } from '../types'
1+
import { ModEntry, ModEntryLocal, ModImageConfig } from '../types'
22
import { FileCache } from '../cache'
33
import './list-entry-highlight'
44
import { LocalMods } from '../local-mods'
@@ -28,6 +28,7 @@ declare global {
2828
modEntryActionButtons: sc.ButtonGui.Type & { ninepatch: ig.NinePatch }
2929
iconGui: ig.ImageGui
3030

31+
updateIcon(this: this, config: ModImageConfig): void
3132
tryDisableMod(this: this, mod: ModEntryLocal): string | undefined
3233
tryEnableMod(this: this, mod: ModEntryLocal): string | undefined
3334
toggleSelection(this: this, force?: boolean): string | undefined
@@ -74,13 +75,7 @@ modmanager.gui.ListEntry = ig.FocusGui.extend({
7475

7576
sc.Model.addObserver(modmanager.gui.menu, this)
7677
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))
8479

8580
const height = 42
8681
this.iconOffset = 25
@@ -176,6 +171,13 @@ modmanager.gui.ListEntry = ig.FocusGui.extend({
176171
}
177172
this.updateHighlightWidth()
178173
},
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+
},
179181
getModName() {
180182
let icon: string = ''
181183

0 commit comments

Comments
 (0)