diff --git a/main.lua b/main.lua index 7bcfc3a..326cc9a 100644 --- a/main.lua +++ b/main.lua @@ -96,14 +96,13 @@ function love.load() } end -local scale_factor function love.resize(w, h) - scale_factor = math.min(w / 640, h / 480) + SCREEN_SCALE_FACTOR = math.min(w / 640, h / 480) GLOBAL_TRANSFORM:setTransformation( - (w - scale_factor * 640) / 2, - (h - scale_factor * 480) / 2, + (w - SCREEN_SCALE_FACTOR * 640) / 2, + (h - SCREEN_SCALE_FACTOR * 480) / 2, 0, - scale_factor + SCREEN_SCALE_FACTOR ) end @@ -152,7 +151,7 @@ end function love.mousemoved(x, y, dx, dy, isTouch) if isTouch then return end local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y) - local dx,dy=dx/scale_factor,dy/scale_factor + local dx,dy=dx/SCREEN_SCALE_FACTOR,dy/SCREEN_SCALE_FACTOR SCENE:onInputMove{type = "mouse", x = x, y = y, dx = dx, dy = dy} end function love.wheelmoved(dx, dy) diff --git a/scene/game.lua b/scene/game.lua index 5eb6de8..f67b196 100644 --- a/scene/game.lua +++ b/scene/game.lua @@ -47,7 +47,7 @@ local menuKey -- MENU key used to go main menu XD function GameScene:new(player_name, replay_file, replay_grade) menuKey = BUTTON.new{ text = "MENU", - x = 270, y = 5, w = 50, h = 20, + x = 265, y = 0, w = 60, h = 25, codeWhenReleased = function() if self.game.input_playback or self.game.game_over or self.game.completed then SCENE = TitleScene() diff --git a/scene/touch_config.lua b/scene/touch_config.lua index b9c3ad4..39011e1 100644 --- a/scene/touch_config.lua +++ b/scene/touch_config.lua @@ -77,7 +77,7 @@ buttonList = { } sliderList = {} sliderList.opacity = newSlider( - 130, 20-1, 100, 100, 0, 100, + 135, 20+2.5, 100, 100, 0, 100, function() local v if focusingButton then @@ -89,10 +89,10 @@ sliderList.opacity = newSlider( sliderList.opacity.value = v end end, - {width = 10, knob = 'circle', track = 'roundrect'} + {width = 20} ) sliderList.size = newSlider( - 130, 40-1, 100, 45, 0, 120, + 135, 50+2.5, 100, 45, 0, 120, function(v) if focusingButton then local v = math.roundUnit(v, 5) @@ -103,7 +103,7 @@ sliderList.size = newSlider( sliderList.size.value = v / 120 end end, - {width = 10, knob = 'circle', track = 'roundrect'} + {width = 20} ) local gridSizeTable = {1, 2, 5, 10, 20, 50, 100} sliderList.gridSize = newSlider( @@ -113,7 +113,7 @@ sliderList.gridSize = newSlider( sliderList.gridSize.value = v gridSize = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1, 1)] end, - {width = 10, knob = 'circle', track = 'roundrect'} + {width = 20} ); sliderList.gridSize.forceLight = true local function sliderList_draw() @@ -130,15 +130,13 @@ end local function sliderList_update() local x, y - if love.mouse.isDown(1) then - x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition()) - elseif #love.touch.getTouches() == 1 then - x, y = love.touch.getPosition(love.touch.getTouches()[1]) + if #love.touch.getTouches() == 1 then + x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.touch.getPosition(love.touch.getTouches()[1])) else - return + x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition()) end for _, s in pairs(sliderList) do - s:update(x, y, true) + s:update(x, y, #love.touch.getTouches() == 1 or love.mouse.isDown(1)) end end @@ -181,7 +179,7 @@ function TouchConfigScene:render() love.graphics.setColor(0, 0, 0, 0.7) -- Opacity and Size - love.graphics.rectangle("fill", 10, 5, 227, 50) + love.graphics.rectangle("fill", 10, 5, 227, 58) -- Snap to grid love.graphics.rectangle("fill", 335, 5, 130, 50) @@ -189,8 +187,8 @@ function TouchConfigScene:render() drawText("Opacity", 20, 10, 100, "left") drawText(string.format("%3.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 190, 10, 40, "left") -- Size - drawText("Size", 20, 30, 100, "left") - drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 190, 30, 40, "left") + drawText("Size", 20, 40, 100, "left") + drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 190, 40, 40, "left") -- Snap to grid drawText(string.format("Snap to grid: %3s", gridSize), 340, 10, 140, "left") @@ -231,12 +229,11 @@ function TouchConfigScene:onInputMove(e) end ---@param e SCENE_onInput function TouchConfigScene:onInputPress(e) - if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end if e.type == "mouse" or e.type == "touch" then if not ( 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 - (e.x >= 75 and e.x <= 185 and e.y >= 12 and e.y <= 44) + (e.x >= 75 and e.x <= 195 and e.y >= 12 and e.y <= 63) ) then VCTRL.focus = nil focusingButton = nil diff --git a/scene/training.lua b/scene/training.lua index 257d798..3dfb0d0 100644 --- a/scene/training.lua +++ b/scene/training.lua @@ -6,7 +6,7 @@ local menuKey function TrainingScene:new() menuKey = BUTTON.new{ text = "MENU", - x = 270, y = 5, w = 50, h = 20, + x = 265, y = 0, w = 60, h = 25, codeWhenReleased = function() SCENE = TitleScene() end }