]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Allow toggling of texture pack by double clicking
authorYaman Qalieh <ybq987@gmail.com>
Wed, 24 Feb 2021 10:50:19 +0000 (05:50 -0500)
committerGitHub <noreply@github.com>
Wed, 24 Feb 2021 10:50:19 +0000 (11:50 +0100)
builtin/mainmenu/tab_content.lua

index 336730bf4d7ea84ca558fcf831885b361503b47a..fb7f121f81f8e1373adb96c01bda091918daafa3 100644 (file)
@@ -145,11 +145,26 @@ local function get_formspec(tabview, name, tabdata)
        return retval
 end
 
+--------------------------------------------------------------------------------
+local function handle_doubleclick(pkg)
+       if pkg.type == "txp" then
+               if core.settings:get("texture_path") == pkg.path then
+                       core.settings:set("texture_path", "")
+               else
+                       core.settings:set("texture_path", pkg.path)
+               end
+               packages = nil
+       end
+end
+
 --------------------------------------------------------------------------------
 local function handle_buttons(tabview, fields, tabname, tabdata)
        if fields["pkglist"] ~= nil then
                local event = core.explode_table_event(fields["pkglist"])
                tabdata.selected_pkg = event.row
+               if event.type == "DCL" then
+                       handle_doubleclick(packages:get_list()[tabdata.selected_pkg])
+               end
                return true
        end