Cleaning stuffs

This commit is contained in:
Nguyễn Quốc Hưng
2024-08-17 16:11:42 +07:00
parent 628cf22110
commit 1f5a21fec4
4 changed files with 27 additions and 30 deletions

View File

@@ -124,7 +124,6 @@ function love.keypressed(key, scancode)
love.resize(love.graphics.getDimensions())
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
SCENE = InputConfigScene()
elseif scancode == "f3" then SCENE = UserManagementScene()
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
-- elseif scancode == "f11" then SETTINGS.firstTime = true
-- function keys are reserved

View File

@@ -1,44 +1,29 @@
local ReplaySelectScene = SCENE:extend()
ReplaySelectScene.title = "Replay"
local scene_self
local replay_list
local buttonList = {
BUTTON.new{
x = 325, y = 385, w = 100, h = 30,
text = CHAR.key.up.." Page up",
codeWhenReleased = function()
if scene_self.page == 1 then
scene_self.page = 1 + math.floor(#scene_self.replays / scene_self.page_flip)
else
scene_self.page = scene_self.page - 1
end
scene_self.replay_select = 1;
end
codeWhenReleased = function() SCENE:onInputPress{input = "left"} end
},
BUTTON.new{
x = 435, y = 385, w = 100, h = 30,
text = CHAR.key.down.." Page down",
codeWhenReleased = function()
if scene_self.page < 1 + math.floor(#scene_self.replays / scene_self.page_flip) then
scene_self.page = scene_self.page + 1
else
scene_self.page = 1
end
scene_self.replay_select = 1;
end
codeWhenReleased = function() SCENE:onInputPress{input = "right"} end
},
BUTTON.new{
x = 105, y = 385, w = 100, h = 30,
text = CHAR.icon.play.." Play",
codeWhenPressed = function() scene_self:onInputPress {input = "menu_decide"} end,
codeWhenReleased = function() scene_self:onInputRelease{input = "menu_decide"} end
codeWhenPressed = function() SCENE:onInputPress {input = "menu_decide"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_decide"} end
},
BUTTON.new{
x = 105, y = 425, w = 100, h = 30,
text = CHAR.icon.home.." Home",
codeWhenPressed = function() scene_self:onInputPress {input = "menu_back"} end,
codeWhenReleased = function() scene_self:onInputRelease{input = "menu_back"} end
codeWhenPressed = function() SCENE:onInputPress {input = "menu_back"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_back"} end
},
BUTTON.new{
x = 215, y = 425, w = 100, h = 30,
@@ -48,20 +33,20 @@ local buttonList = {
BUTTON.new{
x = 325, y = 425, w = 100, h = 30,
text = CHAR.icon.export.." Export",
codeWhenPressed = function() scene_self:onInputPress {input = "rotate_left"} end,
codeWhenReleased = function() scene_self:onInputRelease{input = "rotate_left"} end
codeWhenPressed = function() SCENE:onInputPress {input = "rotate_left"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_left"} end
},
BUTTON.new{
x = 435, y = 425, w = 100, h = 30,
text = CHAR.icon.import.." Import",
codeWhenPressed = function() scene_self:onInputPress {input = "rotate_right"} end,
codeWhenReleased = function() scene_self:onInputRelease{input = "rotate_right"} end
codeWhenPressed = function() SCENE:onInputPress {input = "rotate_right"} end,
codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_right"} end
},
}
function ReplaySelectScene:new()
self:initList()
scene_self = self
SCENE = self
BUTTON.reset(buttonList)
PENTO_MODE = false
end
@@ -212,6 +197,20 @@ function ReplaySelectScene:onInputPress(e)
elseif e.input == "down" or e.scancode == "down" then
if self.replays[1] == nil then SCENE = TitleScene(); return end
self.direction = 'down'
elseif e.input == "left" or e.scancode == "left" then
if self.page == 1 then
self.page = 1 + math.floor(#self.replays / self.page_flip)
else
self.page = self.page - 1
end
self.replay_select = 1;
elseif e.input == "right" or e.scancode == "right" then
if self.page < 1 + math.floor(#self.replays / self.page_flip) then
self.page = self.page + 1
else
self.page = 1
end
self.replay_select = 1;
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
SCENE = TitleScene()
end

View File

@@ -5,7 +5,6 @@ local error_message
local valid_data
local prev_scene
function ReplayTestScene:new(input_file)
prev_scene = SCENE
@@ -36,7 +35,7 @@ function ReplayTestScene:render()
if valid_data then
if error_message then
drawText("Replay test failed! Data corrupted!", 80, 40, 1000)
drawText("Replay test failed!", 80, 40, 1000)
drawText("Press any key to go back. Anyway here is the error info:", 80, 70, 1000)
drawText(error_message, 80, 100, 560)
else

View File

@@ -109,7 +109,7 @@ local function checkCode(c)
if (
code_string == "-1,-1,-1,-1,1,1,1,1" or
code_string == "2,2,2,2,2,2,2,2"
) then
) then
PENTO_MODE = true
end
end