mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Add TV remote code
This commit is contained in:
@@ -8,8 +8,7 @@ local menu_screens = {
|
||||
}
|
||||
|
||||
local buttonList
|
||||
|
||||
function ConfigScene:new(first_time)
|
||||
local function updateButtonList(self)
|
||||
buttonList = {
|
||||
BUTTON.new{
|
||||
text = "1", font = FONT_big,
|
||||
@@ -62,7 +61,17 @@ function ConfigScene:new(first_time)
|
||||
menu_screens[4] = nil
|
||||
buttonList[4] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local secret_code_input = {}
|
||||
local secret_code_used = false
|
||||
|
||||
function ConfigScene:new(first_time)
|
||||
updateButtonList(self)
|
||||
|
||||
secret_code_used = false
|
||||
secret_code_input = {} -- When it matches 79338732 then we will automatically set the special keybind
|
||||
|
||||
self.menu_state = 1
|
||||
if first_time then
|
||||
self.first_time = true
|
||||
@@ -75,11 +84,30 @@ function ConfigScene:update() end
|
||||
|
||||
function ConfigScene:render()
|
||||
MainBackground()
|
||||
if not self.first_time then
|
||||
drawText("Which controls do you want to configure?", 80, 70, 1000)
|
||||
else
|
||||
if secret_code_used then
|
||||
drawText(
|
||||
"Oh WOW! You just typed a special secret code. You may play Tromi on TV right now.\n"..
|
||||
"To return, an special keybind is automatically set.\n"..
|
||||
"You can see keybind list below"
|
||||
, 80, 40, 1000
|
||||
)
|
||||
drawText("", 80, 70, 1000)
|
||||
drawBigText("7 9 3 3 8 7 3 2", 80, 100, 1000)
|
||||
drawText(
|
||||
[[
|
||||
2 - Up 1 - Rotate left 5 - Confirm selection
|
||||
8 - Right 3 - Rotate right 0 - Back
|
||||
4 - Left 7 - Rotate left 2
|
||||
6 - Down 9 - Rotate right 2
|
||||
]],
|
||||
80, 350, 1000)
|
||||
elseif self.first_time then
|
||||
drawText("Thanks for playing Tromi!", 80, 40, 1000)
|
||||
drawText("Please begin by configuring your controls:", 80, 70, 1000)
|
||||
drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000)
|
||||
else
|
||||
drawText("Which controls do you want to configure?", 80, 70, 1000)
|
||||
drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000)
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
@@ -103,6 +131,37 @@ function ConfigScene:onInputMove(e)
|
||||
end
|
||||
end
|
||||
|
||||
---@param key string
|
||||
local function checkSecretCodeInput(self, key)
|
||||
if secret_code_used then return end
|
||||
if key:sub(1, 2) == "kp" then
|
||||
table.insert(secret_code_input, key:sub(3,3))
|
||||
elseif key:find("0-9") == 1 then
|
||||
table.insert(secret_code_input, key)
|
||||
else
|
||||
secret_code_input = {} -- Reset
|
||||
end
|
||||
if table.concat(secret_code_input, "") == "79338732" then
|
||||
-- Set keybind
|
||||
SETTINGS.input.keys = {
|
||||
["2"] = "up", ["kp2"] = "up",
|
||||
["8"] = "down", ["kp8"] = "down",
|
||||
["4"] = "left", ["kp4"] = "left",
|
||||
["6"] = "right", ["kp6"] = "right",
|
||||
["1"] = "rotate_left", ["kp1"] = "rotate_left",
|
||||
["3"] = "rotate_right", ["kp3"] = "rotate_right",
|
||||
["7"] = "rotate_left2", ["kp7"] = "rotate_left2",
|
||||
["9"] = "rotate_right2", ["kp9"] = "rotate_right2",
|
||||
["5"] = "menu_decide", ["kp5"] = "menu_decide",
|
||||
["0"] = "menu_back", ["kp0"] = "menu_back",
|
||||
}
|
||||
SETTINGS.firstTime = false
|
||||
secret_code_used = true
|
||||
updateButtonList(self)
|
||||
end
|
||||
end
|
||||
|
||||
---@param e SCENE_onInput
|
||||
function ConfigScene:onInputPress(e)
|
||||
if e.type == "touch" or e.type == "mouse" then
|
||||
BUTTON.press(buttonList, e.x, e.y, e.id)
|
||||
@@ -117,6 +176,7 @@ function ConfigScene:onInputPress(e)
|
||||
) then
|
||||
SCENE = TitleScene()
|
||||
end
|
||||
checkSecretCodeInput(self, e.key)
|
||||
end
|
||||
function ConfigScene:onInputRelease(e)
|
||||
if e.type == "touch" or e.type == "mouse" then
|
||||
|
||||
Reference in New Issue
Block a user