diff --git a/.shellcheck/build.cfg b/.shellcheck/build.cfg deleted file mode 100644 index b484a76..0000000 --- a/.shellcheck/build.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# Build parameters - -# If True - compresses the mutator when compiling -# Scripts will be stored in binary form -# (reduces the size of the output file) -StripSource="True" - -# Mutators to be compiled -# Specify them with a space as a separator, -# Mutators will be compiled in the specified order -PackageBuildOrder="SomePackageName SomePackageNameMut" - -# Mutators that will be uploaded to the workshop -# Specify them with a space as a separator, -# The order doesn't matter -PackageUpload="SomePackageName SomePackageNameMut" diff --git a/.shellcheck/builder.cfg b/.shellcheck/builder.cfg new file mode 100644 index 0000000..ec62fd3 --- /dev/null +++ b/.shellcheck/builder.cfg @@ -0,0 +1,52 @@ +### Build parameters ### + +# If True - compresses the mutator when compiling +# Scripts will be stored in binary form +# (reduces the size of the output file) +StripSource="True" + +# Mutators to be compiled +# Specify them with a space as a separator, +# Mutators will be compiled in the specified order +PackageBuildOrder="SomePackageName SomePackageNameMut" + + +### Steam Workshop upload parameters ### + +# Mutators that will be uploaded to the workshop +# Specify them with a space as a separator, +# The order doesn't matter +PackageUpload="SomePackageName SomePackageNameMut" + + +### Test parameters ### + +# Map: +Map="KF-Nuked" + +# Game: +# Survival: KFGameContent.KFGameInfo_Survival +# WeeklyOutbreak: KFGameContent.KFGameInfo_WeeklySurvival +# Endless: KFGameContent.KFGameInfo_Endless +# Objective: KFGameContent.KFGameInfo_Objective +# Versus: KFGameContent.KFGameInfo_VersusSurvival +Game="SomePackageName.SomePackageName_GameInfo" + +# Difficulty: +# Normal: 0 +# Hard: 1 +# Suicide: 2 +# Hell: 3 +Difficulty="0" + +# GameLength: +# 4 waves: 0 +# 7 waves: 1 +# 10 waves: 2 +GameLength="0" + +# Mutators +Mutators="SomePackageName.SomePackageNameMut" + +# Additional parameters +Args="" diff --git a/.shellcheck/test.cfg b/.shellcheck/test.cfg deleted file mode 100644 index dc9a98f..0000000 --- a/.shellcheck/test.cfg +++ /dev/null @@ -1,31 +0,0 @@ -# Test parameters - -# Map: -Map="KF-Nuked" - -# Game: -# Survival: KFGameContent.KFGameInfo_Survival -# WeeklyOutbreak: KFGameContent.KFGameInfo_WeeklySurvival -# Endless: KFGameContent.KFGameInfo_Endless -# Objective: KFGameContent.KFGameInfo_Objective -# Versus: KFGameContent.KFGameInfo_VersusSurvival -Game="KFGameContent.KFGameInfo_Survival" - -# Difficulty: -# Normal: 0 -# Hard: 1 -# Suicide: 2 -# Hell: 3 -Difficulty="0" - -# GameLength: -# 4 waves: 0 -# 7 waves: 1 -# 10 waves: 2 -GameLength="0" - -# Mutators -Mutators="SomePackageName.SomePackageNameMut" - -# Additional parameters -Args="" diff --git a/builder b/builder index 307ae54..4d7f144 100644 --- a/builder +++ b/builder @@ -43,6 +43,7 @@ ScriptDir=$(dirname "$ScriptFullname") SteamPath=$(reg_readkey "HKCU\Software\Valve\Steam" "SteamPath") DocumentsPath=$(reg_readkey "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Personal") ThirdPartyBin="$ScriptDir/3rd-party-bin" +DummyPreview="$ScriptDir/dummy_preview.png" # Usefull KF2 executables / Paths / Configs KFDoc="$DocumentsPath/My Games/KillingFloor2" @@ -59,11 +60,14 @@ KFEditorConf="$KFDoc/KFGame/Config/KFEditor.ini" # Source filesystem MutSource="$ScriptDir/.." -MutPubContent="$MutSource/PublicationContent" MutConfig="$MutSource/Config" MutLocalization="$MutSource/Localization" -MutBuildConfig="$MutSource/build.cfg" -MutTestConfig="$MutSource/test.cfg" +MutBuilderConfig="$MutSource/builder.cfg" +MutPubContent="$MutSource/PublicationContent" +MutPubContentDescription="$MutPubContent/description.txt" +MutPubContentTitle="$MutPubContent/title.txt" +MutPubContentPreview="$MutPubContent/preview.png" +MutPubContentTags="$MutPubContent/tags.txt" # Steam workshop upload filesystem KFUnpublishBrewedPC="$KFUnpublish/BrewedPC" @@ -82,8 +86,7 @@ MutWsInfo="$KFDoc/wsinfo.txt" KFEditorConfBackup="$KFEditorConf.backup" # Args -ArgInitBuild="false" -ArgInitTest="false" +ArgInit="false" ArgCompile="false" ArgBrew="false" ArgBrewManual="false" @@ -95,6 +98,7 @@ ArgDebug="false" ArgQuiet="false" ArgWarnings="false" ArgNoColors="false" +ArgForce="false" # Colors RED='' @@ -132,6 +136,15 @@ function get_latest_kfeditor_patcher () # $1: file to save get_latest "notpeelz/kfeditor-patcher" "kfeditor_patcher.exe" "$1" } +function repo_url () # $1: remote.origin.url +{ + if echo "$1" | grep -qoP '^https?://'; then + echo "$1" | sed -r 's|\.git||' + else + echo "$1" | sed -r 's|^.+:(.+)\.git$|https://github.com/\1|' + fi +} + function setup_colors () { if [[ -t 2 ]] && ! is_true "$ArgNoColors" && [[ "${TERM-}" != "dumb" ]]; then @@ -178,14 +191,13 @@ ${BLD}Usage:${DEF} $0 OPTIONS Build, pack, test and upload your kf2 packages to the Steam Workshop. ${BLD}Available options:${DEF} - -ib, --init-build generate $(basename "$MutBuildConfig") with build parameters - -it, --init-test generate $(basename "$MutTestConfig") with test parameters - -i, --init the same as "./$ScriptName --init-build; ./$ScriptName --init-test" + -i, --init generate $(basename "$MutBuilderConfig") and $(basename "$MutPubContent") -c, --compile build package(s) -b, --brew compress *.upk and place inside *.u -bm, --brew-manual the same (almost) as above, but with patched kfeditor by @notpeelz -u, --upload upload package(s) to the Steam Workshop - -t, --test run local single player test with $(basename "$MutTestConfig") parameters + -t, --test run local single player test + -f, --force overwrites existing files when used with --init -q, --quiet run without output -w, --warnings do not close kf2editor automatically (to be able to read warnings) -nc, --no-colors do not use color output @@ -228,14 +240,25 @@ function restore_kfeditorconf () fi } -function init_build () +function init () { local PackageList="" + local AviableMutators="" + local AviableGamemodes="" + local ConfigGamemodes="" + local ProjectName="" + local GitUsername="" + local GitRemoteUrl="" + local PublicationTags="" - msg "creating new build config" - - :> "$MutBuildConfig" - + if [[ -e "$MutBuilderConfig" ]]; then + if is_true "$ArgForce"; then + msg "rewriting $(basename "$MutBuilderConfig")" + fi + else + msg "creating new $(basename "$MutBuilderConfig")" + fi + while read -r Package do if [[ -z "$PackageList" ]]; then @@ -247,8 +270,43 @@ function init_build () msg "packages found: $PackageList" - cat > "$MutBuildConfig" < "$MutBuilderConfig" < "$MutPubContentTitle" + msg "${GRN}$(basename "$MutPubContentTitle") created${DEF}" + fi + + if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then + :> "$MutPubContentDescription" + echo "[h1]${ProjectName}[/h1]" >> "$MutPubContentDescription" + echo "" >> "$MutPubContentDescription" + if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]]; then + echo "[h1]Description[/h1]" >> "$MutPubContentDescription" + if [[ -n "$AviableGamemodes" ]]; then + echo "[b]Gamemode(s):[/b] $AviableGamemodes" >> "$MutPubContentDescription" + fi + if [[ -n "$AviableMutators" ]]; then + echo "[b]Mutator(s):[/b] $AviableMutators" >> "$MutPubContentDescription" + fi + echo "" >> "$MutPubContentDescription" + fi + + GitRemoteUrl=$(repo_url "$(git config --get remote.origin.url)") + if [[ -n "$GitRemoteUrl" ]]; then + { + echo "[h1]Sources[/h1]" + echo "[url=${GitRemoteUrl}]${GitRemoteUrl}[/url]" + echo "" + } >> "$MutPubContentDescription" + fi + + GitUsername=$(git config --get user.name) + if [[ -n "$GitUsername" ]]; then + { + echo "[h1]Author[/h1]" + echo "[url=https://github.com/${GitUsername}]${GitUsername}[/url]" + echo "" + } >> "$MutPubContentDescription" + fi + + msg "${GRN}$(basename "$MutPubContentDescription") created${DEF}" + fi + + if is_true "$ArgForce" || ! [[ -e "$MutPubContentPreview" ]]; then + cp -f "$DummyPreview" "$MutPubContentPreview" + msg "${GRN}$(basename "$MutPubContentPreview") created${DEF}" + fi + + if is_true "$ArgForce" || ! [[ -e "$MutPubContentTags" ]]; then + :> "$MutPubContentTags" + if [[ -n "$AviableGamemodes" ]]; then + PublicationTags="Gamemodes" + fi + if [[ -n "$AviableMutators" ]]; then + if [[ -n "$PublicationTags" ]]; then + PublicationTags="$PublicationTags,Mutators" + else + PublicationTags="Mutators" + fi + echo "$PublicationTags" >> "$MutPubContentTags" + fi + msg "${GRN}$(basename "$MutPubContentTags") created${DEF}" fi } -function read_test_settings () +function read_settings () { - if ! [[ -f "$MutTestConfig" ]]; then init_test; fi + if ! [[ -f "$MutBuilderConfig" ]]; then init; fi - if bash -n "$MutTestConfig"; then - # shellcheck source=./.shellcheck/test.cfg - source "$MutTestConfig" + if bash -n "$MutBuilderConfig"; then + # shellcheck source=./.shellcheck/builder.cfg + source "$MutBuilderConfig" else - die "$MutTestConfig broken! Check this file before continue or create new one using --init-test option" 2 - return 1 + die "$MutBuilderConfig broken! Check this file before continue or create new one using --force --init" 2 fi } @@ -359,7 +506,7 @@ function compile () local StripSourceArg="" local PID="" - read_build_settings + read_settings if ! command -v multini &> /dev/null; then get_latest_multini "$ThirdPartyBin/multini.exe" @@ -464,7 +611,7 @@ function brew () msg "brewing" - read_build_settings + read_settings if ! compiled ; then die "You must compile packages before brewing. Use --compile option for this." 2 @@ -505,7 +652,7 @@ function brew_manual () { msg "manual brewing" - read_build_settings + read_settings if ! compiled ; then die "You must compile packages before brewing. Use --compile option for this." 2 @@ -557,7 +704,7 @@ function upload () { local PreparedWsDir="" - read_build_settings + read_settings if ! compiled ; then die "You must compile packages before uploading. Use --compile option for this." 2 @@ -572,10 +719,10 @@ function upload () PreparedWsDir=$(mktemp -d -u -p "$KFDoc") cat > "$MutWsInfo" < "$MutTestConfig" <