Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Fixing multi-select file actions and new Workspace Tool Font
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed Apr 29, 2020
1 parent 4924fea commit ca7f3fd
Show file tree
Hide file tree
Showing 8 changed files with 462 additions and 218 deletions.
4 changes: 2 additions & 2 deletions Disks/PixelVisionOS/System/Tools/FontTool/saves.json
Expand Up @@ -3,8 +3,8 @@
"GameChip":
{
"savedData":{
"rootDirectory": "/Workspace/MyFirstGame/",
"sessionID": "202004241019252252"
"rootDirectory": "/Disks/PixelVisionOS/System/Tools/WorkspaceTool/",
"sessionID": "202004281823151383"
}
}
}
326 changes: 207 additions & 119 deletions Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-drop-down-menu.lua

Large diffs are not rendered by default.

Expand Up @@ -44,21 +44,21 @@ function WorkspaceTool:OnDeleteFile()
end

-- TODO how should this be handled if there are multiple selections
self.fileActionSrc = self.currentPath
-- self.fileActionSrc = self.currentPath

self.filesToCopy = {}
self.targetFiles = {}

-- Loop through all of the selections
for i = 1, #selections do

local srcPath = self.files[selections[i]].path

-- Make sure the selected directory is included
table.insert(self.filesToCopy, srcPath)
table.insert(self.targetFiles, srcPath)

end

-- print("Files", dump(self.filesToCopy))
-- print("Files", dump(self.targetFiles))

-- Always make sure anything going into the throw out has a unique file name
self:StartFileOperation(self.trashPath, "throw out")
Expand All @@ -75,32 +75,39 @@ function WorkspaceTool:StartFileOperation(destPath, action)

-- Exit out of the function
return

end

-- Set a modal flag so we know what warning to display
local fileActionFlag = 0

-- TODO need to loop through all of the files do pre-check
for i = 1, #self.filesToCopy do
for i = 1, #self.targetFiles do

-- Get the file to test
local filePath = self.filesToCopy[i]
local filePath = self.targetFiles[i]

