Fix some critters.

After about half an hour of cussin and spitting tobacco juice, I came
to some discoveries:
* The clipboard translator wasn't even launching successfully.
* For BKs 1 and 2, remove the nvda dll thereby forcing it to use the
clipboard reader.
* Fix up BK2 to go into the right bottle; it is a 32-bit game.
This commit is contained in:
2025-10-07 10:14:54 -04:00
parent ba0075e74b
commit e3289b92cb
3 changed files with 35 additions and 15 deletions

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash
# Get script directory for relative paths
scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Dialog accessibility
export DIALOGOPTS='--no-lines --visit-items'
@@ -171,7 +174,7 @@ game_installer() {
# Create the menu of available games by reading from .install directory
declare -a menuList
# Get all .sh files from .install directory, excluding those starting with # as first line.
mapfile -t sortedGames < <(for f in "${0%/*}/.install/"*.sh; do
mapfile -t sortedGames < <(for f in "${scriptDir}/.install/"*.sh; do
# Skip if first line starts with #
[[ $(head -n1 "$f") == "#"* ]] && continue
echo "${f##*/%.sh}"
@@ -214,7 +217,7 @@ game_installer() {
;;
*)
# Convert game name to filename format
local installScript="${0%/*}/.install/${game}.sh"
local installScript="${scriptDir}/.install/${game}.sh"
# Check if install script exists
if [[ -f "$installScript" ]]; then
# Source and execute the install script
@@ -341,7 +344,7 @@ kill_game() {
# for games that require custom scripts before launch or custom launch parameters
custom_launch_parameters() {
if [[ "${game[2]}" == "Dragon Pong" ]]; then
"${0%/*}/speech/speak_window_title.sh" DragonPong.exe &
"${scriptDir}/speech/speak_window_title.sh" DragonPong.exe &
pushd "$(winepath "$winePath")"
wine "$wineExec"
popd
@@ -349,13 +352,15 @@ custom_launch_parameters() {
fi
# executioner's-rage: DLL replacement now handled by update_nvda_dlls()
if [[ "${game[2]}" == "Laser Breakout" ]]; then
"${0%/*}/speech/speak_window_title.sh" play.exe &
"${scriptDir}/speech/speak_window_title.sh" play.exe &
fi
if [[ "${game[2]}" == "Bokurano Daibouken 2" ]]; then
"${0%/*}/speech/clipboard_translator.sh" "${game[1]}" bokurano-daibouken2 &
find "${WINEPREFIX}/drive_c/nyanchangame/bk2" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
"${scriptDir}/speech/clipboard_translator.sh" "play.exe" bokurano-daibouken2 &
fi
if [[ "${game[2]}" == "Bokurano Daibouken" ]]; then
"${0%/*}/speech/clipboard_translator.sh" "${game[1]}" bokurano-daibouken &
find "${WINEPREFIX}/drive_c/nyanchangame/bk" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
"${scriptDir}/speech/clipboard_translator.sh" "play.exe" bokurano-daibouken &
fi
if [[ "${game[2]}" == "Bokurano Daibouken 3" ]]; then
dictPath="$(winepath "${winePath}")"
@@ -365,21 +370,21 @@ custom_launch_parameters() {
# DLL replacement now handled by update_nvda_dlls()
if [[ ! -d "${dictPath}/dict" ]] && [[ ! -r "${cache}/bk3-dict.dat" ]]; then
find "${WINEPREFIX}/drive_c/nyanchangame/bk3" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
"${0%/*}/speech/clipboard_translator.sh" "${game[1]}" bokurano-daibouken3 &
"${scriptDir}/speech/clipboard_translator.sh" "play.exe" bokurano-daibouken3 &
fi
fi
if [[ "${game[2]}" == "Bop It Emulator" ]]; then
"${0%/*}/speech/speak_window_title.sh" bop.exe &
"${scriptDir}/speech/speak_window_title.sh" bop.exe &
fi
if [[ "${game[2]}" == "Road to Rage" ]]; then
"${0%/*}/speech/speak_window_title.sh" trtr.exe &
"${scriptDir}/speech/speak_window_title.sh" trtr.exe &
fi
if [[ "${game[2]}" == "Sequence Storm" ]]; then
"${0%/*}/speech/clipboard_reader.sh" SequenceStorm &
"${scriptDir}/speech/clipboard_reader.sh" SequenceStorm &
fi
#if [[ "${game[2]}" == "Shadow Line" ]]; then
#find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
#"${0%/*}/speech/clipboard_translator.sh" play_sr.exe shadow-line &
#"${scriptDir}/speech/clipboard_translator.sh" play_sr.exe shadow-line &
#fi
# sketchbook: DLL replacement now handled by update_nvda_dlls()
if [[ "${game[2]}" == "Audiodisc" ]]; then

View File

@@ -7,6 +7,13 @@
# set -Eeuo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/#:~:text=set%20%2Du,is%20often%20highly%20desirable%20behavior.
shopt -s expand_aliases
# Debug logging
#DEBUG_LOG="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/translator-debug.log"
#exec 2>>"$DEBUG_LOG"
#echo "=== Translator started at $(date) ===" >&2
#echo "Args: $@" >&2
#set -x
if [[ $# -ne 2 ]]; then
echo "Usage: $0 \"application name\" \"file name\"."
exit 1
@@ -88,21 +95,29 @@ while pgrep -f -u "$USER" "$1" &> /dev/null ; do
# Check if we already have a translation
translated=$(sqlite3 "$translationFile" "SELECT translation FROM translations WHERE text = '$normalizedText' LIMIT 1;" 2>/dev/null)
echo "DEBUG: Database lookup result: '$translated'" >&2
if [[ -z "$translated" ]]; then
echo "DEBUG: No cached translation, calling trans command" >&2
# Get translation from the trans utility
translated="$(trans -no-autocorrect -no-warn -brief "$normalizedText" | head -1 | sed 's/\s*$//' | normalizeUnicode)"
echo "DEBUG: trans returned: '$translated'" >&2
if [[ -n "$translated" ]]; then
# Insert using echo piping to avoid escaping issues
echo "$normalizedText|$translated" | sqlite3 -separator "|" "$translationFile" ".import /dev/stdin temp_import"
sqlite3 "$translationFile" "INSERT OR IGNORE INTO translations SELECT * FROM temp_import; DELETE FROM temp_import;"
echo "DEBUG: Saved to database" >&2
fi
fi
# If we got a translation, speak it
if [[ -n "$translated" ]]; then
echo "DEBUG: Speaking translation: '$translated'" >&2
spd-say -- "$translated"
else
echo "DEBUG: No translation available, speaking original: '$text'" >&2
spd-say -- "$text"
fi
# Clear clipboard

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Adapted from the bash snippet found at:
# https://bbs.archlinux.org/viewtopic.php?id=117031