1
0

gif preview support, built-in dummy preview, fix upload tool result check

This commit is contained in:
GenZmeY 2022-06-06 08:39:44 +03:00
parent 49fcaf67a2
commit 02222cf453

80
builder
View File

@ -68,7 +68,7 @@ MutBuilderConfig="$MutSource/builder.cfg"
MutPubContent="$MutSource/PublicationContent" MutPubContent="$MutSource/PublicationContent"
MutPubContentDescription="$MutPubContent/description.txt" MutPubContentDescription="$MutPubContent/description.txt"
MutPubContentTitle="$MutPubContent/title.txt" MutPubContentTitle="$MutPubContent/title.txt"
MutPubContentPreview="$MutPubContent/preview.png" MutPubContentPreview="$MutPubContent/preview"
MutPubContentTags="$MutPubContent/tags.txt" MutPubContentTags="$MutPubContent/tags.txt"
# Steam workshop upload filesystem # Steam workshop upload filesystem
@ -110,6 +110,9 @@ BLU=''
DEF='' DEF=''
BLD='' BLD=''
# PNG
DummyPreviewRaw='\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x20\x00\x00\x00\x20\x01\x03\x00\x00\x00\x49\xb4\xe8\xb7\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\x00\x00\x06\x50\x4c\x54\x45\x00\x00\x00\xff\xff\xff\xa5\xd9\x9f\xdd\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95\x2b\x0e\x1b\x00\x00\x00\x14\x49\x44\x41\x54\x18\xd3\x63\x60\x60\xf8\xff\x9f\x9a\x04\x55\x4d\x63\x60\x00\x00\xed\xbd\x3f\xc1\xbb\x2a\xd9\x62\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82'
function is_true () # $1: Bool arg to check function is_true () # $1: Bool arg to check
{ {
echo "$1" | grep -Piq '^true$' echo "$1" | grep -Piq '^true$'
@ -183,6 +186,11 @@ function die () # $1: String, $2: Exit code
exit "${2-3}" exit "${2-3}"
} }
function warn () # $1: String
{
msg "${YLW}${1-}"
}
function usage () function usage ()
{ {
local HelpMessage="" local HelpMessage=""
@ -413,9 +421,13 @@ EOF
msg "${GRN}$(basename "$MutPubContentDescription") created${DEF}" msg "${GRN}$(basename "$MutPubContentDescription") created${DEF}"
fi fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentPreview" ]]; then if is_true "$ArgForce" || [[ "$(preview_extension)" == "None" ]]; then
cp -f "$DummyPreview" "$MutPubContentPreview" if [[ -e "$DummyPreview" ]]; then
msg "${GRN}$(basename "$MutPubContentPreview") created${DEF}" cp -f "$DummyPreview" "${MutPubContentPreview}.png"
else
printf '%b' "$DummyPreviewRaw" > "${MutPubContentPreview}.png"
fi
msg "${GRN}$(basename "${MutPubContentPreview}.png") created${DEF}"
fi fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then
@ -435,6 +447,19 @@ EOF
fi fi
} }
function preview_extension ()
{
for Ext in gif png jpg jpeg
do
if [[ -e "${MutPubContentPreview}.${Ext}" ]]; then
echo "$Ext"
return 0
fi
done
echo "None"
}
function read_settings () function read_settings ()
{ {
if ! [[ -f "$MutBuilderConfig" ]]; then init; fi if ! [[ -f "$MutBuilderConfig" ]]; then init; fi
@ -516,9 +541,9 @@ function parse_log () # $1: Logfile
FileUnix="$(cygpath -u "$File")" FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")" FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Error" | sed -r 's|^.+Error: ((.+)\(([0-9]+)\) : )?Error,(.+)$|\3|')" Line="$(echo "$Error" | sed -r 's|^.+Error: ((.+)\(([0-9]+)\) : )?Error,(.+)$|\3|')"
msg "${RED}[$I] $FileCompact($Line): $Message" err "[$I] $FileCompact($Line): $Message"
else else
msg "${RED}[$I] $Message" err "[$I] $Message"
fi fi
((I+=1)) ((I+=1))
done < <(grep -P ' Error:(.+:)? Error, ' "$1") done < <(grep -P ' Error:(.+:)? Error, ' "$1")
@ -535,9 +560,9 @@ function parse_log () # $1: Logfile
FileUnix="$(cygpath -u "$File")" FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")" FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Warning" | sed -r 's|^.+Warning: ((.+)\(([0-9]+)\) : )?Warning,(.+)$|\3|')" Line="$(echo "$Warning" | sed -r 's|^.+Warning: ((.+)\(([0-9]+)\) : )?Warning,(.+)$|\3|')"
msg "${YLW}[$I] $FileCompact($Line): $Message" warn "[$I] $FileCompact($Line): $Message"
else else
msg "${YLW}[$I] $Message" warn "[$I] $Message"
fi fi
((I+=1)) ((I+=1))
done < <(grep -P ' Warning:(.+:)? Warning, ' "$1") done < <(grep -P ' Warning:(.+:)? Warning, ' "$1")
@ -685,7 +710,7 @@ function brew ()
read_settings read_settings
if ! compiled ; then if ! compiled; then
die "You must compile packages before brewing. Use --compile option for this." 2 die "You must compile packages before brewing. Use --compile option for this." 2
fi fi
@ -730,7 +755,7 @@ function brew_manual ()
read_settings read_settings
if ! compiled ; then if ! compiled; then
die "You must compile packages before brewing. Use --compile option for this." 2 die "You must compile packages before brewing. Use --compile option for this." 2
fi fi
@ -761,7 +786,7 @@ function brew_manual ()
function publish_unpublished () function publish_unpublished ()
{ {
msg "${YLW}warn: uploading without brewing${DEF}" warn "uploading without brewing${DEF}"
mkdir -p "$KFPublishBrewedPC" "$KFPublishScript" "$KFPublishPackages" mkdir -p "$KFPublishBrewedPC" "$KFPublishScript" "$KFPublishPackages"
@ -779,10 +804,12 @@ function publish_unpublished ()
function upload () function upload ()
{ {
local PreparedWsDir="" local PreparedWsDir=""
local Preview=""
local Success="False"
read_settings read_settings
if ! compiled ; then if ! compiled; then
die "You must compile packages before uploading. Use --compile option for this." 2 die "You must compile packages before uploading. Use --compile option for this." 2
fi fi
@ -790,6 +817,14 @@ function upload ()
publish_unpublished publish_unpublished
fi fi
Preview="${MutPubContentPreview}.$(preview_extension)"
if ! [[ -e "$Preview" ]]; then
die "No preview image in PublicationContent" 2
elif [[ $(stat --printf="%s" "$Preview") -ge 1048576 ]]; then
warn "The size of $(basename "$Preview") is greater than 1mb. Steam may prevent you from loading content with this image. if you get an error while loading - try using a smaller preview."
fi
find "$KFPublish" -type d -empty -delete find "$KFPublish" -type d -empty -delete
PreparedWsDir="$(mktemp -d -u -p "$KFDoc")" PreparedWsDir="$(mktemp -d -u -p "$KFDoc")"
@ -797,7 +832,7 @@ function upload ()
cat > "$MutWsInfo" <<EOF cat > "$MutWsInfo" <<EOF
\$Description "$(cat "$MutPubContentDescription")" \$Description "$(cat "$MutPubContentDescription")"
\$Title "$(cat "$MutPubContentTitle")" \$Title "$(cat "$MutPubContentTitle")"
\$PreviewFile "$(cygpath -w "$MutPubContentPreview")" \$PreviewFile "$(cygpath -w "$Preview")"
\$Tags "$(cat "$MutPubContentTags")" \$Tags "$(cat "$MutPubContentTags")"
\$MicroTxItem "false" \$MicroTxItem "false"
\$PackageDirectory "$(cygpath -w "$PreparedWsDir")" \$PackageDirectory "$(cygpath -w "$PreparedWsDir")"
@ -806,15 +841,24 @@ EOF
cp -rf "$KFPublish" "$PreparedWsDir" cp -rf "$KFPublish" "$PreparedWsDir"
msg "upload to steam workshop" msg "upload to steam workshop"
if is_true "$ArgQuiet"; then while read -r Output
CMD //C "$(cygpath -w "$KFWorkshop") $(basename "$MutWsInfo")" &>/dev/null do
else if echo "$Output" | grep -qiF 'Successfully uploaded workshop file to Steam'; then
CMD //C "$(cygpath -w "$KFWorkshop") $(basename "$MutWsInfo")" Success="True"
break
elif echo "$Output" | grep -qiF 'error'; then
err "UploadTool: $Output"
fi fi
msg "${GRN}successfully uploaded to steam workshop${DEF}" done < <("$KFWorkshop" "$(basename "$MutWsInfo")" 2>&1)
rm -rf "$PreparedWsDir" rm -rf "$PreparedWsDir"
rm -f "$MutWsInfo" rm -f "$MutWsInfo"
if is_true "$Success"; then
msg "${GRN}successfully uploaded to steam workshop${DEF}"
else
die "upload to steam workshop failed" 2
fi
} }
function run_test () function run_test ()