Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/disabled_classes.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"AnimationNodeStateMachinePlayback",
"AnimationNodeStateMachineTransition",
"AspectRatioContainer",
"AtlasTexture",
"AudioBusLayout",
"AudioEffect",
"AudioStream",
Expand Down
93 changes: 61 additions & 32 deletions .github/file_format.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,69 @@
#!/usr/bin/env bash

# This script ensures proper POSIX text file formatting and a few other things.

set -uo pipefail
IFS=$'\n\t'

# Function to check if file is UTF-8.
is_utf8() {
local file="$1"
# Use file command if available, otherwise assume UTF-8.
if command -v file >/dev/null 2>&1; then
file -b --mime-encoding "$file" | grep -q "utf-8\|ascii"
else
return 0 # Assume UTF-8 if can't check.
fi
}

# Function to convert CRLF to LF.
convert_line_endings() {
local file="$1"
# Check if file has CRLF endings.
if grep -q $'\r$' "$file" 2>/dev/null; then
# Convert CRLF to LF using sed.
sed -i 's/\r$//' "$file"
echo "Converted CRLF to LF: $file"
fi
}

# Function to remove trailing spaces and ensure final newline.
clean_whitespace() {
local file="$1"
# Remove trailing spaces and ensure final newline.
sed -i -e '/[^ \t]/ s/[ \t]*$//' -e '/^[ \t]*$/ s/ *$//' -e '$a\' "$file"
}

# Loops through all text files tracked by Git.
git grep -zIl '' |
while IFS= read -rd '' f; do
# Exclude some types of files.
if [[ "$f" == *"svg" ]]; then
continue
elif [[ "$f" == *"build" ]]; then
continue
elif [[ "$f" == *".patch" ]]; then
continue
fi
# Ensure that files are UTF-8 formatted.
recode UTF-8 "$f" 2> /dev/null
# Ensure that files have LF line endings and do not contain a BOM.
dos2unix "$f" 2> /dev/null
# Remove trailing space characters and ensure that files end
# with newline characters. -l option handles newlines conveniently.
perl -i -ple 's/ *$//g' "$f"
# Remove the character sequence "== true" if it has a leading space.
perl -i -pe 's/\x20== true//g' "$f"
# We don't want to change lines around braces in godot/tscn files.
if [[ "$f" == *"godot" ]]; then
continue
elif [[ "$f" == *"tscn" ]]; then
# Exclude some types of files.
if [[ "$f" == *"svg" ]]; then
continue
elif [[ "$f" == *"build" ]]; then
continue
elif [[ "$f" == *".patch" ]]; then
continue
fi
# Disallow empty lines after the opening brace.
sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f"
# Disallow some empty lines before the closing brace.
sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f"
fi

if ! is_utf8 "$f"; then
echo "Warning: $f may not be UTF-8 encoded"
fi

convert_line_endings "$f"
clean_whitespace "$f"

# Remove the character sequence "== true" if it has a leading space.
sed -i 's/ [=][=] true//g' "$f"

# We don't want to change lines around braces in godot/tscn files.
if [[ "$f" == *"godot" ]] || [[ "$f" == *"tscn" ]]; then
continue
fi

# Disallow empty lines after the opening brace.
sed -i ':a;N;$!ba;s/{\n\n/{\n/g' "$f"

# Disallow some empty lines before the closing brace.
sed -i ':a;N;$!ba;s/\n\n}/\n}/g' "$f"
done

git diff > patch.patch
Expand All @@ -43,15 +72,15 @@ MAXSIZE=5

# If no patch has been generated all is OK, clean up, and exit.
if (( FILESIZE < MAXSIZE )); then
printf "Files in this commit comply with the formatting rules.\n"
rm -f patch.patch
exit 0
printf "Files in this commit comply with the formatting rules.\n"
rm -f patch.patch
exit 0
fi

