mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Validate theme type name input in Add Theme Type dialog
This commit is contained in:
parent
4ebf67c12d
commit
e5373c5cb0
3 changed files with 25 additions and 19 deletions
|
|
@ -176,8 +176,10 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
|
||||
// Static helpers.
|
||||
bool Theme::is_valid_type_name(const String &p_name) {
|
||||
for (int i = 0; i < p_name.length(); i++) {
|
||||
if (!is_ascii_identifier_char(p_name[i])) {
|
||||
int len = p_name.length();
|
||||
const char32_t *str = p_name.ptr();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!is_ascii_identifier_char(str[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -188,14 +190,28 @@ bool Theme::is_valid_item_name(const String &p_name) {
|
|||
if (p_name.is_empty()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < p_name.length(); i++) {
|
||||
if (!is_ascii_identifier_char(p_name[i])) {
|
||||
int len = p_name.length();
|
||||
const char32_t *str = p_name.ptr();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!is_ascii_identifier_char(str[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String Theme::validate_type_name(const String &p_name) {
|
||||
String type_name = p_name.strip_edges();
|
||||
int len = type_name.length();
|
||||
char32_t *buffer = type_name.ptrw();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!is_ascii_identifier_char(buffer[i])) {
|
||||
buffer[i] = '_';
|
||||
}
|
||||
}
|
||||
return type_name;
|
||||
}
|
||||
|
||||
// Fallback values for theme item types, configurable per theme.
|
||||
void Theme::set_default_base_scale(float p_base_scale) {
|
||||
if (default_base_scale == p_base_scale) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue