Love-js updated to set love file size for web.
This commit is contained in:
parent
ea38605427
commit
0b2faf372b
|
@ -3,7 +3,7 @@ help="love-js.sh: \n\
|
||||||
For the full project please see https://github.com/Davidobot/love.js \n\
|
For the full project please see https://github.com/Davidobot/love.js \n\
|
||||||
\n\
|
\n\
|
||||||
usage: \n\
|
usage: \n\
|
||||||
./love-js.sh [directory-name] [project-name] [version] \n\
|
./love-js.sh [directory-name] [project-name] [version] [cache]\n\
|
||||||
\n\
|
\n\
|
||||||
eg: \n\
|
eg: \n\
|
||||||
./love-js.sh ../../releases/ project 0.1.0 \n\
|
./love-js.sh ../../releases/ project 0.1.0 \n\
|
||||||
|
@ -21,7 +21,6 @@ fi
|
||||||
release_dir=$1
|
release_dir=$1
|
||||||
name=$2
|
name=$2
|
||||||
version=$3
|
version=$3
|
||||||
|
|
||||||
## confirm that $release_dir/$name-$version.love exists
|
## confirm that $release_dir/$name-$version.love exists
|
||||||
if [ ! -f $release_dir/$name-$version.love ]; then
|
if [ ! -f $release_dir/$name-$version.love ]; then
|
||||||
echo "love file not found!"
|
echo "love file not found!"
|
||||||
|
@ -33,9 +32,12 @@ release="compat"
|
||||||
canvas_colour="62, 50, 100"
|
canvas_colour="62, 50, 100"
|
||||||
page_colour=$canvas_colour
|
page_colour=$canvas_colour
|
||||||
text_colour="223, 7, 114"
|
text_colour="223, 7, 114"
|
||||||
initial_memory=0 #$(du -b $release_dir/$name-$version.love | awk '{print $1}')
|
initial_memory=0
|
||||||
|
module_size=$(du -b $release_dir/$name-$version.love | awk '{print $1}')
|
||||||
title=$(echo $name-$version | sed -r 's/\<./\U&/g' | sed -r 's/-/\ /g')
|
title=$(echo $name-$version | sed -r 's/\<./\U&/g' | sed -r 's/-/\ /g')
|
||||||
|
cachemodule=$4
|
||||||
|
|
||||||
|
echo $release_dir $name $version $cachemodule
|
||||||
# echo $title " " $canvas_colour " " $text_colour " " $initial_memory
|
# echo $title " " $canvas_colour " " $text_colour " " $initial_memory
|
||||||
|
|
||||||
call_dir=$(pwd)
|
call_dir=$(pwd)
|
||||||
|
@ -55,7 +57,8 @@ cat src/love.css | \
|
||||||
$name-$version/theme/love.css
|
$name-$version/theme/love.css
|
||||||
|
|
||||||
cat src/game.js | \
|
cat src/game.js | \
|
||||||
sed "s/{{{metadata}}}/{\"package_uuid\":\"2fd99e56-5455-45dd-86dd-7af724874d65\",\"remote_package_size\":4506139,\"files\":[{\"filename\":\"\/game.love\",\"crunched\":0,\"start\":0,\"end\":4506139,\"audio\":false}]}/" > \
|
sed "s/{{{cachemodule}}}/${cachemodule}/g" | \
|
||||||
|
sed "s/{{{metadata}}}/{\"package_uuid\":\"2fd99e56-5455-45dd-86dd-7af724874d65\",\"remote_package_size\":$module_size,\"files\":[{\"filename\":\"\/game.love\",\"crunched\":0,\"start\":0,\"end\":$module_size,\"audio\":false}]}/" > \
|
||||||
$name-$version/game.js
|
$name-$version/game.js
|
||||||
|
|
||||||
cp src/consolewrapper.js $name-$version
|
cp src/consolewrapper.js $name-$version
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
var Module;
|
var Module;
|
||||||
|
|
||||||
|
var CACHEMODULE = {{{cachemodule}}};
|
||||||
|
|
||||||
if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
|
if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
|
||||||
|
|
||||||
if (!Module.expectedDataFileDownloads) {
|
if (!Module.expectedDataFileDownloads) {
|
||||||
|
@ -250,20 +252,25 @@ Module.expectedDataFileDownloads++;
|
||||||
openDatabase(
|
openDatabase(
|
||||||
function(db) {
|
function(db) {
|
||||||
checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME,
|
checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME,
|
||||||
function(useCached) {
|
function(useCached) {
|
||||||
Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached};
|
Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached};
|
||||||
if (useCached) {
|
if (useCached && CACHEMODULE) {
|
||||||
console.info('loading ' + PACKAGE_NAME + ' from cache');
|
console.info('loading ' + PACKAGE_NAME + ' from cache');
|
||||||
fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, preloadFallback);
|
fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, processPackageData, preloadFallback);
|
||||||
} else {
|
} else {
|
||||||
console.info('loading ' + PACKAGE_NAME + ' from remote');
|
console.info('loading ' + PACKAGE_NAME + ' from remote');
|
||||||
fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE,
|
fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE,
|
||||||
function(packageData) {
|
function(packageData) {
|
||||||
|
if(CACHEMODULE){
|
||||||
cacheRemotePackage(db, PACKAGE_PATH + PACKAGE_NAME, packageData, {uuid:PACKAGE_UUID}, processPackageData,
|
cacheRemotePackage(db, PACKAGE_PATH + PACKAGE_NAME, packageData, {uuid:PACKAGE_UUID}, processPackageData,
|
||||||
function(error) {
|
function(error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
processPackageData(packageData);
|
processPackageData(packageData);
|
||||||
});
|
});}
|
||||||
|
else {
|
||||||
|
processPackageData(packageData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
, preloadFallback);
|
, preloadFallback);
|
||||||
}
|
}
|
||||||
|
|
2
makefile
2
makefile
|
@ -43,7 +43,7 @@ releases/$(NAME)-$(VERSION)-win.zip: $(LOVEFILE)
|
||||||
mv releases/$(NAME)-win32.zip $@
|
mv releases/$(NAME)-win32.zip $@
|
||||||
|
|
||||||
releases/$(NAME)-$(VERSION)-web.zip: $(LOVEFILE)
|
releases/$(NAME)-$(VERSION)-web.zip: $(LOVEFILE)
|
||||||
cd releases && ../buildtools/love-js/love-js.sh $(PWD)/releases $(NAME) $(VERSION)
|
cd releases && ../buildtools/love-js/love-js.sh $(PWD)/releases $(NAME) $(VERSION) false
|
||||||
|
|
||||||
linux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
linux: releases/$(NAME)-$(VERSION)-x86_64.AppImage
|
||||||
mac: releases/$(NAME)-$(VERSION)-macos.zip
|
mac: releases/$(NAME)-$(VERSION)-macos.zip
|
||||||
|
|
Loading…
Reference in a new issue