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

74
builder
View File

@ -68,7 +68,7 @@ MutBuilderConfig="$MutSource/builder.cfg"
MutPubContent="$MutSource/PublicationContent"
MutPubContentDescription="$MutPubContent/description.txt"
MutPubContentTitle="$MutPubContent/title.txt"
MutPubContentPreview="$MutPubContent/preview.png"
MutPubContentPreview="$MutPubContent/preview"
MutPubContentTags="$MutPubContent/tags.txt"
# Steam workshop upload filesystem
@ -110,6 +110,9 @@ BLU=''
DEF=''
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
{
echo "$1" | grep -Piq '^true$'
@ -183,6 +186,11 @@ function die () # $1: String, $2: Exit code
exit "${2-3}"
}
function warn () # $1: String
{
msg "${YLW}${1-}"
}
function usage ()
{
local HelpMessage=""
@ -413,9 +421,13 @@ EOF
msg "${GRN}$(basename "$MutPubContentDescription") created${DEF}"
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentPreview" ]]; then
cp -f "$DummyPreview" "$MutPubContentPreview"
msg "${GRN}$(basename "$MutPubContentPreview") created${DEF}"
if is_true "$ArgForce" || [[ "$(preview_extension)" == "None" ]]; then
if [[ -e "$DummyPreview" ]]; then
cp -f "$DummyPreview" "${MutPubContentPreview}.png"
else
printf '%b' "$DummyPreviewRaw" > "${MutPubContentPreview}.png"
fi
msg "${GRN}$(basename "${MutPubContentPreview}.png") created${DEF}"
fi
if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then
@ -435,6 +447,19 @@ EOF
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 ()
{
if ! [[ -f "$MutBuilderConfig" ]]; then init; fi
@ -516,9 +541,9 @@ function parse_log () # $1: Logfile
FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Error" | sed -r 's|^.+Error: ((.+)\(([0-9]+)\) : )?Error,(.+)$|\3|')"
msg "${RED}[$I] $FileCompact($Line): $Message"
err "[$I] $FileCompact($Line): $Message"
else
msg "${RED}[$I] $Message"
err "[$I] $Message"
fi
((I+=1))
done < <(grep -P ' Error:(.+:)? Error, ' "$1")
@ -535,9 +560,9 @@ function parse_log () # $1: Logfile
FileUnix="$(cygpath -u "$File")"
FileCompact="$(echo "$FileUnix" | sed -r "s|^$KFDev(.+)$|\1|")"
Line="$(echo "$Warning" | sed -r 's|^.+Warning: ((.+)\(([0-9]+)\) : )?Warning,(.+)$|\3|')"
msg "${YLW}[$I] $FileCompact($Line): $Message"
warn "[$I] $FileCompact($Line): $Message"
else
msg "${YLW}[$I] $Message"
warn "[$I] $Message"
fi
((I+=1))
done < <(grep -P ' Warning:(.+:)? Warning, ' "$1")
@ -761,7 +786,7 @@ function brew_manual ()
function publish_unpublished ()
{
msg "${YLW}warn: uploading without brewing${DEF}"
warn "uploading without brewing${DEF}"
mkdir -p "$KFPublishBrewedPC" "$KFPublishScript" "$KFPublishPackages"
@ -779,6 +804,8 @@ function publish_unpublished ()
function upload ()
{
local PreparedWsDir=""
local Preview=""
local Success="False"
read_settings
@ -790,6 +817,14 @@ function upload ()
publish_unpublished
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
PreparedWsDir="$(mktemp -d -u -p "$KFDoc")"
@ -797,7 +832,7 @@ function upload ()
cat > "$MutWsInfo" <<EOF
\$Description "$(cat "$MutPubContentDescription")"
\$Title "$(cat "$MutPubContentTitle")"
\$PreviewFile "$(cygpath -w "$MutPubContentPreview")"
\$PreviewFile "$(cygpath -w "$Preview")"
\$Tags "$(cat "$MutPubContentTags")"
\$MicroTxItem "false"
\$PackageDirectory "$(cygpath -w "$PreparedWsDir")"
@ -806,15 +841,24 @@ EOF
cp -rf "$KFPublish" "$PreparedWsDir"
msg "upload to steam workshop"
if is_true "$ArgQuiet"; then
CMD //C "$(cygpath -w "$KFWorkshop") $(basename "$MutWsInfo")" &>/dev/null
else
CMD //C "$(cygpath -w "$KFWorkshop") $(basename "$MutWsInfo")"
while read -r Output
do
if echo "$Output" | grep -qiF 'Successfully uploaded workshop file to Steam'; then
Success="True"
break
elif echo "$Output" | grep -qiF 'error'; then
err "UploadTool: $Output"
fi
msg "${GRN}successfully uploaded to steam workshop${DEF}"
done < <("$KFWorkshop" "$(basename "$MutWsInfo")" 2>&1)
rm -rf "$PreparedWsDir"
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 ()