Commit Graph

245 Commits

Author SHA1 Message Date
Alex Szpakowski 0cefb12c13 Add a variant of love.filesystem.getInfo which filters based on file type. getInfo(filename, "directory") will only return info for non-symlinked directories, for example. 2018-03-24 14:43:56 -03:00
Bart van Strien f32237a524 Prevent error in File:lines if the last line does not end with a newline (resolves #1383) 2018-02-17 14:55:39 +01:00
Bart van Strien d60849a9d5 Fix looping in File:lines on opened files (resolves #1377) 2018-02-11 12:10:57 +01:00
Bart van Strien fc9fcd2626 Prevent needless seeking in File:lines on closed files (issue #1377) 2018-02-10 12:06:30 +01:00
Alex Szpakowski a461f2d7af Improve the error message when love.filesystem.init fails. 2018-01-28 16:53:09 -04:00
Alex Szpakowski 0bc820ee0e Merged in cigumo/love (pull request #99)
Changes Filesystem::setSource mount order on Android

Simplifies the way setSource is handled on Android. It tries to mount
first and if that fails it will copy to memory and mount.

This works alongside a separate patch to GameActivity.java submitted
to the love-android-sdl2 repo, that contains the /sdcard/lovegame
fallback mechanism, and also allows to copy the game.love to the app
cache dir, which is useful for large files.
2018-01-25 02:15:29 +00:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski 0b7cb4a353 Add variants of File:read and love.filesystem.read which take an enum to determine whether they return a FileData or string. 2017-12-22 16:32:54 -04:00
Alex Szpakowski 640e8f0d2e love.filesystem.mount can accept a Data object containing zipped data.
- Add mount(Data, archivename, mountpoint [, appendtopath]). 'archivename' must be a string that has not been used with mount before.
- Add mount(FileData, mountpoint [, appendtopath]). The file path of the FileData is used as the archive name.
- Add unmount(Data).
- unmount(archivename) also works.
2017-12-16 23:09:15 -04:00
Alex Szpakowski ce46fa3ebe Remove PhysFS 2.x-specific code, it's no longer needed since we always have PhysFS 3. 2017-12-16 19:56:02 -04:00
Alex Szpakowski 1d8a3326b3 Include the physfs 3.0.1 source in love. 2017-12-15 19:41:17 -04:00
Bart van Strien 19ddc27069 Use a seekless implementation of File:lines/love.filesystem.lines
The previous algorithm would seek every time. This meant that although reading
from a filesystem would be quick (especially with disk caching), but reading
from a zip would be extremely slow.

The new version is rouhgly as fast on a filesystem, but appears not to slow
down on zips at all. Not in my tests, at least.

--HG--
branch : minor
2017-11-11 21:42:52 +01:00
Bart van Strien 9e4374935d Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)
All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
2017-10-02 17:11:53 +02:00
Alex Szpakowski bdc6eb3b29 Fix copy/paste error in the love.filesystem.isDirectory deprecation message.
--HG--
branch : minor
2017-09-25 15:52:49 +00:00
Alex Szpakowski 90e86c329d Add love.data module.
- Moved love.math.compress / decompress / decode / encode / hash to love.data.
- Changed love.data.compress/decompress to take the format argument first instead of second.
- Added love.data.newDataView. Returns a read-only subsection of an existing Data object.
- Added love.data.newByteData. Mostly useful in combination with LuaJIT's FFI as it has no extra methods currently.
- Added implementations of Lua 5.3's data packing APIs: love.data.packString / packData / unpack / getPackedSize.

Resolves issue #1336.
Resolves issue #1331.

--HG--
branch : minor
2017-09-24 19:25:27 -03:00
Alex Szpakowski 4ee85e1793 love get* APIs which return tables with fields can optionally accept a table argument to fill in, instead of creating a new table.
--HG--
branch : minor
2017-09-22 19:47:55 -03:00
Alex Szpakowski bf67d7ad0e PHYSFS_enumerateFiles bug has been fixed post-2.1.0.
--HG--
branch : minor
2017-09-04 01:18:48 -03:00
Alex Szpakowski e4e4c6673e Use PhysFS_getErrorByCode instead of PhysFS_getLastError, when available.
--HG--
branch : minor
2017-09-03 19:47:46 -03:00
Alex Szpakowski 737433d157 Update love.filesystem backend to always use PhysFS 2.1+ codepaths when available.
--HG--
branch : minor
2017-09-03 19:34:46 -03:00
Alex Szpakowski 23c9edcc52 Hopefully fix the build
--HG--
branch : minor
2017-08-27 18:17:30 -03:00
Alex Szpakowski 9d0e984c3d Add love.filesystem.getInfo. Deprecate love.filesystem.exists/isDirectory/isFile/isSymlink/getLastModified/getSize. Resolves issue #641.
--HG--
branch : minor
2017-08-27 18:14:54 -03:00
Alex Szpakowski fee157b6b9 Functions that take a boolean argument now properly type-check for it.
--HG--
branch : minor
2017-08-14 22:56:20 -03:00
Alex Szpakowski 7566db14f2 love.filesystem.isFile and isDirectory behave consistently between PhysFS 2.0 and 2.1/3.0 (see issue #641).
--HG--
branch : minor
2017-08-06 00:53:49 -03:00
Alex Szpakowski 2dd6408d00 Images/[Compressed]ImageData can be created using any Data, instead of just files or FileData.
--HG--
branch : minor
2017-08-05 23:55:20 -03:00
Alex Szpakowski 17cf7bba83 Cleaned up love.graphics.newShader's wrapper code a bit.
--HG--
branch : minor
2017-07-29 23:09:45 -03:00
Alex Szpakowski 5ef6730497 Added a variant of love.graphics.captureScreenshot which takes a single filename parameter. Resolves issue #1293.
--HG--
branch : minor
2017-07-29 12:54:53 -03:00
Alex Szpakowski 94ce558126 require now looks for both .dylib and .so extensions for C dynamic libraries in macOS, instead of just .so.
It also now replaces all occurrences of '??' and '?' in the path with the module filename and module name respectively, rather than just the first occurrence.

--HG--
branch : minor
2017-07-27 19:54:56 -03:00
Alex Szpakowski 518ed6f524 Small code style cleanup
--HG--
branch : minor
2017-07-21 21:17:55 -03:00
Raidho 8572a33880 Prettifyed the code exploiting inheritance rules
added missing comma, added missing `override`

--HG--
branch : minor
2017-02-10 18:36:47 +03:00
Raidho 6ea1ebde9c Data:clone ported to minor
minor tweaks

--HG--
branch : minor
2017-02-10 06:19:53 +03:00
Alex Szpakowski 28ed5e5a4b Actually merge the latest default into minor…
--HG--
branch : minor
2017-01-12 22:55:19 -04:00
evan yeung 8d269226c0 Let the love.filesystem loader support the template path for multiple interrogation mark. 2017-01-04 02:26:22 +00:00
evan yeung 9b77dbe262 Let the love.filesystem loader support the template path for multiple interrogation mark. 2017-01-04 01:56:27 +00:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski d26002f5cc Revamped and streamlined retina / high-DPI support (resolves issue #1122).
With the highdpi window flag enabled on a retina-capable display and OS, content should now appear to the user at the same size and in the same positions as with the flag disabled.

As a result, mouse and touch coordinates, Texture and graphics dimensions, and the graphics coordinate system now use pixel density-scaled units instead of pixels. Raw pixel units should generally only be used for things such as shader algorithms which execute per-pixel and rely on accurate pixel dimensions. love.window.fromPixels and friends typically don’t need to be used anymore.

Images, Canvases, and Fonts can have an optional explicit ‘pixel density’ set when creating them. This allows for easily loading high pixel density content which displays at the same size as regular or low pixel density content.

API changes:

- Added Texture:getPixelWidth/getPixelHeight/getPixelDimensions and Texture:getPixelDensity. Texture:getWidth/getHeight return the pixel density-scaled width and height (as it will appear on the screen when drawn) rather than the number of pixels on each texture dimension.

- Added love.graphics.getPixelWidth/getPixelHeight/getPixelDimensions.

- Added optional ‘pixeldensity’ field to the settings table parameter of love.graphics.newImage. It defaults to 1, or if the file the Image was loaded from has “@2x”, “@3x”, etc. at the end of its name, it uses that number as the pixel density scale by default.

- love.graphics.newCanvas now takes a table as its third parameter, with fields “format”, “msaa”, and “pixeldensity”. pixeldensity defaults to the main screen’s pixel density. The width and height parameters specify the visual size that the Canvas will be drawn at / can be drawn to (pixel density-scaled units).

- love.graphics.newVideo accepts a table as its second parameter, with optional fields “audio” and “pixeldensity”. pixeldensity defaults to 1.

- love.graphics.newFont variants have an optional pixeldensity parameter at the end of the argument list. For TrueType fonts this defaults to the current pixel density scale of the screen, and for BMFonts and ImageFonts this defaults to 1.

- Added Font:getPixelDensity.

- Renamed love.window.getPixelScale to love.window.getPixelDensity.

--HG--
branch : minor
2016-12-29 23:55:51 -04:00
Bart van Strien 06f4d6363e Move all love::Type initialisation to their respective (new) files
Previously Data, Stream, Drawable and Image (and for some reason Filesystem) had types in types.cpp

--HG--
branch : dynamiccore2
2016-11-30 12:55:08 +01:00
Bart van Strien 9f6aa716fa Pass Type to luax_register_type by pointer instead of reference
Since the type is passed to va_start, and apparently that's undefined behaviour if it's a reference.

<Textmode> the best kind of behavior

--HG--
branch : dynamiccore2
2016-11-14 21:51:47 +01:00
Bart van Strien d967a755e5 Make love::Type handle type names
TODO: Fix undefined behaviour in luax_register_type, you can't use a va_list after a reference type

--HG--
branch : dynamiccore2
2016-11-14 21:06:53 +01:00
Bart van Strien 5d43c9601a Automatically deduce the type in luax_pushtype, if possible
--HG--
branch : dynamiccore2
2016-11-13 17:38:42 +01:00
Bart van Strien 7dd960619d Automatically deduce the type in luax_checktype, luax_getmodule, luax_optmodule and luax_totype
--HG--
branch : dynamiccore2
2016-11-13 17:13:40 +01:00
Bart van Strien c761202486 Build type information on first use (load-time), instead of using a hardcoded list
--HG--
branch : dynamiccore2
2016-11-13 16:38:57 +01:00
Alex Szpakowski ef61573cd3 Merge default into minor
--HG--
branch : minor
2016-08-29 22:41:24 -03:00
Alex Szpakowski acde58d311 Improved the error message when nil is passed as the first argument to love.image.newImageData (resolves issue #1205). 2016-08-21 11:22:21 -03:00
Alex Szpakowski 31b44797bc Merge default into minor
--HG--
branch : minor
2016-05-12 18:20:01 -03:00
T-Bone 4ef7504c05 Fixed things pointed out by Alex Szpakowski and Bart von Strien 2016-04-09 07:28:03 +02:00
T-Bone b2291fb62a Fixes to make Löve compile on Windows 10 UWP 2016-04-07 22:56:03 +02:00
Bart van Strien db8e7a7670 Merge default into minor
--HG--
branch : minor
2016-04-02 17:19:20 +02:00
Alex Szpakowski 1b1572ad85 love.filesystem.mount accepts DroppedFiles in the first parameter. You could previously pass in DroppedFile:getFilename() and it would work too, this just makes it a bit nicer. 2016-03-31 17:58:27 -03:00
Alex Szpakowski 734789eb93 Added love.math.encode(format, data | string [, linelength]) and love.math.decode(format, data | string). Current formats are "base64" and "hex". The optional line length only applies to base64 and specifies the maximum number of characters per line in the encoded string.
Removed the variant of love.filesystem.newFileData which decoded a base64-encoded string since it's redundant.

--HG--
branch : minor
2016-03-28 19:28:40 -03:00
Alex Szpakowski 2e5f385be3 Merge default into minor
--HG--
branch : minor
2016-03-03 21:28:30 -04:00