Skip to content

Commit

Permalink
mods menu (temporary placeholder layout)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuglioIsStupid committed Jun 11, 2024
1 parent fbfefc7 commit 9e0e88e
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/love/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"love"
],
"Lua.diagnostics.disable": [
"redundant-parameter"
"redundant-parameter",
"missing-parameter"
],
"Lua.runtime.version": "LuaJIT",
"Lua.runtime.special": [],
Expand Down
Binary file not shown.
Binary file added src/love/images/png/menu/menu_mods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/love/lib/fft/luafft.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@diagnostic disable: undefined-global
--[[
This package provides functions to carry out Fast Fourier Transformations.
Expand Down
5 changes: 5 additions & 0 deletions src/love/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ function love.load()
menuSettings = require "states.menu.options.OptionsState"
menuCredits = require "states.menu.menuCredits"
menuSelect = require "states.menu.menuSelect"
menuMods = require "states.menu.menuMods"
resultsScreen = require "states.menu.results"

firstStartup = true
Expand Down Expand Up @@ -616,6 +617,10 @@ function love.mousemoved(x, y, dx, dy, istouch)
end
end

function love.wheelmoved(x, y)
Gamestate.wheelmoved(x, y)
end

function love.touchpressed(id, x, y, dx, dy, pressure)
Gamestate.touchpressed(id, x, y, dx, dy, pressure)
end
Expand Down
57 changes: 57 additions & 0 deletions src/love/modding/importMods.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local importMods = {}
importMods.storedMods = {}
importMods.storedModsScripts = {}
importMods.storedModsIncludingDisabled = {}
importMods.inMod = false
importMods.uiHealthbarMod = nil
importMods.uiHealthbarTextMod = nil
Expand Down Expand Up @@ -77,6 +78,17 @@ function importMods.loadMod(mod) -- The file name of the mod
})
end

function importMods.loadModToAllModsIncludingDisabled(modMeta, path)
table.insert(importMods.storedModsIncludingDisabled, {
name = modMeta.name,
description = modMeta.description,
enabled = modMeta.enabled,
creator = modMeta.creator,
path = path
})
end


function importMods.getAllModsStages()
local stagesList = {}
for i, mod in ipairs(importMods.storedMods) do
Expand All @@ -93,6 +105,18 @@ function importMods.getAllModsStages()
return stagesList
end

function importMods.getAllMods()
local modsList = {}
for i, mod in ipairs(importMods.storedModsIncludingDisabled) do
table.insert(modsList, mod)
end
return modsList
end

function importMods.getModFromIndex(index)
return importMods.storedModsIncludingDisabled[index]
end

function importMods.getStageFileFromName(name)
for i, mod in ipairs(importMods.storedMods) do
if love.filesystem.getInfo(mod.path .. "/stages/" .. name .. ".lua") then
Expand Down Expand Up @@ -167,8 +191,10 @@ function importMods.loadAllMods()
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
print("Loading mod: " .. mod)
importMods.loadMod(mod)
end
importMods.loadModToAllModsIncludingDisabled(meta, "mods/" .. mod)
end
end
end
Expand Down Expand Up @@ -196,6 +222,37 @@ function importMods.getModFromStage(fileName)
return nil
end

function importMods.rewriteAllMetas(newModMetas)
for i, mod in ipairs(importMods.storedModsIncludingDisabled) do
mod.name = newModMetas[i].name
mod.description = newModMetas[i].description
mod.enabled = newModMetas[i].enabled
mod.creator = newModMetas[i].creator

love.filesystem.write(mod.path .. "/meta.lua", [[
return {
enabled = ]] .. tostring(mod.enabled) .. [[,
name = "]] .. mod.name .. [[",
creator = "]] .. mod.creator .. [[",
description = "]] .. mod.description .. [["
}
]])
end
end

function importMods.reloadAllMods()
importMods.storedMods = {}
importMods.storedModsScripts = {}
importMods.storedModsIncludingDisabled = {}
-- update weekMeta, weekDesc, and weekData to remove all mods past modWeekPlacement
for i = #weekMeta, modWeekPlacement + 1, -1 do
table.remove(weekMeta, i)
table.remove(weekDesc, i)
table.remove(weekData, i)
end
importMods.loadAllMods()
end

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

Expand Down
4 changes: 2 additions & 2 deletions src/love/modules/graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ return {
screenWidth, screenHeight = width, height
end,
getWidth = function()
return screenWidth or love.graphics.getWidth()
return 1280 or love.graphics.getWidth()
end,
getHeight = function()
return screenHeight or love.graphics.getHeight()
return 720 or love.graphics.getHeight()
end,

cache = {},
Expand Down
1 change: 1 addition & 0 deletions src/love/sprites/Alphabet.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@diagnostic disable: undefined-global
return graphics.newSprite(
Alphabet.image,
-- Automatically generated from alphabet.xml
Expand Down
24 changes: 24 additions & 0 deletions src/love/sprites/menu/mods.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
return graphics.newSprite(
love.graphics.newImage(graphics.imagePath("menu/menu_mods")),
-- Automatically generated from menu_mods.xml
{
{x = 0, y = 0, width = 355, height = 139, offsetX = 0, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 1: mods basic0000
{x = 0, y = 0, width = 355, height = 139, offsetX = 0, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 2: mods basic0001
{x = 0, y = 0, width = 355, height = 139, offsetX = 0, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 3: mods basic0002
{x = 356, y = 0, width = 355, height = 140, offsetX = 0, offsetY = 0, offsetWidth = 0, offsetHeight = 0, rotated = false}, -- 4: mods basic0003
{x = 356, y = 0, width = 355, height = 140, offsetX = 0, offsetY = 0, offsetWidth = 0, offsetHeight = 0, rotated = false}, -- 5: mods basic0004
{x = 356, y = 0, width = 355, height = 140, offsetX = 0, offsetY = 0, offsetWidth = 0, offsetHeight = 0, rotated = false}, -- 6: mods basic0005
{x = 0, y = 141, width = 353, height = 139, offsetX = -1, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 7: mods basic0006
{x = 0, y = 141, width = 353, height = 139, offsetX = -1, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 8: mods basic0007
{x = 0, y = 141, width = 353, height = 139, offsetX = -1, offsetY = -1, offsetWidth = 355, offsetHeight = 140, rotated = false}, -- 9: mods basic0008
{x = 354, y = 141, width = 395, height = 192, offsetX = 0, offsetY = -1, offsetWidth = 401, offsetHeight = 193, rotated = false}, -- 10: mods white0000
{x = 0, y = 334, width = 401, height = 189, offsetX = 0, offsetY = 0, offsetWidth = 401, offsetHeight = 193, rotated = false}, -- 11: mods white0001
{x = 402, y = 334, width = 400, height = 189, offsetX = 0, offsetY = -1, offsetWidth = 401, offsetHeight = 193, rotated = false} -- 12: mods white0002
},
{
["hover"] = {start = 10, stop = 12, speed = 24, offsetX = 0, offsetY = 0},
["idle"] = {start = 1, stop = 9, speed = 24, offsetX = 0, offsetY = 0}
},
"idle",
true
)
Loading

0 comments on commit 9e0e88e

Please sign in to comment.