Skip to content

Commit 9de0c97

Browse files
committed
feat: new search filters and server platform info
1 parent 55d6991 commit 9de0c97

File tree

3 files changed

+66
-19
lines changed

3 files changed

+66
-19
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@ All notable changes to this project will be documented in this file.
55

66
## [Unreleased]
77

8+
## [0.1.1](https://github.com/WoozyMasta/dayz-ctl/releases/tag/0.1.1) - 2024-03-27
9+
810
### Added
911

1012
* Menu option for update game and all installed mods
13+
* Additional server browser searches:
14+
* Filter by Top of Maps ...
15+
* Filter by Map Name ...
16+
* Filter by Top of Mods ...
17+
* Filter by Mod ID ...
18+
* Filter by Mod Name ...
19+
* Linux Servers
20+
* Windows Servers
21+
* The server detailed description field displays information on which
22+
platform it runs on: Linux or Windows.
1123

1224
### Changed
1325

1426
* Fix steamcmd installation
1527
* Menu choose options now with more dynamic height
28+
* Minor ShellCheck issues
1629

1730
## [0.1.0](https://github.com/WoozyMasta/dayz-ctl/releases/tag/0.1.0) - 2022-10-11
1831

dayz-ctl

+52-18
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,15 @@ applyServerFiltres() {
330330
'Oficial Server' 'Moded' "Mods < $DAYZ_FILTER_MOD_LIMIT ..."
331331
'Without Password' 'First Person' 'Day Time' 'With BattlEye'
332332
'With Players' "Players > $DAYZ_FILTER_PLAYERS_LIMIT% ..." 'Not Full'
333-
'Filter by Map ...'
334333
# Second page
335334
'Not Oficial Server' 'Not Moded' "Mods > $DAYZ_FILTER_MOD_LIMIT ..."
336335
'With Password' 'Third Person' 'Night Time' 'Without BattlEye'
337336
'Without Players' "Players < $DAYZ_FILTER_PLAYERS_LIMIT% ..." 'Full'
337+
# Third page
338338
"Player slots ≥ $DAYZ_FILTER_PLAYERS_SLOTS ..."
339+
'Filter by Top of Maps ...' 'Filter by Map Name ...'
340+
'Filter by Top of Mods ...' 'Filter by Mod ID ...' 'Filter by Mod Name ...'
341+
'Linux Servers' 'Windows Servers'
339342
) filters=()
340343

