From edc250deb843e2caca6781a15cc519c71c795748 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 31 Dec 2017 23:26:38 -0500 Subject: [PATCH] Cleanup core script extensions Cleanup default scripts --- data/assets/dawn.scene | 8 ++--- data/assets/default.scene | 8 ++--- data/assets/juno.scene | 8 ++--- data/assets/newhorizons.scene | 8 ++--- data/assets/osirisrex.scene | 8 ++--- data/assets/rosetta.scene | 8 ++--- .../missions/voyager/voyager2.asset | 3 +- data/assets/voyager.scene | 8 ++--- scripts/bind_common_keys.lua | 20 ----------- scripts/common_scripts.lua | 20 ----------- .../{scene_helper.lua => core_scripts.lua} | 34 ++++++++++++++----- src/engine/openspaceengine.cpp | 2 +- src/scene/scene.cpp | 3 -- 13 files changed, 57 insertions(+), 81 deletions(-) delete mode 100644 scripts/bind_common_keys.lua delete mode 100644 scripts/common_scripts.lua rename scripts/{scene_helper.lua => core_scripts.lua} (70%) diff --git a/data/assets/dawn.scene b/data/assets/dawn.scene index b708734f3f..55f91b8b88 100644 --- a/data/assets/dawn.scene +++ b/data/assets/dawn.scene @@ -19,10 +19,10 @@ local DawnAsset = asset.require('scene/solarsystem/missions/dawn/dawn') asset.onInitialize(function () openspace.time.setTime("2011 AUG 06 00:00:00") - openspace.set_default_dashboard() - openspace.set_default_gui_sorting() + openspace.setDefaultDashboard() + openspace.setDefaultGuiSorting() - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "Dawn", "Ceres", "Vesta" }) @@ -45,7 +45,7 @@ end) asset.onDeinitialize(function () openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "Dawn", "Ceres", "Vesta" }) end) diff --git a/data/assets/default.scene b/data/assets/default.scene index 304ca39320..364d38fcab 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -60,14 +60,14 @@ asset.onInitialize(function () openspace.time.setTime(openspace.time.currentWallTime()) sceneHelper.bindKeys(Keybindings) - openspace.set_default_dashboard() - openspace.set_default_gui_sorting() + openspace.setDefaultDashboard() + openspace.setDefaultGuiSorting() openspace.globebrowsing.loadWMSServersFromFile( openspace.absPath("${DATA}/globebrowsing_servers.lua") ) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "Earth", "Mars", "Moon" }) @@ -96,7 +96,7 @@ asset.onDeinitialize(function () openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "Earth", "Mars", "Moon" }) end) diff --git a/data/assets/juno.scene b/data/assets/juno.scene index 11553fef04..f42cd27d5d 100644 --- a/data/assets/juno.scene +++ b/data/assets/juno.scene @@ -17,15 +17,15 @@ local junoAsset = asset.require('scene/solarsystem/missions/juno/juno') asset.onInitialize(function () openspace.time.setTime("2016-07-01T10:05:00.00") - openspace.set_default_dashboard() - openspace.set_default_gui_sorting() + openspace.setDefaultDashboard() + openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ 1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400, 28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600 }) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "Jupiter", "Juno" }) @@ -49,7 +49,7 @@ end) asset.onDeinitialize(function () openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "Jupiter", "Juno" }) end) diff --git a/data/assets/newhorizons.scene b/data/assets/newhorizons.scene index 2b7294122a..7dc6f9f881 100644 --- a/data/assets/newhorizons.scene +++ b/data/assets/newhorizons.scene @@ -133,7 +133,7 @@ asset.onInitialize(function () openspace.time.setTime("2015-07-14T08:00:00.00") sceneHelper.bindKeys(Keybindings) - openspace.set_default_dashboard() + openspace.setDefaultDashboard() openspace.dashboard.addDashboardItem({ Type = "DashboardItemSpacing", Spacing = 25 @@ -151,14 +151,14 @@ asset.onInitialize(function () Type = "DashboardItemInstruments" }) - openspace.set_default_gui_sorting() + openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ 1, 5, 10, 20, 40, 60, 120, 360, 540, 1080, 2160, 4320, 8640 }) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "Pluto", "NewHorizons", "Charon" }) @@ -183,7 +183,7 @@ asset.onDeinitialize(function () sceneHelper.unbindKeys(Keybindings) openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "Pluto", "NewHorizons", "Charon" }) end) diff --git a/data/assets/osirisrex.scene b/data/assets/osirisrex.scene index e01840cd74..556981a006 100644 --- a/data/assets/osirisrex.scene +++ b/data/assets/osirisrex.scene @@ -83,7 +83,7 @@ asset.onInitialize(function () openspace.time.setTime("2016 SEP 8 23:00:00.500") sceneHelper.bindKeys(Keybindings) - openspace.set_default_dashboard() + openspace.setDefaultDashboard() openspace.dashboard.addDashboardItem({ Type = "DashboardItemSpacing", Spacing = 25 @@ -101,14 +101,14 @@ asset.onInitialize(function () Type = "DashboardItemInstruments" }) - openspace.set_default_gui_sorting() + openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ 1, 5, 10, 20, 40, 60, 120, 360, 540, 1080, 2160, 4320, 8640 }) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "OsirisRex", "BennuBarycenter", "Earth" }) @@ -133,7 +133,7 @@ asset.onDeinitialize(function () sceneHelper.unbindKeys(Keybindings) openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "OsirisRex", "BennuBarycenter", "Earth" }) end) diff --git a/data/assets/rosetta.scene b/data/assets/rosetta.scene index 899477a5a4..93f37fa291 100644 --- a/data/assets/rosetta.scene +++ b/data/assets/rosetta.scene @@ -84,7 +84,7 @@ asset.onInitialize(function () openspace.time.setTime("2014-08-01T03:05:00.000") sceneHelper.bindKeys(Keybindings) - openspace.set_default_dashboard() + openspace.setDefaultDashboard() openspace.dashboard.addDashboardItem({ Type = "DashboardItemSpacing", Spacing = 25 @@ -102,14 +102,14 @@ asset.onInitialize(function () Type = "DashboardItemInstruments" }) - openspace.set_default_gui_sorting() + openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ 1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400, 28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600 }) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "67P", "Rosetta", "Philae" }) @@ -136,7 +136,7 @@ asset.onDeinitialize(function () sceneHelper.unbindKeys(Keybindings) openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "67PBarycenter", "Rosetta", "Philae" }) end) diff --git a/data/assets/scene/solarsystem/missions/voyager/voyager2.asset b/data/assets/scene/solarsystem/missions/voyager/voyager2.asset index ef3af105b9..c4253d5a65 100644 --- a/data/assets/scene/solarsystem/missions/voyager/voyager2.asset +++ b/data/assets/scene/solarsystem/missions/voyager/voyager2.asset @@ -278,5 +278,6 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { VoyagerTrailCruiseSaturnUranus, VoyagerTrailEncounterUranus, VoyagerTrailCruiseUranusNeptune, - VoyagerTrailEncounterNeptune + VoyagerTrailEncounterNeptune, + VoyagerTrailCruiseNeptuneInf }) diff --git a/data/assets/voyager.scene b/data/assets/voyager.scene index 7db4c1d8cd..9bce0d584e 100644 --- a/data/assets/voyager.scene +++ b/data/assets/voyager.scene @@ -24,15 +24,15 @@ local VoyagerAsset = asset.require('scene/solarsystem/missions/voyager/voyager1' asset.onInitialize(function () openspace.time.setTime("1977 SEP 10 12:00:00") - openspace.set_default_dashboard() - openspace.set_default_gui_sorting() + openspace.setDefaultDashboard() + openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ 1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400, 28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600 }) - openspace.mark_interesting_nodes({ + openspace.markInterestingNodes({ "Earth", "Voyager 1", "Voyager 2", "Jupiter", "Saturn", "Uranus", "Neptune" }) @@ -55,7 +55,7 @@ end) asset.onDeinitialize(function () openspace.removeVirtualProperty("*Trail.renderable.Enabled") - openspace.remove_interesting_nodes({ + openspace.removeInterestingNodes({ "Earth", "Voyager 1", "Voyager 2", "Jupiter", "Saturn", "Uranus", "Neptune" }) end) diff --git a/scripts/bind_common_keys.lua b/scripts/bind_common_keys.lua deleted file mode 100644 index 3101b7945e..0000000000 --- a/scripts/bind_common_keys.lua +++ /dev/null @@ -1,20 +0,0 @@ ---[[ OpenSpace keybinding script ]]-- - --- Load the common helper functions -dofile(openspace.absPath('${SCRIPTS}/common.lua')) - -openspace.clearKeys() -helper.setCommonKeys() -helper.setDeltaTimeKeys({ --- 1 2 3 4 5 6 7 8 9 0 --------------------------------------------------------------------------------------------------------------------------- --- 1s 2s 5s 10s 30s 1m 2m 5m 10m 30m - 1, 2, 5, 10, 30, 60, 120, 300, 600, 1800, - --- 1h 2h 3h 6h 12h 1d 2d 4d 1w 2w - 3600, 7200, 10800, 21600, 43200, 86400, 172800, 345600, 604800, 1209600, - --- 1mo 2mo 3mo 6mo 1yr 2y 5y 10y 20y 50y - 2592000, 5184000, 7776000, 15552000, 31536000, 63072000, 157680000, 315360000, 630720000, 1576800000 -}) --- OBS: One month (1mo) is approximated by 30 days. diff --git a/scripts/common_scripts.lua b/scripts/common_scripts.lua deleted file mode 100644 index 5c3475edc5..0000000000 --- a/scripts/common_scripts.lua +++ /dev/null @@ -1,20 +0,0 @@ -openspace.documentation = { - { - Name = "rebindKey", - Arguments = "string, string", - Documentation = "Rebinds all scripts from the old key (first argument) to the " .. - "new key (second argument)." - } -} - -openspace.rebindKey = function(old_key, new_key) - local t = openspace.getKeyBinding(old_key) - openspace.clearKey(old_key) - for _, v in pairs(t) do - if v["Remote"] then - openspace.bindKey(new_key, v["Command"]) - else - openspace.bindKeyLocal(new_key, v["Command"]) - end - end -end diff --git a/scripts/scene_helper.lua b/scripts/core_scripts.lua similarity index 70% rename from scripts/scene_helper.lua rename to scripts/core_scripts.lua index 91c39ab0b8..6467fbfefd 100644 --- a/scripts/scene_helper.lua +++ b/scripts/core_scripts.lua @@ -1,36 +1,42 @@ openspace.documentation = { { - Name = "mark_interating_nodes", + Name = "markInteratingNodes", Arguments = "List of nodes", Documentation = "This function marks the scene graph nodes identified by name " .. "as interesting, which will provide shortcut access to focus buttons and " .. "featured properties." }, { - Name = "remove_interesting_nodes", + Name = "removeInterestingNodes", Arguments = "List of nodes", Documentation = "This function removes unmarks the scene graph nodes " .. "identified by name as interesting, thus removing the shortcuts from the " .. "features properties list." }, { - Name = "set_default_gui_sorting", + Name = "setDefaultGuiSorting", Arguments = "", Documentation = "This function sets the default GUI sorting for the space " .. "environment to increasing size, from solar system, through Milky Way, " .. "Universe and finishing with other elements" }, { - Name = "set_default_dashboard", + Name = "setDefaultDashboard", Arguments = "", Documentation = "This function sets the default values for the dashboard " .. "consisting of 'DashboardItemDate', 'DashboardItemSimulationIncrement', " .. "'DashboardItemDistance', 'DashboardItemFramerate', and " .. "'DashboardItemParallelConnection'." + }, + { + Name = "rebindKey", + Arguments = "string, string", + Documentation = "Rebinds all scripts from the old key (first argument) to the " .. + "new key (second argument)." } } -openspace.mark_interesting_nodes = function(nodes) +openspace.markInterestingNodes = function(nodes) for _, n in pairs(nodes) do if openspace.hasSceneGraphNode(n) then openspace.addTag(n, "GUI.Interesting") @@ -38,7 +44,7 @@ openspace.mark_interesting_nodes = function(nodes) end end -openspace.remove_interesting_nodes = function(nodes) +openspace.removeInterestingNodes = function(nodes) for _, n in pairs(nodes) do if openspace.hasSceneGraphNode(n) then openspace.removeTag(n, "GUI.Interesting") @@ -46,7 +52,7 @@ openspace.remove_interesting_nodes = function(nodes) end end -openspace.set_default_dashboard = function() +openspace.setDefaultDashboard = function() openspace.dashboard.addDashboardItem({ Type = "DashboardItemDate" }) @@ -68,7 +74,7 @@ openspace.set_default_dashboard = function() }) end -openspace.set_default_gui_sorting = function() +openspace.setDefaultGuiSorting = function() openspace.setPropertyValueSingle( 'Global Properties.ImGUI.Main.Properties.Ordering', { @@ -76,3 +82,15 @@ openspace.set_default_gui_sorting = function() } ) end + +openspace.rebindKey = function(oldKey, newKey) + local t = openspace.getKeyBinding(oldKey) + openspace.clearKey(oldKey) + for _, v in pairs(t) do + if v["Remote"] then + openspace.bindKey(newKey, v["Command"]) + else + openspace.bindKeyLocal(newKey, v["Command"]) + end + end +end diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 48a3c667ac..8c548ee60a 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1535,7 +1535,7 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() { } }, { - absPath("${SCRIPTS}/common_scripts.lua") + absPath("${SCRIPTS}/core_scripts.lua") } }; } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 5f6a940b8a..fc41935d2e 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -613,9 +613,6 @@ scripting::LuaLibrary Scene::luaLibrary() { "Checks whether the specifies SceneGraphNode is present in the current " "scene" } - }, - { - absPath("${SCRIPTS}/scene_helper.lua") } }; }