diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/dist/html/full-size.html | 9 | ||||
-rwxr-xr-x | misc/scripts/fix_headers.py | 8 | ||||
-rwxr-xr-x | misc/scripts/fix_style.sh | 60 |
3 files changed, 71 insertions, 6 deletions
diff --git a/misc/dist/html/full-size.html b/misc/dist/html/full-size.html index 44b009524c..0e8a41a9fc 100644 --- a/misc/dist/html/full-size.html +++ b/misc/dist/html/full-size.html @@ -162,8 +162,13 @@ $GODOT_HEAD_INCLUDE requestAnimationFrame(animate); function adjustCanvasDimensions() { - canvas.width = innerWidth; - canvas.height = innerHeight; + var scale = window.devicePixelRatio || 1; + var width = window.innerWidth; + var height = window.innerHeight; + canvas.width = width * scale; + canvas.height = height * scale; + canvas.style.width = width + "px"; + canvas.style.height = height + "px"; } animationCallbacks.push(adjustCanvasDimensions); adjustCanvasDimensions(); diff --git a/misc/scripts/fix_headers.py b/misc/scripts/fix_headers.py index 823c9acfde..d94db22b42 100755 --- a/misc/scripts/fix_headers.py +++ b/misc/scripts/fix_headers.py @@ -33,7 +33,7 @@ header = """\ /*************************************************************************/ """ -files = open("files", "rb") +files = open("files", "r") fname = files.readline() @@ -67,7 +67,7 @@ while (fname != ""): # In a second pass, we skip all consecutive comment lines starting with "/*", # then we can append the rest (step 2). - fileread = open(fname.strip(), "rb") + fileread = open(fname.strip(), "r") line = fileread.readline() header_done = False @@ -92,11 +92,11 @@ while (fname != ""): fileread.close() # Write - filewrite = open(fname.strip(), "wb") + filewrite = open(fname.strip(), "w") filewrite.write(text) filewrite.close() # Next file fname = files.readline() -files.close()
\ No newline at end of file +files.close() diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh new file mode 100755 index 0000000000..7a335c21ea --- /dev/null +++ b/misc/scripts/fix_style.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Command line arguments +run_clang_format=false +run_fix_headers=false +usage="Invalid argument. Usage:\n$0 <option>\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a" + +if [ -z "$1" ]; then + echo -e $usage + exit 0 +fi + +while [ $# -gt 0 ]; do + case "$1" in + --clang-format|-c) + run_clang_format=true + ;; + --headers|-h) + run_fix_headers=true + ;; + --all|-a) + run_clang_format=true + run_fix_headers=true + ;; + *) + echo -e $usage + exit 0 + esac + shift +done + +echo "Removing generated files, some have binary data and make clang-format freeze." +find -name "*.gen.*" -delete + +# Apply clang-format +if $run_clang_format; then + # Sync list with pre-commit hook + FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl" + + for extension in ${FILE_EXTS}; do + echo -e "Formatting ${extension} files..." + find \( -path "./.git" \ + -o -path "./thirdparty" \ + -o -path "./platform/android/java/src/com" \ + \) -prune \ + -o -name "*${extension}" \ + -exec clang-format -i {} \; + done +fi + +# Add missing copyright headers +if $run_fix_headers; then + echo "Fixing copyright headers in Godot code files..." + find \( -path "./.git" -o -path "./thirdparty" \) -prune \ + -o -regex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|m\|mm\|java\)' \ + > tmp-files + cat tmp-files | grep -v ".git\|thirdparty\|theme_data.h\|platform/android/java/src/com\|platform/android/java/src/org/godotengine/godot/input/InputManager" > files + python misc/scripts/fix_headers.py + rm -f tmp-files files +fi |