Change special code, add a way to skip keys

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-26 21:30:56 +07:00
parent 4b001cdf57
commit 478a8bf49e
5 changed files with 47 additions and 34 deletions

View File

@@ -11,7 +11,7 @@ local Randomizer = require 'game.randomizer'
local GameMode = Object:extend() local GameMode = Object:extend()
function GameMode:new(player_name, input_file, replay_grade) function GameMode:new(player_name, input_file, replay_grade)
VCTRL.toggle(MOBILE and not input_file) VCTRL.toggle(MOBILE and not input_file and not SETTINGS.tvMode)
if player_name == nil then self.training = true else self.training = false end if player_name == nil then self.training = true else self.training = false end
if input_file ~= nil then if input_file ~= nil then

View File

@@ -85,28 +85,26 @@ function ConfigScene:update() end
function ConfigScene:render() function ConfigScene:render()
MainBackground() MainBackground()
if secret_code_used then if secret_code_used then
drawText( if SETTINGS.tvMode then
"Oh WOW! You may play Tromi on TV right now and typed a secret code.\n".. drawText("TV mode is ON now! Check keybind below", 80, 40, 1000)
"To return, an special keybind is automatically set.\n".. drawText("Which controls do you want to configure?", 80, 70, 1000)
"You can see keybind list below" drawText(
, 80, 40, 1000 "2 - Up 1 - Rotate left 5 - Confirm selection\n"..
) "8 - Right 3 - Rotate right 0 - Back\n"..
drawText("", 80, 70, 1000) "4 - Left 7 - Rotate left 2\n"..
drawBigText("7 9 3 3 8 7 3 2", 80, 100, 1000) "6 - Down 9 - Rotate right 2", 80, 350, 1000
drawText( )
"2 - Up 1 - Rotate left 5 - Confirm selection\n".. else
"8 - Right 3 - Rotate right 0 - Back\n".. drawText("TV mode is OFF now!", 80, 40, 1000)
"4 - Left 7 - Rotate left 2\n".. drawText("Which controls do you want to configure?", 80, 70, 1000)
"6 - Down 9 - Rotate right 2", 80, 350, 1000 end
) elseif self.first_time then
elseif self.first_time then drawText("Thanks for playing Tromi!", 80, 40, 1000)
drawText("Thanks for playing Tromi!", 80, 40, 1000) drawText("Please begin by configuring your controls:", 80, 70, 1000)
drawText("Please begin by configuring your controls:", 80, 70, 1000) else
drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000) drawText("Which controls do you want to configure?", 80, 70, 1000)
else end
drawText("Which controls do you want to configure?", 80, 70, 1000) drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000)
drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000)
end
love.graphics.setColor(1, 1, 1, 0.5) love.graphics.setColor(1, 1, 1, 0.5)
love.graphics.rectangle("fill", 75, 120 + 40 * self.menu_state, 300, 40) love.graphics.rectangle("fill", 75, 120 + 40 * self.menu_state, 300, 40)
@@ -134,12 +132,18 @@ local function checkSecretCodeInput(self, key)
if secret_code_used then return end if secret_code_used then return end
if key:sub(1, 2) == "kp" then if key:sub(1, 2) == "kp" then
table.insert(secret_code_input, key:sub(3,3)) table.insert(secret_code_input, key:sub(3,3))
elseif key:find("[0-9]") == 1 then elseif key:find("[0-9.]") == 1 then
table.insert(secret_code_input, key) table.insert(secret_code_input, key)
else else
secret_code_input = {} -- Reset secret_code_input = {} -- Reset
end end
if table.concat(secret_code_input, "") == "79338732" then
if #secret_code_input > 8 then
table.remove(secret_code_input, 1)
end
local current_code = table.concat(secret_code_input, "")
if current_code == "88663366" then --TVMODEON
-- Set keybind -- Set keybind
SETTINGS.input.keys = { SETTINGS.input.keys = {
["2"] = "up", ["kp2"] = "up", ["2"] = "up", ["kp2"] = "up",
@@ -154,8 +158,13 @@ local function checkSecretCodeInput(self, key)
["0"] = "menu_back", ["kp0"] = "menu_back", ["0"] = "menu_back", ["kp0"] = "menu_back",
} }
SETTINGS.firstTime = false SETTINGS.firstTime = false
SETTINGS.tvMode = true
secret_code_used = true secret_code_used = true
updateButtonList(self) updateButtonList(self)
elseif current_code == "........" then
SETTINGS.input.keys = {}
SETTINGS.tvMode = false
secret_code_used = true
end end
end end

