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

Commit

Permalink
Fixes for #245, #247, 244, and 128.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 2, 2020
1 parent 39c5be9 commit 3422bba
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 982 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,13 @@ function SettingsTool:CreateControllerPanel()
field.onAction = function(value)

self.showBlinker = false
local inputLabel = self.selectedInputID == 1 and "Key" and "Buttons"
local inputLabel = self.selectedInputID == 1 and "Key" or "Button"

self:RemapKey("Player" ..tostring(self.selectedPlayerID) .. field.type .. inputLabel, self:ConvertKeyToKeyCode(value))
local success = self:RemapKey("Player" ..tostring(self.selectedPlayerID) .. field.type .. inputLabel, self:ConvertKeyToKeyCode(value))


self.usedKeysInvalid = true


-- self:DrawInputSprite(field.type)

-- InvalidateData()
if(success == true) then
pixelVisionOS:DisplayMessage(string.format("Player %d %s remapping was saved.", self.selectedInputID, inputLabel))
end

end

Expand Down Expand Up @@ -134,7 +130,7 @@ function SettingsTool:UpdateControllerPanel()

for i = 1, #inputMap do
local field = self.inputFields[i]
editorUI:ChangeInputField(field, self:ConvertKeyCodeToChar(tonumber(ReadMetadata(inputMap[i]))), false)
editorUI:ChangeInputField(field, self:ConvertKeyCodeToChar(tonumber(ReadBiosData(inputMap[i]))), false)
end

else
Expand Down Expand Up @@ -214,31 +210,6 @@ function SettingsTool:DrawBlinkSprite()
DrawSprites(inputbuttonon.spriteIDs, 154, 62, inputbuttonon.width)
end

-- function SettingsTool:OnPlayerSelection(value)

-- if(self.invalid == true) then

-- pixelVisionOS:ShowMessageModal("Unsaved Changes", "You have not saved your changes for this controller. Do you want to save them before switching to a different player?", 160, true,
-- function()
-- if(pixelVisionOS.messageModal.selectionValue == true) then
-- -- Save changes
-- self:OnSave()

-- end

-- -- Quit the tool
-- self:TriggerPlayerSelection(value)

-- end
-- )

-- else
-- Quit the tool
-- self:TriggerPlayerSelection(value)
-- end

-- end

function SettingsTool:TriggerPlayerSelection(value)
self.selectedPlayerID = value

Expand All @@ -265,33 +236,6 @@ function SettingsTool:TriggerPlayerSelection(value)

end

-- function SettingsTool:OnInputSelection(value)

-- -- if(self.invalid == true) then

-- -- pixelVisionOS:ShowMessageModal("Unsaved Changes", "You have not saved your changes for this controller. Do you want to save them before switching to a different input mode?", 160, true,
-- -- function()
-- -- if(pixelVisionOS.messageModal.selectionValue == true) then
-- -- -- Save changes
-- -- OnSave()

-- -- end

-- -- -- TODO looks like there may be a race condition when switching between players here and selection is not displayed correctly from tilemap cache

-- -- -- Quit the tool
-- -- self:OnTriggerInputSelection(value)

-- -- end
-- -- )

-- -- else
-- -- Quit the tool
-- self:OnTriggerInputSelection(value)
-- -- end

-- end

function SettingsTool:OnTriggerInputSelection(value)

-- make sure the controller is connected first
Expand Down Expand Up @@ -348,16 +292,14 @@ function SettingsTool:GetUsedKeys()

if(self.usedKeysInvalid ~= false) then



self.usedControllerKeys = {}

-- Player 1 Keys
for i = 1, #player1Keys do

local key = player1Keys[i]

self.usedControllerKeys[key] = self:ConvertKeyCodeToChar(tonumber(ReadMetadata(key)))
self.usedControllerKeys[key] = self:ConvertKeyCodeToChar(tonumber(ReadBiosData(key)))

end

Expand All @@ -366,7 +308,7 @@ function SettingsTool:GetUsedKeys()

