1
0

update project initialization

This commit is contained in:
GenZmeY 2022-09-02 11:52:07 +03:00
parent 3de5131f89
commit a8fa850186

135
builder
View File

@ -256,16 +256,25 @@ function restore_kfeditorconf ()
fi fi
} }
function print_list () # $1: List with spaces, $2: New separator
{
echo "${1// /$2}"
}
function init () function init ()
{ {
local PackageList="" local PackageList=""
local AviableMutators="" local AviableMutators=""
local AviableGamemodes="" local AviableGamemodes=""
local ConfigGamemodes="" local AviableMaps=""
local ProjectName="" local ProjectName=""
local GitUsername="" local GitUsername=""
local GitRemoteUrl="" local GitRemoteUrl=""
local PublicationTags="" local PublicationTags=""
local DefGamemode=""
local DefMap=""
local BaseList=""
local BaseListNext=""
if [[ -e "$MutBuilderConfig" ]]; then if [[ -e "$MutBuilderConfig" ]]; then
if is_true "$ArgForce"; then if is_true "$ArgForce"; then
@ -275,6 +284,16 @@ function init ()
msg "creating new $(basename "$MutBuilderConfig")" msg "creating new $(basename "$MutBuilderConfig")"
fi 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 while read -r Package
do do
if [[ -z "$PackageList" ]]; then if [[ -z "$PackageList" ]]; then
@ -284,44 +303,91 @@ function init ()
fi fi
done < <(find "$MutSource" -mindepth 2 -maxdepth 2 -type d -ipath '*/Classes' | sed -r 's|.+/([^/]+)/[^/]+|\1|' | sort) done < <(find "$MutSource" -mindepth 2 -maxdepth 2 -type d -ipath '*/Classes' | sed -r 's|.+/([^/]+)/[^/]+|\1|' | sort)
if [[ -z "$PackageList" ]]; then if [[ -n "$PackageList" ]]; then
die "No packages found! Check project filesystem, fix config and try again" msg "packages found: $(print_list "$PackageList" ", ")"
fi fi
msg "packages found: $PackageList" # DISCLAMER: BigO nightmare (*)
# Remove seniors with a weak psyche from the screen
for Package in $PackageList #
do # (*) 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 # find available mutators
while read -r MutClass BaseList='(KF)?Mutator'
BaseListNext=''
while [[ -n "$BaseList" ]]
do do
if [[ -z "$AviableMutators" ]]; then for Base in $BaseList
AviableMutators="$Package.$MutClass" do
else for Package in $PackageList
AviableMutators="$AviableMutators,$Package.$MutClass" do
fi while read -r Class
done < <(grep -rihPo '\s.+extends\s(KF)?Mutator' "$MutSource/$Package" | awk '{ print $1 }') 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 # find available gamemodes
while read -r GamemodeClass BaseList='KFGameInfo_'
BaseListNext=''
while [[ -n "$BaseList" ]]
do do
if [[ -z "$AviableGamemodes" ]]; then for Base in $BaseList
AviableGamemodes="$Package.$GamemodeClass" do
else for Package in $PackageList
AviableGamemodes="$AviableGamemodes,$Package.$GamemodeClass" do
fi while read -r Class
done < <(grep -rihPo '\s.+extends\sKFGameInfo_' "$MutSource/$Package" | awk '{ print $1 }') do
done 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 if [[ -n "$AviableMutators" ]]; then
msg "mutators found: $AviableMutators" msg "mutators found: $(print_list "$AviableMutators" ", ")"
fi fi
if [[ -z "$AviableGamemodes" ]]; then if [[ -z "$AviableGamemodes" ]]; then
ConfigGamemodes="KFGameContent.KFGameInfo_Survival" DefGamemode="KFGameContent.KFGameInfo_Survival"
else else
ConfigGamemodes="$AviableGamemodes" msg "custom gamemodes found: $(print_list "$AviableGamemodes" ", ")"
msg "custom gamemodes found: $AviableGamemodes" fi
if [[ -z "$AviableMaps" ]]; then
DefMap="KF-Nuked"
else
msg "maps found: $(print_list "$AviableMaps" ", ")"
fi fi
if is_true "$ArgForce" || ! [[ -e "$MutBuilderConfig" ]]; then if is_true "$ArgForce" || ! [[ -e "$MutBuilderConfig" ]]; then
@ -360,7 +426,7 @@ PackageUpload="$PackageList"
### Test parameters ### ### Test parameters ###
# Map: # Map:
Map="KF-Nuked" Map="$DefMap"
# Game: # Game:
# Survival: KFGameContent.KFGameInfo_Survival # Survival: KFGameContent.KFGameInfo_Survival
@ -368,7 +434,7 @@ Map="KF-Nuked"
# Endless: KFGameContent.KFGameInfo_Endless # Endless: KFGameContent.KFGameInfo_Endless
# Objective: KFGameContent.KFGameInfo_Objective # Objective: KFGameContent.KFGameInfo_Objective
# Versus: KFGameContent.KFGameInfo_VersusSurvival # Versus: KFGameContent.KFGameInfo_VersusSurvival
Game="$ConfigGamemodes" Game="$DefGamemode"
# Difficulty: # Difficulty:
# Normal: 0 # Normal: 0
@ -384,7 +450,7 @@ Difficulty="0"
GameLength="0" GameLength="0"
# Mutators # Mutators
Mutators="$AviableMutators" Mutators="$(print_list "$AviableMutators" ",")"
# Additional parameters # Additional parameters
Args="" Args=""
@ -403,15 +469,16 @@ EOF
if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then if is_true "$ArgForce" || ! [[ -e "$MutPubContentDescription" ]]; then
:> "$MutPubContentDescription" :> "$MutPubContentDescription"
echo "[h1]${ProjectName}[/h1]" >> "$MutPubContentDescription" if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]] || [[ -n "$AviableMaps" ]]; then
echo "" >> "$MutPubContentDescription"
if [[ -n "$AviableGamemodes" ]] || [[ -n "$AviableMutators" ]]; then
echo "[h1]Description[/h1]" >> "$MutPubContentDescription" echo "[h1]Description[/h1]" >> "$MutPubContentDescription"
if [[ -n "$AviableMaps" ]]; then
echo "[b]Maps:[/b][list][*]$(print_list "$AviableMaps" '[*]')[/list]" >> "$MutPubContentDescription"
fi
if [[ -n "$AviableGamemodes" ]]; then if [[ -n "$AviableGamemodes" ]]; then
echo "[b]Gamemode(s):[/b] $AviableGamemodes" >> "$MutPubContentDescription" echo "[b]Gamemodes:[/b][list][*]$(print_list "$AviableGamemodes" '[*]')[/list]" >> "$MutPubContentDescription"
fi fi
if [[ -n "$AviableMutators" ]]; then if [[ -n "$AviableMutators" ]]; then
echo "[b]Mutator(s):[/b] $AviableMutators" >> "$MutPubContentDescription" echo "[b]Mutators:[/b][list][*]$(print_list "$AviableMutators" '[*]')[/list]" >> "$MutPubContentDescription"
fi fi
echo "" >> "$MutPubContentDescription" echo "" >> "$MutPubContentDescription"
fi fi