0.2.2 • Published 7 months ago

starfield-ts-ml-config-menu v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

starfield-ts-config-menu

Config Menu allows you to modify the config on each plugin without having to restart the modloader.

Main menu image

Adding support on your plugin

npm i starfield-ts-ml-config-menu

Then, you can import the config menu client, and add a configuration:

import { getConfigMenuClient } from 'starfield-ts-ml-configmenu/dist/src/client'
...
const pluginConfig = {
  plugin: 'plugin-name', // You put here the unique plugin name, so it can be identified in the menu
  config: this.pluginConfig, // You put here your config
  hook: `/plugin-endpoint/update-config` // You define here the hook where the config menu is going to call with the updated config. Is going to be called everytime a field is edited
}
getConfigMenuClient(this.config).addConfig(pluginConfig)
...
// Next, you define the hook endpoint
await this.mlContext.httpServer.add('/plugin-endpoint/update-config', async (config): Promise<string> => {
  // You can define here how you want to treat the updated config received
  this.pluginConfig = config as unknown as IYourPluginConfigType
  serializeConfig('plugins/plugin-name/config.yml', this.pluginConfig) // On this example, we just update the config and store it in disk again
  return 'OK'
}, HTTPMethod.Post)

Configuration

The configuration for this mod in config.yml is mainly to define the position where the config window is going to be shown.

position:
  x: 1
  y: 1
  z: 0
size:
  x: 500
  y: 500
xAxis: 'right'
yAxis: 'top'

Requirements

My other mods