Add action to hide all globe trails when approaching a planet/moon

This commit is contained in:
Emma Broman
2021-12-06 09:06:01 +01:00
parent 3638a118cb
commit 83b6345c86
3 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
local hide_trails = {
Identifier = "os.hide_all_globe_trails",
Name = "Hide All Trails (Planets and Moons)",
Command = [[
openspace.printInfo('Hide all trails')
local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled');
for _,v in pairs(list) do
-- openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v))
openspace.setPropertyValueSingle(v, false)
end
local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled');
for _,v in pairs(moonlist) do
openspace.setPropertyValueSingle(v, false)
end
]],
Documentation = [[Set the visiblility of the trials of all the moons and planets in
our solar system to false.]],
GuiPath = "/Trails",
IsLocal = true
}
asset.export("hide_trails", hide_trails.Identifier)
local show_trails = {
Identifier = "os.show_all_globe_trails",
Name = "Show All Trails (Planets and Moons)",
Command = [[
openspace.printInfo('Show all trails')
local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled');
for _,v in pairs(list) do
-- openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v))
openspace.setPropertyValueSingle(v, true)
end
local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled');
for _,v in pairs(moonlist) do
openspace.setPropertyValueSingle(v, true)
end
]],
Documentation = [[Set the visiblility of the trials of all the moons and planets in
our solar system to true.]],
GuiPath = "/Trails",
IsLocal = true
}
asset.export("show_trails", show_trails.Identifier)
asset.onInitialize(function()
openspace.action.registerAction(show_trails)
openspace.action.registerAction(hide_trails)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(show_trails.Identifier)
openspace.action.removeAction(hide_trails.Identifier)
end)

View File

@@ -0,0 +1,27 @@
local action = asset.require('actions/toggle_globe_trails')
asset.onInitialize(function()
openspace.event.registerEventAction(
"CameraFocusTransition",
action.show_trails,
{ Transition = "Exiting" }
);
openspace.event.registerEventAction(
"CameraFocusTransition",
action.hide_trails,
{ Transition = "Approaching" }
);
end)
asset.onDeinitialize(function()
openspace.event.unregisterEventAction(
"CameraFocusTransition",
action.show_trails,
{ Transition = "Exiting" }
);
openspace.event.unregisterEventAction(
"CameraFocusTransition",
action.hide_trails,
{ Transition = "Approaching" }
);
end)

View File

@@ -44,6 +44,7 @@
],
"assets": [
"base",
"events/toggle_globe_trails",
"scene/solarsystem/planets/earth/earth",
"scene/solarsystem/planets/earth/satellites/satellites",
"util/joysticks/T.A320 Pilot",