View File

@@ -54,20 +54,20 @@ function KeyConfigScene:render()
end end
end end
if self.input_state > #configurable_inputs then if self.input_state > #configurable_inputs then
drawText("Press enter to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape to cancel" or ""),0,0,1000) drawText("Press Enter/Confirm Selection to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape/Go Back to cancel" or ""),0,0,1000)
else else
drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000) drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000)
drawText("Function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20,1000) drawText("Press any key from other input than keyboard will also skip.\nFunction keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20,1000)
end end
end end
function KeyConfigScene:onInputPress(e) function KeyConfigScene:onInputPress(e)
if e.type == "key" then if e.type == "key" then
-- function keys, escape, and tab are reserved and can't be remapped -- function keys, escape, and tab are reserved and can't be remapped
if e.scancode == "escape" then if e.scancode == "escape" or (self.input_state > #configurable_inputs and e.input == "menu_back") then
SCENE = InputConfigScene(SETTINGS.firstTime) SCENE = InputConfigScene(SETTINGS.firstTime)
elseif self.input_state > #configurable_inputs then elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then if e.scancode == "return" or e.input == "menu_decide" then
SETTINGS.input.keys = self.new_input SETTINGS.input.keys = self.new_input
SCENE = SETTINGS.firstTime and TitleScene() or InputConfigScene() SCENE = SETTINGS.firstTime and TitleScene() or InputConfigScene()
SETTINGS.firstTime = false SETTINGS.firstTime = false
@@ -86,6 +86,9 @@ function KeyConfigScene:onInputPress(e)
self.new_input[e.scancode] = configurable_inputs[self.input_state] self.new_input[e.scancode] = configurable_inputs[self.input_state]
self.input_state = self.input_state + 1 self.input_state = self.input_state + 1
end end
elseif self.input_state < #configurable_inputs then
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
self.input_state = self.input_state + 1
end end
end end

View File

@@ -54,7 +54,7 @@ function StickConfigScene:render()
end end
end end
if self.input_state > #configurable_inputs then if self.input_state > #configurable_inputs then
drawText("Press enter to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape to cancel" or ""), 0, 0, 1000) drawText("Press enter/Confirm Selection to confirm, delete/backspace to retry" .. (SETTINGS.input and ", escape/Go Back to cancel" or ""), 0, 0, 1000)
else else
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000) drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
end end
@@ -71,10 +71,10 @@ end
function StickConfigScene:onInputPress(e) function StickConfigScene:onInputPress(e)
if e.type == "key" then if e.type == "key" then
-- function keys, escape, and tab are reserved and can't be remapped -- function keys, escape, and tab are reserved and can't be remapped
if e.scancode == "escape" then if e.scancode == "escape" or (self.input_state > #configurable_inputs and e.input == "menu_back") then
SCENE = InputConfigScene() SCENE = InputConfigScene()
elseif self.input_state > #configurable_inputs then elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then if e.scancode == "return" or e.input == "" then
-- save new input, then load next scene -- save new input, then load next scene
local had_config = SETTINGS.input ~= nil local had_config = SETTINGS.input ~= nil
if not SETTINGS.input then SETTINGS.input = {} end if not SETTINGS.input then SETTINGS.input = {} end
@@ -86,7 +86,7 @@ function StickConfigScene:onInputPress(e)
self.set_inputs = newSetInputs() self.set_inputs = newSetInputs()
self.new_input = {} self.new_input = {}
end end
elseif e.scancode == "tab" then else -- Other keys - skip
self.set_inputs[configurable_inputs[self.input_state]] = "skipped" self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
self.input_state = self.input_state + 1 self.input_state = self.input_state + 1
end end

View File

@@ -28,7 +28,8 @@ local _defaultSettings = {
{type='button',x=320- 40,y=420,key= 'menu_decide',r=35,iconSize=60,alpha=0.4}, {type='button',x=320- 40,y=420,key= 'menu_decide',r=35,iconSize=60,alpha=0.4},
{type='button',x=320+ 40,y=420,key= 'menu_back',r=35,iconSize=60,alpha=0.4}, {type='button',x=320+ 40,y=420,key= 'menu_back',r=35,iconSize=60,alpha=0.4},
} }
} },
tvMode = false -- 79338732
} }
SETTINGS = setmetatable( SETTINGS = setmetatable(