9 Commits

Author SHA1 Message Date
Squishy (C6H12O6+NaCl+H2O)
c9a97856fd Update virtual control scene 2024-05-29 22:24:48 +07:00
Squishy (C6H12O6+NaCl+H2O)
8f902caa22 Update virtual control texture 2024-05-29 20:32:29 +07:00
Squishy (C6H12O6+NaCl+H2O)
4e0815e13a Updating README file 2024-05-29 15:53:29 +07:00
Squishy (C6H12O6+NaCl+H2O)
c555e98081 Replace font 2024-05-29 15:33:46 +07:00
Squishy (C6H12O6+NaCl+H2O)
fbfd9ee0db Update font related stuff 2024-05-29 10:34:57 +07:00
Squishy (C6H12O6+NaCl+H2O)
3c473fd5f3 convert indents to spaces 2024-05-29 10:01:34 +07:00
Squishy (C6H12O6+NaCl+H2O)
dd55171204 Replacing font, to avoid license issue 2024-05-29 09:56:59 +07:00
Squishy (C6H12O6+NaCl+H2O)
6beacc51f5 Update conf.lua 2024-05-29 00:27:15 +07:00
Squishy (C6H12O6+NaCl+H2O)
c14c702d17 Update touch control 2024-05-29 00:26:05 +07:00
20 changed files with 328 additions and 290 deletions

View File

