This commit is contained in:
SweetSea-ButImNotSweet
2024-05-21 20:07:53 +07:00
parent 7c39c1ada8
commit 5cf9deb9eb
7 changed files with 149 additions and 61 deletions

View File

@@ -1,11 +1,22 @@
local NameEntryScene = SCENE:extend()
NameEntryScene.title = "Game Start"
local buttonList = {
BUTTON.new{
text = "<\nCHAR", font = FONT_big,
x = 40, y = 160, w = 70, h = 70,
},
BUTTON.new{
text = ">\nCHAR", font = FONT_big,
x = 130, y = 160, w = 70, h = 70,
}
}
local Grid = require 'game.grid'
local bitser = require 'libs.bitser'
function NameEntryScene:new()
self.chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890."
self.hars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890."
self.char_pos = 1
self.name_entry = {'A','A','A'}
self.entry_pos = 1
@@ -48,6 +59,8 @@ end
function NameEntryScene:render()
MainBackground()
BUTTON.draw(buttonList)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.line(216,80,216,80+(16*self.grid.height))
love.graphics.line(216+(16*self.grid.width),80,216+(16*self.grid.width),80+(16*self.grid.height))
@@ -108,8 +121,16 @@ function NameEntryScene:update()
self.entry_chars = self.name_entry[1]..self.name_entry[2]..self.name_entry[3]
end
function NameEntryScene:onInputMove(e)
if e.type == "mouse" then
BUTTON.checkHovering(buttonList, e.x, e.y)
end
end
function NameEntryScene:onInputPress(e)
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
if e.type == "mouse" or e.type == "touch" then
BUTTON.press(buttonList, e.x, e.y)
elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
self.delete_confirm = false
self.delete_input_count = 0
if self.entry_pos == 4 then
@@ -177,7 +198,11 @@ function NameEntryScene:onInputPress(e)
end
function NameEntryScene:onInputRelease(e)
if e.input == "left" or e.scancode == "left" or e.input == "right" or e.scancode == "right" then
if e.type == "mouse" then
BUTTON.release(buttonList, e.x, e.y)
elseif e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y, true)
elseif e.input == "left" or e.scancode == "left" or e.input == "right" or e.scancode == "right" then
self.direction = nil
self.repeat_counter = self.repeat_limit-1
end

View File

@@ -94,15 +94,29 @@ end
function TitleScene:onInputPress(e)
if e.type == "touch" then
local selecting = math.floor((e.y - 198) / 20)
if (e.x >= 20 and e.x <= 260) and (selecting > 0 and selecting <= #main_menu_screens) then
if
(e.x >= 20 and e.x <= 260) and
(selecting > 0 and selecting <= #main_menu_screens)
then
if self.main_menu_state ~= selecting then
self.main_menu_state = selecting
else
VCTRL.toggle(true)
SCENE = main_menu_screens[selecting]()
end
elseif e.x >= 14 and e.y >= 40 and e.x <= 274 and e.y <= 170 then
elseif
e.x >= 14 and
e.y >= 40 and
e.x <= 274 and
e.y <= 160
then
if e.x >= 137 then -- Right
table.remove(self.code, 8)
table.insert(self.code, 1, 1)
else -- Left
table.remove(self.code, 8)
table.insert(self.code, 1, -1)
end
end
else
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then

View File

@@ -7,7 +7,7 @@ TouchConfigScene.title = "Touchscreen config\n(you can tap anywhere on touch scr
2. Add behaviors
]]
local widgetList = {
local buttonList = {
select_widget = BUTTON.new{
text = "Select key\n[Rotate right 2]",
x = 10, y = 10, w = 120, h = 110
@@ -33,6 +33,7 @@ local widgetList = {
BUTTON.new{
text = "Opacity: 50%\nTap to reset",
x = 255, y = 70, w = 100, h = 50,
codeWhenReleased = function() PlaySE("autopromote") end
},
BUTTON.new{
text = "[+]\nTotally see",
@@ -52,23 +53,7 @@ local widgetList = {
text = "RESET to\nDEFAULT",
x = 560, y = 70, w = 70, h = 50,
},
}
local function widgetList_update()
for _, v in pairs(widgetList) do v:update() end
end
local function widgetList_draw()
for _, v in pairs(widgetList) do v:draw() end
end
local function widgetList_isHovering(x, y)
for _, v in pairs(widgetList) do v:isHovering(x, y) end
end
local function widgetList_press()
for _, v in pairs(widgetList) do v:press() end
end
local function widgetList_release()
for _, v in pairs(widgetList) do v:release() end
end
function TouchConfigScene:new()
-- TODO
@@ -79,31 +64,28 @@ end
function TouchConfigScene:render()
MainBackground()
widgetList_draw()
BUTTON.draw(buttonList)
end
---@param e SCENE_onInput
function TouchConfigScene:onInputMove(e)
if e.type == "mouse" then
widgetList_isHovering(e.x, e.y)
BUTTON.checkHovering(buttonList, e.x, e.y)
end
end
---@param e SCENE_onInput
function TouchConfigScene:onInputPress(e)
if e.input == 'menu_back' then SCENE = InputConfigScene() end
if e.type == "mouse" then widgetList_press() end
if e.type == "touch" then
widgetList_isHovering(e.x,e.y)
widgetList_press()
if e.type == "mouse" or e.type == "touch" then
BUTTON.press(buttonList, e.x, e.y)
end
end
---@param e SCENE_onInput
function TouchConfigScene:onInputRelease(e)
if e.type == "mouse" then
widgetList_release()
widgetList_isHovering(x, y)
BUTTON.release(buttonList, e.x, e.y)
elseif e.type == "touch" then
widgetList_release()
BUTTON.release(buttonList, e.x, e.y, true)
end
end