Skip to content

Commit

Permalink
Results screen finished, add mod folder (custom format, not a pre-exi…
Browse files Browse the repository at this point in the history
…sting format)

Disable mod folder support in modules/constants.lua
  • Loading branch information
GuglioIsStupid committed May 27, 2024
1 parent 2df5f49 commit 21b55e3
Show file tree
Hide file tree
Showing 41 changed files with 1,394 additions and 122 deletions.
Binary file added src/love/images/png/resultsScreen/difEasy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/difErect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/difHard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/difNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/scorePopin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/love/images/png/resultsScreen/topBarBlack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 102 additions & 37 deletions src/love/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ function love.load()
NoteSplash = require "modules.Splash"
HoldCover = require "modules.Cover"
loadSavedata()
settings.pixelPerfect = false

-- Modding
importMods = require "modding.importMods"

-- XML Modules
Sprite = require "modules.xml.Sprite"
Expand Down Expand Up @@ -238,6 +242,7 @@ function love.load()
menuSettings = require "states.menu.options.OptionsState"
menuCredits = require "states.menu.menuCredits"
menuSelect = require "states.menu.menuSelect"
resultsScreen = require "states.menu.results"

firstStartup = true

Expand Down Expand Up @@ -392,6 +397,8 @@ function love.load()
}
}

modWeekPlacement = #weekMeta -- everything after the main weeks is a mod folder.

-- LÖVE init
if curOS == "OS X" then
love.window.setIcon(love.image.newImageData("icons/macos.png"))
Expand Down Expand Up @@ -450,11 +457,17 @@ function love.load()
(love.audio.getVolume())
))


volumeWidth = {width = 160 }

if CONSTANTS.OPTIONS.DO_MODS then
importMods.setup()
importMods.loadAllMods()
end

Gamestate.switch(menu)

love.setFpsCap(settings.fpsCap)

DO_SAVE_DATA = true
end

function love.resize(width, height)
Expand Down Expand Up @@ -520,6 +533,21 @@ function love.keypressed(key)
lastAudioVolume = love.audio.getVolume()
love.audio.setVolume(0)
end
--[[ elseif key == "-" and love.keyboard.isDown("lalt") then
Gamestate.switch(resultsScreen, {
diff = "hard",
song = "High Erect",
artist = "Kohta Takahashi (feat. Kawai Sprite)",
scores = {
sickCount = 10,
goodCount = 15,
badCount = 20,
shitCount = 25,
missedCount = 30,
maxCombo = 384,
score = 192000
}
}) ]]
elseif key == "-" then
volFade = 1
if fixVol > 0 then
Expand Down Expand Up @@ -594,41 +622,78 @@ function love.draw()
graphics.screenBase(push:getWidth(), push:getHeight())

if mainDrawing then
push:start()
graphics.setColor(1, 1, 1) -- Fade effect on
Gamestate.draw()
love.graphics.setColor(1, 1, 1) -- Fade effect off
love.graphics.setFont(font)
if status.getLoading() then
love.graphics.print("Loading...", push:getWidth() - 175, push:getHeight() - 50)
end
if volFade > 0 then
love.graphics.setColor(1, 1, 1, volFade)
fixVol = tonumber(string.format(
"%.1f ",
(love.audio.getVolume())
))
love.graphics.setColor(0.5, 0.5, 0.5, volFade - 0.3)

love.graphics.rectangle("fill", 1110, 0, 170, 50)

love.graphics.setColor(1, 1, 1, volFade)

if volTween then Timer.cancel(volTween) end
volTween = Timer.tween(
0.2,
volumeWidth,
{width = fixVol * 160},
"out-quad"
)
love.graphics.rectangle("fill", 1113, 10, volumeWidth.width, 30)
graphics.setColor(1, 1, 1, 1)
end
if fade.mesh then
graphics.setColor(1,1,1)
love.graphics.draw(fade.mesh, 0, fade.y, 0, push:getWidth(), fade.height)
end
push:finish()
if not status.getNoResize() then
push:start()
graphics.setColor(1, 1, 1) -- Fade effect on
Gamestate.draw()
love.graphics.setColor(1, 1, 1) -- Fade effect off
love.graphics.setFont(font)
if status.getLoading() then
love.graphics.print("Loading...", push:getWidth() - 175, push:getHeight() - 50)
end
if volFade > 0 then
love.graphics.setColor(1, 1, 1, volFade)
fixVol = tonumber(string.format(
"%.1f ",
(love.audio.getVolume())
))
love.graphics.setColor(0.5, 0.5, 0.5, volFade - 0.3)

