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:
@@ -19,15 +19,17 @@ Ported to Android by SweetSea with on-screen control (with some necessary change
|
||||
* No differences in gameplay
|
||||
* Files will be saved into ``Android/data/org.love2d.android/tromi_mobile`` instead the location where the game files in
|
||||
* All UIs are touch-able
|
||||
* <details><summary>Changes the way to input secret code to activate Pentominoes mode</summary><img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/SPOILER_secret_code.png">To insert the left arrow, tap on the left, so does to right arrow.</details>
|
||||
* Rename ``Max Gravity Training`` to ``20G Training``
|
||||
* <details><summary>Add a special pre-made keybind for Android TV (only supports TV models have their remote has numerical area (0-9))</summary><img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/SPOILER_tv_code.png"></special>
|
||||
* <details><summary>Changes the way to input secret code to activate Pentominoes mode</summary><img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/SPOILER_pento_code.png">To insert the left arrow, tap on the left, so does to right arrow.</details>
|
||||
* Add a loading screen (this need to be updated later)
|
||||
* Replaced ``binser`` serializer with ``bitser`` serializer (IDK why it is failed when saving, this change ***make configuration and profile files cannot be imported back to original Tromi***, except replay)
|
||||
|
||||
# TODO
|
||||
|
||||
- [ ] Add a way to export replay for Android > 11
|
||||
- [ ] Revert ``bitser`` with ``binser`` (if and only if I can make it works)
|
||||
- [ ] Design a new on-screen buttons skin (the current one is come from [C₂₉H₂₅N₃O₅](https://github.com/C29H25N3O5), I am aware that it's not fit to Tromi's design language)
|
||||
- [ ] (Low priority) Design a new menu screen
|
||||
|
||||
# License (GNU GPLv3)
|
||||
Please read ``LICENSE.txt`` for more information.<br>
|
||||
|
||||
9
main.lua
9
main.lua
@@ -102,10 +102,10 @@ function love.draw()
|
||||
-- love.graphics.line(0, grid_height * iy, 640, grid_height * iy)
|
||||
-- end
|
||||
|
||||
-- local x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
-- love.graphics.setColor(0, 0, 0, 0.8)
|
||||
-- love.graphics.rectangle("fill", 5, 450, 115, 25)
|
||||
-- drawText(string.format("X: %.1d; Y: %.1d", x, y), 10, 455, 110, "left")
|
||||
local x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
love.graphics.setColor(0, 0, 0, 0.8)
|
||||
love.graphics.rectangle("fill", 5, 450, 115, 25)
|
||||
drawText(string.format("X: %.1d; Y: %.1d", x, y), 10, 455, 110, "left")
|
||||
|
||||
-- love.graphics.setColor(1, 1, 1, 1)
|
||||
-- love.graphics.setLineWidth(2)
|
||||
@@ -157,6 +157,7 @@ function love.keypressed(key, scancode)
|
||||
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||
SCENE = InputConfigScene()
|
||||
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
|
||||
elseif scancode == "f11" then SETTINGS.firstTime = true
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||
return
|
||||
|
||||
@@ -12,8 +12,8 @@ function SCENE:render() end
|
||||
---@field type "key"|"joystick"|"virtual"|"touch"|"mouse"|"wheel"
|
||||
---
|
||||
---@field input? string # Action triggered<br>Only visible via keyboard and gamepad
|
||||
---@field key? love.KeyConstant Only visible via keyboard and gamepad
|
||||
---@field scancode? love.Scancode Only visible via keyboard and gamepad
|
||||
---@field key? love.KeyConstant Key pressed? Only visible via keyboard and gamepad
|
||||
---@field scancode? love.Scancode Key pressed but on the US layout? Only visible via keyboard and gamepad
|
||||
---
|
||||
---@field x? number Only visible via touch and mouse
|
||||
---@field y? number Only visible via touch and mouse
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local TrainingScene = SCENE:extend()
|
||||
TrainingScene.title = "20G Training"
|
||||
TrainingScene.title = "Max Gravity Training"
|
||||
|
||||
local menuKey
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 514 KiB After Width: | Height: | Size: 514 KiB |
BIN
screenshot/SPOILER_tv_code.png
Normal file
BIN
screenshot/SPOILER_tv_code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 494 KiB |
Reference in New Issue
Block a user