mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Фича недавних файлов
This commit is contained in:
parent
d6644783aa
commit
b98a4f39fd
@ -13,11 +13,12 @@ local MineOSInterface = require("MineOSInterface")
|
||||
|
||||
local resourcesPath = MineOSCore.getCurrentScriptDirectory()
|
||||
local toolsPath = resourcesPath .. "Tools/"
|
||||
local configPath = MineOSPaths.applicationData .. "Picture Edit/Config.cfg"
|
||||
local configPath = MineOSPaths.applicationData .. "Picture Edit/Config2.cfg"
|
||||
local savePath
|
||||
|
||||
local config = {
|
||||
recentColors = {},
|
||||
recentFiles = {},
|
||||
transparencyBackground = 0xFFFFFF,
|
||||
transparencyForeground = 0xD2D2D2,
|
||||
}
|
||||
@ -51,6 +52,17 @@ local function loadConfig()
|
||||
end
|
||||
end
|
||||
|
||||
local function addRecentFile(path)
|
||||
for i = 1, #config.recentFiles do
|
||||
if config.recentFiles[i] == path then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(config.recentFiles, 1, path)
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
loadConfig()
|
||||
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
@ -318,6 +330,7 @@ local function loadImage(path)
|
||||
local result, reason = image.load(path)
|
||||
if result then
|
||||
savePath = path
|
||||
addRecentFile(path)
|
||||
mainContainer.image.data = result
|
||||
mainContainer.image.reposition()
|
||||
else
|
||||
@ -329,12 +342,12 @@ local function saveImage(path)
|
||||
local result, reason = image.save(path, mainContainer.image.data, 6)
|
||||
if result then
|
||||
savePath = path
|
||||
addRecentFile(path)
|
||||
else
|
||||
GUI.error(reason)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
mainContainer.menu:addItem("PE", 0x00B6FF)
|
||||
|
||||
local fileItem = mainContainer.menu:addItem("File")
|
||||
@ -358,6 +371,15 @@ fileItem.onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
local subMenu = menu:addSubMenu("Open recent", #config.recentFiles == 0)
|
||||
for i = 1, #config.recentFiles do
|
||||
subMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
|
||||
loadImage(config.recentFiles[i])
|
||||
end
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
|
||||
menu:addItem("Save", not savePath).onTouch = function()
|
||||
saveImage(savePath)
|
||||
end
|
||||
|
||||
@ -1482,8 +1482,8 @@ local function contextMenuAddSeparator(menu, ...)
|
||||
return dropDownMenuAddSeparator(menu, ...)
|
||||
end
|
||||
|
||||
local function contextMenuAddSubMenu(menu, text)
|
||||
local item = menu:addItem(text, false, "►")
|
||||
local function contextMenuAddSubMenu(menu, text, disabled)
|
||||
local item = menu:addItem(text, disabled, "►")
|
||||
item.subMenu = GUI.contextMenu(1, 1)
|
||||
item.subMenu.colors = menu.colors
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user