asset.require("./base")
local trailAction = asset.require("actions/trails/toggle_trails_planets_moons").ToggleTrails



local TogglePlanetLabels = {
  Identifier = "os_default.TogglePlanetLabels",
  Name = "Toggle planet labels",
  Command = [[
    local list = openspace.getProperty("{solarsystem_labels}.Renderable.Enabled")
    for _,v in pairs(list) do
      openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v))
    end
  ]],
  Documentation = "Turns on visibility for all solar system labels",
  GuiPath = "/Solar System",
  IsLocal = false,
  Key = "l"
}

asset.onInitialize(function()
  openspace.action.registerAction(TogglePlanetLabels)
  openspace.bindKey(TogglePlanetLabels.Key, TogglePlanetLabels.Identifier)

  openspace.bindKey("h", trailAction)
end)

asset.onDeinitialize(function()
  openspace.clearKey("h")

  openspace.action.removeAction(TogglePlanetLabels)
  openspace.clearKey(TogglePlanetLabels.Key)
end)

asset.export("TogglePlanetLabels", TogglePlanetLabels.Identifier)
