I agree with Lafolie's sentiment; it's much more fun and rewarding to work on the game play rather than the administrative stuff. But I know, at least for me, that it's hard to do that if you don't at least have an idea of how you might do those boring things.
I don't know if this helps you much or not, but I've been working on a menu system for myself. I was building a game and realized I needed some way to configure it (much like you) so I started this project. It's probably not the optimal solution, but it will give you an idea of what's necessary. Here's a screenshot:
- menu.png (22.72 KiB) Viewed 6190 times
Attached is a demo with a video and audio menu (very basic) and an exit function. I've used
kikito's middleclass as a means of making it more object oriented. The code is fairly well documented (at least functions and their parameters). It's also got a basic input system and a 'class' that made dealing with colors easier for me. The main.lua contains the code that creates the menu.
Here is a snippet of code that sets up the video portion of the menu:
Code: Select all
menu = MinimalMenu()
-- set up an options menu.
local options = menu:addItem(nil, 'Options', nil, nil)
-- set up a video menu with fullscreen (on, off), vsync (on, off) and available resolutions
local video = menu:addItem(options, 'Video', 'Contains options about video parameters', nil)
local fullscreen = menu:addItem(video, 'Fullscreen', 'Sets the application to fullscreen', nil)
menu:addItem(fullscreen, 'On', '', function() game.mode.fullscreen = true; updateMode() end)
menu:addItem(fullscreen, 'Off', '', function() game.mode.fullscreen = false; updateMode() end)
if game.mode.fullscreen == false then fullscreen.selectedChild = 2 end
local vsync = menu:addItem(video, 'Vsync', 'Sets the vertical sync', nil)
menu:addItem(vsync, 'On', '', function() game.mode.vsync = true; updateMode() end)
menu:addItem(vsync, 'Off', '', function() game.mode.vsync = false; updateMode() end)
if game.mode.vsync == false then vsync.selectedChild = 2 end
local resolutions = menu:addItem(video, 'Resolutions', 'Select a resolution.', nil)
local modes = love.graphics.getModes()
table.sort(modes, function(a, b) return a.width*a.height < b.width*b.height end)
for _, mode in pairs(modes) do
menu:addItem(resolutions, mode.width .. 'x' .. mode.height, 'no hint',
function() game.mode.width = mode.width; game.mode.height = mode.height; updateMode() end)
end
It's not enough to have a menu, you'll need some kind of game state library to make it work. If you are starting from nothing I'd suggest having a look at
hump which has a good set of basic functionality (including game states). There are tons of
other libraries to peruse as well. And don't be like me and totally miss the
snippets section of the wiki!
The demo does not save any settings, it starts with the defaults every time you load it up.
Note: it's not quite done, but it's close enough.