local key = player2Keys[i]

self.usedControllerKeys[key] = self:ConvertKeyCodeToChar(tonumber(ReadMetadata(key)))
self.usedControllerKeys[key] = self:ConvertKeyCodeToChar(tonumber(ReadBiosData(key)))

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,44 @@ function SettingsTool:CreateDisplayPanel()
self.scaleInputData.max = 4
self.scaleInputData.onAction = function(value) self:OnChangeScale(value) end

self.fullScreenCheckBoxData = editorUI:CreateToggleButton({x = 128, y = 192, w = 8, h = 8}, "checkbox", "Toggle full screen mode.")
self.fullScreenCheckBoxData.hitRect = {x = 131, y = 192, w = 8, h = 8}
self.fullScreenCheckBoxData.onAction = function(value)
Fullscreen(value)
self.stretchCheckBoxData = editorUI:CreateToggleButton({x = 128, y = 208, w = 8, h = 8}, "checkbox", "Stretch the display to fit the window.")

self.stretchCheckBoxData.onAction = function (value)
StretchScreen(value)

WriteBiosData("FullScreen", value == true and "True" or "False")
WriteBiosData("StretchScreen", value == true and "True" or "False")
end

editorUI:ToggleButton(self.fullScreenCheckBoxData, Fullscreen(), false)
editorUI:ToggleButton(self.stretchCheckBoxData, StretchScreen())

self.cropCheckBoxData = editorUI:CreateToggleButton({x = 128, y = 200, w = 8, h = 8}, "checkbox", "Enable the window to crop.")
self.cropCheckBoxData.onAction = function (value)
CropScreen(value)

WriteBiosData("CropScreen", value == true and "True" or "False")

end

editorUI:ToggleButton(self.cropCheckBoxData, CropScreen())

self.stretchCheckBoxData = editorUI:CreateToggleButton({x = 128, y = 208, w = 8, h = 8}, "checkbox", "Stretch the display to fit the window.")

self.stretchCheckBoxData.onAction = function (value)
StretchScreen(value)

WriteBiosData("StretchScreen", value == true and "True" or "False")
self.fullScreenCheckBoxData = editorUI:CreateToggleButton({x = 128, y = 192, w = 8, h = 8}, "checkbox", "Toggle full screen mode.")
self.fullScreenCheckBoxData.hitRect = {x = 131, y = 192, w = 8, h = 8}
self.fullScreenCheckBoxData.onAction = function(value)
Fullscreen(value)

WriteBiosData("FullScreen", value == true and "True" or "False")


editorUI:Enable(self.cropCheckBoxData, not value)
editorUI:ToggleButton(self.cropCheckBoxData, value == false and CropScreen() or false, false)

editorUI:Enable(self.stretchCheckBoxData, value)
editorUI:ToggleButton(self.stretchCheckBoxData, value == true and StretchScreen() or false, false)

end

editorUI:ToggleButton(self.stretchCheckBoxData, StretchScreen())
editorUI:ToggleButton(self.fullScreenCheckBoxData, Fullscreen())


self.crtToggleButton = editorUI:CreateToggleButton({x = 128, y = 216, w = 8, h = 8}, "checkbox", "Toggle the CRT effect.")

Expand Down
13 changes: 12 additions & 1 deletion Disks/PixelVisionOS/System/Tools/SettingsTool/code-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,21 @@ function SettingsTool:RemapKey(keyName, keyCode)

-- Make sure that the key code is valid
if (keyCode == -1) then
return
return false
end

print("Write Bios", keyName, tostring(keyCode))

-- Save the new mapped key to the bios
WriteBiosData(keyName, tostring(keyCode));


print("Read Bios", ReadBiosData(keyName), self:ConvertKeyCodeToChar(ReadBiosData(keyName)))

self.usedKeysInvalid = true

self:GetUsedKeys()

return true

end

0 comments on commit 3422bba

Please sign in to comment.