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

Commit

Permalink
Cleaning up disk eject.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 1, 2020
1 parent 141d528 commit 0606977
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 143 deletions.
10 changes: 5 additions & 5 deletions Disks/PixelVisionOS/System/Tools/TextEditorTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"GameChip":
{
"savedData":{
"targetFile": "/Workspace/NewProjectB/code.lua",
"sessionID": "202004300651588082",
"rootDirectory": "/Workspace/HelloWorld/",
"cursor": "1,1",
"scroll": "1,1",
"selectedSprite": "0",
"scroll": "1,1"
"cursor": "1,1",
"rootDirectory": "/Workspace/HelloWorld/",
"sessionID": "202005011328585504",
"targetFile": "/Workspace/MouseWheelTest/code.lua"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,52 +170,34 @@ function WorkspaceTool:CreateDropDownMenu()

end

function WorkspaceTool:OnEjectDisk()
function WorkspaceTool:OnEjectDisk(diskPath)

local selections = self:CurrentlySelectedFiles()

if(#selections > 1) then
return
end
if(diskPath == nil) then

local diskName = self.files[selections[1]].name
local selections = self:CurrentlySelectedFiles()

-- if(diskName == nil) then
-- local id = desktopIconButtons.currentSelection
-- diskName = desktopIcons[id].name
-- end
if(#selections > 1) then
return
end

diskPath = self.files[selections[1]].name
end

pixelVisionOS:ShowMessageModal("Eject Disk", "Do you want to eject the '".. diskName.."'disk?", 160, true,
pixelVisionOS:ShowMessageModal("Eject Disk", "Do you want to eject the '".. diskPath.EntityName .."'disk?", 160, true,
function()

-- Only perform the copy if the user selects OK from the modal
if(pixelVisionOS.messageModal.selectionValue) then

-- if(currentDirectory ~= nil) then
EjectDisk(diskPath)

-- -- Close the window of the disk you are trying to eject
-- if(currentDirectory.GetDirectorySegments()[1] == "disk" and currentDirectory.GetDirectorySegments()[2] == diskName) then
-- CloseWindow()
-- end

-- end

EjectDisk(NewWorkspacePath("/Disks/" .. diskName .. "/"))

-- ResetGame()


self:OpenWindow(self.workspacePath)

-- self:RefreshWindow(true)
ResetGame()

end

end
)



end


Expand Down
15 changes: 12 additions & 3 deletions Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,17 @@ function WorkspaceTool:FileDropAction(src, dest)
-- print("Trash")
action = "move"
elseif(destSeg[1] == "Tmp" and destSeg[2] == "Trash") then
-- print("Trash")
action = "throw out"

if(#selections == 1 and self.files[selections[1]].type == "disk") then

self:OnEjectDisk(self.files[selections[1]].path)

return

else
-- print("Trash")
action = "throw out"
end
elseif(srcSeg[1] == "Disks" and destSeg[1] == "Disks") then
if(srcSeg[2] ~= destSeg[2]) then
action = "copy"
Expand All @@ -873,7 +882,7 @@ function WorkspaceTool:FileDropAction(src, dest)
end

-- Perform the file action
self:StartFileOperation(self.currentPath, destPath, action)
-- self:StartFileOperation(self.currentPath, destPath, action)

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,98 +66,6 @@ function WorkspaceTool:Init()

end

function WorkspaceTool:Update(timeDelta)

-- This needs to be the first call to make sure all of the OS and editor UI is updated first
pixelVisionOS:Update(timeDelta)



-- -- Loop through all of the registered UI and update them
-- for i = 1, self.uiTotal do

-- -- Get a reference to the UI data
-- local ref = self.uiComponents[i]

-- if(ref ~= nil) then

-- -- Only update UI when the modal is not active
-- if(pixelVisionOS:IsModalActive() == false or ref.ignoreModal) then

-- -- Call the UI scope's update and pass back in the UI data
-- ref.uiScope[ref.uiUpdate](ref.uiScope, ref.uiData)

-- end

-- end

-- end

end

function WorkspaceTool:Draw()

-- The UI should be the last thing to draw after your own custom draw calls
pixelVisionOS:Draw()

end

-- function WorkspaceTool:RegisterUI(data, updateCall, scope, ignoreModal)

-- scope = scope or pixelVisionOS

-- -- Try to remove an existing instance of the component
-- self:RemoveUI(data.name)

-- table.insert(self.uiComponents, {uiData = data, uiUpdate = updateCall, uiScope = scope, ignoreModal = ignoreModal or false})

-- self.uiTotal = #self.uiComponents

-- -- Return an instance of the component
-- return data

-- end

-- function WorkspaceTool:RemoveUI(name)

-- local i
-- local removeItem = -1

-- for i = 1, self.uiTotal do

-- if(self.uiComponents[i].uiData.name == name) then

-- -- Set the remove flag to true
-- removeItem = i

-- -- Exit out of the loop
-- break

-- end

-- end

-- -- If there is nothing to remove than exit out of the function
-- if(removeItem == -1) then
-- return
-- end

-- -- Remove item
-- table.remove(self.uiComponents, removeItem)

-- -- Update the total
-- self.uiTotal = #self.uiComponents

-- -- For debugging

-- print("Remove", removeItem, "total", self.uiTotal)

-- for i = 1, #self.uiComponents do
-- print("Left over", self.uiComponents[i].uiData.name)
-- end

-- end

function WorkspaceTool:Shutdown()

-- Save the current session ID
Expand Down
7 changes: 4 additions & 3 deletions Disks/PixelVisionOS/System/Tools/WorkspaceTool/code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function Update(timeDelta)
return
end

-- Update the workspace tool
workspaceTool:Update(timeDelta)
-- This needs to be the first call to make sure all of the OS and editor UI is updated first
pixelVisionOS:Update(timeDelta)


end
Expand Down Expand Up @@ -85,7 +85,8 @@ function Draw()
return
end

workspaceTool:Draw()
-- The UI should be the last thing to draw after your own custom draw calls
pixelVisionOS:Draw()

end

Expand Down
6 changes: 3 additions & 3 deletions Disks/PixelVisionOS/System/Tools/WorkspaceTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"GameChip":
{
"savedData":{
"sessionID": "202005011154504346",
"scrollPos": "0",
"lastPath": "/Workspace/",
"selection": "0",
"lastPath": "/Workspace/NewProjectB/"
"scrollPos": "0",
"sessionID": "202005011553217454"
}
}
}
10 changes: 4 additions & 6 deletions Runners/PixelVision8/Runner/PixelVision8Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,15 @@ private bool AwaitDebuggerAttach()

public void EjectDisk(string path)
{
// ejectingDisk = true;
ejectingDisk = true;

workspaceServicePlus.RemoveDisk(WorkspacePath.Parse(path));

// workspaceServicePlus.EjectDisk(WorkspacePath.Parse(path));
workspaceServicePlus.EjectDisk(WorkspacePath.Parse(path));

UpdateDiskInBios();

// AutoLoadDefaultGame();
AutoLoadDefaultGame();

// ejectingDisk = false;
ejectingDisk = false;
}

public void EnableAutoRun(bool value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public override void ShutdownSystem()
public void EjectDisk(WorkspacePath filePath)
{
RemoveDisk(filePath);

// What happens when there are no disks
if (TotalDisks > 1)
try
Expand Down

0 comments on commit 0606977

Please sign in to comment.