Commit Graph

220 Commits

Author SHA1 Message Date
Haoyu Qiu a3f91b9fdc Fix left aligned integer sign in string formatting
(cherry picked from commit 767134fd8d)
2022-05-05 15:17:52 +02:00
Rémi Verschelde 71066cd63b
Update copyright statements to 2022
Happy new year to the wonderful Godot community!

(cherry picked from commit a627cdafc5)
2022-01-13 16:00:37 +01:00
Haoyu Qiu b90bec546d
Make `--doctool` locale aware
* Adds `indent(prefix)` to `String`
* Moves the loading of tool/doc translation into
  `editor/editor_translation.{h,cpp}`
* Makes use of doc translation when generating XML class references, and
  setup the translation locale based on `-l LOCALE` CLI parameter.

The XML class reference won't be translated if `-l LOCALE` parameter is
not given, or when it's `-l en`.

(cherry picked from commit c11b1850c4)
2021-12-16 17:06:52 +01:00
Rémi Verschelde 1b65550ec7
clang-format: Various fixes to comments alignment from `clang-format` 13
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-28 14:50:32 +02:00
Yuri Sizov b02c61ddb1 Ignore OS specific values (constants, project settings, properties)
Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2021-10-10 23:40:32 +03:00
Rémi Verschelde 81da3b8ba4
Use translated docs in PropertySelector
And do the dedent and stripping for both translated and
non-translated strings for consistency, and so that we
don't need to do it at the call site.

(cherry picked from commit a16031beb6)
2021-10-07 12:48:23 +02:00
Rémi Verschelde 9729432ec0
i18n: Add support for translating the class reference
- Parse `.po` files from `doc/translations/*.po` like already done
  with `editor/translations/*.po`.
- Add logic to register a doc translation mapping in `TranslationServer`
  and `EditorSettings`.
- Add `DTR()` to lookup the doc translation mapping (similar to `TTR()`).
  Strings are automatically dedented and stripped of whitespace to ensure
  that they would match the translation catalog.
- Use `DTR()` to translate relevant strings in `EditorHelp`,
  `EditorInspector`, `CreateDialog`, `ConnectionsDialog`.
- Small simplification to `TranslationLoaderPO`, the path argument was
  not really meaningful.

(cherry picked from commit 4857648a16)
2021-10-07 12:48:23 +02:00
Hugo Locurcio 59eafe4cd3
Remove `#ifdefs` for handling compilation with Visual Studio < 2015
Godot 3.3 and later require Visual Studio 2017 to be compiled.

(cherry picked from commit fc0bfbb33b)
2021-09-19 11:30:22 +02:00
Theraot d03f7c0598 [3.x] Fix get_base_dir windows top level directory logic
This is a fix for https://github.com/godotengine/godot/issues/52048
2021-09-16 06:38:29 -05:00
Jonas Bernemann 3b5ee6a38a
String::format leave passed values untouched
If the passed value or key contains double quotation marks it will no
longer get removed.

(cherry picked from commit a403efb67c)
2021-07-13 10:20:03 +02:00
Philip Whitfield 606331fdcb
fix url parsing with port numbers
String.get_slice_count is always at least 1 or 2 for bases with a port number.
Before this change the following URL would return ERR_INVALID_PARAMETER ```ws://127.0.0.1:8000/test```