341344
# '✅ Oficial Server' '🛠️ Moded' "⬆️ Mods > $DAYZ_FILTER_MOD_LIMIT"
@@ -345,10 +348,11 @@ applyServerFiltres() {
345348
# '❌ Not Oficial Server' '⚙️ Not Moded' "⬇️ Mods < $DAYZ_FILTER_MOD_LIMIT"
346349
# '🔒 With Password' '👥 Third Person' '🌙 Night Time' '⚠️ Without BattlEye'
347350
# '💤 Without Players' "📉 Players < $DAYZ_FILTER_PLAYERS_LIMIT%" '🚫 Full'
351+
# '🐧 Linux Servers' '🪟 Windows Servers'
348352

349353
while read -u 3 -r filter; do
350354
case $filter in
351-
'Filter by Map'*)
355+
'Filter by Top of Maps'*)
352356
map=$(gum choose --height="$(($(tput lines)-8))" < <(
353357
jq -er '
354358
.result | map(.map) |
@@ -357,6 +361,15 @@ applyServerFiltres() {
357361
' "$DAYZ_SERVER_DB"
358362
))
359363
filters+=(".value.map==\"$map\"");;
364+
'Filter by Top of Mods'*)
365+
mod_top=$(gum choose --height="$(($(tput lines)-8))" < <(
366+
jq -er '
367+
.result | map(.mods[].name) |
368+
reduce .[] as $i ({};setpath([$i]; getpath([$i]) + 1)) |
369+
to_entries | sort_by(.value) | reverse[] | .key
370+
' "$DAYZ_SERVER_DB"
371+
))
372+
filters+=(".value.mods[].name==\"$mod_top\"");;
360373
'Oficial Server') filters+=('.value.shard=="public"');;
361374
'Not Oficial Server') filters+=('.value.shard!="public"');;
362375
'Moded') filters+=('.value.mods | length > 0');;
@@ -371,6 +384,8 @@ applyServerFiltres() {
371384
'Full') filters+=('.value.players >= .value.maxPlayers');;
372385
'With BattlEye') filters+=('.value.battlEye');;
373386
'Without BattlEye') filters+=('.value.battlEye==false');;
387+
'Linux Servers') filters+=('.value.environment=="l"');;
388+
'Windows Servers') filters+=('.value.environment!="l"');;
374389
'Day Time') filters+=(
375390
'def d:(.value.time | split(":")[0] | tonumber); d >= 6 and d <= 18'
376391
);;
@@ -411,18 +426,39 @@ applyServerFiltres() {
411426
--char-limit 3 --value "$DAYZ_FILTER_PLAYERS_SLOTS"
412427
)"
413428
filters+=(".value.maxPlayers >= $count");;
429+
'Filter by Map Name'*)
430+
request_map="$(
431+
gum input --prompt 'Part or exact map name: ' \
432+
--char-limit 256 --value 'Utes'
433+
)"
434+
filters+=(".value.map | test(\"${request_map,,}\"; \"i\")");;
435+
'Filter by Mod ID'*)
436+
request_mod="$(
437+
gum input --prompt 'Part or exact ID for a mod from the workshop: ' \
438+
--char-limit 10 --value '3098891860'
439+
)"
440+
filters+=(".value.mods[].steamWorkshopId | contains($request_mod)");;
441+
'Filter by Mod Name'*)
442+
request_mod="$(
443+
gum input --prompt 'Part or exact Name for a mod from the workshop: ' \
444+
--char-limit 256 --value 'ts4ta:core'
445+
)"
446+
filters+=(
447+
".value.mods[].name | test(\"${request_mod,,}\"; \"i\")"
448+
);;
414449
esac
415450
done 3< <(
416451
printf '%s\n' "${available_filters[@]}" | \
417452
gum choose --no-limit \
418-
--height="$(menuHeight $((${#available_filters[@]}/2)))"
453+
--height="$(menuHeight 10)" # $((${#available_filters[@]}/2))
419454
)
420455

421456
select="select($(printf '(%s) and ' "${filters[@]}")) |"
422457
printf '%s' "${select//and[[:space:]])/)}"
423458
}
424459