love.graphics.rectangle("fill", 1110, 0, 170, 50)

love.graphics.setColor(1, 1, 1, volFade)

if volTween then Timer.cancel(volTween) end
volTween = Timer.tween(
0.2,
volumeWidth,
{width = fixVol * 160},
"out-quad"
)
love.graphics.rectangle("fill", 1113, 10, volumeWidth.width, 30)
graphics.setColor(1, 1, 1, 1)
end
if fade.mesh then
graphics.setColor(1,1,1)
love.graphics.draw(fade.mesh, 0, fade.y, 0, push:getWidth(), fade.height)
end
push:finish()
else
graphics.setColor(1, 1, 1) -- Fade effect on
Gamestate.draw()
love.graphics.setColor(1, 1, 1) -- Fade effect off
love.graphics.setFont(font)
if status.getLoading() then
love.graphics.print("Loading...", graphics.getWidth() - 175, graphics.getHeight() - 50)
end
if volFade > 0 then
love.graphics.setColor(1, 1, 1, volFade)
fixVol = tonumber(string.format(
"%.1f ",
(love.audio.getVolume())
))
love.graphics.setColor(0.5, 0.5, 0.5, volFade - 0.3)

love.graphics.rectangle("fill", 1110, 0, 170, 50)

love.graphics.setColor(1, 1, 1, volFade)

if volTween then Timer.cancel(volTween) end
volTween = Timer.tween(
0.2,
volumeWidth,
{width = fixVol * 160},
"out-quad"
)
love.graphics.rectangle("fill", 1113, 10, volumeWidth.width, 30)
graphics.setColor(1, 1, 1, 1)
end
if fade.mesh then
graphics.setColor(1,1,1)
love.graphics.draw(fade.mesh, 0, fade.y, 0, graphics.getWidth(), fade.height)
end
end


graphics.setColor(1,1,1,capturedScreenshot.flash)
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
Expand Down
85 changes: 85 additions & 0 deletions src/love/modding/importMods.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
local importMods = {}
importMods.storedMods = {}
importMods.inMod = false

function importMods.setup()
if not love.filesystem.getInfo("mods") then
love.filesystem.createDirectory("mods")
end
end

function importMods.loadMod(mod) -- The file name of the mod
if love.filesystem.getInfo("mods/" .. mod .. "/stages/") then
local stagesList = love.filesystem.getDirectoryItems("mods/" .. mod .. "/stages")
for i, stage in ipairs(stagesList) do
local stageData = require(("mods." .. mod .. ".stages." .. stage):gsub("/", "."):gsub(".lua", ""))
stages[stageData.name] = stageData
end
end

if love.filesystem.getInfo("mods/" .. mod .. "/weeks/") then
local weeksList = love.filesystem.getDirectoryItems("mods/" .. mod .. "/weeks")
for i, week in ipairs(weeksList) do
local weekDataFile = require(("mods." .. mod .. ".weeks." .. week):gsub("/", "."):gsub(".lua", ""))
table.insert(weekData, weekDataFile)
table.insert(weekDesc, weekDataFile.description)
table.insert(weekMeta, {
weekDataFile.name,
weekDataFile.songs
})
end
end

table.insert(importMods.storedMods, {
name = mod,
path = "mods/" .. mod
})

print("Loaded mod: " .. mod)
end

function importMods.loadAllMods()
local mods = love.filesystem.getDirectoryItems("mods")
for i, mod in ipairs(mods) do
if love.filesystem.getInfo("mods/" .. mod .. "/meta.lua") then
local meta = love.filesystem.load("mods/" .. mod .. "/meta.lua")()
if meta.enabled == nil or meta.enabled then
importMods.loadMod(mod)
end
end
end
end

