Add preload and scripts

This commit is contained in:
Varun Patil 2020-05-06 13:03:51 +05:30
parent ad9474a6e9
commit 47ee508ae5
6 changed files with 1146 additions and 0 deletions

14
extra/dummify.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
for f in Graphics/**/*
do
echo $f
echo "1" > $f
done
for f in Audio/**/*
do
echo $f
echo "1" > $f
done

8
extra/dump.rb Normal file
View File

@ -0,0 +1,8 @@
require 'yaml'
eval(IO.read('dump_rgss.rb'))
file = File.open(ARGV[0], "r")
data = Marshal.load(file)
IO.write('dump.yml', data.to_yaml)

84
extra/dump.sh Executable file
View File

@ -0,0 +1,84 @@
#!/bin/bash
ARRAY=()
ARRAYFILES=()
FILE=$1
mkdir -p preload/Data
rm -f preload/$FILE.json
touch preload/$FILE.json
ruby dump.rb $FILE
while IFS= read -r line; do
if [[ $line == *"::"* ]]; then
continue
fi
if [[ $line == *"!"* ]]; then
continue
fi
if [[ $line == *"true" ]]; then
continue
fi
if [[ $line == *"false" ]]; then
continue
fi
if [[ $line == *"[]" ]]; then
continue
fi
if [[ $line == *":"* ]]; then
value=${line#*:}
value=${value//[[:blank:]]/}
value=${value//\'}
re="^[0-9.-]+$"
if [[ $value =~ $re ]] ; then
continue
fi
re='^EV[0-9]+$'
if [[ $value =~ $re ]] ; then
continue
fi
if [[ $value == 'A' ]] ; then
continue
fi
if [[ $value == "''" ]] ; then
continue
fi
if [ -z "$value" ] ; then
continue
fi
if [[ " ${ARRAY[@]} " =~ " ${value} " ]]; then
continue
fi
echo $value
ARRAY+=($value)
files="$(find -name "$value.*")"
files="${files//\.\/}"
if [ -z "$files" ] ; then
continue
fi
echo "$files"
ARRAYFILES+=($files)
fi
done < dump.yml
rm dump.yml
echo '[' >> preload/$FILE.json
printf '"%s",\n' "${ARRAYFILES[@]}" | sed '$s/,$//' >> preload/$FILE.json
echo ']' >> preload/$FILE.json
echo "============================================================"
cat preload/$FILE.json
echo "============================================================"

1025
extra/dump_rgss.rb Normal file

File diff suppressed because it is too large Load Diff

View File

@ -172,6 +172,20 @@
window.onerror = function() {
alert("An error occured!")
};
window.fileLoadedAsync = function(file) {
if (!(/.*Map.*rxdata/i.test(file))) return;
fetch('preload/' + file + '.json')
.then(function(response) {
return response.json();
})
.then(function(jsonResponse) {
jsonResponse.forEach((f) => {
fetch('gameasync/' + f).then().catch();
});
});
};
</script>
{{{ SCRIPT }}}

View File

@ -37,6 +37,7 @@ EM_JS(void, load_file_async_js, (const char* fullPathC), {
FS.createPreloadedFile(path, filename, iurl, true, true, function() {
window.fileAsyncCache[fullPath] = 1;
if (window.setNotBusy) window.setNotBusy();
if (window.fileLoadedAsync) window.fileLoadedAsync(fullPath);
wakeUp();
}, console.error);
});