Skip to content

Commit

Permalink
Assetify v.4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ov-tron committed Jun 27, 2022
1 parent 5cc173b commit df7f62e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [Library]/assetify_library/handlers/bundler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local parseModules = {
local function parse(rw)
if not rw or (imports.type(rw) ~= "string") then return false end
for i, j in pairs(parseModules) do
rw = imports.utf8.gsub(rw, i, j, true, "(", ".:)")
rw = imports.utf8.gsub(rw, i, j, _, true, "(", ".:)")
end
return rw
end
Expand Down
2 changes: 1 addition & 1 deletion [Library]/assetify_library/meta.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<meta>

<info author="vStudio" name="Assetify Library" type="Library" version="4.3.0"/>
<info author="vStudio" name="Assetify Library" type="Library" version="4.4.0"/>
<min_mta_version server="1.5.9" client="1.5.9"/>
<aclrequest>
<right name="function.fetchRemote" access="true"/>
Expand Down
18 changes: 11 additions & 7 deletions [Library]/assetify_library/utilities/asset.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,19 @@ if localPlayer then
return true
end
else
function asset:buildManifest(assetPath, manifestPath)
local manifestData = imports.file.read(assetPath..manifestPath)
function asset:buildManifest(rootPath, localPath, manifestPath)
localPath = localPath or rootPath
local manifestData = imports.file.read(localPath..manifestPath)
manifestData = (manifestData and imports.json.decode(manifestData)) or false
if manifestData then
for i, j in imports.pairs(manifestData) do
local url, directory = imports.file.parseURL(j, "json")
if url and directory then
url = imports.string.sub(url, #directory + 1)
manifestData[i] = asset:buildManifest(assetPath..directory, url)
local cURL = imports.file.parseURL(j)
if cURL and cURL.url and cURL.extension and cURL.pointer and (cURL.extension == "json") then
local pointerPath = ((cURL.pointer == "rootDir") and rootPath) or ((cURL.pointer == "localDir") and localPath) or false
if pointerPath then
local __cURL = imports.file.parseURL(imports.file.resolveURL(pointerPath..(cURL.directory or "")..cURL.file, imports.file.validPointers["localDir"]..rootPath))
manifestData[i] = asset:buildManifest(rootPath, __cURL.directory or "", __cURL.file)
end
end
end
end
Expand Down Expand Up @@ -359,7 +363,7 @@ else
for i = 1, #cAssetPack.manifestData, 1 do
local assetName = cAssetPack.manifestData[i]
local assetPath = (asset.references.root)..imports.string.lower(assetType).."/"..assetName.."/"
local assetManifestData = asset:buildManifest(assetPath, (asset.references.asset)..".json")
local assetManifestData = asset:buildManifest(assetPath, _, (asset.references.asset)..".json")
if assetManifestData then
assetManifestData.streamRange = imports.math.max(imports.tonumber(assetManifestData.streamRange) or 0, asset.ranges.streamRange)
assetManifestData.enableLODs = (assetManifestData.enableLODs and true) or false
Expand Down
70 changes: 60 additions & 10 deletions [Library]/assetify_library/utilities/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
local imports = {
type = type,
pairs = pairs,
split = split,
tonumber = tonumber,
select = select,
unpack = unpack,
Expand Down Expand Up @@ -138,21 +139,67 @@ class = {
---------------------

file = {
validPointers = {rootDir = "~/", localDir = "@/"},
exists = imports.fileExists,
delete = imports.fileDelete,

parseURL = function(path, extension)
if not path or not extension or (imports.type(path) ~= "string") or (imports.type(extension) ~= "string") then return false end
local _, startN = imports.utf8.find(path, "@/")
local endN = imports.utf8.find(path, "."..extension)
startN, endN = (startN and (startN + 1)) or startN, (endN and (endN - 1)) or endN
if startN and endN then
local url = imports.utf8.sub(path, startN, endN)
if imports.string.match(url, "%w") then return url.."."..extension, imports.string.match(url, "(.*[/\\])") or "" end
parseURL = function(path)
if not path or (imports.type(path) ~= "string") then return false end
local extension = imports.utf8.match(path, "^.+%.(.+)$")
extension = (extension and imports.utf8.match(extension, "%w") and extension) or false
local pointer, pointerEndN = nil, nil
for i, j in imports.pairs(file.validPointers) do
local startN, endN = imports.utf8.find(path, j)
if startN and endN and (startN == 1) then
pointer, pointerEndN = i, endN + 1
break
end
end
local url = imports.utf8.sub(path, pointerEndN or 1, #path - ((extension and (#extension + 1)) or 0))
if imports.utf8.match(url, "%w") then
local cURL = {
pointer = pointer or false,
url = (extension and (url.."."..extension)) or url,
extension = extension,
directory = imports.utf8.match(url, "(.*[/\\])") or false
}
cURL.file = (cURL.extension and imports.utf8.sub(cURL.url, (cURL.directory and (#cURL.directory + 1)) or 1)) or false
return cURL
end
return false
end,

resolveURL = function(path, chroot)
if not path or (imports.type(path) ~= "string") or (chroot and (imports.type(chroot) ~= "string")) then return false end
local cURL = file.parseURL(path)
if not cURL then return false end
cURL.url = (cURL.pointer and imports.utf8.gsub(cURL.url, file.validPointers[(cURL.pointer)], "")) or cURL.url
local cDirs = imports.split(cURL.url, "/")
if #cDirs > 0 then
if chroot then
chroot = file.parseURL(((imports.utf8.sub(chroot, #chroot) ~= "/") and chroot.."/") or chroot)
chroot = (chroot and chroot.pointer and imports.utf8.gsub(chroot.url, file.validPointers[(chroot.pointer)], "")) or chroot
end
cURL.url = false
local vDirs = {}
for i = 1, #cDirs, 1 do
local j = cDirs[i]
if j == "..." then
if not chroot or (chroot ~= cURL.url) then
imports.table.remove(vDirs, vDirs.__N)
end
else
imports.table.insert(vDirs, j)
end
cURL.url = imports.table.concat(vDirs, "/")
local __cURL = file.parseURL(cURL.url)
cURL.url = (__cURL and not __cURL.file and cURL.url.."/") or cURL.url
end
cURL.url = ((cURL.pointer and file.validPointers[(cURL.pointer)]) or "")..(cURL.url or "")
end
return cURL.url
end,

read = function(path)
if not path or not imports.fileExists(path) then return false end
local cFile = imports.fileOpen(path, true)
Expand All @@ -179,10 +226,13 @@ file = {
---------------------

local __utf8_gsub = imports.utf8.gsub
utf8.gsub = function(string, matchWord, replaceWord, isStrictcMatch, matchPrefix, matchPostfix)
utf8.gsub = function(string, matchWord, replaceWord, matchLimit, isStrictcMatch, matchPrefix, matchPostfix)
if not matchWord then
print(string)
end
matchPrefix, matchPostfix = matchPrefix or "", matchPostfix or ""
matchWord = (isStrictcMatch and "%f[^"..matchPrefix.."%z%s]"..matchWord.."%f["..matchPostfix.."%z%s]") or matchPrefix..matchWord..matchPostfix
return __utf8_gsub(string, matchWord, replaceWord)
return __utf8_gsub(string, matchWord, replaceWord, matchLimit)
end


Expand Down
2 changes: 1 addition & 1 deletion [Library]/assetify_mapper/meta.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<meta>

<info author="vStudio" name="Assetify Mapper" type="Library" version="4.3.0"/>
<info author="vStudio" name="Assetify Mapper" type="Library" version="4.4.0"/>
<min_mta_version server="1.5.9" client="1.5.9"/>

<!-- Imports -->
Expand Down

0 comments on commit df7f62e

Please sign in to comment.