2022-04-27 18:32:52 +00:00
|
|
|
# Love Loader
|
|
|
|
|
|
|
|
Custom menu for selecting game from multiple for Love2D.
|
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
Works from Love2D 0.10.
|
|
|
|
|
2022-05-30 07:33:56 +00:00
|
|
|
![PSP Style](./scr/psp.png)
|
|
|
|
|
|
|
|
[Other screenshots](./scr)
|
|
|
|
|
2022-04-27 18:32:52 +00:00
|
|
|
# How it works?
|
|
|
|
|
2022-05-30 07:33:56 +00:00
|
|
|
Just place games into `games` folder! (like `this_folder/games/game/main.lua`)
|
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
Technically, this creates the loop until game wasn't selected or user wants to exit,
|
2022-05-30 07:33:56 +00:00
|
|
|
with custom event handling and redrawing.
|
|
|
|
|
|
|
|
# LibLL
|
|
|
|
|
2022-07-07 16:37:27 +00:00
|
|
|
Love Loader from 2.0 includes backend API to simplify creating custom skins.
|
2022-05-30 07:33:56 +00:00
|
|
|
|
|
|
|
It have not so many functions and fields:
|
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
```lua
|
|
|
|
ll.games = { -- field for games with structure below
|
2022-05-30 07:33:56 +00:00
|
|
|
{
|
|
|
|
name = 'string', -- Friendly name for game or placeholder
|
|
|
|
desc = 'string', -- Description for game or placeholder
|
|
|
|
base = 'string', -- base directory used in game mounting, must end with `/`
|
|
|
|
dir = 'string', -- directory name, used if no name was defined
|
|
|
|
main = 'string', -- main file to execute or `main.lua`
|
|
|
|
screens = {'array of', 'path to screenshots'},
|
|
|
|
scrcur = 1, --[[number]] -- current index from screenshots
|
|
|
|
scrprv = 1, --[[number]] -- previous index from screenshots
|
|
|
|
dat = nil, --[[any]] -- maybe platform-dependent data to reduce operations
|
|
|
|
}
|
2022-07-08 13:12:11 +00:00
|
|
|
}
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
ll.mdir -- string or nil, contains full mounted directory.
|
|
|
|
ll.mgme -- game or nil, contains mounted game
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
-- check if game mounted by ll.mdir!
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.gameNew(
|
|
|
|
configuration, --string
|
|
|
|
fileName, -- string, not used
|
|
|
|
baseDirectory, -- string
|
|
|
|
gameDirectory -- string
|
|
|
|
) -- creates game object (defined above) and returns it.
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.gameAdd(...) -- same as ll.gameNew with insertion into ll.games.
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.addGame(fileName, fileContent) -- reserved function for file dropping.
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.mount(gameObject) -- mounts game.
|
|
|
|
-- throws error.
|
|
|
|
-- Sets ll.mdir and ll.mgme
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.umount() -- unmounts game if was mounted.
|
|
|
|
-- Unsets ll.mdir and ll.mgme
|
2022-05-30 07:33:56 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
ll.home = llHome
|
2022-04-27 18:32:52 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.devtools() -- enable developer tools.
|
2022-04-27 18:32:52 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
if ll.dt then -- is developer tools enabled?
|
|
|
|
__LL = ll -- global variable with Love Loader instance.
|
|
|
|
end
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.fsIsAbs(file) -- is file absolute? (/file)
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.fsIsRel(file) -- is file relative? (./file)
|
|
|
|
-- return not ll.fsIsAbs(file)
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.fsDir(path) -- get directory name (2 from /1/2/3.file)
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.fsFile(path) -- get file (including dividers after) (2 from /1/2)
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.kbInit(
|
|
|
|
direction, -- string: '*', 'h', 'v', 'x', 'y'
|
|
|
|
c1, -- number, coordinate before card (for mouse) (left/top)
|
|
|
|
c2, -- number, coordinate after card (for mouse) (right/bottom)
|
|
|
|
clim -- number = -1, other coordinate limit (for mouse) (x for v, y for h), -1 to disable
|
|
|
|
) -- initialize keyboard module (inside skins).
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function ll.kbGet() -- get key pressed.
|
|
|
|
-- need ll.kbInit(...) before
|
|
|
|
-- returns nil | string: '<', '>', 'o', 'm', ('^', 'v' if direction == '*')
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
```
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-05-30 07:33:56 +00:00
|
|
|
# API
|
2022-04-27 18:32:52 +00:00
|
|
|
|
2022-07-07 16:37:27 +00:00
|
|
|
To reduce things to do for game developers, this loader creates some global variables to use.
|
2022-04-27 18:32:52 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
You can also use it without Love Loader (or if your game can distribute without loader)
|
|
|
|
using `require 'll-min'`
|
2022-04-27 18:33:49 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
```lua
|
|
|
|
W, H = width, height -- of the screen.
|
2022-04-27 18:33:49 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function love.resize() -- internal function that updates W, H and calls resize function if exists.
|
2022-04-28 18:35:21 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function resize() -- payload for love.resize function.
|
2022-04-28 18:35:21 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function love.event.quit() -- *should* exit to Love Loader screen.
|
2022-04-28 18:35:21 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
function llHome() -- function called by love.event.quit.
|
2022-04-28 18:35:21 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
llUsed = false -- is Love Loader (not minimal API) used.
|
2022-04-27 18:32:52 +00:00
|
|
|
|
2022-07-08 13:12:11 +00:00
|
|
|
COLDIV = 1 -- or 255, color divider for love.graphics.setColor function (150/COLDIV).
|
|
|
|
|
|
|
|
MOBILE = false -- is this device runs Android or iOS?
|
|
|
|
```
|
2022-07-07 16:37:27 +00:00
|
|
|
|
2022-04-27 18:32:52 +00:00
|
|
|
# Fill game information
|
|
|
|
|
|
|
|
To fill game information in game folder need to create `info.ll` file.
|
|
|
|
|
|
|
|
Syntax is `k = v` with `# comments`
|
|
|
|
|
|
|
|
```
|
|
|
|
# are there needed any comments?
|
|
|
|
name = New awesome game using Love Loader
|
|
|
|
desc = Some descripion about the game.
|
|
|
|
# main = optional main file instead of `main.lua`
|
2022-04-28 18:35:21 +00:00
|
|
|
pic = screen.png
|
2022-05-30 07:33:56 +00:00
|
|
|
pics = [ screen.png; screen2.png ] # wow arrays
|
2022-04-27 18:32:52 +00:00
|
|
|
```
|
2022-07-07 16:37:27 +00:00
|
|
|
|