Skip to content

Commit a41474e

Browse files
committed
Add modmanager.openModOptionsMenu
1 parent bdfe7ac commit a41474e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/gui/options/mod-options-menu.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { ModEntry } from '../../types'
22
import { GuiOption, ModOptionsSettings } from '../../mod-options'
3+
import { LocalMods } from '../../local-mods'
34

45
declare global {
6+
namespace modmanager {
7+
function openModOptionsMenu(modId: string): void
8+
}
59
namespace modmanager.gui {
610
interface OptionsMenu extends sc.BaseMenu, sc.Model.Observer {
711
mod: ModEntry
@@ -38,6 +42,19 @@ declare global {
3842
}
3943
}
4044

45+
modmanager.openModOptionsMenu = (modId: string) => {
46+
const record = LocalMods.getAllRecord()
47+
const mod = record[modId]
48+
if (!mod) throw new Error(`Mod: "${modId}" does not have options menu!`)
49+
if (sc.menu.currentMenu == sc.MENU_SUBMENU.START) {
50+
sc.menu.setDirectMode(true, sc.MENU_SUBMENU.MOD_OPTIONS)
51+
sc.model.enterMenu(true)
52+
} else {
53+
sc.menu.pushMenu(sc.MENU_SUBMENU.MOD_OPTIONS)
54+
}
55+
modmanager.gui.optionsMenu.updateEntries(mod)
56+
}
57+
4158
modmanager.gui.OptionsMenu = sc.BaseMenu.extend({
4259
init() {
4360
this.parent()

0 commit comments

Comments
 (0)