asset.require("./triton/triton")
asset.require("./triton/default_layers")
asset.require("./nereid/nereid")



local NeptuneMajorMoonsOn = {
  Identifier = "os.solarsystem.NeptuneMajorMoonsOn",
  Name = "Turn on major moons and trails",
  Command = [[
    local trails = openspace.getProperty("{moonTrail_major_neptune}.Renderable.Enabled")
    local trails_fade = openspace.getProperty("{moonTrail_major_neptune}.Renderable.Fade")

    local moons = openspace.getProperty("{moon_major_neptune}.Renderable.Enabled")
    local moons_fade = openspace.getProperty("{moon_major_neptune}.Renderable.Fade")

    for i, v in pairs(trails_fade) do
      openspace.setPropertyValueSingle(trails[i], true)
      openspace.setPropertyValueSingle(v, 1, 2, "Linear")
    end

    for i, v in pairs(moons_fade) do
      openspace.setPropertyValueSingle(moons[i], true)
      openspace.setPropertyValueSingle(v, 1, 2, "Linear")
    end
  ]],
  Documentation = "Turn ON Neptune's major moons and their trails",
  GuiPath = "/Solar System/Neptune",
  IsLocal = true
}

local NeptuneMajorMoonsOff = {
  Identifier = "os.solarsystem.NeptuneMajorMoonsOff",
  Name = "Turn off majors moon and trails",
  Command = [[
    local trails = openspace.getProperty("{moonTrail_major_neptune}.Renderable.Enabled")
    local trails_fade = openspace.getProperty("{moonTrail_major_neptune}.Renderable.Fade")

    local moons = openspace.getProperty("{moon_major_neptune}.Renderable.Enabled")
    local moons_fade = openspace.getProperty("{moon_major_neptune}.Renderable.Fade")

    for i, v in pairs(trails_fade) do
      openspace.setPropertyValueSingle(
        v,
        0,
        2,
        "Linear",
        "openspace.setPropertyValueSingle('" .. trails[i] .. "', false)"
      )
    end

    for i, v in pairs(moons_fade) do
      openspace.setPropertyValueSingle(
        v,
        0,
        2,
        "Linear",
        "openspace.setPropertyValueSingle('" .. moons[i] .. "', false)"
      )
    end
  ]],
  Documentation = "Turn OFF Neptune's major moons and their trails",
  GuiPath = "/Solar System/Neptune",
  IsLocal = true
}


asset.onInitialize(function()
  openspace.action.registerAction(NeptuneMajorMoonsOn)
  openspace.action.registerAction(NeptuneMajorMoonsOff)
end)

asset.onDeinitialize(function()
  openspace.action.removeAction(NeptuneMajorMoonsOff)
  openspace.action.removeAction(NeptuneMajorMoonsOn)
end)

asset.export("NeptuneMajorMoonsOn", NeptuneMajorMoonsOn.Identifier)
asset.export("NeptuneMajorMoonsOff", NeptuneMajorMoonsOff.Identifier)



asset.meta = {
  Name = "Neptune Major Moons",
  Version = "1.0",
  Description = "Meta asset containing Neptune's major moons Triton and Nereid",
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
