WohlSoft / LunaLua

LunaLua - LunaDLL with Lua, is a free extension mod for SMBX 1.3 game engine, core of the X2 project.
https://codehaus.moe/
GNU General Public License v3.0
33 stars 12 forks source link

List extra settings parsing #58

Closed Emral closed 11 months ago

Emral commented 1 year ago

Adding this block allows SMBX2's extra settings parser to properly populate arbitrary list extra settings. Here's one of those JSON files in practice, if you'd like to take a look. Unlike other extra settings, the "children" object serves as the template from which fields for each element are generated:


  "style": "groupbox",
  "title": "Crate Settings",
  "layout": [
    {
    "control": "listGroup",
    "name": "contentList",
      "collapse": true,
      "default-collapsed": false,
    "title": "Contents",
    "children": [
        {
          "control": "itemSelect",
          "name": "npc",
          "title": "NPC",
          "type": "npc",
          "tooltip": "Which NPC should be in the crate.",
          "value-default": 0
        },
        {
                    "control": "spinBox",
                    "type": "int",
                    "name": "count",
                    "title" : "Amount",
          "tooltip": "Number of this NPC to spawn.",
                    "value-default": 1,
                    "value-min": 1,
                    "value-max": 99
                },
        {
          "control": "group",
          "collapse": true,
          "default-collapsed": true,
          "name": "advanced",
          "title": "Advanced Data",
          "children": [
          {
            "control": "spinBox",
            "type": "int",
            "name": "stack",
            "title" : "Stack",
            "tooltip": "Spawns additional NPCs in a stack. Can be positive (down) or negative (up). Useful for Pokeys or Ladders.",
            "value-default": 0,
            "value-min": -50,
            "value-max": 50
          },
          {
            "control": "spinBox",
            "type": "double",
            "name": "speed",
            "title" : "Speed",
            "tooltip": "Velocity of the NPC when the crate breaks.",
            "value-default": 4.5,
            "value-min": 0,
            "value-max": 16
          },
          {
            "control": "spinBox",
            "type": "double",
            "name": "angle",
            "title" : "Angle",
            "tooltip": "Angle of the NPC on ejection.",
            "value-default": 45,
            "value-min": -180,
            "value-max": 180
          },
          {
            "control": "checkBox",
            "name": "angleDirection",
            "title" : "Throw-based angle",
            "tooltip": "Whether or not the angle depends on throw direction.",
            "value-default": true
          },
          {
            "control": "spinBox",
            "type": "double",
            "name": "delay",
            "title" : "Delay",
            "tooltip": "Time spent intangible after coming out of the crate.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 90
          },
          {
            "control": "checkBox",
            "name": "floaty",
            "title" : "Floaty",
            "tooltip": "If true, the NPC has no gravity acting upon it during the intangible period.",
            "value-default": false
          },
          {
            "control": "int",
            "type": "int",
            "name": "ai1",
            "title" : "Ai1",
            "tooltip": "Ai1 field of the spawned NPC.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 99999
          },
          {
            "control": "int",
            "type": "int",
            "name": "ai2",
            "title" : "Ai2",
            "tooltip": "Ai2 field of the spawned NPC.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 99999
          },
          {
            "control": "int",
            "type": "int",
            "name": "ai3",
            "title" : "Ai3",
            "tooltip": "Ai3 field of the spawned NPC.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 99999
          },
          {
            "control": "int",
            "type": "int",
            "name": "ai4",
            "title" : "Ai4",
            "tooltip": "Ai4 field of the spawned NPC.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 99999
          },
          {
            "control": "int",
            "type": "int",
            "name": "ai5",
            "title" : "Ai5",
            "tooltip": "Ai5 field of the spawned NPC.",
            "value-default": 0,
            "value-min": 0,
            "value-max": 99999
          },
          {
            "control": "checkBox",
            "name": "friendly",
            "title" : "Friendly",
            "tooltip": "If true, the NPC spawns as friendly.",
            "value-default": false
          },
          {
            "control": "checkBox",
            "name": "dontMove",
            "title" : "Don't Move",
            "tooltip": "If true, the NPC spawns with the Don't Move flag set.",
            "value-default": false
          },
          {
            "control": "lineEdit",
            "name": "layerName",
            "title": "Layer Name",
            "tooltip": "Layer to spawn the NPC onto.",
            "value-default": ""
          },
          {
            "control": "lineEdit",
            "name": "noMoreObjInLayer",
            "title": "Layer is Empty Event",
            "tooltip": "Event to trigger when the layer is empty.",
            "value-default": ""
          },
          {
            "control": "lineEdit",
            "name": "deathEvent",
            "title": "Death Event",
            "tooltip": "Event to trigger when the spawned NPC dies.",
            "value-default": ""
          },
          {
            "control": "lineEdit",
            "name": "talkEventName",
            "title": "Talk Event",
            "tooltip": "Event to trigger when the NPC is talked to.",
            "value-default": ""
          }
        ]}
            ]
        }
  ]
}```
Emral commented 1 year ago

DRAT i just realized an oversight. The default values of the template is lost in the transition. Preparing a fix.

Emral commented 12 months ago

I've updated the pull request with the fix to the issue that defaults weren't properly copied to lua. I also set my visual studio to use spaces instead of tabs so if it's still using tabs, microsoft's being rebellious for some reason.