mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Change special code, add a way to skip keys
This commit is contained in:
@@ -11,7 +11,7 @@ local Randomizer = require 'game.randomizer'
|
||||
local GameMode = Object:extend()
|
||||
|
||||
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 input_file ~= nil then
|
||||
|
||||
@@ -85,28 +85,26 @@ function ConfigScene:update() end
|
||||
function ConfigScene:render()
|
||||
MainBackground()
|
||||
if secret_code_used then
|
||||
drawText(
|
||||
"Oh WOW! You may play Tromi on TV right now and typed a secret code.\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\n"..
|
||||
"8 - Right 3 - Rotate right 0 - Back\n"..
|
||||
"4 - Left 7 - Rotate left 2\n"..
|
||||
"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
|
||||
if SETTINGS.tvMode then
|
||||
drawText("TV mode is ON now! Check keybind below", 80, 40, 1000)
|
||||
drawText("Which controls do you want to configure?", 80, 70, 1000)
|
||||
drawText(
|
||||
"2 - Up 1 - Rotate left 5 - Confirm selection\n"..
|
||||
"8 - Right 3 - Rotate right 0 - Back\n"..
|
||||
"4 - Left 7 - Rotate left 2\n"..
|
||||
"6 - Down 9 - Rotate right 2", 80, 350, 1000
|
||||
)
|
||||
else
|
||||
drawText("TV mode is OFF now!", 80, 40, 1000)
|
||||
drawText("Which controls do you want to configure?", 80, 70, 1000)
|
||||
end
|
||||
elseif self.first_time then
|
||||
drawText("Thanks for playing Tromi!", 80, 40, 1000)
|
||||
drawText("Please begin by configuring your controls:", 80, 70, 1000)
|
||||
else
|
||||
drawText("Which controls do you want to configure?", 80, 70, 1000)
|
||||
end
|
||||
drawBigText(table.concat(secret_code_input, " "), 80, 100, 1000)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
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 key:sub(1, 2) == "kp" then
|
||||
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)
|
||||
else
|
||||
secret_code_input = {} -- Reset
|
||||
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
|
||||
SETTINGS.input.keys = {
|
||||
["2"] = "up", ["kp2"] = "up",
|
||||
@@ -154,8 +158,13 @@ local function checkSecretCodeInput(self, key)
|
||||
["0"] = "menu_back", ["kp0"] = "menu_back",
|
||||
}
|
||||
SETTINGS.firstTime = false
|
||||
SETTINGS.tvMode = true
|
||||
secret_code_used = true
|
||||
updateButtonList(self)
|
||||
elseif current_code == "........" then
|
||||
SETTINGS.input.keys = {}
|
||||
SETTINGS.tvMode = false
|
||||
secret_code_used = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -54,20 +54,20 @@ function KeyConfigScene:render()
|
||||
end
|
||||
end
|
||||
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
|
||||
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
|
||||
|
||||
function KeyConfigScene:onInputPress(e)
|
||||
if e.type == "key" then
|
||||
-- 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)
|
||||
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
|
||||
SCENE = SETTINGS.firstTime and TitleScene() or InputConfigScene()
|
||||
SETTINGS.firstTime = false
|
||||
@@ -86,6 +86,9 @@ function KeyConfigScene:onInputPress(e)
|
||||
self.new_input[e.scancode] = configurable_inputs[self.input_state]
|
||||
self.input_state = self.input_state + 1
|
||||
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
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function StickConfigScene:render()
|
||||
end
|
||||
end
|
||||
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
|
||||
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
|
||||
end
|
||||
@@ -71,10 +71,10 @@ end
|
||||
function StickConfigScene:onInputPress(e)
|
||||
if e.type == "key" then
|
||||
-- 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()
|
||||
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
|
||||
local had_config = SETTINGS.input ~= nil
|
||||
if not SETTINGS.input then SETTINGS.input = {} end
|
||||
@@ -86,7 +86,7 @@ function StickConfigScene:onInputPress(e)
|
||||
self.set_inputs = newSetInputs()
|
||||
self.new_input = {}
|
||||
end
|
||||
elseif e.scancode == "tab" then
|
||||
else -- Other keys - skip
|
||||
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
||||
self.input_state = self.input_state + 1
|
||||
end
|
||||
|
||||
@@ -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_back',r=35,iconSize=60,alpha=0.4},
|
||||
}
|
||||
}
|
||||
},
|
||||
tvMode = false -- 79338732
|
||||
}
|
||||
|
||||
SETTINGS = setmetatable(
|
||||
|
||||
Reference in New Issue
Block a user