@@ -36,22 +36,22 @@ Ported to Android (mobile and TV) by SweetSea with on-screen control (with some
Navigate to where you put ``tromi_mobile.love`` in the File manager (the one you downloaded from the link in Install for TV section), just opening and Tromi should be launched. Navigate to where you put ``tromi_mobile.love`` in the File manager (the one you downloaded from the link in Install for TV section), just opening and Tromi should be launched.
# Differences from original Tromi # Differences from original Tromi
> This is required, to follow the used license (GNU GPL v3) > I must make this list to follow the used license (GNU GPL v3)<br>
> :no_entry: There are ***very much*** breaking changes right now, and I can't always finish this list. I may try hard to do it.
* No differences in gameplay * No differences in gameplay
* Files will be saved into ``Android/data/org.love2d.android/tromi_mobile`` instead the location where the game files in * Files will be saved into ``Android/data/org.love2d.android/tromi_mobile`` instead the location where the game files in
* Add ``simple-button`` module, made by SweetSea * Add ``simple-button`` module, made by me (SweetSea)
* All UIs are touch-able * All UIs are touch-able
* Add on-screen buttons * Add on-screen buttons
* Replaced icons for 3 direction buttons (Left, Down, Right) * Replaced icons for 3 direction buttons (Left, Down, Right), using from Techmino's font (outdated image)
<img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/Replay_screen_differences.png"> <img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/Replay_screen_differences.png">
* Add a special pre-made keybind for Android TV (only supports TV models have their remote has numerical area (0-9))<img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/SPOILER_tv_code.png"> * Add a special pre-made keybind for Android TV (only supports TV models have their remote has numerical area (0-9))<img src="https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile/raw/branch/main/screenshot/SPOILER_tv_code.png">
* <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> * <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) * Add a loading screen ~~(this need to be updated later)~~
* Update ``binser`` library, this fixes some weird bugs related to saving * Update ``binser`` library, this fixes some weird bugs related to saving
* Replaced old Cambridge's ``config`` module with the new one inspired by "the sequel of Techmino"s ``SETTINGS`` module * Replaced old Cambridge's ``config`` module with the new one inspired by "the sequel of Techmino"s ``SETTINGS`` module
# TODO # TODO
- [ ] Add a way to export ~~replay~~ data for Android > 11 - [ ] Add a way to export ~~replay~~ data for Android > 11
- [x] Revert ``bitser`` with ``binser`` (if and only if I can make it works) - [x] Revert ``bitser`` with ``binser`` (if and only if I can make it works)
- [x] 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) - [x] 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)
@@ -71,7 +71,7 @@ A small note about the music:
# Special thanks # Special thanks
* mycophobia for writing the original Tromi * mycophobia for writing the original Tromi
* MrZ_26 for the base of ``VCTRL`` module (yea I stole from him his code ;-; ) * MrZ_26 for the base of ``VCTRL`` module (yea I stole from him his code ;-; )
* C₂₉H₂₅N₃O₅ for his virtual key design (used while during inital development), and icon font (actually I extracted and re-pack as a new font from his orginal production file) * C₂₉H₂₅N₃O₅ for his virtual key design (used while during inital development), and icon font (from Techmino).
# Don't forget to check # Don't forget to check
* [Original Tromi](https://mycophobia.org/tromi) * [Original Tromi](https://mycophobia.org/tromi)

View File

@@ -1,5 +1,5 @@
function love.conf(t) function love.conf(t)
t.identity = "tromi_ver3" t.identity = "tromi_mobile"
t.externalstorage=true t.externalstorage=true
t.console = true t.console = true

View File

@@ -143,6 +143,15 @@ function drawText(text, x, y, size, orientation, color)
love.graphics.printf(text, x, y, size*2, orientation, nil, 0.5) love.graphics.printf(text, x, y, size*2, orientation, nil, 0.5)
end end
function drawBoldText(text, x, y, size, orientation, color)
if color == nil then color = {1, 1, 1, 1} end
love.graphics.setFont(FONT_bold)
love.graphics.setColor(0, 0, 0, 0.8)
love.graphics.printf(text, x+1, y+1, size*2, orientation, nil, 0.50)
love.graphics.setColor(color)
love.graphics.printf(text, x, y, size*2, orientation, nil, 0.5)
end
function drawBigText(text, x, y, size, orientation, color) function drawBigText(text, x, y, size, orientation, color)
if color == nil then color = {1, 1, 1, 1} end if color == nil then color = {1, 1, 1, 1} end
love.graphics.setFont(FONT_big) love.graphics.setFont(FONT_big)

View File

@@ -677,6 +677,7 @@ function GameMode:onPieceEnter()
end end
function GameMode:onGameOver() function GameMode:onGameOver()
if not self.training then VCTRL.toggle(false) end
if not self.input_playback and not self.training and not PENTO_MODE then if not self.input_playback and not self.training and not PENTO_MODE then
if not self.did_grades then if not self.did_grades then
self.grade_score = self.grade_score + self.speed_level self.grade_score = self.grade_score + self.speed_level
@@ -921,19 +922,19 @@ end
function GameMode:drawInputDisplay(left, top) function GameMode:drawInputDisplay(left, top)
if self.replay_inputs[self.frames] ~= nil then if self.replay_inputs[self.frames] ~= nil then
drawText("+", left+10, top+8, 1000, "left") drawText("", left+7.5, top+ 8, 1000, "left")
drawText("", left+10, top+18, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['down']),1,1-boolToInt(self.replay_inputs[self.frames]['down']),1}) drawText(CHAR.key.down , left+ 5, top+18, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['down']),1,1-boolToInt(self.replay_inputs[self.frames]['down']),1})
drawText("", left, top+8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['left']),1,1-boolToInt(self.replay_inputs[self.frames]['left']),1}) drawText(CHAR.key.left , left- 5, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['left']),1,1-boolToInt(self.replay_inputs[self.frames]['left']),1})
drawText("", left+20, top+8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['right']),1,1-boolToInt(self.replay_inputs[self.frames]['right']),1}) drawText(CHAR.key.right, left+ 15, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['right']),1,1-boolToInt(self.replay_inputs[self.frames]['right']),1})
drawText("L", left+ 35, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_left']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_left']),1}) drawText("L", left+ 35, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_left']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_left']),1})
drawText("R", left+ 50, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_right']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_right']),1}) drawText("R", left+ 50, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_right']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_right']),1})
drawText("L", left+ 65, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_left2']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_left2']),1}) drawText("L", left+ 65, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_left2']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_left2']),1})
drawText("R", left+ 80, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_right2']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_right2']),1}) drawText("R", left+ 80, top+ 8, 1000, "left",{1-boolToInt(self.replay_inputs[self.frames]['rotate_right2']),1,1-boolToInt(self.replay_inputs[self.frames]['rotate_right2']),1})
else else
drawText("+", left+10, top+8, 1000, "left") drawText("" , left+7.5, top+ 8, 1000, "left")
drawText("", left+10, top+18, 1000, "left") drawText(CHAR.key.down , left+ 5, top+18, 1000)
drawText("", left, top+8, 1000, "left") drawText(CHAR.key.left , left- 5, top+ 8, 1000)
drawText("", left+20, top+8, 1000, "left") drawText(CHAR.key.right, left+ 15, top+ 8, 1000)
drawText("L" , left+ 35, top+ 8, 1000, "left") drawText("L" , left+ 35, top+ 8, 1000, "left")
drawText("R" , left+ 50, top+ 8, 1000, "left") drawText("R" , left+ 50, top+ 8, 1000, "left")
drawText("L" , left+ 65, top+ 8, 1000, "left") drawText("L" , left+ 65, top+ 8, 1000, "left")
@@ -946,16 +947,16 @@ function GameMode:drawSpeedStats(left, top)
love.graphics.rectangle("fill", left+3, top+3, 190, 145, 10, 10) love.graphics.rectangle("fill", left+3, top+3, 190, 145, 10, 10)
love.graphics.setColor(0.05,0.05,0.05,1) love.graphics.setColor(0.05,0.05,0.05,1)
love.graphics.rectangle("fill", left, top, 190, 145, 10, 10) love.graphics.rectangle("fill", left, top, 190, 145, 10, 10)
drawText("Efficiency Bonus: ", left+15, top+10, 1000, "left") drawText("Efficiency Bonus: ", left+15, top+5, 1000, "left")
local lines = self.total_lines local lines = self.total_lines
if lines == 0 then lines = 1 end if lines == 0 then lines = 1 end
if self.move_count == 0 then if self.move_count == 0 then
drawText(string.format(" %4d Num. of Moves", self.target), left+15, top+25, 1000, "left") drawText(string.format(" %4d Num. of Moves", self.target), left+15, top+20, 1000, "left")
else else
drawText(string.format(" %4d Num. of Moves", self.move_count), left+15, top+25, 1000, "left") drawText(string.format(" %4d Num. of Moves", self.move_count), left+15, top+20, 1000, "left")
end end
drawText(string.format("/ %4d Active Frames", self.last_active), left+15, top+40, 1000, "left") drawText(string.format("/ %4d Active Frames", self.last_active), left+15, top+35, 1000, "left")
drawText(string.format("= %1.2f\n (0 added for hole)\n %1.2f %dpc Average\nx %s x Lines\n+ %4d", self.last_percent, self.total_speed_loss, #self.speed_table, self.bonus_components['speed'], self.last_speed), left+15, top+55, 1000, "left") drawText(string.format("= %1.2f\n (0 added for hole)\n %1.2f %dpc Average\nx %s x Lines\n+ %4d", self.last_percent, self.total_speed_loss, #self.speed_table, self.bonus_components['speed'], self.last_speed), left+15, top+50, 1000, "left")
end end
function GameMode:drawLinesStats(left, top) function GameMode:drawLinesStats(left, top)
@@ -991,7 +992,7 @@ function GameMode:drawScoringInfo()
love.graphics.rectangle("fill", 68, 270, 140, 190, 10, 10) love.graphics.rectangle("fill", 68, 270, 140, 190, 10, 10)
love.graphics.setColor(0.05,0.05,0.05,1) love.graphics.setColor(0.05,0.05,0.05,1)
love.graphics.rectangle("fill", 65, 267, 140, 190, 10, 10) love.graphics.rectangle("fill", 65, 267, 140, 190, 10, 10)
drawText(string.format("Replay in progress\n\n\n\n\n\n\n\n\n%s", formatTime(self.frames)), 70, 275, 1000, "left") drawBoldText(string.format("REPLAY IN PROGRESS\n\n\n\n\n\n\n\n\n%s", formatTime(self.frames)), 70, 275, 1000, "left")
drawBigText(string.format("%s", self.grade), 100, 143, 1000, "left") drawBigText(string.format("%s", self.grade), 100, 143, 1000, "left")
self:drawInputDisplay(103,185) self:drawInputDisplay(103,185)
elseif not PENTO_MODE then elseif not PENTO_MODE then

View File

@@ -64,7 +64,7 @@ function control_type.button:new(data)
r=data.r or 80, -- size r=data.r or 80, -- size
shape=data.shape or 'circle', shape=data.shape or 'circle',
key=data.key or 'X', key=data.key or 'X',
iconSize=data.iconSize or 80, iconSize=data.iconSize or 60,
alpha=data.alpha or 0.75, alpha=data.alpha or 0.75,
quad=virtual_quad[data.key] quad=virtual_quad[data.key]
},self) },self)
@@ -148,6 +148,7 @@ local touches={}
local global_toggle=false local global_toggle=false
VCTRL={} VCTRL={}
VCTRL.focus=nil -- Focusing buttons VCTRL.focus=nil -- Focusing buttons
VCTRL.hasChanged = false
---@class VCTRL.data ---@class VCTRL.data
---@field type 'button' ---@field type 'button'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@@ -1,7 +1,8 @@
-- SIMPLE-BUTTON.lua -- SIMPLE-BUTTON.lua<br>
-- A simple module that aims to help you quickly create buttons -- A simple module that aims to help you quickly create buttons<br>
-- It is can be used as a base class to help you quickly creating button -- It is can be used as a base class to help you quickly creating button<br>
-- This module has type notations so IntelliSense should give you some suggestions -- This module has type notations so IntelliSense should give you some suggestions<br>
local BUTTON = {}
-- MIT License -- MIT License
@@ -174,9 +175,6 @@ function button:release(x, y, touchID)
end end
end end
local BUTTON = {}
---@param D BUTTON.button|BUTTON.newData ---@param D BUTTON.button|BUTTON.newData
---@param safe? boolean @ Creating widget? If not then ignore accept missing important parameters ---@param safe? boolean @ Creating widget? If not then ignore accept missing important parameters
---@return nil ---@return nil