(cherry picked from commit 3d9f29910c)
2021-06-17 12:47:54 +02:00
Henry Conklin a28beb3048
Add support for numeric XML entities to XMLParser
* Add support for decimal numeric entities to String::xml_unescape
* Add more error checks to String::xml_unescape
* Refactor XMLParser to use String::xml_unescape instead of an internal
implementation
2021-06-03 11:44:47 +02:00
Rémi Verschelde 140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde 64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde 3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Fabio Alessandrelli 77e3514315
[Net] Implement String::parse_url for parsing URLs.
Splits the URL into (scheme, host, port, path).
Supports both literal IPv4 and IPv6.
Strip credentials when present (e.g. http://user:pass@example.com/).

Use that function in both HTTPRequest and WebSocketClient.

(cherry picked from commit 3bb40669d5)
2021-05-03 21:39:43 +02:00
Daniel Kříž edcb95cede
fix wrong encoding in uri_encode
(cherry picked from commit 13c999d9d7)
2021-04-12 00:23:43 +02:00
abaire b032067e42 Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
kleonc e900ca1f76
Make String::ends_with don't use String::rfind
(cherry picked from commit ad0943e3d3)
2021-02-11 13:12:06 +01:00
Aaron Franke 226528097e
[3.2] Backport hex_to_int/bin_to_int zero check and C# changes 2021-01-28 09:24:44 -05:00
Vedat Günel 39cf22a9c7
Fix String.ends_with() for empty string arguments
(cherry picked from commit 1d0437c95b)
2021-01-26 17:00:17 +01:00
Rémi Verschelde 49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Fredia Huya-Kouadio 94aa09a854 Fix the `String::get_base_dir()` logic to properly check for top level directories on Windows. 2020-12-23 00:43:03 -08:00
Maganty Rushyendra a46fd28ae3
Fix natural sort comparison for strings with large numbers
Fix errors when comparing strings with large numbers (> INT64_MAX).
Comparisons now occur by comparing individual digits, instead of
converting to int64_t first.

(cherry picked from commit de46c92711)
2020-10-19 15:12:11 +02:00
Serhat 09a8dd7b3b
Fixed padding bug of sprintf function
(cherry picked from commit 9f2cdfea82)
2020-10-04 20:51:58 +02:00
bruvzg 8dab067c01
Add missing NULL termination to the String::repeat function. 2020-08-11 17:23:44 +03:00
Maganty Rushyendra 7670e1fc79 Fix errors in overflow checks for String conversion to int
Current error checks for to_int and to_int64 do not issue overflow error
messages for INT64_MAX + 1, INT64_MAX + 2, and others close to the
limits. Likewise, error checks for hex_to_int, hex_to_int64 and bin_to_int64
issue false positive error messages for INT64_MIN or INT32_MIN. This commit
fixes these error checks.
2020-07-06 08:44:18 +08:00
Rémi Verschelde 362193db6a String: Use ABS macro in padding code
Follow-up to #39261.

(cherry picked from commit cbcc0eacd5)
2020-06-11 11:44:06 +02:00
Maganty Rushyendra 6344b75453 Enable zero padding with float specifier for format strings
Godot currently supports zero padding for integers, octals and
hexadecimals when using format strings, but not for floats.

This commit adds support for zero padding for floats, thus ensuring
consistent behavior for all types, and making Godot's format specifiers'
behavior closer to c's `printf()`.

Before: `print("<%07.2f>" % -0.2345)` prints `<  -0.23>`.
Now: `print("<%07.2f>" % -0.2345)` prints `<-000.23>`.
     `print("<%7.2f>" % -0.2345)` prints `<  -0.23>`.
(cherry picked from commit b7d835d9ca)
2020-06-11 09:41:37 +02:00
dankan1890 7ccfbd61a4 Fixed String::humanize_size crash.
Close #35872

(cherry picked from commit ca0ee767cb)
2020-02-14 15:59:12 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Haoyu Qiu e7e095da3f Encodes property names properly in project.godot 2019-12-20 10:42:08 +08:00
Yuri Roubinsky 8674655a45 Fix build warning in ustring.cpp on Windows/MSVC platform 2019-12-18 17:40:51 +03:00
Catchawink b2a14042d5 Fixed issues with using a relative path in the export window.
Before this fix, opening relative export paths inside of an EditorFileDialog was not possible. This was fixed by modifying String::path_to_file() to save relative paths in EditorExportPreset::set_export_path() more appropriately and changing EditorFileDialog::set_current_dir() to open relative paths.
2019-12-16 09:50:42 -05:00
Rafał Mikrut ed1c4bc77d Removed unused variables, add some constants numbers 2019-12-10 05:13:02 +01:00
Rafał Mikrut 99d8626f4a Fix some overflows and unitialized variables 2019-11-20 16:22:16 +01:00
bruvzg 5d6ff7f2a2
Fix MinGW/clang/LLD/UCRT build. 2019-11-08 15:04:35 +02:00
Jamie Pate bdb7adecfb Fix #24137 Different number of leading zeros on MINGW printf("%lg")
Use _set_output_format() on MINGW platform to force _snprintf_s() to
conform to the C99 standard and match the other platforms.

Fixes #24137
2019-11-07 16:23:35 -08:00
Rafał Mikrut 9ddb3265e1 Fix some crashes, overflows and using variables without values 2019-11-01 16:16:31 +01:00
Hugo Locurcio 3b8004865d
Remove redundant condition in `String::_humanize_digits()` 2019-10-04 18:07:06 +02:00
Andrii Doroshenko (Xrayez) a0d00c0e99 Bind the `String::humanize_size` method
The method signature is also changed to use `uint64_t` instead of `size_t`
for it to be Variant-compatible.
2019-10-04 15:51:13 +03:00
Rémi Verschelde ef2a7834c9
Merge pull request #31883 from aole/create-string-function-repeat
Create a GDScript String function repeat
2019-09-24 11:50:58 +02:00
Rémi Verschelde ed18e3f195
Merge pull request #32273 from Calinou/humanize-size-fix-i18n
Fix i18n in `String::humanize_size()`
2019-09-23 15:57:18 +02:00
Hugo Locurcio a51e8b1ff0
Fix i18n in `String::humanize_size()`
Calls to `RTR()` must be added to each string so the PO file generator
can pick them up.
2019-09-23 13:54:10 +02:00
qarmin 50be65bf43 Changed some code found by Clang Tidy and Coverity 2019-09-22 18:45:08 +02:00
Hugo Locurcio 9a94fe7d26
Improve the `String::humanize_size()` method
- Use "B" insted of "Bytes" to be more compact
- Use suffixes that denote a binary prefix
- Make suffixes localizable

This removes the need for the custom
`EditorNetworkProfiler:_format_bandwidth()` method.
2019-09-05 19:48:46 +02:00
Bhupendra Aole 073f625a91 Create a GDScript String function repeat
Fixes #30610
2019-09-03 13:06:13 -04:00
qarmin 33c62db7af Add forgotten pointer checking 2019-08-24 13:34:14 +02:00