-- Figure out the final path for the file
local finalDestPath = NewWorkspacePath(destPath.Path .. filePath.Path:sub(#self.currentPath.Path + 1))

-- Check to see if file is child of the destination path
if(filePath.IsChildOf(finalDestPath)) then
-- Set flag to 1 for a child path error
print("filePath", filePath.Path, destPath.Path, finalDestPath.Path)

if(filePath.isDirectory and filePath.Path == destPath.Path) then

fileActionFlag = 1
break

elseif(filePath.IsChildOf(finalDestPath)) then

-- Set flag to 2 for a child path error
fileActionFlag = 2
break

-- Test the final path only if it's not being moved to the throw out
elseif(PathExists(finalDestPath) and action ~= "throw out") then

-- Set flag to 2 for a douplicate file warning
fileActionFlag = 2
-- Set flag to 3 for a douplicate file warning
fileActionFlag = 3

break

Expand All @@ -112,16 +119,24 @@ function WorkspaceTool:StartFileOperation(destPath, action)

if(fileActionFlag == 1) then

pixelVisionOS:ShowMessageModal(
"Workspace Path Conflict",
"Can't perform a file action on a path that is the same as the destination path.",
128 + 16, false, function() self:CancelFileActions() end
)
return
elseif(fileActionFlag == 2) then

pixelVisionOS:ShowMessageModal(
"Workspace Path Conflict",
"Can't perform a file action on a path that is the child of the destination path.",
128 + 16, false, function() self:CancelFileActions() end
)
return

elseif(fileActionFlag == 2) then
elseif(fileActionFlag == 3) then

-- local duplicate = destPath.Path == self.filesToCopy[1].Path
-- local duplicate = destPath.Path == self.targetFiles[1].Path

-- Ask if the file first item should be duplicated
pixelVisionOS:ShowMessageModal(
Expand Down Expand Up @@ -152,7 +167,7 @@ function WorkspaceTool:StartFileOperation(destPath, action)

pixelVisionOS:ShowMessageModal(
"Workspace ".. action .." Action",
"Do you want to ".. action .. " " .. #self.filesToCopy .. " files?",
"Do you want to ".. action .. " " .. #self.targetFiles .. " files?",
160,
true,
function()
Expand Down Expand Up @@ -189,9 +204,9 @@ function WorkspaceTool:OnRunFileAction(destPath, action, duplicate)
-- Build the arguments
local args = { self.currentPath, destPath, action, duplicate}

for i = 1, #self.filesToCopy do
for i = 1, #self.targetFiles do

table.insert(args, self.filesToCopy[i])
table.insert(args, self.targetFiles[i])

end

Expand All @@ -209,7 +224,7 @@ function WorkspaceTool:OnRunFileAction(destPath, action, duplicate)
self.progressModal = ProgressModal:Init("File Action ", editorUI, function() self:CancelFileActions() end)

self.progressModal.fileAction = action
self.progressModal.totalFiles = (#self.filesToCopy - 2)
self.progressModal.totalFiles = (#self.targetFiles - 2)
end

-- Open the modal
Expand Down Expand Up @@ -238,6 +253,8 @@ function WorkspaceTool:UpdateFileActionProgress(data)
-- Refresh the window and get the new file list
self:RefreshWindow(true)

self.selectedFiles = nil

-- Remove the callback from the UI update loop
pixelVisionOS:RemoveUI("ProgressUpdate")

Expand Down Expand Up @@ -392,17 +409,17 @@ function WorkspaceTool:OnPaste(dest)

local paths = data.value

self.filesToCopy = {}
self.targetFiles = {}

for i = 1, #paths do

if(PathExists(paths[i])) then
table.insert(self.filesToCopy, paths[i])
table.insert(self.targetFiles, paths[i])
end

end

if(#self.filesToCopy) then
if(#self.targetFiles) then

pixelVisionOS:ClearClipboard()
self:StartFileOperation(dest, "copy")
Expand Down Expand Up @@ -649,13 +666,14 @@ end
function WorkspaceTool:CanEject()

local selections = self:CurrentlySelectedFiles()
print("selections", dump(selections))

if(selections == nil) then
return
end

for i = 1, #selections do
if(selections[i].type == "disk") then
if(self.files[selections[i]].type == "disk") then
return true
end
end
Expand Down
Expand Up @@ -143,7 +143,7 @@ function PixelVisionOS:CreateIconButtonStates(data, spriteName, text, bgColor)

for i = 1, #text do

lines[#lines] = lines[#lines] .. text:sub(i, i):upper()
lines[#lines] = lines[#lines] .. text:sub(i, i)--:upper()

if(i % maxWidth == 0 and i ~= #text)then
table.insert(lines, "")
Expand Down Expand Up @@ -186,7 +186,7 @@ function PixelVisionOS:CreateIconButtonStates(data, spriteName, text, bgColor)
end

-- Draw the text
canvas:DrawText(line, x, y, "medium", textColor, - 4)
canvas:DrawText(line, x, y, "medium5", textColor, - 4)

end

Expand Down Expand Up @@ -386,7 +386,7 @@ function PixelVisionOS:ToggleIconButton(data, value, callAction)
end

-- invert the selected value
data.selected = true
-- data.selected = true

-- Invalidate the button so it redraws
self.editorUI:Invalidate(data)
Expand Down Expand Up @@ -545,6 +545,8 @@ function PixelVisionOS:UpdateIconGroup(data)
return
end

data.isDragging = false

-- Set data for the total number of buttons for the loop
local total = #data.buttons
local btn = nil
Expand All @@ -558,6 +560,8 @@ function PixelVisionOS:UpdateIconGroup(data)
if(btn ~= nil) then
if(btn.dragging == true) then

data.isDragging = true

-- Look for drop targets
for i = 1, #self.editorUI.collisionManager.dragTargets do

Expand Down Expand Up @@ -643,6 +647,9 @@ function PixelVisionOS:UpdateIconGroup(data)

-- DrawPixels(btn.cachedPixelData["up"], 0,0)
self.editorUI:NewDraw("DrawPixels", data.drawIconArgs)

-- TODO need a file count when dragging
-- self.editorUI:NewDraw("DrawText", {string.format("%02d", 1), data.drawIconArgs[2], data.drawIconArgs[3], DrawMode.Sprite, "small", 15, -4})
end

end
Expand Down Expand Up @@ -676,7 +683,7 @@ function PixelVisionOS:SelectIconButton(data, id, trigger)

if(data.singleSelection == true) then
-- Make sure that the button is selected before we disable it
buttonData.selected = true
-- buttonData.selected = true
-- self:Enable(buttonData, false)

end
Expand Down

0 comments on commit ca7f3fd

Please sign in to comment.