flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
294 stars 25 forks source link

Replace dots with slashes when concatenating resource paths #21

Closed Rinkaa closed 4 years ago

Rinkaa commented 4 years ago

Calling FileDialog from Slab locating at a subfolder raises error:

Error

libs/Slab/Internal/UI/Image.lua:42: Could not open file libs.Slab/Internal/Resources/Textures/Folder.png. Does not exist.

Traceback

[C]: in function 'newImage' libs/Slab/Internal/UI/Image.lua:42: in function 'GetImage' libs/Slab/Internal/UI/Image.lua:82: in function 'Begin' libs/Slab/Internal/UI/Dialog.lua:120: in function 'FileDialogItem' libs/Slab/Internal/UI/Dialog.lua:506: in function 'FileDialog'

And at Dialog.lua:120:

Image.Begin('FileDialog_Folder', {Path = SLAB_PATH .. "/Internal/Resources/Textures/Folder.png"})

where SLAB_PATH is "libs.Slab".

I searched all occurances of SLAB_PATH and found this: (At Style.lua:81)

local StylePath = "/Internal/Resources/Styles/"
local Path = SLAB_PATH .. StylePath
Path = string.gsub(Path, "%.", "/")

Imitaing this, I fixed all similar concatenatings with gsub and made this PR.

Rinkaa commented 4 years ago

Also, I wonder if the solution is solid enough with gsub instead of FileSystem.GetSlabPath()... Well, lua projects rarely use dots in filenames on the other hand, and gsub surely costs less in performance.