From d95280abbd573f460a401a57969e0b5198809f28 Mon Sep 17 00:00:00 2001 From: Jesse Freeman Date: Wed, 6 Jan 2021 09:53:11 -0500 Subject: [PATCH] Rebuilding Info Tool to support switching between C# and Lua Runners. Also mfixed issues in text editor with saving, showing line numbers, and highlighting call backs. --- .../Libs/pixel-vision-ui-text-editor-v2.lua | 2 +- .../Tools/InfoTool/code-build-panel.lua | 222 ++++++++++++++++ .../Tools/InfoTool/code-drop-down-menu.lua | 106 +++++++- .../Tools/InfoTool/code-game-info-panel.lua | 138 +++++++++- .../System/Tools/InfoTool/code-info-tool.lua | 249 +++++------------- .../Tools/InfoTool/code-library-panel.lua | 167 ++++++++++++ .../Tools/InfoTool/code-runner-panel.lua | 48 ++++ .../System/Tools/InfoTool/tilemap.png | Bin 2503 -> 2517 bytes .../TextEditorTool/code-drop-down-menu.lua | 13 +- .../TextEditorTool/code-editor-panel.lua | 4 +- .../Tools/TextEditorTool/code-text-tool.lua | 18 +- .../Tools/WorkspaceTool/code-window.lua | 4 + PixelVision8Lite.CoreDesktop.csproj | 31 +-- ProgramLite.cs | 57 ++-- 14 files changed, 799 insertions(+), 260 deletions(-) create mode 100644 Disks/PixelVisionOS/System/Tools/InfoTool/code-build-panel.lua create mode 100644 Disks/PixelVisionOS/System/Tools/InfoTool/code-library-panel.lua create mode 100644 Disks/PixelVisionOS/System/Tools/InfoTool/code-runner-panel.lua diff --git a/Disks/PixelVisionOS/System/Libs/pixel-vision-ui-text-editor-v2.lua b/Disks/PixelVisionOS/System/Libs/pixel-vision-ui-text-editor-v2.lua index 119b9011..0fb10829 100755 --- a/Disks/PixelVisionOS/System/Libs/pixel-vision-ui-text-editor-v2.lua +++ b/Disks/PixelVisionOS/System/Libs/pixel-vision-ui-text-editor-v2.lua @@ -17,7 +17,7 @@ function EditorUI:CreateTextEditor(rect, text, toolTip, font, colorOffset) comment = 6, -- string = 11, -- api = 7, -- - callback = 15, -- + callback = 8, -- escape = 15, -- disabled = 5, -- } diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-build-panel.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-build-panel.lua new file mode 100644 index 00000000..23c9a077 --- /dev/null +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-build-panel.lua @@ -0,0 +1,222 @@ +--[[ + Pixel Vision 8 - Draw Tool + Copyright (C) 2017, Pixel Vision 8 (http://pixelvision8.com) + Created by Jesse Freeman (@jessefreeman) + + Please do not copy and distribute verbatim copies + of this license document, but modifications without + distributing is allowed. +]]-- + +local buildInfoPanelID = "BuildInfoPanel" + +function InfoTool:CreateBuildInfoPanel() + + local buildFlagWin = editorUI:CreateToggleButton({x = 200, y = 176+ 24, w = 8, h = 8}, "checkbox", "Create a Windows executable.") + + buildFlagWin.onAction = function(value) + + self:InvalidateData() + + end + + local winRunnerExists = PathExists(NewWorkspacePath(self.buildTemplatePaths[1].path)) + + if(winRunnerExists) then + editorUI:ToggleButton(buildFlagWin, gameEditor:ReadMetadata(self.buildFlagLabels[1]) == "true") + end + + editorUI:Enable(buildFlagWin, winRunnerExists) + + table.insert(self.buildFlagCheckboxes, buildFlagWin) + + local buildFlagMac = editorUI:CreateToggleButton({x = 200, y = 184+ 24, w = 8, h = 8}, "checkbox", "Create a Mac App.") + + + buildFlagMac.onAction = function(value) + + self:InvalidateData() + + end + + local macRunnerExists = PathExists(NewWorkspacePath(self.buildTemplatePaths[2].path)) + + if(macRunnerExists) then + editorUI:ToggleButton(buildFlagMac, gameEditor:ReadMetadata(self.buildFlagLabels[2]) == "true") + end + + editorUI:Enable(buildFlagMac, macRunnerExists) + + table.insert(self.buildFlagCheckboxes, buildFlagMac) + + local buildFlagLinux = editorUI:CreateToggleButton({x = 200, y = 192+ 24, w = 8, h = 8}, "checkbox", "Create a Linux executable.") + + buildFlagLinux.onAction = function(value) + + self:InvalidateData() + + end + + local linuxRunnerExists = PathExists(NewWorkspacePath(self.buildTemplatePaths[3].path)) + + if(linuxRunnerExists) then + editorUI:ToggleButton(buildFlagLinux, gameEditor:ReadMetadata(self.buildFlagLabels[3]) == "true") + end + + editorUI:Enable(buildFlagLinux, linuxRunnerExists) + + + table.insert(self.buildFlagCheckboxes, buildFlagLinux) + + + local buildFlagExtras = editorUI:CreateToggleButton({x = 200, y = 208, w = 8, h = 8}, "checkbox", "Create a Linux executable.") + + editorUI:ToggleButton(buildFlagExtras, gameEditor:ReadMetadata(self.buildFlagLabels[4]) == "true") + + buildFlagExtras.onAction = function(value) + + self:InvalidateData() + + end + + -- These UI elements live outside of the panel + + self.buildButtonData = editorUI:CreateButton({x = 216, y = 32}, "buildbutton", "Build the game disk.") + self.buildButtonData.onAction = function(value) + + self.libFilesToCopy = {} + + for i = 1, #self.filePaths do + -- print("Include", dump(filePaths[i])) + if(self.filePaths[i].selected == true) then + + table.insert(self.libFilesToCopy, self.filePaths[i].name) + end + end + + -- buildFlagWin + + pixelVisionOS:ShowMessageModal("Build Game", "Are you sure you want to build ".. self.nameInputData.text .."'? This will create a new PV8 disk and executables for any selected platforms.", 160, true, + function() + + if(pixelVisionOS.messageModal.selectionValue == true) then + + self:OnExportGame() + -- TODO need to call the build function + -- OnInstall() + + end + + end + ) + + end + + -- self.cleanCheckboxData = editorUI:CreateToggleButton({x = 216, y = 56, w = 8, h = 8}, "radiobutton", "Toggles doing a clean build and removes all previous builds.") + + -- editorUI:ToggleButton(self.cleanCheckboxData, gameEditor:ReadMetadata("clear", "false") == "true", false) + + -- self.cleanCheckboxData.onAction = function(value) + + -- -- print("Clean build", value) + + -- if(value == false) then + -- self:InvalidateData() + -- return + -- end + + -- pixelVisionOS:ShowMessageModal("Warning", "Are you sure you want to do a clean build? This will delete the build directory before creating the PV8 disk. Old builds will be deleted. This can not be undone.", 160, true, + -- function() + + + -- if(pixelVisionOS.messageModal.selectionValue == false) then + + -- -- Force the checkbox back into the false state + -- editorUI:ToggleButton(self.cleanCheckboxData, false, false) + + -- else + -- -- Force the checkbox back into the false state + -- editorUI:ToggleButton(self.cleanCheckboxData, true, false) + -- end + + -- -- Force the button to redraw since restoring the modal will show the old state + -- editorUI:Invalidate(self.cleanCheckboxData) + -- self:InvalidateData() + -- end + -- ) + +-- end + + + pixelVisionOS:RegisterUI({name = buildInfoPanelID}, "BuildInfoPanelUpdate", self) + +end + +function InfoTool:BuildInfoPanelUpdate() + + for i = 1, #self.buildFlagCheckboxes do + editorUI:UpdateButton(self.buildFlagCheckboxes[i]) + end + + editorUI:UpdateButton(self.buildButtonData) + -- editorUI:UpdateButton(self.cleanCheckboxData) + +end + +function InfoTool:OnExportGame() + + local srcPath = NewWorkspacePath(self.rootDirectory) + local destPath = srcPath.AppendDirectory("Builds") + local infoFile = srcPath.AppendFile("info.json") + local dataFile = srcPath.AppendFile("data.json") + + -- TODO need to read game name from info file + if(PathExists(srcPath.AppendDirectory("info.json")) == false) then + SaveText(infoFile, "{\"name\":\""..srcPath.EntityName.."\"}") + end + + local metaData = ReadJson(infoFile) + + local gameName = (metaData ~= nil and metaData["name"] ~= nil) and metaData["name"] or srcPath.EntityName + + + local systemData = ReadJson(dataFile) + + local maxSize = 512 + + if(systemData["GameChip"]) then + + if(systemData["GameChip"]["maxSize"]) then + maxSize = systemData["GameChip"]["maxSize"] + end + end + + -- Manually create a game disk from the current folder's files + local srcFiles = GetEntities(srcPath) + local pathOffset = #srcPath.Path + + local gameFiles = {} + + for i = 1, #srcFiles do + local srcFile = srcFiles[i] + local destFile = NewWorkspacePath(srcFile.Path:sub(pathOffset)) + gameFiles[srcFile] = destFile + end + + local response = CreateDisk(gameName, gameFiles, destPath, maxSize) + + self.buildingDisk = true + + if(self.progressModal == nil) then + -- + -- -- Create the model + self.progressModal = ProgressModal:Init("File Action ", editorUI) + + -- Open the modal + pixelVisionOS:OpenModal(self.progressModal) + + end + + -- end + +end \ No newline at end of file diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-drop-down-menu.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-drop-down-menu.lua index 40b88e1f..94eb4dd5 100755 --- a/Disks/PixelVisionOS/System/Tools/InfoTool/code-drop-down-menu.lua +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-drop-down-menu.lua @@ -8,13 +8,12 @@ distributing is allowed. ]]-- -function InfoTool:CreateDropDownMenu() +SaveShortcut = 5 - -- Get a list of all the editors - local editorMapping = pixelVisionOS:FindEditors() +function InfoTool:CreateDropDownMenu() -- Find the json editor - self.textEditorPath = editorMapping["json"] + self.textEditorPath = pixelVisionOS:FindEditors()["json"] local menuOptions = { @@ -31,3 +30,102 @@ function InfoTool:CreateDropDownMenu() pixelVisionOS:CreateTitleBarMenu(menuOptions, "See menu options for this tool.") end + +function InfoTool:OnEditJSON() + + if(self.invalid == true) then + + pixelVisionOS:ShowMessageModal("Unsaved Changes", "You have unsaved changes. Do you want to save your work before you edit the raw data file?", 160, true, + function() + + if(pixelVisionOS.messageModal.selectionValue == true) then + -- Save changes + self:OnSave() + + end + + -- Quit the tool + self:EditJSON() + + end + ) + + else + -- Quit the tool + self:EditJSON() + end + +end + +function InfoTool:EditJSON() + + local metaData = { + directory = self.rootDirectory, + file = self.rootDirectory .. "info.json", + } + + LoadGame(self.textEditorPath, metaData) + +end + +function InfoTool:OnQuit() + + if(self.invalid == true) then + + pixelVisionOS:ShowMessageModal("Unsaved Changes", "You have unsaved changes. Do you want to save your work before you edit the raw data file?", 160, true, + function() + + if(pixelVisionOS.messageModal.selectionValue == true) then + -- Save changes + self:OnSave() + + end + + -- Quit the tool + QuitCurrentTool() + + end + ) + + else + -- Quit the tool + QuitCurrentTool() + end + +end + +function InfoTool:OnSave() + + local flags = {SaveFlags.Meta} + + local includeString = "" + + for i = 1, #self.filePaths do + + local file = self.filePaths[i] + + if(file.selected == true) then + includeString = includeString .. file.name .. "," + end + + end + + -- gameEditor:WriteMetadata("clear", tostring(self.cleanCheckboxData.selected)) + + gameEditor:WriteMetadata("runnerType", self.runnerType) + + gameEditor:WriteMetadata("includeLibs", includeString:sub(1, - 2)) + + -- Add the build flags + for i = 1, #self.buildFlagCheckboxes do + gameEditor:WriteMetadata(self.buildFlagLabels[i], tostring(self.buildFlagCheckboxes[i].selected)) + end + + gameEditor:Save(self.rootDirectory, flags) + + -- Display that the data was saved and reset invalidation + pixelVisionOS:DisplayMessage("The game's 'data.json' file has been updated.", 5) + + self:ResetDataValidation() + +end diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-game-info-panel.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-game-info-panel.lua index 6e73cf52..33f18ca1 100755 --- a/Disks/PixelVisionOS/System/Tools/InfoTool/code-game-info-panel.lua +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-game-info-panel.lua @@ -11,14 +11,146 @@ local gameInfoPanelID = "GameInfoPanel" function InfoTool:CreateGameInfoPanelPanel() + + local pathSplit = string.split(self.targetFile, "/") + -- Update title with file path + self.toolTitle = pathSplit[#pathSplit - 1] .. "/" .. pathSplit[#pathSplit] - pixelVisionOS:RegisterUI({name = gameInfoPanelID}, "GameInfoPanelUpdate", self) + if(self.rootDirectory ~= nil) then -end + -- Load only the game data we really need + self.success = gameEditor:Load(self.rootDirectory, {SaveFlags.Meta}) -function InfoTool:GameInfoPanelUpdate() + end + + + -- TODO need to read the custom icon + local customIconPath = NewWorkspacePath(self.rootDirectory).AppendFile("icon.png") + + if(PathExists(customIconPath) == true) then + else + DrawSprites( iconrunnerup.spriteIDs, 8 + 4, 32 + 3, iconrunnerup.width, false, false, DrawMode.TilemapCache) + end + + local name = gameEditor:ReadMetadata("name", "untitled") + + local description = gameEditor:ReadMetadata("description", "") + + self.nameInputData = editorUI:CreateInputField({x = 48, y = 40, w = 160}, name, "Enter in a file name to this string input field.", "file") + + self.nameInputData.onAction = function(value) + + gameEditor:WriteMetadata("name", value) + + self:InvalidateData() + + end + + self.inputAreaData = editorUI:CreateInputArea({x = 16, y = 72, w = 208, h = 56}, description, "Click to edit the text.") + self.inputAreaData.wrap = false + self.inputAreaData.editable = true + self.inputAreaData.autoDeselect = false + self.inputAreaData.colorize = codeMode + + self.inputAreaData.onAction = function(value) + + gameEditor:WriteMetadata("description", value) + + self:InvalidateData() + end + + -- Prepare the input area for scrolling + self.inputAreaData.scrollValue = {x = 0, y = 0} + + self.vSliderData = editorUI:CreateSlider({x = 235 - 8, y = 73 - 5, w = 10, h = 56 + 9}, "vsliderhandle", "Scroll text vertically.") + self.vSliderData.onAction = function(value) self:OnVerticalScroll(value) end + + self.hSliderData = editorUI:CreateSlider({ x = 16 + 4 - 8, y = 136 - 5, w = 208 + 9, h = 10}, "hsliderhandle", "Scroll text horizontally.", true) + self.hSliderData.onAction = function(value) self:OnHorizontalScroll(value) end + + + pixelVisionOS:RegisterUI({name = gameInfoPanelID}, "GameInfoPanelUpdate", self) + +end + +function InfoTool:GameInfoPanelUpdate() + + editorUI:UpdateInputField(self.nameInputData) + + editorUI:UpdateInputArea(self.inputAreaData) + + -- Check to see if we should show the horizontal slider + local showVSlider = #self.inputAreaData.buffer > self.inputAreaData.tiles.h + + -- Test if we need to show or hide the slider + if(self.vSliderData.enabled ~= showVSlider) then + editorUI:Enable(self.vSliderData, showVSlider) + end + + if(self.vSliderData.enabled == true) then + self.inputAreaData.scrollValue.y = (self.inputAreaData.vy - 1) / (#self.inputAreaData.buffer - self.inputAreaData.tiles.h) + + if(self.vSliderData.value ~= self.inputAreaData.scrollValue.y) then + + -- InvalidateLineNumbers() + + editorUI:ChangeSlider(self.vSliderData, self.inputAreaData.scrollValue.y, false) + end + + end + + -- Update the slider + editorUI:UpdateSlider(self.vSliderData) + + -- Check to see if we should show the vertical slider + local showHSlider = self.inputAreaData.maxLineWidth > self.inputAreaData.tiles.w + + -- Test if we need to show or hide the slider + if(self.hSliderData.enabled ~= showHSlider) then + editorUI:Enable(self.hSliderData, showHSlider) + end + + if(self.hSliderData.enabled == true) then + self.inputAreaData.scrollValue.x = (self.inputAreaData.vx - 1) / ((self.inputAreaData.maxLineWidth + 1) - self.inputAreaData.tiles.w) + + if(self.hSliderData.value ~= self.inputAreaData.scrollValue.x) then + -- print(self.inputAreaData.vx, self.inputAreaData.maxLineWidth, self.inputAreaData.tiles.w) + -- print("self.inputAreaData.scrollValue.x", self.inputAreaData.scrollValue.x) + + editorUI:ChangeSlider(self.hSliderData, self.inputAreaData.scrollValue.x, false) + end + + end + + -- Update the slider + editorUI:UpdateSlider(self.hSliderData) + +end + +function InfoTool:OnHorizontalScroll(value) + + local charPos = math.ceil(((self.inputAreaData.maxLineWidth + 1) - (self.inputAreaData.tiles.w)) * value) + 1 + + if(self.inputAreaData.vx ~= charPos) then + self.inputAreaData.vx = charPos + editorUI:TextEditorInvalidateBuffer(self.inputAreaData) + end + +end + +function InfoTool:OnVerticalScroll(value) + + print("value", value) + + local line = math.ceil((#self.inputAreaData.buffer - (self.inputAreaData.tiles.h - 1)) * value) + if(self.inputAreaData.vy ~= line) then + self.inputAreaData.vy = Clamp(line, 1, #self.inputAreaData.buffer) + + editorUI:TextEditorInvalidateBuffer(self.inputAreaData) + end + end \ No newline at end of file diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-info-tool.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-info-tool.lua index b5c3bdbb..87b52a53 100755 --- a/Disks/PixelVisionOS/System/Tools/InfoTool/code-info-tool.lua +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-info-tool.lua @@ -13,6 +13,10 @@ InfoTool = {} InfoTool.__index = InfoTool LoadScript("code-drop-down-menu") +LoadScript("code-game-info-panel") +LoadScript("code-build-panel") +LoadScript("code-library-panel") +LoadScript("code-runner-panel") LoadScript("code-installer-modal") LoadScript("pixel-vision-os-progress-modal-v1") @@ -53,21 +57,32 @@ function InfoTool:Init() -- Create a global reference of the new workspace tool setmetatable(_infoTool, InfoTool) - if(_infoTool.targetFile ~= nil) then + - _infoTool:BuildUI() + + if(_infoTool.targetFile ~= nil) then + + local pathSplit = string.split(_infoTool.rootDirectory, "/") + _infoTool.toolTitle = pathSplit[#pathSplit] .. "/data.json" + + _infoTool:CreateDropDownMenu() - --_infoTool:CreateGameInfoPanelPanel() + _infoTool:CreateGameInfoPanelPanel() + _infoTool:CreateLibraryInfoPanel() + _infoTool:CreateBuildInfoPanel() + _infoTool:CreateRunnerInfoPanel() + + _infoTool:ResetDataValidation() else - pixelVisionOS:ChangeTitle(toolName, "toolbaricontool") + pixelVisionOS:ChangeTitle(_infoTool.toolName, "toolbaricontool") DrawRect(48, 40, 160, 8, 0, DrawMode.TilemapCache) DrawRect(16, 72, 208, 64, 0, DrawMode.TilemapCache) DrawRect(16, 168, 228, 56, 11, DrawMode.TilemapCache) - pixelVisionOS:ShowMessageModal(toolName .. " Error", "The tool could not load without a reference to a file to edit.", 160, false, + pixelVisionOS:ShowMessageModal(_infoTool.toolName .. " Error", "The tool could not load without a reference to a file to edit.", 160, false, function() QuitCurrentTool() end @@ -81,58 +96,11 @@ function InfoTool:Init() end function InfoTool:BuildUI() - - - local pathSplit = string.split(self.targetFile, "/") - - -- Update title with file path - self.toolTitle = pathSplit[#pathSplit - 1] .. "/" .. pathSplit[#pathSplit] - if(self.rootDirectory ~= nil) then - - -- Load only the game data we really need - self.success = gameEditor:Load(self.rootDirectory, {SaveFlags.Meta}) - - end - - self:CreateDropDownMenu() - - local name = gameEditor:ReadMetadata("name", "untitled") - - local description = gameEditor:ReadMetadata("description", "") - - self.nameInputData = editorUI:CreateInputField({x = 48, y = 40, w = 160}, name, "Enter in a file name to this string input field.", "file") - - self.nameInputData.onAction = function(value) - - gameEditor:WriteMetadata("name", value) - - self:InvalidateData() - - end + + - --self.inputAreaData = editorUI:CreateInputArea({x = 16, y = 72, w = 208, h = 56}, description, "Click to edit the text.") - --self.inputAreaData.wrap = false - --self.inputAreaData.editable = true - --self.inputAreaData.autoDeselect = false - --self.inputAreaData.colorize = codeMode - -- - --self.inputAreaData.onAction = function(value) - -- - -- gameEditor:WriteMetadata("description", value) - -- - -- self:InvalidateData() - --end - -- - ---- Prepare the input area for scrolling - --self.inputAreaData.scrollValue = {x = 0, y = 0} - -- - --self.vSliderData = editorUI:CreateSlider({x = 235 - 8, y = 73 - 5, w = 10, h = 56 + 9}, "vsliderhandle", "Scroll text vertically.") - --self.vSliderData.onAction = function() self:OnVerticalScroll(value) end - -- - --self.hSliderData = editorUI:CreateSlider({ x = 16 + 4 - 8, y = 136 - 5, w = 208 + 9, h = 10}, "hsliderhandle", "Scroll text horizontally.", true) - --self.hSliderData.onAction = function() self:OnHorizontalScroll(value) end - -- + -- --local startY = 168 + 8 -- @@ -449,7 +417,7 @@ function Init() -- local pathSplit = string.split(rootDirectory, "/") -- Update title with file path - -- toolTitle = pathSplit[#pathSplit] .. "/data.json" + toolTitle = pathSplit[#pathSplit] .. "/data.json" --LoadInstallScript(targetFile) local name = gameEditor:ReadMetadata("name", "untitled") @@ -971,41 +939,9 @@ end -- -- end -function OnFileValueChange(value) - local offset = math.ceil((#filePaths - maxFilesToDisplay) * value) - DrawFileList(offset) -end - -function DrawFileList(offset) - - fileListOffset = offset or 0 - - DrawRect(24, 168 + 8, 144, 56 - 8, 11, DrawMode.TilemapCache) - - for i = 1, maxFilesToDisplay do - - local file = filePaths[i + fileListOffset] or "" - local fileName = file.name - local checkValue = file.selected - - editorUI:ToggleButton(fileCheckboxes[i], checkValue, false) - - if(#fileName > 35) then - fileName = fileName:sub(1, 32) .. "..." - end - - -- TODO need to check the size of the name - - fileName = string.rpad(fileName, 200, " "):upper() - - DrawText(fileName, 25, 168 + (i * 8), DrawMode.TilemapCache, "small", 0, - 4) - - end - -end -- function OnInstall() @@ -1134,60 +1070,60 @@ function Update(timeDelta) -- Only update the tool's UI when the modal isn't active if(pixelVisionOS:IsModalActive() == false) then - editorUI:UpdateInputField(self.nameInputData) + -- editorUI:UpdateInputField(self.nameInputData) - editorUI:UpdateInputArea(self.inputAreaData) + -- editorUI:UpdateInputArea(self.inputAreaData) -- if(self.inputAreaData.invalidText == true) then -- InvalidateData() -- -- InvalidateLineNumbers() -- end - -- Check to see if we should show the horizontal slider - local showVSlider = #self.inputAreaData.buffer > self.inputAreaData.tiles.h + -- -- Check to see if we should show the horizontal slider + -- local showVSlider = #self.inputAreaData.buffer > self.inputAreaData.tiles.h - -- Test if we need to show or hide the slider - if(self.vSliderData.enabled ~= showVSlider) then - editorUI:Enable(self.vSliderData, showVSlider) - end + -- -- Test if we need to show or hide the slider + -- if(self.vSliderData.enabled ~= showVSlider) then + -- editorUI:Enable(self.vSliderData, showVSlider) + -- end - if(self.vSliderData.enabled == true) then - self.inputAreaData.scrollValue.y = (self.inputAreaData.vy - 1) / (#self.inputAreaData.buffer - self.inputAreaData.tiles.h) + -- if(self.vSliderData.enabled == true) then + -- self.inputAreaData.scrollValue.y = (self.inputAreaData.vy - 1) / (#self.inputAreaData.buffer - self.inputAreaData.tiles.h) - if(self.vSliderData.value ~= self.inputAreaData.scrollValue.y) then + -- if(self.vSliderData.value ~= self.inputAreaData.scrollValue.y) then - -- InvalidateLineNumbers() + -- -- InvalidateLineNumbers() - editorUI:ChangeSlider(self.vSliderData, self.inputAreaData.scrollValue.y, false) - end + -- editorUI:ChangeSlider(self.vSliderData, self.inputAreaData.scrollValue.y, false) + -- end - end + -- end - -- Update the slider - editorUI:UpdateSlider(self.vSliderData) + -- -- Update the slider + -- editorUI:UpdateSlider(self.vSliderData) - -- Check to see if we should show the vertical slider - local showHSlider = self.inputAreaData.maxLineWidth > self.inputAreaData.tiles.w + -- -- Check to see if we should show the vertical slider + -- local showHSlider = self.inputAreaData.maxLineWidth > self.inputAreaData.tiles.w - -- Test if we need to show or hide the slider - if(self.hSliderData.enabled ~= showHSlider) then - editorUI:Enable(self.hSliderData, showHSlider) - end + -- -- Test if we need to show or hide the slider + -- if(self.hSliderData.enabled ~= showHSlider) then + -- editorUI:Enable(self.hSliderData, showHSlider) + -- end - if(self.hSliderData.enabled == true) then - self.inputAreaData.scrollValue.x = (self.inputAreaData.vx - 1) / ((self.inputAreaData.maxLineWidth + 1) - self.inputAreaData.tiles.w) + -- if(self.hSliderData.enabled == true) then + -- self.inputAreaData.scrollValue.x = (self.inputAreaData.vx - 1) / ((self.inputAreaData.maxLineWidth + 1) - self.inputAreaData.tiles.w) - if(self.hSliderData.value ~= self.inputAreaData.scrollValue.x) then - -- print(self.inputAreaData.vx, self.inputAreaData.maxLineWidth, self.inputAreaData.tiles.w) - -- print("self.inputAreaData.scrollValue.x", self.inputAreaData.scrollValue.x) + -- if(self.hSliderData.value ~= self.inputAreaData.scrollValue.x) then + -- -- print(self.inputAreaData.vx, self.inputAreaData.maxLineWidth, self.inputAreaData.tiles.w) + -- -- print("self.inputAreaData.scrollValue.x", self.inputAreaData.scrollValue.x) - editorUI:ChangeSlider(self.hSliderData, self.inputAreaData.scrollValue.x, false) - end + -- editorUI:ChangeSlider(self.hSliderData, self.inputAreaData.scrollValue.x, false) + -- end - end + -- end - -- Update the slider - editorUI:UpdateSlider(self.hSliderData) + -- -- Update the slider + -- editorUI:UpdateSlider(self.hSliderData) editorUI:UpdateButton(buildButtonData) @@ -1291,50 +1227,9 @@ function Draw() end -function OnQuit() - - -- Quit the tool - QuitCurrentTool() - -end - -function OnEditJSON() - - if(invalid == true) then - pixelVisionOS:ShowMessageModal("Unsaved Changes", "You have unsaved changes. Do you want to save your work before you edit the raw data file?", 160, true, - function() - - if(pixelVisionOS.messageModal.selectionValue == true) then - -- Save changes - OnSave() - end - -- Quit the tool - EditJSON() - - end - ) - - else - -- Quit the tool - EditJSON() - end - -end - -function EditJSON() - - local metaData = { - directory = rootDirectory, - file = rootDirectory .. "info.json", - } - - LoadGame(textEditorPath, metaData) - - -end function OnReset() @@ -1391,26 +1286,26 @@ function OnSave() end -function OnHorizontalScroll(value) +-- function OnHorizontalScroll(value) - local charPos = math.ceil(((self.inputAreaData.maxLineWidth + 1) - (self.inputAreaData.tiles.w)) * value) + 1 +-- local charPos = math.ceil(((self.inputAreaData.maxLineWidth + 1) - (self.inputAreaData.tiles.w)) * value) + 1 - if(self.inputAreaData.vx ~= charPos) then - self.inputAreaData.vx = charPos - editorUI:TextEditorInvalidateBuffer(self.inputAreaData) - end +-- if(self.inputAreaData.vx ~= charPos) then +-- self.inputAreaData.vx = charPos +-- editorUI:TextEditorInvalidateBuffer(self.inputAreaData) +-- end -end +-- end -function OnVerticalScroll(value) +-- function OnVerticalScroll(value) - local line = math.ceil((#self.inputAreaData.buffer - (self.inputAreaData.tiles.h - 1)) * value) - if(self.inputAreaData.vy ~= line) then - self.inputAreaData.vy = Clamp(line, 1, #self.inputAreaData.buffer) +-- local line = math.ceil((#self.inputAreaData.buffer - (self.inputAreaData.tiles.h - 1)) * value) +-- if(self.inputAreaData.vy ~= line) then +-- self.inputAreaData.vy = Clamp(line, 1, #self.inputAreaData.buffer) - editorUI:TextEditorInvalidateBuffer(self.inputAreaData) - end +-- editorUI:TextEditorInvalidateBuffer(self.inputAreaData) +-- end - -- InvalidateLineNumbers() +-- -- InvalidateLineNumbers() -end +-- end diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-library-panel.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-library-panel.lua new file mode 100644 index 00000000..126d10b7 --- /dev/null +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-library-panel.lua @@ -0,0 +1,167 @@ +--[[ + Pixel Vision 8 - Draw Tool + Copyright (C) 2017, Pixel Vision 8 (http://pixelvision8.com) + Created by Jesse Freeman (@jessefreeman) + + Please do not copy and distribute verbatim copies + of this license document, but modifications without + distributing is allowed. +]]-- + +local libraryInfoPanelID = "LibraryInfoPanel" + +function InfoTool:CreateLibraryInfoPanel() + + + local startY = 168 + 8 + + -- Get all of the shared library paths + local libPath = SharedLibPaths() + + -- Load libs and split + local includedLibs = string.split(gameEditor:ReadMetadata("includeLibs", ""), ",") + + for i = 1, #libPath do + + local tmpFiles = GetEntities(libPath[i]) + + for i = 1, #tmpFiles do + + local tmpFile = tmpFiles[i] + + if(tmpFile.IsFile and tmpFile.GetExtension() == ".lua") then + + local tmpName = tmpFile.EntityNameWithoutExtension + + if(self.sharedLibFiles[tmpName] == nil) then + + local selected = table.indexOf(includedLibs, tmpName) > - 1 + + -- Store the file and path + self.sharedLibFiles[tmpName] = tmpFile + + -- Add to the display list + table.insert(self.filePaths, {name = tmpName, selected = selected, path = tmpFile.Path}) + + end + + end + + end + + + end + + -- Need to see if there are enough files to display + if(#self.filePaths < self.maxFilesToDisplay) then + self.maxFilesToDisplay = #self.filePaths + + -- TODO disable scroller + end + + for i = 1, self.maxFilesToDisplay do + local tmpCheckbox = editorUI:CreateToggleButton({x = 16, y = startY, w = 8, h = 8}, "checkbox", "Select a library file to include with the build.") + tmpCheckbox.onAction = function(value) + + if(Key(Keys.LeftShift) or Key(Keys.RightShift)) then + + -- Loop through all of the files + for i = 1, #self.filePaths do + + -- Change all of the file values + self.filePaths[i].selected = value + + end + + self:DrawFileList(self.fileListOffset) + + else + + -- Change a single file value + self.filePaths[i + self.fileListOffset].selected = value + end + + self:InvalidateData() + + end + + startY = startY + 8 + + table.insert(self.fileCheckboxes, tmpCheckbox) + + end + + self.fileSliderData = editorUI:CreateSlider({x = 168, y = 168 + 8, w = 16, h = 56 - 8}, "vsliderhandle", "Scroll to see the more files to install.") + self.fileSliderData.onAction = function(value) self:OnFileValueChange(value) end + + editorUI:Enable(self.fileSliderData, #self.filePaths > self.maxFilesToDisplay) + + -- Reset list + self:DrawFileList() + + pixelVisionOS:RegisterUI({name = libraryInfoPanelID}, "LibraryInfoPanelUpdate", self) + +end + +function InfoTool:LibraryInfoPanelUpdate() + + for i = 1, self.maxFilesToDisplay do + editorUI:UpdateButton(self.fileCheckboxes[i]) + end + + editorUI:UpdateSlider(self.fileSliderData) + +end + +function InfoTool:DrawFileList(offset) + + self.fileListOffset = offset or 0 + + DrawRect(24, 168 + 8, 144, 56 - 8, 11, DrawMode.TilemapCache) + + for i = 1, self.maxFilesToDisplay do + + local file = self.filePaths[i + self.fileListOffset] or "" + local fileName = file.name + local checkValue = file.selected + + editorUI:ToggleButton(self.fileCheckboxes[i], checkValue, false) + + if(#fileName > 35) then + fileName = fileName:sub(1, 32) .. "..." + end + + -- TODO need to check the size of the name + + fileName = string.rpad(fileName, 200, " "):upper() + + DrawText(fileName, 25, 168 + (i * 8), DrawMode.TilemapCache, "small", 0, - 4) + + end + +end + +function InfoTool:OnFileValueChange(value) + + local offset = math.ceil((#self.filePaths - self.maxFilesToDisplay) * value) + + self:DrawFileList(offset) + +end + +function InfoTool:OnReset() + + pixelVisionOS:ShowMessageModal("Reset Installer", "Do you want to reset the installer to its default values?", 160, true, + function() + if(pixelVisionOS.messageModal.selectionValue == true) then + + for i = 1, #self.filePaths do + self.filePaths[i].selected = true + end + + self:DrawFileList(self.fileListOffset) + end + end + ) + +end \ No newline at end of file diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/code-runner-panel.lua b/Disks/PixelVisionOS/System/Tools/InfoTool/code-runner-panel.lua new file mode 100644 index 00000000..531cbbb9 --- /dev/null +++ b/Disks/PixelVisionOS/System/Tools/InfoTool/code-runner-panel.lua @@ -0,0 +1,48 @@ +--[[ + Pixel Vision 8 - Draw Tool + Copyright (C) 2017, Pixel Vision 8 (http://pixelvision8.com) + Created by Jesse Freeman (@jessefreeman) + + Please do not copy and distribute verbatim copies + of this license document, but modifications without + distributing is allowed. +]]-- + +local runnerInfoPanelID = "RunnerInfoPanel" + +function InfoTool:CreateRunnerInfoPanel() + + self.runnerTypes = {"lua", "c#"} + + -- Get runner setting + + local selectedRunnerID = Clamp(table.indexOf(self.runnerTypes, gameEditor:ReadMetadata("runnerType", "lua")), 1, 2) + + self.runnerToggleGroup = editorUI:CreateToggleGroup(true) + + + + -- C# Button + editorUI:ToggleGroupButton(self.runnerToggleGroup, {x = 200, y = 176, w = 8, h = 8}, "radiobutton", "Use the C# runner.") + + -- Lua Button + editorUI:ToggleGroupButton(self.runnerToggleGroup, {x = 200, y = 176 + 8, w = 8, h = 8}, "radiobutton", "Use the Lua runner.") + + editorUI:SelectToggleButton(self.runnerToggleGroup, selectedRunnerID); + + pixelVisionOS:RegisterUI({name = runnerInfoPanelID}, "RunnerInfoPanelUpdate", self) + + self.runnerToggleGroup.onAction = function(value) + + self.runnerType = self.runnerTypes[value] + self:InvalidateData() + + end + +end + +function InfoTool:RunnerInfoPanelUpdate() + + editorUI:UpdateToggleGroup(self.runnerToggleGroup) + +end \ No newline at end of file diff --git a/Disks/PixelVisionOS/System/Tools/InfoTool/tilemap.png b/Disks/PixelVisionOS/System/Tools/InfoTool/tilemap.png index 3b9c36b467b597b638ed30c024df0ef3ccb4e472..650f5a804fee05f7b512d8b2eda0061491f334f2 100755 GIT binary patch delta 2288 zcmZuzdpy+X8h>Y)QY12#zklX08E@`MmYFvJ!l0Hgwri;zw zR%;MZE|Xzg)1+KN05)VCc0S;Bkup2nnWoR)vTk(icwN@n^aH1pbWE)CQV=8W;hT15 zKHu~P5w@dhg9;%Awx^PeK9~S|yXA38p7HhWQ*Kx0ynnl&8FIR^HZW*$sHS5Fv;<5ds{;adHJGHln6Y~==z0HZ$_R8JapDMg)kI7#Y)=YLmRR&} zqlUWcXMYW|J|By~iP@NiOg4ToaFmpb42n!# zE{Bq=``f%0+fj{%u`971smvu`yrJLUsrAX+nzBvfQ1WH|JZ@Yju*8c4#dpQ`p^k_; zN6q5`9rST$UaN>d&#IQqMD(eizfK7A?@u!fA*y6vJAwl+C1v#SvpknL;RL^0R_En2 zIwLvYRUHcF$5RqM2-Sk!?ARGUz>N1P@WVtpY3iEZt}G7RZdVM|x~(hi_{~#Y zNy9>&X2EMbvfd{7pL~(m$8{9@8alJuUO`ABa6{Bf^=t>x^Nk~tt`hF zqCc`>mr+TMm33Cyl}9b(Sj&p!i{2fr4t@Y_``_yHr3!)KqaI2{j|F#Hquh~t z?woMGcZUmAbGjF9c7rpN(2cia&JrE>T1+;S&Am=kl*X8K4Y#H^C&8gEs&mD}DJA4FVF(8X8wp+gevf#|}=#R;!Z;m3Kf(n164eMvHwl&=ylt)6NS!CtxfW$~mPxwgZR#KZxL*Rs$Ughak1 z*LXu6Ei4$&UeXAh4IwI5R#7 z&*xV2Xn}nk?`hDVLPv$*MoXUzs6IxZ9>=^r2#pq6Cdzp^{@QF#4@9}DPQqZyM0U8& zv6wA9X^$gu*tp3i)`CB_i{rY ziXFXt({>THclD%ZJZ#dE8|ol32F|AcM;UwtyP8)QX7Shh)r&;JLBq7cxEv^!INQo= zXRz_o#nr`G4F>xec2ap~#7}dyU$P1*ZG6eY&?{G)D0a$5@r2M{2gK&yICjKi8ln8V z;mt5$pUEq3gM$l3?F{Is3ea;N_;>DqC|CBw@~H&&LOG{vw{q2Ak?8r7nU2x<8h}{x zfOTnOD_+|VSVPz8%#+dIf?#Dui@FjGn!NnL63CmxWXq^Es+{pC;^dF+U!Zn5dP}@zs=)_SBsqI2fm^ z}yhsP!%q!VpMH{o)2m@DKZ^VB`PE#Op0B1Czw{a~M z%=ohBLK67wtOdF~2Wr`;kt71`$GWw+Fq2BIxw%2xUwjV-l2Y>|3y@Vr@FWt5N$QmK zXo+IDoF5mJvV?KrMTwJ);_m#^Dfsdqu9#EM delta 2260 zcmYk8dpOkV7RTQiG>RH+GEOR-dgQ4vO754btu1Y45|VKn_3V>NE`?~O@f&;BqeG%S zm0Kv4%g8PF+l-wpA*SP6ei(_uU|hxw=61+F?eqTi{;}ToUGMs?^;xS=wN*8FKeY9p zgWU<&=*P3eoq>Bk{$tB%H#X|&l{m!CHli{j7IP`p+d%t|EtZGlWP|_nqVdg(3<3dye`njA`o;xq$VbO+XIP%LSPr& zX5Crrrn4`FX|(FlVVQWT9$lizfrOtTIc~n5P;EmMEO&o71o7Zhg^wf8rh$3YmfA_y z*-^GVSjlst*%3k`y2A>#X_II`FCn;bGK5nHeU=*Z?TW6Ws<_Rj(M0((4FEhV|~vwRrAL~&LPgK z$qc1Adhwx5X$adB$uj?DI{&IBdfA_o(cOLk5`kQS?lH(k;)p*AXnu}!D%x(QzKFY1 z3sR~q5zspzZkcBFZX`kqA^-GIeR9h}c^8#KCWd3SH(AzdO0xHWD z?8(g9RXB0+_fTUa$Eh<-IjI+bS_^-K^fnET`=;*3oe)sDAjqUeE-?raik!eY)T%51 zfg^1`cR@e}k?n@7M_4MxlJxmpp@_+xTGTmM?vHqW+g%#cBZ<=T;nZZS2d+i0E#<;a zTtV=k_SAL`m_rB&)^_vLUHhgdSTW-Qe z^$fxMkD2wC)WFfoq8qlZ2kaX*V`{Rx3P@dyd&_ZFXnQ4q>_O7*CQ|#0)Yq$p?kaDG z*i9dm3x|5@6~eAX2i=(kKiKD8*7O8!R5|a69keBsVM2m?(w2{kcV@(YbR;Hicbm-E zvqvk-tJ1?E?KEt%+yCHjnn_XHvieE5^nyNS*b@k(*sL;3*%=FjPN`2O?UGhDPHk$R zOv1J`j+r&}g$8akX3F6fn#1}j;*K#HucUJaR4!Zn?B1fql)UI6qs({uySE<3nr2*o z?v%jNiy!mF$fg>kBUBKtRR>2<EkN085_1;*I&I6R8PMJ8ctDEv(T5F5!ny;`;+o#XAs2%9^SG6(uBKvm~Cr1G<1=O}AsUN1829eRnRq4IyZ+n=v`w#3%) z=bn3OgX*-gxTyeQHB&R}r|zZpxH{fi(rPyfdn~}Om}3ZyMAT0$2ZWznV8?;fS{=e5 zQ6IuQjBScAmrqSIp>P*#xp`3oox;|J-Y(RWT2zlK=0oAcYaL*Bo}&2VBWkHHA3Zwt z+452-YNodw6IwEy4PUmB$b!$osIyEXCyZk4&$d0`qPwONnem)lYKJDBytdNy72*o3 zt+SXmjl+U9U2X}{Cu0__I#@U;HR*t|6Bz7pIy<^gL?1cd=nju?7_HURk#w>CU~kYQ zzG*R$2sLLlMpI^;VgzHsg{H<-YMnS3c2+Z$O-==IANejv50km+&Edm{2xp-*Hz`!< z7Gt28bKL{-d@4u6OiNSUV#|vI4U^Ty$=$!8C9xTGd`Sr<#Chl@AsqU_0+<}H?EdO{ zJfY{8mmGp{GBOUpy_JAbbs3Jk0_)iKvEyZRx|9|ED%WK1PsOsKuRQqtGknv~Ii)qC z%!|EnY-C*4yOMCC>ctR`C2^_O|4m&g`OJxWm6flb`92P)WPYd2Uv%AQ1-bJ3DN#Jg zn#Zr}FeQ*n>gTLdyfgE#>Ihta`&j5PBPa93;b96JwKdi}ToET2>^f7)^?1oB9ylEe z`?%E|MuO|w11^aQUuA8|jc(r~vy|o4uKT4rmBSxiJdgth4>@Q$?V0fo_h-UY9yJ$wxR;)`d6T2COS3 zKD1mmCjvT6{Eq8fG$1oHM>=l2I;#&fPPp0ogtYjoA;FgW>OxoDT{{8xR|f8_k=n*r zGTyA_%}c=Fhjqb|yo&IWwwnMBiE^-8_bdG!D%r-i(IU)U9?W=nh=~B}4CnF(`Qklh zXxdECqlB?Z{>#3lsDS)cAh@ci4c-n;WE^Z+7sqnf^7@YMw$+HRF%@)b9LAzIE9Too y@V)PE;{OBYRGEmI7b`gwB;A-I0@*NfrcDM=4*uk6asmsiFNafjyW*3iU;hhO=}7GW diff --git a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-drop-down-menu.lua b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-drop-down-menu.lua index 40c2c55d..a281a6d1 100755 --- a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-drop-down-menu.lua +++ b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-drop-down-menu.lua @@ -8,6 +8,8 @@ distributing is allowed. ]]-- +NewShortcut, SaveShortcut, CutShortcut, CopyShortcut, PasteShortcut = 3, 10, 6, 7, 8 + function TextTool:CreateDropDownMenu() local menuOptions = @@ -17,27 +19,24 @@ function TextTool:CreateDropDownMenu() {divider = true}, {name = "New", action = function() self:NewFile() end, enabled = false, key = Keys.N, toolTip = "Create a new text file."}, -- Reset all the values {name = "Rename", action = function() self:RenameFile() end, enabled = false, key = Keys.N, toolTip = "Create a new text file."}, -- Reset all the values - {name = "Save", action = function() self:OnSave() end, enabled = false, key = Keys.S, toolTip = "Save changes made to the text file."}, -- Reset all the values - --{name = "Revert", action = nil, enabled = false, toolTip = "Revert the text file to its previous state."}, -- Reset all the values {divider = true}, {name = "Cut", action = function() self:OnCutText() end, enabled = false, key = Keys.X, toolTip = "Cut the currently selected text."}, -- Reset all the values {name = "Copy", action = function() self:OnCopyText() end, enabled = false, key = Keys.C, toolTip = "Copy the currently selected text."}, -- Reset all the values {name = "Paste", action = function() self:OnPasteColor() end, enabled = false, key = Keys.V, toolTip = "Paste the last copied text."}, -- Reset all the values - } if(self.codeMode == true) then table.insert(menuOptions, {divider = true}) table.insert(menuOptions, {name = "Toggle Lines", action = function() self:ToggleLineNumbers() end, key = Keys.L, toolTip = "Toggle the line numbers for the editor."}) + table.insert(menuOptions, {name = "Run Game", action = function() self:OnRunGame() end, key = Keys.R, toolTip = "Run the code for this game."}) - if(PathExists(NewWorkspacePath(self.rootDirectory).AppendFile("code.lua"))) then - table.insert(menuOptions, {name = "Run Game", action = function() self:OnRunGame() end, key = Keys.R, toolTip = "Run the code for this game."}) - end + SaveShortcut = SaveShortcut + 3 end -- Add the last part of the menu options table.insert(menuOptions, {divider = true}) + table.insert(menuOptions, {name = "Save", action = function() self:OnSave() end, enabled = false, key = Keys.S, toolTip = "Save changes made to the text file."}) -- Reset all the values table.insert(menuOptions, {name = "Quit", key = Keys.Q, action = function() self:OnQuit() end, toolTip = "Quit the current game."}) -- Quit the current game pixelVisionOS:CreateTitleBarMenu(menuOptions, "See menu options for this tool.") @@ -47,7 +46,7 @@ end function TextTool:OnRunGame() - local data = {codeFile = _textTool.targetFile} + local data = {codeFile = self.targetFile} -- if(self.codeMode == true) then diff --git a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-editor-panel.lua b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-editor-panel.lua index 05baef45..4d452194 100755 --- a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-editor-panel.lua +++ b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-editor-panel.lua @@ -243,11 +243,11 @@ function TextTool:DrawLineNumbers() end local offset = self.inputAreaData.vy - 1 - local totalLines = self.inputAreaData.tiles.h + -- local totalLines = self.inputAreaData.tiles.h local padWidth = (self.lineWidth / 8) - 1 for i = 1, self.inputAreaData.tiles.h do - DrawText(string.lpad(tostring(i + offset), padWidth, "0") .. " ", 1, 2 + i, DrawMode.Tile, "input", 44) + DrawText(string.lpad(tostring(i + offset), padWidth, "0") .. " ", 1, 2 + i, DrawMode.Tile, "large", 6) end diff --git a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-text-tool.lua b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-text-tool.lua index d22150f2..889d7730 100755 --- a/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-text-tool.lua +++ b/Disks/PixelVisionOS/System/Tools/TextEditorTool/code-text-tool.lua @@ -74,20 +74,9 @@ function TextTool:LoadSuccess() self:CreateDropDownMenu() - - - -- inputAreaData.colorOffset = 32 - --self.inputAreaData.onAction = function(text) - -- -- print("input area updated") - --end - - -- TODO need to read the toggle line state from the bios - self.showLines = ReadBiosData("ShowLinesInTextEditor") == "True" and true or false self:CreateEditorPanel() - - self:ResetDataValidation() @@ -102,7 +91,7 @@ function TextTool:InvalidateData() pixelVisionOS:ChangeTitle(self.toolTitle .."*", "toolbariconfile") - pixelVisionOS:EnableMenuItem(4, true) + pixelVisionOS:EnableMenuItem(SaveShortcut, true) self.invalid = true @@ -121,7 +110,7 @@ function TextTool:ResetDataValidation() -- Reset the input field's text validation editorUI:TextEditorResetTextValidation(self.inputAreaData) - pixelVisionOS:EnableMenuItem(4, false) + pixelVisionOS:EnableMenuItem(SaveShortcut, false) end @@ -131,7 +120,7 @@ function TextTool:OnSave() if(success == true) then pixelVisionOS:DisplayMessage("Saving '" .. self.targetFile .. "'.", 5 ) - ResetDataValidation() + self:ResetDataValidation() else pixelVisionOS:DisplayMessage("Unable to save '" .. self.targetFile .. "'.", 5 ) end @@ -154,6 +143,7 @@ function TextTool:Shutdown() WriteSaveData("sessionID", SessionID()) if(targetFile ~= nil) then + WriteSaveData("targetFile", self.targetFile) local state = editorUI:TextEditorGetState(self.inputAreaData) diff --git a/Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-window.lua b/Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-window.lua index a55689dc..cb1cbc56 100755 --- a/Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-window.lua +++ b/Disks/PixelVisionOS/System/Tools/WorkspaceTool/code-window.lua @@ -568,6 +568,10 @@ function WorkspaceTool:OnWindowIconClick(id) -- Check to see if the file is an executable elseif(type == "run") then + -- TODO need to read the info file and see what runner to use + + -- TODO need to pass the main code file to the metat data + local metaData = { codeFile = "code.cs" } diff --git a/PixelVision8Lite.CoreDesktop.csproj b/PixelVision8Lite.CoreDesktop.csproj index 36e4f564..29be6fcd 100755 --- a/PixelVision8Lite.CoreDesktop.csproj +++ b/PixelVision8Lite.CoreDesktop.csproj @@ -33,6 +33,7 @@ + @@ -40,8 +41,10 @@ Content\%(RecursiveDir)%(Filename)%(Extension) PreserveNewest - - + + Content\%(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + @@ -87,29 +90,15 @@ - - - - + + + + + - - - - - - - - - - - - - - - diff --git a/ProgramLite.cs b/ProgramLite.cs index 81452b5d..260e196d 100755 --- a/ProgramLite.cs +++ b/ProgramLite.cs @@ -15,22 +15,19 @@ public static void Main(string[] args) { // Fix a bug related to parsing numbers in Europe, among other things CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; - CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; - - var root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content"); - - // Need to do this for MacOS - // if (root.EndsWith("/MonoBundle/Content")) root = root.Replace("/MonoBundle/Content", "/Resources/Content"); - - // TODO there is a bug where this will not go to the boot error + CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; + + var root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content"); + + // TODO there is a bug where this will not go to the boot error using (var game = new ExampleRunner(root)) { game.Run(); - } - + } + } - } - + } + class ExampleRunner : CSharpRunner { public ExampleRunner(string gamePath) : base(gamePath) @@ -39,18 +36,18 @@ public ExampleRunner(string gamePath) : base(gamePath) protected override void AddGameChip() { - _tmpEngine.ActivateChip("GameChip", new DrawSpritesExample()); + _tmpEngine.ActivateChip("GameChip", new ExampleGameChip()); } - } - - class DrawSpritesExample : GameChipLite + } + + class ExampleGameChip : GameChipLite { // Use floats to store the subpixel position private float speed = 5; private float nextPos; - private int lastSpriteCount; - - // Use this point to position the sprites + private int lastSpriteCount; + + // Use this point to position the sprites private Point pos; // A group of sprite IDs for the DrawSprites() API @@ -70,11 +67,11 @@ public override void Init() for (int i = 0; i < test.Length; i++) { test[i] = 15; - } - - // DrawPixels(test, 0, 0, 8, 8, false, false, DrawMode.TilemapCache); - - // DrawText("Works", 8, 0, DrawMode.TilemapCache, "large"); + } + + // DrawPixels(test, 0, 0, 8, 8, false, false, DrawMode.TilemapCache); + + // DrawText("Works", 8, 0, DrawMode.TilemapCache, "large"); } public override void Update(int timeDelta) @@ -85,9 +82,9 @@ public override void Update(int timeDelta) // Need to convert the nextPoint to an int, so we'll save it in a point pos.X = MathUtil.Repeat((int)nextPos, display.X + 16); pos.Y = MathUtil.Repeat((int)nextPos, display.Y + 16); - } - - + } + + public override void Draw() { // Redraw the display @@ -104,10 +101,8 @@ public override void Draw() // Draw the x,y position of each sprite DrawText("(" + MathUtil.FloorToInt(nextPos) + ",8)", pos.X + 32, 8, DrawMode.Sprite, "large", 15); - DrawText("(36," + MathUtil.FloorToInt(nextPos) + ")", 66, pos.Y + 12, DrawMode.Sprite, "large", 15); - - - + DrawText("(36," + MathUtil.FloorToInt(nextPos) + ")", 66, pos.Y + 12, DrawMode.Sprite, "large", 15); + lastSpriteCount = CurrentSprites; } }