425460
# Preview window for show server details
461+
# shellcheck disable=SC2317
426462
fzfPreview() {
427463
local index="$1" server_data server_ip mods_count ping_limit=1 ping_count=1
428464

@@ -445,7 +481,7 @@ fzfPreview() {
445481
}
446482

447483
serverPing() {
448-
ping -q -c $ping_count -W $ping_limit "$1" | awk -F '/' \
484+
ping -q -c "$ping_count" -W "$ping_limit" "$1" | awk -F '/' \
449485
'END {print ($5==""?"❔":$5 " ms")}'
450486
}
451487

@@ -473,7 +509,10 @@ fzfPreview() {
473509
Public: | \(if .shard=="public" then "🟢" else "🔴" end)
474510
Modded: | \(if .mods|length > 0 then "🟢 [" +
475511
(.mods|length|tostring) + "]" else "🔴" end)
476-
Version: | \(.version)"' <<< "$server_data" | gum format
512+
Version: | \(.version)
513+
Platform: | \(if .environment=="l" then
514+
"🐧 [linux]" else "🪟 [windows]"
515+
end)"' <<< "$server_data" | gum format
477516

478517
echo
479518
server_ip="$(jq -er '.endpoint.ip' <<< "$server_data")"
@@ -556,7 +595,7 @@ getNotInstalledMods() {
556595
} | gum format
557596

558597
# Helper for install mods without StemCMD
559-
if [ ! $DAYZ_STEAMCMD_ENABLED = true ] && [ "${#missed_mods[@]}" -gt 0 ]; then
598+
if [ ! "$DAYZ_STEAMCMD_ENABLED" = true ] && [ "${#missed_mods[@]}" -gt 0 ]; then
560599
if command -v xdg-open &>/dev/null && gum confirm --prompt.align=center \
561600
'Open all Steam Workshop links for missing mods for you?'
562601
then
@@ -861,7 +900,6 @@ connectFromArg() {
861900
)
862901
addHistoryServer "$ip" "$query_port" "$name"
863902
runDayZ "${exec_args[@]}"
864-
exit 0
865903
}
866904

867905
# Connect by IP:port
@@ -1282,7 +1320,7 @@ configMenu() {
12821320
# Base options #1
12831321
local config_menu_options=('Game launch options' 'Change Steam root dir')
12841322
# Options for SteamCMD
1285-
if [ $DAYZ_STEAMCMD_ENABLED = true ]; then
1323+
if [ "$DAYZ_STEAMCMD_ENABLED" = true ]; then
12861324
config_menu_options+=('Change Steam login' 'Disable SteamCMD')
12871325
else
12881326
config_menu_options+=('Set Steam login')
@@ -1296,7 +1334,7 @@ configMenu() {
12961334
'Remove manged mods'
12971335
'Remove all mod links'
12981336
)
1299-
[ $DAYZ_STEAMCMD_ENABLED = true ] &&
1337+
[ "$DAYZ_STEAMCMD_ENABLED" = true ] &&
13001338
config_menu_options+=('Force update game and all mods')
13011339
fi
13021340
# Base options #3
@@ -1466,7 +1504,7 @@ export dayz_path="$steam_root/common/DayZ"
14661504
export dayz_workshop_path="$steam_root/workshop/content/$DAYZ_GAME_ID"
14671505

14681506
# Get Steam profile
1469-
if [ $DAYZ_STEAMCMD_ENABLED = true ]; then
1507+
if [ "$DAYZ_STEAMCMD_ENABLED" = true ]; then
14701508
steam_login="$(jq -er '.steam_login // ""' "$DAYZ_PROFILE" 2>/dev/null)"
14711509
if [ -z "$steam_login" ]; then
14721510
setProfileSteamLogin
@@ -1552,11 +1590,11 @@ while read -r option; do
15521590
fi;;
15531591
'Direct Connect')
15541592
server_data="$(directConnect)";;
1555-
'Launch Game') runDayZ "${dayz_launch_options[@]}"; exit 0;;
1556-
'Play Offline') runDayZOffline "${dayz_launch_options[@]}"; exit 0;;
1593+
'Launch Game') runDayZ "${dayz_launch_options[@]}";;
1594+
'Play Offline') runDayZOffline "${dayz_launch_options[@]}";;
15571595
'DayZ News') getDayzNews "$(($(tput lines)/2-3))" | less -R; execSelf;;
15581596
'Config') configMenu;;
1559-
*) fail "Unknown option $option"; exit 0;;
1597+
*) fail "Unknown option $option";;
15601598
esac
15611599
done < <(
15621600
printf '%s\n' "${main_menu_options[@]}" | \
@@ -1623,8 +1661,7 @@ while read -r option; do
16231661
argsFromServerData "$server_data" "${dayz_launch_options[@]}"
16241662
)
16251663
addHistoryServer "$server_ip" "$server_query_port" "$server_name"
1626-
runDayZ "${exec_args[@]}"
1627-
exit 0;;
1664+
runDayZ "${exec_args[@]}";;
16281665
*) fail "Unknown option $1";;
16291666
esac
16301667
done < <(printf '%s\n' "${choose_play_options[@]}" | gum choose --no-limit)
@@ -1635,6 +1672,3 @@ exit 0
16351672
# flatpak run --branch=stable --arch=x86_64 --command=/app/bin/steam-wrapper com.valvesoftware.Steam "${@}"
16361673

16371674
# TODO add some args for usage
1638-
1639-
# TODO
1640-
# https://github.com/CypherMediaGIT/DayZCommunityOfflineMode-DeerIsle-Edition

install

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ if ! command -v steamcmd &>/dev/null; then
182182
chmod +x "$bin_path/steamcmd"
183183

184184
"$bin_path/steamcmd" +@ShutdownOnFailedCommand 1 +quit || steamcmd_rc=$?
185-
if [ $steamcmd_rc -ne 42 ]; then
185+
if [ "$steamcmd_rc" -ne 42 ]; then
186186
rm -r -- "$bin_path/steamcmd" "$steamcmd_path"
187187
fail 'There is something wrong with SteamCMD installation,' \
188188
'try installing it yourself:' \

0 commit comments

Comments
 (0)