View File

@@ -1,9 +1,11 @@
-- Fonts -- Fonts
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28) FONT_tromi = love.graphics.newFont('res/fonts/Iosevka-Bold.ttf' , 28)
FONT_big = love.graphics.newFont('res/fonts/monofonto rg.otf', 56) FONT_big = love.graphics.newFont('res/fonts/Iosevka-Heavy.ttf', 56)
FONT_bold = love.graphics.newFont('res/fonts/Iosevka-Heavy.ttf', 28)
FONT_tromi:setFallbacks(love.graphics.newFont('res/fonts/icon.otf', 28)) -- Icons
FONT_big :setFallbacks(love.graphics.newFont('res/fonts/icon.otf', 56)) FONT_tromi:setFallbacks(love.graphics.newFont('res/fonts/techmino_proportional.otf', 28))
FONT_bold :setFallbacks(love.graphics.newFont('res/fonts/techmino_proportional.otf', 28))
FONT_big :setFallbacks(love.graphics.newFont('res/fonts/techmino_proportional.otf', 56))
CHAR = require("char") CHAR = require("char")
local font_height = FONT_tromi:getHeight() * 0.5 local font_height = FONT_tromi:getHeight() * 0.5
@@ -35,12 +37,7 @@ BUTTON.setDefaultOption{
local lineAmount local lineAmount
do do
local _, t local _, t = self.font:getWrap(text, (self.w - 5) * 2)
if need_big_font then
_, t = FONT_big:getWrap(text, (self.w - 5) * 2)
else
_, t = FONT_tromi:getWrap(text, (self.w - 5) * 2)
end
lineAmount = #t lineAmount = #t
end end
@@ -49,8 +46,10 @@ BUTTON.setDefaultOption{
local textHeight = _font_height * (lineAmount * 0.5) local textHeight = _font_height * (lineAmount * 0.5)
local textPos = self.y + (self.h * 0.5) - textHeight local textPos = self.y + (self.h * 0.5) - textHeight
if need_big_font then if self.font == FONT_big then
drawBigText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor) drawBigText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor)
elseif self.font == FONT_bold then
drawBoldText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor)
else else
drawText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor) drawText(text, self.x + 2.5, textPos, self.w - 5, self.textOrientation, self.textColor)
end end

