asset.require("./inner_moons")
asset.require("./irregular_prograde_moons")
asset.require("./irregular_retrograde_moons")



local UranusMinorMoonsOn = {
  Identifier = "os.solarsystem.UranusMinorMoonsOn",
  Name = "Turn ON minor moons and trails",
  Command = [[
    local trails = openspace.getProperty("{moonTrail_minor_uranus}.Renderable.Enabled")
    local trails_fade = openspace.getProperty("{moonTrail_minor_uranus}.Renderable.Fade")

    local moons = openspace.getProperty("{moon_minor_uranus}.Renderable.Enabled")
    local moons_fade = openspace.getProperty("{moon_minor_uranus}.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 Uranus's minor moons and their trails",
  GuiPath = "/Solar System/Uranus",
  IsLocal = true
}

local UranusMinorMoonsOff = {
  Identifier = "os.solarsystem.UranusMinorMoonsOff",
  Name = "Turn OFF minors moon and trails",
  Command = [[
    local trails = openspace.getProperty("{moonTrail_minor_uranus}.Renderable.Enabled")
    local trails_fade = openspace.getProperty("{moonTrail_minor_uranus}.Renderable.Fade")

    local moons = openspace.getProperty("{moon_minor_uranus}.Renderable.Enabled")
    local moons_fade = openspace.getProperty("{moon_minor_uranus}.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 Uranus's minor moons and their trails",
  GuiPath = "/Solar System/Uranus",
  IsLocal = true
}


asset.onInitialize(function()
  openspace.action.registerAction(UranusMinorMoonsOn)
  openspace.action.registerAction(UranusMinorMoonsOff)
end)

asset.onDeinitialize(function()
  openspace.action.removeAction(UranusMinorMoonsOff)
  openspace.action.removeAction(UranusMinorMoonsOn)
end)

asset.export("UranusMinorMoonsOn", UranusMinorMoonsOn.Identifier)
asset.export("UranusMinorMoonsOff", UranusMinorMoonsOff.Identifier)



asset.meta = {
  Name = "Uranus Minor Moons",
  Version = "1.1",
  Description = [[Meta asset containing three moon groups: Inner Moons, Irregular Prograde
    Moons and Irregular Retrograde Moons]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