# A patch has been created, notify the user, clean up, and exit.
printf "\n*** The following differences were found between the code "
printf "and the formatting rules:\n\n"
cat patch.patch
printf "\n*** Aborting, please fix the formatting issue(s).'\n"
printf "\n*** Aborting, please fix the formatting issue(s).\n"
rm -f patch.patch
exit 1
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:
# Which godot version to use for exporting.
GODOT_VERSION: 4.5
# Which godot release to use for exporting. (stable/rc/beta/alpha)
GODOT_RELEASE: beta5
GODOT_RELEASE: stable
# Used in the editor config file name. Do not change this for patch releases.
GODOT_FEATURE_VERSION: 4.5
# Commit hash
GODOT_COMMIT_HASH: c81fd6c
GODOT_COMMIT_HASH: 2dd26a027
PROJECT_NAME: VectorTouch
BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes disable_physics_2d=yes disable_navigation_2d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes module_mbedtls_enabled=yes swappy=no build_profile=../vectortouch/.github/disabled_classes.build
GODOT_REPO: https://github.com/godotengine/godot.git
Expand Down
22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,28 @@ After submitting your pull request, I (MewPurPur) will review your changes and m

Editing translations is explained [here](translations/README.md)

## Code guidelines
## Code guidelines and style

To document some quirks of our code that we've decided on:
As usual, look around and try to copy the things you find in surrounding code.

- StringNames are avoided when possible. We do this because it makes the codebase simpler, although if something is actually shown to be performance-critical, it can be reconsidered.
- Nodes may only be exported if their runtime structure isn't known.
Guidelines:

- StringNames are avoided when possible.
- Rationale: This makes the codebase simpler, and StringNames aren't a universal optimization. I've heard of a lot of cases where they counterintuitively make performance worse, and I don't currently understand them well-enough to not fall into traps. If performance benefits for using StringName somewhere are arduously benchmarked, it can be considered.
- We avoid exporting nodes, unless their runtime structure isn't known.
- Strings are always translated with `Translator.translate()`, not `tr()`.

## Code style
Follow the [GDScript style guide](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html). Almost all this guide's rules are enforced here.

For scripts, only GDScript code is allowed. Follow the [GDScript style guide](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html). Most of its rules are enforced here. Additionally:
We have some additional style rules:

- Static typing is used as much as possible.
- Always use static typing. And if possible, use inferred typing, i.e., `var f := 4.0` instead of `var f: float = 4.0`
- Comments are typically written like sentences with punctuation.
- Two spaces are used to separate inline comments and code.
- Inline comments are separated from the code by two spaces.
- Documentation comments are written like normal comments, without modifiers like `[param]` or `[code]`.
- Rationale: The amount by which they improve the readability of the documentation isn't enough to outweigh how much worse they are when you look at them in code. I believe they aren't suitable in a project where only developers will be reading them.
- For empty lines in the middle of indented blocks, the scope's indentation is kept.
- Rationale: I don't really know why this isn't conventional, I find that it just gets in the way when you want to add code where there were previously empty spaces.
- Class names use `class_name X extends Y` syntax.

Don't make pull requests for code style changes without discussing them first (unless it's for corrections to abide by the ones described here). The same generally applies to making style changes unrelated to a PR's main goal. Pull requests may also get production tweaks to tweak their style before being merged.
6 changes: 3 additions & 3 deletions assets/icons/ApplyMatrix.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://cqg7ga6y3m0v1"
path="res://.godot/imported/ApplyMatrix.svg-4b4fb4d9ae9b2b8df69ee71dac2db3d2.svgtex"
path="res://.godot/imported/ApplyMatrix.svg-4b4fb4d9ae9b2b8df69ee71dac2db3d2.dpitex"

[deps]

