Skip to content

Commit

Permalink
Added list-ini-values.sh bash script + updated 'autocomplete.txt'
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisDiligens committed Jan 18, 2023
1 parent 697065c commit 389c7ec
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Additional files/autocomplete.txt

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Docs/Fundamentals.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ The \*.ini file suffixes are:

The keys in the \*.ini files seem to follow the Hungarian Notation:

| Prefix | Type of value |
| ------ | ----------------------------------------- |
| `b` | Boolean (`0` for `false`, `1` for `true`) |
| `c` | Character (?) |
| `d` | Double-precision float (?) |
| `f` | Floating-point number |
| `i` | Integer |
| `s` | String |
| `u` | Unsigned integer |
| Prefix | Type of value |
| --------- | ----------------------------------------- |
| `b` | Boolean (`0` for `false`, `1` for `true`) |
| `c` | Character (?) |
| `d` | Double-precision float (?) |
| `f` | Floating-point number |
| `i` | Integer |
| `s` | String |
| `u`, `ui` | Unsigned integer |

Sometimes these prefixes are capitalized. (Seems random)

Expand Down
1 change: 1 addition & 0 deletions Docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ This is an attempt to document the project for developers.
- [Fundamentals: Understanding what the app does](Fundamentals.md)
- [Building the app](Building.md)
- [Project and folder structure](Project%20Structure.md)
- [Extracting *.ini values and updating the "autocomplete.txt"](ini%20values.md)
- [Flowcharts and program structure](Program.md)
- [Theming (specific)](Theming.md)
21 changes: 21 additions & 0 deletions Docs/ini values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Extracting *.ini values

The app ships with an "autocomplete.txt" file that contains all the *.ini sections and keys that can be extracted from the game's executable.

I made a small bash script for this. All that is needed to update the "autocomplete.txt" file is to run this:

```bash
$ bash ./list-ini-values.sh --path <path-to-Fallout76> --comma-separated > ./Additional\ files/autocomplete.txt
```

You can also list all available *.ini keys in a human readable form:

```bash
$ bash ./list-ini-values.sh --path <path-to-Fallout76>
```

If you want to run this script under Windows, you need either [Cygwin](https://www.cygwin.com/), [Git Bash](https://gitforwindows.org/) (which is often bundled with git anyway), or [WSL2](https://learn.microsoft.com/en-us/windows/wsl/). Pick one.

Credit goes it u/LinuxVersion on Reddit:
- https://www.reddit.com/r/fo76/comments/om82q0/all_2832_ini_settings_recognized_by_the_game/
- https://pastebin.com/raw/rxuSq05A
77 changes: 77 additions & 0 deletions list-ini-values.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# To run this script on Windows, you require Cygwin, Git Bash, or WSL2.
# For the --path argument, you have to input something like this:
# Cygwin: /cygdrive/c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe
# Git Bash: /c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe
# WSL2: /mnt/c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe

# Credit: u/LinuxVersion on Reddit
# -> https://www.reddit.com/r/fo76/comments/om82q0/all_2832_ini_settings_recognized_by_the_game/
# -> https://pastebin.com/raw/rxuSq05A

function show_help () {
echo "Small bash script to extract *.ini settings from the executable."
echo ""
echo "Usage:"
echo "$ ./list-ini-values.sh --path <path-to-Fallout76.exe>"
echo ""
echo "Options:"
echo " -p or --path <path-to-Fallout76.exe>"
echo " -c or --comma-separated"
echo " -h or --help"
}

while [[ $# -gt 0 ]]; do
case $1 in
-p|--path)
exe_path="$2"
shift
shift
;;
-c|--comma-separated)
comma_separated=1
shift
;;
-h|--help|-?)
show_help
exit 0
;;
--)
shift
;;
-*|--*|*)
echo "Unknown option $1"
exit 1
;;
esac
done

if [ $# -ne 0 ]; then
echo "unknown option(s): $@"
exit 1
fi

if [ -z "$exe_path" ]; then
show_help
exit 1
fi

if [ ! -f "$exe_path" ]; then
echo "The path '$exe_path' does not exist or isn't a file."
exit 1
fi

if [ "$comma_separated" = "1" ]; then
grep -a -o "[abcfhirsu][iA-Z][a-zA-Z0-9_]\{2,\}:[A-Z][A-Za-z0-9_]\{2,\}" "$exe_path" | # Grab all strings that look sort of like this: uWorkshopLODRadius:Workshop
sed 's/\(.*[^:]\):\(\w\+\)/\2\n\1/p' | # Separate each *.ini key and section by a newline
sort | # Sort alphabetically
uniq | # Remove duplicates
head -c -1 | # Remove the last trailing newline
tr '\n' ',' # Replace all newlines by comma_separated
else
grep -a -o "[abcfhirsu][iA-Z][a-zA-Z0-9_]\{2,\}:[A-Z][A-Za-z0-9_]\{2,\}" "$exe_path" | # Grab all strings that look sort of like this: uWorkshopLODRadius:Workshop
sed 's/\(.*[^:]\):\(\w\+\)/[\2] \1/p' | # Clean it up: "key:section" -> "[section] key"
sort | # Sort alphabetically
uniq # Remove duplicates
fi

0 comments on commit 389c7ec

Please sign in to comment.