local state = require("modules.states.playstate") local myMath = require("modules.math") local myTypes = require("modules.types") local files = require("modules.files") local json = require("modules.json") local logging = require("modules.logging") local songs = require("charts.songs") local curSong = songs[1] local curIndex = 1 local evilCurIndex = 1 local curDiffList = songs[1].difficulties local curDiff = songs[1].difficulties[1] local curDiffInd = 1 local curState = nil local stateLoaded = false local pressed = {false,false,false} local bg local logo local gf local freaky = love.audio.newSource("sounds/freakyMenu.ogg", "stream") local left local function setup() bg = myTypes.Image("images/menuBG.png", 0) bg.ui = false bg.layer = -10 gf = myTypes.Sprite("sprites/gfDanceTitle.png", "sprites/gfDanceTitle.json") gf:PlayAnimation("gfDance", 24, true) gf.position = myTypes.Vector2(340, 60) for index, rect in next, gf.quads.gfDance do rect.resize = myTypes.Vector2(0.7,.7) end gf.layer = 3 left = myTypes.Image("images/MenuLeft.png") left.layer = 0 left.resize = myTypes.Vector2(3, 1) local arrow = myTypes.Image("images/eventArrow.png") arrow.position.y = 330 arrow.layer = 1 arrow.resize = myTypes.Vector2(.5,.5) freaky:play() end local font = love.graphics.newFont("fonts/FridayNightFunkin-Regular.ttf", 40) local gettingKey local settings = json.parse(files.read_file("settings.json")) local keybinds = settings.Keybinds local scroll = love.audio.newSource("sounds/ui/scrollMenu.ogg", "static") local confirm = love.audio.newSource("sounds/ui/confirmMenu.ogg", "static") function love.update(dt) if curState and curState.loaded then if stateLoaded then curState.update(dt) else stateLoaded = true -- skipping this update frame curState.finish() end elseif not curState then myTypes.render.cameraTarget = myTypes.Vector2(0,0) myTypes.updateSprites(dt) end end function love.draw() if curState and stateLoaded then curState.draw() else myTypes.drawSprites() evilCurIndex = myMath.lerp(evilCurIndex, curIndex, .3) for index, song in next, songs do love.graphics.print({{0,0,0}, song.name}, font, 300, love.graphics:getHeight()/2 + (50 * (index - evilCurIndex - .7)), 0, 1, 1, 200) end love.graphics.print({{0,0,0}, curDiff}, font, 600, 660) love.graphics.print( {{0,0,0}, string.format("Left: %s, Down: %s, Up: %s, Right: %s \nDownscroll: %s", keybinds[1], keybinds[2], keybinds[3], keybinds[4], settings.Downscroll )}) love.graphics.print({{0,0,0}, "Press 1 to change LEFT \nPress 2 to change DOWN \nPress 3 to change UP \nPress 4 to change RIGHT \nPress 0 to toggle DOWNSCROLL"}, 500, 0) end end function run() myTypes.destroyAllSprites() freaky:stop() curState = state(curSong.name, curDiff) curState.quit = function() curState = nil stateLoaded = false myTypes.destroyAllSprites() setup() end curState.restart = function() curState = nil stateLoaded = false myTypes.destroyAllSprites() run() end curState.load() end function love.keypressed(key, un, is) if curState and stateLoaded then curState.keypressed(key, un, is) elseif not curState then if not gettingKey then if key == "return" then run() elseif key == "down" then curIndex, curSong = next(songs, curIndex) if not curSong then curIndex, curSong = next(songs) curDiffList = curSong.difficulties else curDiffList = curSong.difficulties end curDiffInd = 1 curDiff = curDiffList[1] scroll:stop() scroll:play() elseif key == "up" then --the solution was so stupid easy if songs[curIndex - 1] then curSong = songs[curIndex - 1] curDiffList = songs[curIndex - 1].difficulties curDiffInd = 1 curDiff = curDiffList[curDiffInd] curIndex = curIndex - 1 else curSong = songs[#songs] curIndex = #songs curDiffList = songs[curIndex].difficulties curDiffInd = 1 curDiff = curDiffList[curDiffInd] end curDiffInd = 1 curDiff = curDiffList[1] scroll:stop() scroll:play() elseif key == "right" then if curDiffList[curDiffInd + 1] then curDiff = curDiffList[curDiffInd + 1] curDiffInd = curDiffInd + 1 else curDiff = curDiffList[1] curDiffInd = 1 end scroll:stop() scroll:play() elseif key == "left" then if curDiffList[curDiffInd - 1] then curDiff = curDiffList[curDiffInd - 1] curDiffInd = curDiffInd - 1 else curDiff = curDiffList[#curDiffList] curDiffInd = #curDiffList end scroll:stop() scroll:play() elseif tonumber(key) and tonumber(key) < 5 then if key == "0" then settings.Downscroll = not settings.Downscroll files.write_file("settings.json", json.stringify(settings)) else gettingKey = tonumber(key) end end else keybinds[gettingKey] = key gettingKey = nil files.write_file("settings.json", json.stringify(settings)) confirm:stop() confirm:play() end end end love.window.setMode(1280, 720, { fullscreen = false , resizable = true}) setup()