source_file="res://assets/icons/ApplyMatrix.svg"
dest_files=["res://.godot/imported/ApplyMatrix.svg-4b4fb4d9ae9b2b8df69ee71dac2db3d2.svgtex"]
dest_files=["res://.godot/imported/ApplyMatrix.svg-4b4fb4d9ae9b2b8df69ee71dac2db3d2.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/Arrow.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://coda6chhcatal"
path="res://.godot/imported/Arrow.svg-454f1a120b660e1c200a4fee4bc9d4e9.svgtex"
path="res://.godot/imported/Arrow.svg-454f1a120b660e1c200a4fee4bc9d4e9.dpitex"

[deps]

source_file="res://assets/icons/Arrow.svg"
dest_files=["res://.godot/imported/Arrow.svg-454f1a120b660e1c200a4fee4bc9d4e9.svgtex"]
dest_files=["res://.godot/imported/Arrow.svg-454f1a120b660e1c200a4fee4bc9d4e9.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/BWHandle.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://ksx758sjihau"
path="res://.godot/imported/BWHandle.svg-9588bc79a1c5a24e3ab185d58c8cacd6.svgtex"
path="res://.godot/imported/BWHandle.svg-9588bc79a1c5a24e3ab185d58c8cacd6.dpitex"

[deps]

source_file="res://assets/icons/BWHandle.svg"
dest_files=["res://.godot/imported/BWHandle.svg-9588bc79a1c5a24e3ab185d58c8cacd6.svgtex"]
dest_files=["res://.godot/imported/BWHandle.svg-9588bc79a1c5a24e3ab185d58c8cacd6.dpitex"]

[params]

Expand Down
2 changes: 1 addition & 1 deletion assets/icons/Checkerboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions assets/icons/Checkerboard.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://c68og6bsqt0lb"
path="res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.svgtex"
path="res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.dpitex"

[deps]

source_file="res://assets/icons/Checkerboard.svg"
dest_files=["res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.svgtex"]
dest_files=["res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/CheckerboardColorButton.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://y0l74x73w0co"
path="res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.svgtex"
path="res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.dpitex"

[deps]

source_file="res://assets/icons/CheckerboardColorButton.svg"
dest_files=["res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.svgtex"]
dest_files=["res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.dpitex"]

[params]

Expand Down
2 changes: 1 addition & 1 deletion assets/icons/CheckerboardMini.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions assets/icons/CheckerboardMini.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://stpallv5q0rb"
path="res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.svgtex"
path="res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.dpitex"

[deps]

source_file="res://assets/icons/CheckerboardMini.svg"
dest_files=["res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.svgtex"]
dest_files=["res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/Clear.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://dw7ho4df0uh4p"
path="res://.godot/imported/Clear.svg-3a871eef1b434e2f0f43b3b19cfa4303.svgtex"
path="res://.godot/imported/Clear.svg-3a871eef1b434e2f0f43b3b19cfa4303.dpitex"

[deps]

source_file="res://assets/icons/Clear.svg"
dest_files=["res://.godot/imported/Clear.svg-3a871eef1b434e2f0f43b3b19cfa4303.svgtex"]
dest_files=["res://.godot/imported/Clear.svg-3a871eef1b434e2f0f43b3b19cfa4303.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/Close.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://b0y4h5tuyrais"
path="res://.godot/imported/Close.svg-ec226890f15a36af010397a4558772f4.svgtex"
path="res://.godot/imported/Close.svg-ec226890f15a36af010397a4558772f4.dpitex"

[deps]

source_file="res://assets/icons/Close.svg"
dest_files=["res://.godot/imported/Close.svg-ec226890f15a36af010397a4558772f4.svgtex"]
dest_files=["res://.godot/imported/Close.svg-ec226890f15a36af010397a4558772f4.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/CodeEditor.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://drl587rrnbwo3"
path="res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.svgtex"
path="res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.dpitex"

[deps]

source_file="res://assets/icons/CodeEditor.svg"
dest_files=["res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.svgtex"]
dest_files=["res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/CodeOptions.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://dthdjf4v2vlvg"
path="res://.godot/imported/CodeOptions.svg-494ca15fb7ae22eb042af52beb4677fd.svgtex"
path="res://.godot/imported/CodeOptions.svg-494ca15fb7ae22eb042af52beb4677fd.dpitex"

[deps]

source_file="res://assets/icons/CodeOptions.svg"
dest_files=["res://.godot/imported/CodeOptions.svg-494ca15fb7ae22eb042af52beb4677fd.svgtex"]
dest_files=["res://.godot/imported/CodeOptions.svg-494ca15fb7ae22eb042af52beb4677fd.dpitex"]

[params]

Expand Down
6 changes: 3 additions & 3 deletions assets/icons/Compress.svg.import
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[remap]

importer="svg"
type="SVGTexture"
type="DPITexture"
uid="uid://c5kgvxffw35gi"
path="res://.godot/imported/Compress.svg-108f53e6f660b13f0dc7d2a72d7cff0f.svgtex"
path="res://.godot/imported/Compress.svg-108f53e6f660b13f0dc7d2a72d7cff0f.dpitex"

[deps]

source_file="res://assets/icons/Compress.svg"
dest_files=["res://.godot/imported/Compress.svg-108f53e6f660b13f0dc7d2a72d7cff0f.svgtex"]
dest_files=["res://.godot/imported/Compress.svg-108f53e6f660b13f0dc7d2a72d7cff0f.dpitex"]

[params]

Expand Down
1 change: 1 addition & 0 deletions assets/icons/Computer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading