diff --git a/scene/replay.lua b/scene/replay.lua index 5a1af34..d818ad2 100644 --- a/scene/replay.lua +++ b/scene/replay.lua @@ -1,48 +1,60 @@ local ReplaySelectScene = SCENE:extend() ReplaySelectScene.title = "Replay" +local scene_self local replay_list local buttonList = { BUTTON.new{ - text = CHAR.key.up.."\nUP", font = FONT_big, - x = 425, y = 80, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "up"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "up"} end + x = 325, y = 385, w = 100, h = 30, + text = CHAR.key.up.." Page up", + codeWhenReleased = function() + scene_self.page = math.max(scene_self.page - 1, 0) + scene_self.replay_select = 1; + end }, BUTTON.new{ - text = CHAR.key.down.."\nDOWN", font = FONT_big, - x = 425, y = 240, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "down"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "down"} end + x = 435, y = 385, w = 100, h = 30, + text = CHAR.key.down.." Page down", + codeWhenReleased = function() + scene_self.page = math.max(scene_self.page - 1, 1+(math.floor(#scene_self.replays / scene_self.page_flip))) + scene_self.replay_select = 1; + end }, BUTTON.new{ - text = CHAR.icon.play.."\nPLAY", font = FONT_big, - x = 345, y = 160, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "menu_decide"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "menu_decide"} end + 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 }, BUTTON.new{ - text = CHAR.icon.home.."\nHOME", font = FONT_big, - x = 505, y = 160, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "menu_back"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "menu_back"} end + 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 }, BUTTON.new{ - text = CHAR.icon.export.."\nEXP.", font = FONT_big, - x = 345, y = 320, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "rotate_left"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_left"} end + x = 215, y = 425, w = 100, h = 30, + text = CHAR.icon.save.." Converter", + codeWhenReleased = function() love.system.openURL("https://sweetsea-butimnotsweet.github.io/tromi_replay_converter/") end }, BUTTON.new{ - text = CHAR.icon.import.."\nIMP.", font = FONT_big, - x = 505, y = 320, w = 80, h = 80, - codeWhenPressed = function() SCENE:onInputPress {input = "rotate_right"} end, - codeWhenReleased = function() SCENE:onInputRelease{input = "rotate_right"} end + 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 + }, + 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 }, } function ReplaySelectScene:new() self:initList() + scene_self = self + BUTTON.reset(buttonList) PENTO_MODE = false end @@ -51,7 +63,7 @@ function ReplaySelectScene:initList() replay_list = love.filesystem.getDirectoryItems('saves/replays/') table.sort(replay_list, function(a,b) return a > b end) self.replay_text = {} - self.page_flip = 16 + self.page_flip = 10 self.page = 1 local gradeNames = { "19k", "18k", "17k", "16k", "15k", "14k", "13k", "12k", "11k", @@ -81,13 +93,15 @@ end function ReplaySelectScene:render() MainBackground() + love.graphics.setColor(0, 0, 0, 0.7) + love.graphics.rectangle("fill", 0, 0, 640, 480) love.graphics.setColor(0.4, 1, 1, 0.5) - love.graphics.rectangle("fill", 0, 20 + 20 * self.replay_select, 640, 22) + love.graphics.rectangle("fill", 0, 15 + 30 * self.replay_select, 640, 27) BUTTON.draw(buttonList) drawText('Name - Grade - Score', 40, 20, 1000, "left") - drawText(string.format('Page %s/%s', self.page, math.floor(#self.replays / self.page_flip) + 1), 20, 440, 1000, "left") + drawText(string.format('Page %s/%s', self.page, math.floor(#self.replays / self.page_flip) + 1), 215, 390, 100, "center") local i, j = 1, 1 while i <= #self.replay_text do @@ -95,7 +109,7 @@ function ReplaySelectScene:render() elseif j < 1 then j = self.page_flip end if i > (self.page-1) * self.page_flip and i <= self.page * self.page_flip then - drawText(self.replay_text[i], 40, 20 + 20 * j, 1000, "left") + drawText(self.replay_text[i], 40, 20 + 30 * j, 1000, "left") end j = j + 1 i = i + 1 @@ -145,8 +159,15 @@ function ReplaySelectScene:onInputPress(e) local selected_replay = self.replays[self.replay_select + ((self.page-1) * self.page_flip)] local selected_replay_text = self.replay_text[self.replay_select + ((self.page-1) * self.page_flip)] - if e.type == "touch" or e.type == "mouse" then - BUTTON.press(buttonList, e.x, e.y, e.id) + if (e.type == "touch" or e.type == "mouse") and not BUTTON.press(buttonList, e.x, e.y, e.id) then + local selection = math.floor((e.y - 15) / 30) + if ( + selection >= 1 and + selection <= self.repeat_limit and + selection + ((self.page-1) * self.page_flip) <= #replay_list + ) then + self.replay_select = selection + end elseif e.input == "menu_decide" or e.scancode == "return" then if self.replays[1] == nil then SCENE = TitleScene(); return else