mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Moved bookmarks file to live in user folder, auto create default if it does not exists
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
Group (optional),Name (required),Globe (optional),Lat (required if globe),Lon (required if globe),Altitude (optional if globe),x (required if not globe),y (required if not globe),z (required if not globe),Scale (optional),LineWidth (optional)
|
||||
NASA,Kennedy Space Center,Earth,28.6658276,-80.70282839,,,,,,
|
||||
|
@@ -4,12 +4,32 @@ local bookmarkHelper = asset.require("util/generate_bookmarks")
|
||||
-- ensure that it is loaded first
|
||||
asset.require("scene/solarsystem/planets/earth/earth")
|
||||
|
||||
local localBookmarks = openspace.absPath("${USER}/bookmarks/localbookmarks.csv")
|
||||
|
||||
-- Returns true if the file exists and can be opened for reading and false otherwise
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
return f~=nil and io.close(f)
|
||||
end
|
||||
|
||||
-- Create bookmarks file if it does not exist
|
||||
if not file_exists(localBookmarks) then
|
||||
local file = io.open(localBookmarks, "w")
|
||||
file:write(
|
||||
"Group (optional),Name (required),Globe (optional),Lat (required if globe)," ..
|
||||
"Lon (required if globe),Altitude (optional if globe),x (required if not globe)," ..
|
||||
"y (required if not globe),z (required if not globe),Scale (optional)," ..
|
||||
"LineWidth (optional)\n" ..
|
||||
"NASA,Kennedy Space Center,Earth,28.6658276,-80.70282839,,,,,,\n"
|
||||
)
|
||||
file:close()
|
||||
end
|
||||
|
||||
local nodes = bookmarkHelper.loadBookmarks(
|
||||
"Local Bookmarks",
|
||||
"${ASSETS}/customization/localbookmarks.csv"
|
||||
"${USER}/bookmarks/localbookmarks.csv"
|
||||
)
|
||||
|
||||
|
||||
asset.onInitialize(function()
|
||||
for _, n in ipairs(nodes) do
|
||||
local success, error = pcall(openspace.addSceneGraphNode, n)
|
||||
|
||||
Reference in New Issue
Block a user