BIN
res/fonts/Iosevka-Bold.ttf Normal file

Binary file not shown.

BIN
res/fonts/Iosevka-Heavy.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -47,7 +47,7 @@ local function updateButtonList(self)
if not SETTINGS.firstTime then if not SETTINGS.firstTime then
menu_screens[4] = TitleScene menu_screens[4] = TitleScene
buttonList[4] = BUTTON.new{ buttonList[4] = BUTTON.new{
text = "", font = FONT_big, text = CHAR.icon.home, font = FONT_big,
x = 75, y = 280, w = 40, h = 40, x = 75, y = 280, w = 40, h = 40,
codeWhenReleased = function() codeWhenReleased = function()
if self.menu_state ~= 4 then if self.menu_state ~= 4 then

View File

@@ -4,37 +4,37 @@ ReplaySelectScene.title = "Replay"
local replay_list local replay_list
local buttonList = { local buttonList = {
BUTTON.new{ BUTTON.new{
text = "\nUP", font = FONT_big, text = CHAR.key.up.."\nUP", font = FONT_big,
x = 425, y = 80, w = 80, h = 80, x = 425, y = 80, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "up"} end, codeWhenPressed = function() SCENE:onInputPress {input = "up"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "up"} end codeWhenReleased = function() SCENE:onInputRelease{input = "up"} end
}, },
BUTTON.new{ BUTTON.new{
text = "\nDOWN", font = FONT_big, text = CHAR.key.down.."\nDOWN", font = FONT_big,
x = 425, y = 240, w = 80, h = 80, x = 425, y = 240, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "down"} end, codeWhenPressed = function() SCENE:onInputPress {input = "down"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "down"} end codeWhenReleased = function() SCENE:onInputRelease{input = "down"} end
}, },
BUTTON.new{ BUTTON.new{
text = "\nPLAY", font = FONT_big, text = CHAR.icon.play.."\nPLAY", font = FONT_big,
x = 345, y = 160, w = 80, h = 80, x = 345, y = 160, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "menu_decide"} end, codeWhenPressed = function() SCENE:onInputPress {input = "menu_decide"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_decide"} end codeWhenReleased = function() SCENE:onInputRelease{input = "menu_decide"} end
}, },
BUTTON.new{ BUTTON.new{
text = "\nHOME", font = FONT_big, text = CHAR.icon.home.."\nHOME", font = FONT_big,
x = 505, y = 160, w = 80, h = 80, x = 505, y = 160, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "menu_back"} end, codeWhenPressed = function() SCENE:onInputPress {input = "menu_back"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_back"} end codeWhenReleased = function() SCENE:onInputRelease{input = "menu_back"} end
}, },
BUTTON.new{ BUTTON.new{
text = CHAR.icon.export.."\nCOPY", font = FONT_big, text = CHAR.icon.export.."\nEXP.", font = FONT_big,
x = 345, y = 320, w = 80, h = 80, x = 345, y = 320, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "rotate_left"} end, codeWhenPressed = function() SCENE:onInputPress {input = "rotate_left"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_left"} end codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_left"} end
}, },
BUTTON.new{ BUTTON.new{
text = CHAR.icon.import.."\nPASTE", font = FONT_big, text = CHAR.icon.import.."\nIMP.", font = FONT_big,
x = 505, y = 320, w = 80, h = 80, x = 505, y = 320, w = 80, h = 80,
codeWhenPressed = function() SCENE:onInputPress {input = "rotate_right"} end, codeWhenPressed = function() SCENE:onInputPress {input = "rotate_right"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_right"} end codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_right"} end

View File

@@ -44,8 +44,8 @@ function ReplayTestScene:render()
end end
function ReplayTestScene:onInputRelease() function ReplayTestScene:onInputPress()
SCENE = ReplayTestScene() SCENE = ReplaySelectScene()
end end
return ReplayTestScene return ReplayTestScene

View File

@@ -5,13 +5,11 @@ TouchConfigScene.title = "Touchscreen config"
local Grid = require 'game.grid' local Grid = require 'game.grid'
local buttonList local buttonList
local sliderList local sliderList = {}
---@class VCTRL.data ---@class VCTRL.data
local focusingButton local focusingButton
---@type number ---@type number
local snapUnit = 1 local snapUnit = 1
---@type boolean
local hasChanged
---@type function ---@type function
local function exitSceneFunc(saved) local function exitSceneFunc(saved)
@@ -29,37 +27,55 @@ buttonList = {
showToggle = BUTTON.new{ showToggle = BUTTON.new{
text = function() text = function()
if focusingButton then if focusingButton then
return focusingButton.show and "[SHOW]\nHide" or "Show\n[HIDE]" return focusingButton.show and ">SHOW<\nhide" or "show\n>HIDE<"
else else
return "Show\nHide" return "show\nhide"
end end
end, end,
x = 275, y = 5, w = 50, h = 75, x = 400, y = 110, w = 60, h = 40,
codeWhenReleased = function() codeWhenReleased = function()
if focusingButton then if focusingButton then
focusingButton.show = not focusingButton.show focusingButton.show = not focusingButton.show
hasChanged = true VCTRL.hasChanged = true
end end
end, end,
update = function(self) self.textColor = focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5} end update = function(self) self.textColor = focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5} end
}, },
previewToggle = BUTTON.new{ previewToggle = BUTTON.new{
text = "Preview\nON", text = "Preview\nON",
x = 570, y = 35, w = 60, h = 40, x = 570, y = 60, w = 60, h = 40,
codeWhenReleased = function() codeWhenReleased = function()
VCTRL.release() VCTRL.release()
BUTTON.release(buttonList) BUTTON.release(buttonList)
SCENE = TouchConfigPreviewScene() SCENE = TouchConfigPreviewScene()
end end
}, },
resetAll = BUTTON.new{
text = "RESET\nALL",
x = 500, y = 110, w = 60, h = 40,
codeWhenReleased = function()
local selection = love.window.showMessageBox(
"Save config?", "Are you really sure about RESETTING ALL touchscreen configuration?",
{"Yes", "No", escapebutton = 2, enterbutton = 1},
"info", true
)
if selection == 1 then
VCTRL.focus = nil; focusingButton = nil
VCTRL.hasChanged = false
VCTRL.clearAll()
VCTRL.new(SETTINGS.__default__.input.virtual)
SETTINGS.input.virtual = SETTINGS.__default__.input.virtual
end
end
},
menuScreen = BUTTON.new{ menuScreen = BUTTON.new{
text = "MENU", text = "MENU",
x = 570, y = 5, w = 60, h = 25, x = 570, y = 10, w = 60, h = 40,
codeWhenReleased = function() codeWhenReleased = function()
if hasChanged or SETTINGS.firstTime then if VCTRL.hasChanged or SETTINGS.firstTime then
local selection = love.window.showMessageBox( local selection = love.window.showMessageBox(
"Save config?", "Do you want to save your changes before exiting?", "Save config?", "Do you want to save your changes before exiting?",
{"Save", "Discard", "Keep editing", escapebutton = 2, enterbutton = 1}, {"Save", "Discard", "Keep editing", escapebutton = 3, enterbutton = 1},
"info", true "info", true
) )
if selection == 1 then if selection == 1 then
@@ -80,45 +96,59 @@ buttonList = {
end end
} }
} }
sliderList = {} sliderList.buttonSize = newSlider(
200, 30, 120, 0, 0, 120,
function(v)
if focusingButton then
v = math.roundUnit(v, 5)
if focusingButton.r ~= v then
focusingButton.r = v
VCTRL.hasChanged = true
end
sliderList.buttonSize.value = v / 120
end
end,
{width = 40}
)
sliderList.iconSize = newSlider(
480, 30, 120, 0, 0, 100,
function(v)
if focusingButton then
v = math.roundUnit(v, 5)
if focusingButton.iconSize ~= v then
focusingButton.iconSize = v
VCTRL.hasChanged = true
end
sliderList.iconSize.value = v / 100
end
end,
{width = 40}
)
sliderList.opacity = newSlider( sliderList.opacity = newSlider(
155, 20+5, 120, 100, 0, 100, 200, 80, 120, 0, 0, 1,
function() function()
local v local v
if focusingButton then if focusingButton then
v = math.roundUnit(sliderList.opacity.value, 0.01) v = math.roundUnit(sliderList.opacity.value, 0.01)
if focusingButton.alpha~=v then if focusingButton.alpha~=v then
focusingButton.alpha = v focusingButton.alpha = v
hasChanged = true VCTRL.hasChanged = true
end end
sliderList.opacity.value = v sliderList.opacity.value = v
end end
end, end,
{width = 30} {width = 40}
)
sliderList.size = newSlider(
155, 60+2.5, 120, 45, 0, 120,
function(v)
if focusingButton then
local v = math.roundUnit(v, 5)
if focusingButton.r ~= v then
focusingButton.r = v
hasChanged = true
end
sliderList.size.value = v / 120
end
end,
{width = 30}
) )
local gridSizeTable = {1, 2, 5, 10, 20, 50, 100} local gridSizeTable = {1, 2, 5, 10, 20, 50, 100}
sliderList.gridSize = newSlider( sliderList.gridSize = newSlider(
405, 50, 100, 1, 1, #gridSizeTable - 1, 480, 80, 120, 1, 1, #gridSizeTable - 1,
function() function()
local v = math.roundUnit(sliderList.gridSize.value, 1 / 6) local f = #gridSizeTable - 1
local v = math.roundUnit(sliderList.gridSize.value, 1 / f)
sliderList.gridSize.value = v sliderList.gridSize.value = v
snapUnit = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1)] snapUnit = gridSizeTable[math.roundUnit(v * f + 1)]
end, end,
{width = 30} {width = 40}
); sliderList.gridSize.forceLight = true ); sliderList.gridSize.forceLight = true
local function sliderList_draw() local function sliderList_draw()
@@ -145,12 +175,12 @@ local function sliderList_update()
end end
end end
function TouchConfigScene:new(fromPreviewScene) function TouchConfigScene:new()
VCTRL.toggle(true) VCTRL.toggle(true)
VCTRL.focus = nil VCTRL.focus = nil
focusingButton = nil focusingButton = nil
hasChanged = fromPreviewScene
Grid:new(10, 20) Grid:new(10, 20)
-- TODO -- TODO
end end
@@ -159,13 +189,15 @@ function TouchConfigScene:update()
if VCTRL.focus~=focusingButton then if VCTRL.focus~=focusingButton then
focusingButton = VCTRL.focus focusingButton = VCTRL.focus
sliderList.opacity.value = focusingButton.alpha sliderList.opacity.value = focusingButton.alpha
sliderList.size.value = focusingButton.r / 120 sliderList.buttonSize.value = focusingButton.r / 120
sliderList.iconSize.value = focusingButton.iconSize / 100
end end
BUTTON.update(buttonList) BUTTON.update(buttonList)
sliderList_update() sliderList_update()
end end
local string_format = string.format
function TouchConfigScene:render() function TouchConfigScene:render()
MainBackground() MainBackground()
@@ -188,19 +220,16 @@ function TouchConfigScene:render()
end end
love.graphics.setColor(0, 0, 0, 0.7) love.graphics.setColor(0, 0, 0, 0.7)
-- Opacity and Size love.graphics.rectangle("fill", 5, 5, 560, 100)
love.graphics.rectangle("fill", 10, 5, 267, 75)
-- Snap to grid
love.graphics.rectangle("fill", 330, 5, 150, 75)
-- Button Size
drawText(string_format("Size (buttons)\n%14.1d", focusingButton and focusingButton.r or 0), 10, 13, 100, "left")
-- Icon size
drawText(string_format("Size (icons)\n%13.1d%%", focusingButton and focusingButton.iconSize or 0), 290, 13, 100, "left")
-- Opacity -- Opacity
drawText("Opacity", 20, 15, 100, "left") drawText(string_format("Opacity\n%13.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 10, 63, 100, "left")
drawText(string.format("%3.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 225, 15, 40, "left")
-- Size
drawText("Size", 20, 55, 100, "left")
drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 225, 55, 40, "left")
-- Snap to grid -- Snap to grid
drawText(string.format("Snap to grid: %3s", snapUnit), 345, 15, 140, "left") drawText(string_format("Snap to grid\n%14.1d", snapUnit), 290, 63, 100, "left")
for _, v in ipairs(VCTRL) do for _, v in ipairs(VCTRL) do
if v ~= focusingButton then if v ~= focusingButton then
@@ -227,10 +256,8 @@ end
---@param e SCENE_onInput ---@param e SCENE_onInput
function TouchConfigScene:onInputMove(e) function TouchConfigScene:onInputMove(e)
if e.type == "touch" or (e.type == "mouse" and love.mouse.isDown(1)) then if e.type == "touch" or (e.type == "mouse" and love.mouse.isDown(1)) then
if VCTRL.drag(e.dx, e.dy, e.id or 1) then hasChanged = true end if VCTRL.drag(e.dx, e.dy, e.id or 1) then VCTRL.hasChanged = true end
end elseif e.type == "mouse" then
if e.type == "mouse" then
BUTTON.checkHovering(buttonList, e.x, e.y) BUTTON.checkHovering(buttonList, e.x, e.y)
end end
end end
@@ -240,7 +267,8 @@ function TouchConfigScene:onInputPress(e)
if not ( if not (
VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or
BUTTON.press(buttonList, e.x, e.y, e.id) or BUTTON.press(buttonList, e.x, e.y, e.id) or
(e.x >= 80 and e.x <= 230 and e.y >= 10 and e.y <= 77) (e.x >= 120 and e.x <= 280 and e.y >= 10 and e.y <= 100) or
(e.x >= 400 and e.x <= 560 and e.y >= 10 and e.y <= 100)
) then ) then
VCTRL.focus = nil VCTRL.focus = nil
focusingButton = nil focusingButton = nil

View File

@@ -8,7 +8,7 @@ local buttonList
buttonList = { buttonList = {
previewToggle = BUTTON.new{ previewToggle = BUTTON.new{
text = "Preview\nOFF", text = "Preview\nOFF",
x = 570, y = 35, w = 60, h = 40, x = 570, y = 60, w = 60, h = 40,
codeWhenReleased = function() codeWhenReleased = function()
VCTRL.release() VCTRL.release()
BUTTON.release(buttonList) BUTTON.release(buttonList)
@@ -16,8 +16,6 @@ buttonList = {
end end
}, },
} }
local sliderList = {}
local secret_grade_grid = {} local secret_grade_grid = {}
do do
local colour_names = {'R', 'O', 'Y', 'G', 'C', 'B', 'M'} local colour_names = {'R', 'O', 'Y', 'G', 'C', 'B', 'M'}
@@ -80,13 +78,17 @@ end
function TouchConfigPreviewScene:onInputPress(e) function TouchConfigPreviewScene:onInputPress(e)
if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.press(buttonList, e.x, e.y, e.id) if not BUTTON.press(buttonList, e.x, e.y, e.id) then
VCTRL.press(e.x, e.y, e.id or 1)
end
end end
end end
---@param e SCENE_onInput ---@param e SCENE_onInput
function TouchConfigPreviewScene:onInputRelease(e) function TouchConfigPreviewScene:onInputRelease(e)
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y, e.id) if not BUTTON.release(buttonList, e.x, e.y, e.id) then
VCTRL.release(e.id or 1)
end
end end
end end

View File

@@ -28,11 +28,11 @@ local _defaultSettings = {
{type='button',x=320, y=420,key= 'restart',r=35,iconSize=60,alpha=0.4}, {type='button',x=320, y=420,key= 'restart',r=35,iconSize=60,alpha=0.4},
} }
}, },
tvMode = false -- 79338732 tvMode = false
} }
SETTINGS = setmetatable( SETTINGS = setmetatable(
{}, {__default__ = _defaultSettings},
{ {
__index = function(_, k) __index = function(_, k)
if _settings[k] == nil then if _settings[k] == nil then