function importMods.getCurrentMod()
return importMods.storedMods[weekNum - modWeekPlacement]
end

function loadLuaFile(path)
local currentMod = importMods.getCurrentMod()


if love.filesystem.getInfo(currentMod.path .. "/" .. path) then
return love.filesystem.load(currentMod.path .. "/" .. path)
else
return love.filesystem.load(path)
end
end

function loadAudioFile(path)
local currentMod = importMods.getCurrentMod()

if love.filesystem.getInfo(currentMod.path .. "/" .. path) then
return love.audio.newSource(currentMod.path .. "/" .. path, "stream")
else
return love.audio.newSource(path, "stream")
end
--[[ return love.audio.newSource(currentMod.path .. "/" .. path, "stream") ]]
end

function loadImageFile(path)
local currentMod = importMods.getCurrentMod()

return love.graphics.newImage(path)
end

return importMods
6 changes: 6 additions & 0 deletions src/love/modules/constants.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
local CONSTANTS = {}

CONSTANTS.OPTIONS ={
SHOW_RESULTS_SCREEN = true,
DO_SAVE_DATA = true,
DO_MODS = true,
}

CONSTANTS.WEEKS = {
ANIM_LIST = {
"singLEFT",
Expand Down
45 changes: 38 additions & 7 deletions src/love/modules/graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,25 @@ return {
imagePath = function(path)
local pathStr = "images/" .. imageType .. "/" .. path .. "." .. imageType

if love.filesystem.getInfo(pathStr) then
return pathStr
if not importMods.inMod then
if love.filesystem.getInfo(pathStr) then
return pathStr
else
return "images/png/" .. path .. ".png"
end
else
return "images/png/" .. path .. ".png"
local currentMod = importMods.getCurrentMod()
if love.filesystem.getInfo(currentMod.path .. "/images/" .. imageType .. "/" .. path .. "." .. imageType) then
return currentMod.path .. "/images/" .. imageType .. "/" .. path .. "." .. imageType
elseif love.filesystem.getInfo(currentMod.path .. "/images/png/" .. path .. ".png") then
return currentMod.path .. "/images/png/" .. path .. ".png"
else
if love.filesystem.getInfo(pathStr) then
return pathStr
else
return "images/png/" .. path .. ".png"
end
end
end
end,
setImageType = function(type)
Expand Down Expand Up @@ -104,6 +119,14 @@ return {
return image
end,

getWidth = function(self)
return width
end,

getHeight = function(self)
return height
end,

draw = function(self)
local x = self.x
local y = self.y
Expand Down Expand Up @@ -131,7 +154,8 @@ return {

udraw = function(self, sx, sy)
local sx = sx or 7
local sy = sy or 7
local sy = sy or sx
print(sx, sy)
local x = self.x
local y = self.y

Expand Down Expand Up @@ -179,6 +203,7 @@ return {

local isAnimated
local isLooped
local forceFrameStart

local options

Expand Down Expand Up @@ -237,7 +262,7 @@ return {
return anims[name] ~= nil
end,

animate = function(self, animName, loopAnim, func, forceSpecial)
animate = function(self, animName, loopAnim, func, forceSpecial, frameOverride, keepFrameOverride)
-- defaults forceSpecial to true
forceSpecial = forceSpecial == nil and true or forceSpecial
self.holdTimer = 0
Expand Down Expand Up @@ -268,10 +293,16 @@ return {

self.func = func

frame = anim.start
frame = frameOverride or anim.start
isLooped = loopAnim

isAnimated = true

if not keepFrameOverride then
forceFrameStart = nil
else
forceFrameStart = frameOverride
end
end,
getAnims = function(self)
return anims
Expand Down Expand Up @@ -310,7 +341,7 @@ return {
self.func = nil
end
if isLooped then
frame = anim.start
frame = forceFrameStart or anim.start
else
isAnimated = false
end
Expand Down
Loading

0 comments on commit 21b55e3

Please sign in to comment.