From 55bdd154ba704740470b55fd5625320c7625eb3e Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Thu, 1 Sep 2022 12:25:37 +0300 Subject: [PATCH 1/7] make peelz brew a parameter in the config, refactor brew --- builder | 103 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/builder b/builder index a7cbc86..1d8d5fa 100644 --- a/builder +++ b/builder @@ -91,7 +91,6 @@ KFEditorConfBackup="$KFEditorConf.backup" ArgInit="false" ArgCompile="false" ArgBrew="false" -ArgBrewManual="false" ArgUpload="false" ArgTest="false" ArgVersion="false" @@ -204,7 +203,6 @@ ${BLD}Available options:${DEF} -i, --init generate $(basename "$MutBuilderConfig") and $(basename "$MutPubContent") -c, --compile compile 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 -f, --force overwrites existing files when used with --init @@ -216,8 +214,8 @@ ${BLD}Available options:${DEF} -h, --help show this help ${BLD}Short options can be combined, examples:${DEF} + -if recreate build.cfg and PublicationContent, replace old ones -cbu compile, brew, upload - -cbmt compile, brew_manual, run_test -cbhe compile and brew without closing kf2editor etc... EOF @@ -340,6 +338,16 @@ StripSource="True" PackageBuildOrder="$PackageList" +### Brew parameters ### + +# Packages you want to brew using @peelz's patched KFEditor. +# Useful for cases where regular brew doesn't put *.upk inside the package. +# Specify them with a space as a separator, +# The order doesn't matter + +PackagePeelzBrew="" + + ### Steam Workshop upload parameters ### # Mutators that will be uploaded to the workshop @@ -686,9 +694,9 @@ function publish_common () fi } -function brewed () +function brewed () # $1: Wait for packages { - for Package in $PackageUpload + for Package in $1 do if ! test -f "$KFPublishBrewedPC/$Package.u"; then return 1 @@ -705,12 +713,11 @@ function brew_cleanup () find "$MutSource/$Package" -type f -name '*.upk' -printf "%f\n" | xargs -I{} find "$KFPublishBrewedPC" -type f -name {} -delete fi done - - rm -f "$KFPublishBrewedPC"/*.tmp } function brew () { + local PackageBrew="" local PID="" msg "brewing" @@ -721,71 +728,66 @@ function brew () die "You must compile packages before brewing. Use --compile option for this." 2 fi + if [[ -z "$PackagePeelzBrew" ]]; then + PackageBrew="$PackageBuildOrder" + else + for Package in $PackageBuildOrder + do + if ! echo "$PackagePeelzBrew" | grep -Pq "(^|\s+)$Package(\s+|$)"; then + PackageBrew="$Package " + fi + done + fi + rm -rf "$KFPublish" mkdir -p "$KFPublishBrewedPC" if is_true "$ArgHoldEditor"; then - CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageUpload -useunpublished" - if ! brewed; then + CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageBrew -useunpublished" + if ! brewed "$PackageBrew"; then brew_cleanup die "brewing failed" fi - msg "${GRN}successfully brewed${DEF}" else - CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageUpload -useunpublished" & + CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditor") brewcontent -platform=PC $PackageBrew -useunpublished" & PID="$!" while ps -p "$PID" &> /dev/null do - if brewed; then + if brewed "$PackageBrew"; then kill "$PID" - msg "${GRN}successfully brewed${DEF}" break fi sleep 1 done - if ! brewed; then + if ! brewed "$PackageBrew"; then brew_cleanup die "brewing failed" fi fi - publish_common - brew_cleanup - - find "$KFPublish" -type d -empty -delete -} - -function brew_manual () -{ - msg "manual brewing" - - read_settings - - if ! compiled; then - die "You must compile packages before brewing. Use --compile option for this." 2 + if [[ -n "$PackagePeelzBrew" ]]; then + msg "peelz brewing" + + if ! [[ -x "$KFEditorPatcher" ]]; then + get_latest_kfeditor_patcher "$KFEditorPatcher" + fi + + msg "patching $(basename "$KFEditor")" + CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorPatcher")" + msg "${GRN}successfully patched${DEF}" + + for Package in $PackagePeelzBrew + do + merge_packages "$Package" + mv "$KFWin64/$Package.u" "$KFPublishBrewedPC" + find "$MutSource/$Package" -type f -name '*.upk' -printf "%f\n" | xargs -I{} find "$KFPublishBrewedPC" -type f -name {} -delete + done fi - rm -rf "$KFPublish" - - mkdir -p "$KFPublishBrewedPC" - - if ! [[ -x "$KFEditorPatcher" ]]; then - get_latest_kfeditor_patcher "$KFEditorPatcher" - fi - - msg "patching $(basename "$KFEditor")" - CMD //C "cd /D $(cygpath -w "$KFWin64") && $(basename "$KFEditorPatcher")" - msg "${GRN}successfully patched${DEF}" - - for Package in $PackageUpload - do - merge_packages "$Package" - mv "$KFWin64/$Package.u" "$KFPublishBrewedPC" - done - msg "${GRN}successfully brewed${DEF}" + rm -f "$KFPublishBrewedPC"/*.tmp publish_common find "$KFPublish" -type d -empty -delete @@ -820,7 +822,9 @@ function upload () die "You must compile packages before uploading. Use --compile option for this." 2 fi - if ! [[ -d "$KFPublish" ]]; then + if [[ -d "$KFPublish" ]]; then + brew_cleanup + else publish_unpublished fi @@ -874,7 +878,7 @@ function run_test () read_settings - if brewed; then + if brewed "$PackageBuildOrder"; then msg "run test (brewed)" else UseUnpublished="-useunpublished" @@ -894,7 +898,6 @@ function parse_combined_params () # $1: Combined short parameters do if [[ "$Position" -ge "$Length" ]]; then break; fi case "${Param:$Position:2}" in - bm ) ((Position+=2)); ArgBrewManual="true" ;; he ) ((Position+=2)); ArgHoldEditor="true" ;; nc ) ((Position+=2)); ArgNoColors="true" ;; esac @@ -926,7 +929,6 @@ function parse_params () # $@: Args -i | --init ) ArgInit="true" ;; -c | --compile ) ArgCompile="true" ;; -b | --brew ) ArgBrew="true" ;; - -bm | --brew-manual ) ArgBrewManual="true" ;; -u | --upload ) ArgUpload="true" ;; -t | --test ) ArgTest="true" ;; -d | --debug ) ArgDebug="true" ;; @@ -964,7 +966,6 @@ function main () if is_true "$ArgInit"; then init; fi if is_true "$ArgCompile"; then compile; fi if is_true "$ArgBrew"; then brew; fi - if is_true "$ArgBrewManual"; then brew_manual; fi if is_true "$ArgUpload"; then upload; fi if is_true "$ArgTest"; then run_test; fi From 1ad83de1acfe3afedd132a8f3f5f0d8321df2e7b Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Thu, 1 Sep 2022 18:48:41 +0300 Subject: [PATCH 2/7] BrewedPC additional content --- builder | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/builder b/builder index 1d8d5fa..618ed69 100644 --- a/builder +++ b/builder @@ -64,6 +64,7 @@ KFLogs="$KFDoc/KFGame/Logs" MutSource="$(readlink -e "$ScriptDir/..")" MutConfig="$MutSource/Config" MutLocalization="$MutSource/Localization" +MutBrewedPCAddon="$MutSource/BrewedPC" MutBuilderConfig="$MutSource/builder.cfg" MutPubContent="$MutSource/PublicationContent" MutPubContentDescription="$MutPubContent/description.txt" @@ -692,6 +693,11 @@ function publish_common () mkdir -p "$KFPublishConfig" cp -rf "$MutConfig"/* "$KFPublishConfig" fi + + if [[ -d "$MutBrewedPCAddon" ]]; then + mkdir -p "$KFPublishBrewedPC" + cp -rf "$MutBrewedPCAddon"/* "$KFPublishBrewedPC" + fi } function brewed () # $1: Wait for packages @@ -788,7 +794,6 @@ function brew () msg "${GRN}successfully brewed${DEF}" rm -f "$KFPublishBrewedPC"/*.tmp - publish_common find "$KFPublish" -type d -empty -delete } @@ -805,8 +810,6 @@ function publish_unpublished () find "$MutSource/$Package" -type f -name '*.upk' -exec cp -f {} "$KFPublishPackages" \; done - publish_common - find "$KFPublish" -type d -empty -delete } @@ -818,16 +821,18 @@ function upload () read_settings - if ! compiled; then + if ! compiled && ! test -d "$MutBrewedPCAddon"; then die "You must compile packages before uploading. Use --compile option for this." 2 fi if [[ -d "$KFPublish" ]]; then brew_cleanup - else + elif [[ -d "$KFUnpublish" ]]; then publish_unpublished fi + publish_common + Preview="${MutPubContentPreview}.$(preview_extension)" if ! [[ -e "$Preview" ]]; then @@ -838,6 +843,9 @@ function upload () find "$KFPublish" -type d -empty -delete + # it's a bad idea to use the $KFPublish folder for upload + # because in that case some files won't get uploaded to the workshop for some reason + # so create a temporary folder to get around this PreparedWsDir="$(mktemp -d -u -p "$KFDoc")" cat > "$MutWsInfo" < Date: Thu, 1 Sep 2022 15:49:02 +0000 Subject: [PATCH 3/7] Update USAGE.md to version v1.5.0-7-g1ad83de --- USAGE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/USAGE.md b/USAGE.md index 2d48538..d15b691 100644 --- a/USAGE.md +++ b/USAGE.md @@ -11,7 +11,6 @@ Available options: -i, --init generate builder.cfg and PublicationContent -c, --compile compile 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 -f, --force overwrites existing files when used with --init @@ -23,8 +22,8 @@ Available options: -h, --help show this help Short options can be combined, examples: + -if recreate build.cfg and PublicationContent, replace old ones -cbu compile, brew, upload - -cbmt compile, brew_manual, run_test -cbhe compile and brew without closing kf2editor etc... ``` From e21e73936662e0af8650a46e36ae330e8e6589c6 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Thu, 1 Sep 2022 20:40:14 +0300 Subject: [PATCH 4/7] update README.md --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f090b1b..ad32720 100644 --- a/README.md +++ b/README.md @@ -61,14 +61,6 @@ If you have *.upk or localization files, they must be in a specific location. Change the filesystem of the project to such a form that everything works correctly: ``` -/Localization - /INT - *.int -/PublicationContent - preview.png - description.txt - tags.txt - title.txt /SomePackageName1 *.upk /Classes @@ -79,8 +71,18 @@ Change the filesystem of the project to such a form that everything works correc /Classes *.uc *.upkg +/PublicationContent + preview.png + description.txt + tags.txt + title.txt +/Localization + /INT + *.int /Config *.ini +/BrewedPC + *.* /tools builder builder.cfg From 3de5131f891e009a6bd9a76dbee8354d70d33459 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Fri, 2 Sep 2022 11:51:25 +0300 Subject: [PATCH 5/7] Update README.md --- README.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ad32720..7c8a4ae 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ If your project contains several mutators, *.upk files, external dependencies, o When you run compilation for the first time or do `./tools/builder --init` `builder.cfg` appears in your project folder. Edit it to set build/test/upload options. The config contains the necessary comments inside. -Edit the files in the PublicationContent folder - they are responsible for the description in the Steam Workshop. +Edit the files in the `PublicationContent` folder - they are responsible for the description in the Steam Workshop. ## Project filesystem If you have *.upk or localization files, they must be in a specific location. @@ -88,10 +88,27 @@ Change the filesystem of the project to such a form that everything works correc builder.cfg ``` +**Note:** Use the `BrewedPC` folder for additional content such as sound files for your weapons or other stuff. This will be copied to the final BrewedPC before being uploaded to the workshop. +By the way, this allows you to use a script to upload maps (although this was not its original purpose). Just put the map(s) in `BrewedPC` (don't forget to edit the `PublicationContent`) and run `./tools/builder -u`. + ## Examples (Projects that use KF2-BuildTools) -[LightTIM](https://github.com/GenZmeY/KF2-LightTIM) - simplest case (one mutator) -[ServerExt](https://github.com/GenZmeY/KF2-Server-Extension) - Two mutators are compiled, there are *.upk files and localization -[UnofficialMod](https://github.com/GenZmeY/UnofficialMod) - Three mutators are compiled (one of them is a dependency), two mutators are uploaded to the steam workshop +**Simplest case (one mutator):** +- [AdminAutoLogin](https://github.com/GenZmeY/KF2-AdminAutoLogin) +- [StartWave](https://github.com/GenZmeY/KF2-StartWave) +- [TAWOD](https://github.com/GenZmeY/KF2-TAWOD) +- [ZedSpawner](https://github.com/GenZmeY/KF2-ZedSpawner) + +**Mutator + Localization:** +- [ControlledVoteCollector](https://github.com/GenZmeY/KF2-ControlledVoteCollector) +- [CustomTraderInventory](https://github.com/GenZmeY/KF2-CustomTraderInventory) +- [YetAnotherScoreboard](https://github.com/GenZmeY/KF2-YetAnotherScoreboard) + +**Two mutators are compiled, there are upk and localization:** +- [ServerExt](https://github.com/GenZmeY/KF2-Server-Extension) + +**Three mutators are compiled (one of them is a dependency),** +**two mutators are uploaded to the steam workshop:** +- [UnofficialMod](https://github.com/GenZmeY/UnofficialMod) # Other [TODO List](TODO.md) From a8fa850186118ffafc88cc7ac9018a57701fa577 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Fri, 2 Sep 2022 11:52:07 +0300 Subject: [PATCH 6/7] update project initialization --- builder | 135 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 34 deletions(-) diff --git a/builder b/builder index 618ed69..27ddb97 100644 --- a/builder +++ b/builder @@ -256,16 +256,25 @@ function restore_kfeditorconf () fi } +function print_list () # $1: List with spaces, $2: New separator +{ + echo "${1// /$2}" +} + function init () { local PackageList="" local AviableMutators="" local AviableGamemodes="" - local ConfigGamemodes="" + local AviableMaps="" local ProjectName="" local GitUsername="" local GitRemoteUrl="" local PublicationTags="" + local DefGamemode="" + local DefMap="" + local BaseList="" + local BaseListNext="" if [[ -e "$MutBuilderConfig" ]]; then if is_true "$ArgForce"; then @@ -274,6 +283,16 @@ function init () else msg "creating new $(basename "$MutBuilderConfig")" fi + + while read -r Map + do + if [[ -z "$AviableMaps" ]]; then + DefMap="$Map" + AviableMaps="$Map" + else + AviableMaps="$AviableMaps $Map" + fi + done < <(find "$MutBrewedPCAddon" -type f -iname '*.kfm' -printf "%f\n" | sort) while read -r Package do @@ -284,44 +303,91 @@ function init () fi done < <(find "$MutSource" -mindepth 2 -maxdepth 2 -type d -ipath '*/Classes' | sed -r 's|.+/([^/]+)/[^/]+|\1|' | sort) - if [[ -z "$PackageList" ]]; then - die "No packages found! Check project filesystem, fix config and try again" + if [[ -n "$PackageList" ]]; then + msg "packages found: $(print_list "$PackageList" ", ")" fi - msg "packages found: $PackageList" - - for Package in $PackageList - do + # DISCLAMER: BigO nightmare (*) + # Remove seniors with a weak psyche from the screen + # + # (*) As planned though: + # Initialized once and quickly even on large projects, + # There is no point in optimizing this + if [[ -n "$PackageList" ]]; then # find available mutators - while read -r MutClass + BaseList='(KF)?Mutator' + BaseListNext='' + while [[ -n "$BaseList" ]] do - if [[ -z "$AviableMutators" ]]; then - AviableMutators="$Package.$MutClass" - else - AviableMutators="$AviableMutators,$Package.$MutClass" - fi - done < <(grep -rihPo '\s.+extends\s(KF)?Mutator' "$MutSource/$Package" | awk '{ print $1 }') + for Base in $BaseList + do + for Package in $PackageList + do + while read -r Class + do + if [[ -z "$AviableMutators" ]]; then + AviableMutators="$Package.$Class" + else + AviableMutators="$AviableMutators $Package.$Class" + fi + if [[ -z "$BaseListNext" ]]; then + BaseListNext="$Class" + else + BaseListNext="$BaseListNext $Class" + fi + done < <(grep -rihPo "\s.+extends\s${Base}" "${MutSource}/${Package}" | awk '{ print $1 }') + done + done + BaseList="$BaseListNext" + BaseListNext="" + done # find available gamemodes - while read -r GamemodeClass + BaseList='KFGameInfo_' + BaseListNext='' + while [[ -n "$BaseList" ]] do - if [[ -z "$AviableGamemodes" ]]; then - AviableGamemodes="$Package.$GamemodeClass" - else - AviableGamemodes="$AviableGamemodes,$Package.$GamemodeClass" - fi - done < <(grep -rihPo '\s.+extends\sKFGameInfo_' "$MutSource/$Package" | awk '{ print $1 }') - done + for Base in $BaseList + do + for Package in $PackageList + do + while read -r Class + do + if [[ -z "$AviableGamemodes" ]]; then + AviableGamemodes="$Package.$Class" + if [[ -z "$DefGamemode" ]]; then + DefGamemode="$Package.$Class" + fi + else + AviableGamemodes="$AviableGamemodes $Package.$Class" + fi + if [[ -z "$BaseListNext" ]]; then + BaseListNext="$Class" + else + BaseListNext="$BaseListNext $Class" + fi + done < <(grep -rihPo "\s.+extends\s${Base}" "${MutSource}/${Package}" | awk '{ print $1 }') + done + done + BaseList="$BaseListNext" + BaseListNext="" + done + fi if [[ -n "$AviableMutators" ]]; then - msg "mutators found: $AviableMutators" + msg "mutators found: $(print_list "$AviableMutators" ", ")" fi if [[ -z "$AviableGamemodes" ]]; then - ConfigGamemodes="KFGameContent.KFGameInfo_Survival" + DefGamemode="KFGameContent.KFGameInfo_Survival" else - ConfigGamemodes="$AviableGamemodes" - msg "custom gamemodes found: $AviableGamemodes" + msg "custom gamemodes found: $(print_list "$AviableGamemodes" ", ")" + fi + + if [[ -z "$AviableMaps" ]]; then + DefMap="KF-Nuked" + else + msg "maps found: $(print_list "$AviableMaps" ", ")" fi if is_true "$ArgForce" || ! [[ -e "$MutBuilderConfig" ]]; then @@ -360,7 +426,7 @@ PackageUpload="$PackageList" ### Test parameters ### # Map: -Map="KF-Nuked" +Map="$DefMap" # Game: # Survival: KFGameContent.KFGameInfo_Survival @@ -368,7 +434,7 @@ Map="KF-Nuked" # Endless: KFGameContent.KFGameInfo_Endless # Objective: KFGameContent.KFGameInfo_Objective # Versus: KFGameContent.KFGameInfo_VersusSurvival -Game="$ConfigGamemodes" +Game="$DefGamemode" # Difficulty: # Normal: 0 @@ -384,7 +450,7 @@ Difficulty="0" GameLength="0" # Mutators -Mutators="$AviableMutators" +Mutators="$(print_list "$AviableMutators" ",")" # Additional parameters Args="" @@ -403,15 +469,16 @@ EOF if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then :> "$MutPubContentDescription" - echo "[h1]${ProjectName}[/h1]" >> "$MutPubContentDescription" - echo "" >> "$MutPubContentDescription" - if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]]; then + if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]] || [[ -n "$AviableMaps" ]]; then echo "[h1]Description[/h1]" >> "$MutPubContentDescription" + if [[ -n "$AviableMaps" ]]; then + echo "[b]Maps:[/b][list][*]$(print_list "$AviableMaps" '[*]')[/list]" >> "$MutPubContentDescription" + fi if [[ -n "$AviableGamemodes" ]]; then - echo "[b]Gamemode(s):[/b] $AviableGamemodes" >> "$MutPubContentDescription" + echo "[b]Gamemodes:[/b][list][*]$(print_list "$AviableGamemodes" '[*]')[/list]" >> "$MutPubContentDescription" fi if [[ -n "$AviableMutators" ]]; then - echo "[b]Mutator(s):[/b] $AviableMutators" >> "$MutPubContentDescription" + echo "[b]Mutators:[/b][list][*]$(print_list "$AviableMutators" '[*]')[/list]" >> "$MutPubContentDescription" fi echo "" >> "$MutPubContentDescription" fi From c3872fb1e0a5e0018e2abf06b1db3c160bd6327d Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Fri, 2 Sep 2022 12:30:53 +0300 Subject: [PATCH 7/7] Update TODO.md and README.md --- README.md | 9 ++++++++- TODO.md | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c8a4ae..143ad28 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,14 @@ - Easily switch between different projects. # Requirements -- [git-bash](https://git-scm.com/download/win) +- [Killing Floor 2](https://store.steampowered.com/app/232090/Killing_Floor_2/); +- Killing Floor 2 - SDK; +- [git-bash](https://git-scm.com/download/win). + +# Limits +You can keep mod sources anywhere, but `Killing Floor 2` and `Killing Floor 2 - SDK` must be installed on the system drive (C:\ in most cases). + +(I plan to fix this limitation in the future) # Add to your project Make sure that the location of folders and files in your project as follows (Correct it if it's not): diff --git a/TODO.md b/TODO.md index 10e48c5..8336a42 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,4 @@ # TODO: -- [ ] *.upk (or *.kfm) with it's own filesystem (like in weapon packs) - [ ] add kf2 support in another steam library (`Steam\steamapps\libraryfolders.vdf` may help) -- [x] close the KFEditor window only after it stops writing to Launch.log to be able to show warnings - [ ] hooks (precompile, postcompile, prebrew, etc...) - [ ] improve error parser (class vs name mismatch, etc...) -- [ ] manual brew config setting