builtin: Move common/async_event.lua to mainmenu/async_event.lua
authorsfan5 <sfan5@live.de>
Fri, 15 May 2020 14:38:19 +0000 (16:38 +0200)
committersfan5 <sfan5@live.de>
Sun, 17 May 2020 19:37:01 +0000 (21:37 +0200)
It only works in the context of the mainmenu.

builtin/common/async_event.lua [deleted file]
builtin/mainmenu/async_event.lua [new file with mode: 0644]
builtin/mainmenu/init.lua

diff --git a/builtin/common/async_event.lua b/builtin/common/async_event.lua
deleted file mode 100644 (file)
index 988af79..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-
-core.async_jobs = {}
-
-local function handle_job(jobid, serialized_retval)
-       local retval = core.deserialize(serialized_retval)
-       assert(type(core.async_jobs[jobid]) == "function")
-       core.async_jobs[jobid](retval)
-       core.async_jobs[jobid] = nil
-end
-
-if core.register_globalstep then
-       core.register_globalstep(function(dtime)
-               for i, job in ipairs(core.get_finished_jobs()) do
-                       handle_job(job.jobid, job.retval)
-               end
-       end)
-else
-       core.async_event_handler = handle_job
-end
-
-function core.handle_async(func, parameter, callback)
-       -- Serialize function
-       local serialized_func = string.dump(func)
-
-       assert(serialized_func ~= nil)
-
-       -- Serialize parameters
-       local serialized_param = core.serialize(parameter)
-
-       if serialized_param == nil then
-               return false
-       end
-
-       local jobid = core.do_async_callback(serialized_func, serialized_param)
-
-       core.async_jobs[jobid] = callback
-
-       return true
-end
-
diff --git a/builtin/mainmenu/async_event.lua b/builtin/mainmenu/async_event.lua
new file mode 100644 (file)
index 0000000..04bfb78
--- /dev/null
@@ -0,0 +1,32 @@
+
+core.async_jobs = {}
+
+local function handle_job(jobid, serialized_retval)
+       local retval = core.deserialize(serialized_retval)
+       assert(type(core.async_jobs[jobid]) == "function")
+       core.async_jobs[jobid](retval)
+       core.async_jobs[jobid] = nil
+end
+
+core.async_event_handler = handle_job
+
+function core.handle_async(func, parameter, callback)
+       -- Serialize function
+       local serialized_func = string.dump(func)
+
+       assert(serialized_func ~= nil)
+
+       -- Serialize parameters
+       local serialized_param = core.serialize(parameter)
+
+       if serialized_param == nil then
+               return false
+       end
+
+       local jobid = core.do_async_callback(serialized_func, serialized_param)
+
+       core.async_jobs[jobid] = callback
+
+       return true
+end
+
index 130c3e73cf61a518ab86486e3ee43f638487ddcd..c17e792702f89fafb640d068153003b6a8fccec5 100644 (file)
@@ -20,20 +20,18 @@ mt_color_blue  = "#6389FF"
 mt_color_green = "#72FF63"
 mt_color_dark_green = "#25C191"
 
---for all other colors ask sfan5 to complete his work!
-
 local menupath = core.get_mainmenu_path()
 local basepath = core.get_builtin_path()
 local menustyle = core.settings:get("main_menu_style")
 defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
                                        DIR_DELIM .. "pack" .. DIR_DELIM
 
-dofile(basepath .. "common" .. DIR_DELIM .. "async_event.lua")
 dofile(basepath .. "common" .. DIR_DELIM .. "filterlist.lua")
 dofile(basepath .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
 dofile(basepath .. "fstk" .. DIR_DELIM .. "dialog.lua")
 dofile(basepath .. "fstk" .. DIR_DELIM .. "tabview.lua")
 dofile(basepath .. "fstk" .. DIR_DELIM .. "ui.lua")
+dofile(menupath .. DIR_DELIM .. "async_event.lua")
 dofile(menupath .. DIR_DELIM .. "common.lua")
 dofile(menupath .. DIR_DELIM .. "pkgmgr.lua")
 dofile(menupath .. DIR_DELIM .. "textures.lua")