Jump to content

Clear Cache - Option in the editor


klepto2
 Share

Recommended Posts

I promote this suggestion because:

In the latest weeks you made a great progress with the editor, but while testing the editor with lots of files i found some things which could be made easier if a small clear cache function is integrated: Also this function is more or less a very easy one to implemnt.

  • In the latest updates you suggested multiple times to delete the thumbnail folder
  • The overall cache can grow extremely in size and to easily clean it up from the editor would be handy
  • the clear cache should be optionally global or per project
  • Upvote 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

I am pleased this worked perfectly. Just place this Lua file somewhere in Ultra Engine/Scripts/Start:

 

local extension = {}

function extension.NukeDir(path, extension)
    local files = LoadDir(path)
    for n = 1, #files do
        local filepath = path.."/"..files[n]
        if FileType(filepath) == 2 then
            extension.NukeDir(filepath, extension)
        else
            DeleteFile(filepath)
        end
    end
    DeleteDir(path)
end

function extension.hook(event, extension)
    if event.id == EVENT_WIDGETACTION then
        if event.source == extension.menuitem then
            local path = GetPath(PATH_PROGRAMDATA).."/Ultra Engine/Thumbnails"
            if FileType(path) == 2 then
                extension.NukeDir(path, extension)
            end
            Print("Thumbnail cache cleared.")
            return false
        end        
    end
end

--------------------------------------------------------------------
-- Add menu item
--------------------------------------------------------------------

local menu = program.menu:FindChild("Scripting", false)
if menu == nil then
    Print("Error: Could not find \"Scripting\" menu.")
    return
end

local submenu = menu:FindChild("Utilities", false)
if submenu == nil then
    submenu = CreateMenu("Utilities", menu)
end
extension.menuitem = CreateMenu("Clear thumbnail cache", submenu)

ListenEvent(EVENT_WIDGETACTION, extension.menuitem, extension.hook, extension)

 

 

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...