diff options
68 files changed, 1516 insertions, 1334 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 25dd408dce..0d699cdacb 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1104,6 +1104,8 @@ ProjectSettings::ProjectSettings() { } extensions.push_back("shader"); + GLOBAL_DEF("editor/run/main_run_args", ""); + GLOBAL_DEF("editor/script/search_in_file_extensions", extensions); custom_prop_info["editor/script/search_in_file_extensions"] = PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/script/search_in_file_extensions"); diff --git a/core/math/color.cpp b/core/math/color.cpp index 8affb07e8c..64abd6dd08 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -379,11 +379,11 @@ int Color::find_named_color(const String &p_name) { name = name.replace("_", ""); name = name.replace("'", ""); name = name.replace(".", ""); - name = name.to_lower(); + name = name.to_upper(); int idx = 0; while (named_colors[idx].name != nullptr) { - if (name == named_colors[idx].name) { + if (name == String(named_colors[idx].name).replace("_", "")) { return idx; } idx++; diff --git a/core/math/color_names.inc b/core/math/color_names.inc index e5b935ea9c..2020bdbfca 100644 --- a/core/math/color_names.inc +++ b/core/math/color_names.inc @@ -9,152 +9,155 @@ struct NamedColor { Color color; }; +// NOTE: This data is duplicated in the file: +// modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs + static NamedColor named_colors[] = { - { "aliceblue", Color(0.94, 0.97, 1.00) }, - { "antiquewhite", Color(0.98, 0.92, 0.84) }, - { "aqua", Color(0.00, 1.00, 1.00) }, - { "aquamarine", Color(0.50, 1.00, 0.83) }, - { "azure", Color(0.94, 1.00, 1.00) }, - { "beige", Color(0.96, 0.96, 0.86) }, - { "bisque", Color(1.00, 0.89, 0.77) }, - { "black", Color(0.00, 0.00, 0.00) }, - { "blanchedalmond", Color(1.00, 0.92, 0.80) }, - { "blue", Color(0.00, 0.00, 1.00) }, - { "blueviolet", Color(0.54, 0.17, 0.89) }, - { "brown", Color(0.65, 0.16, 0.16) }, - { "burlywood", Color(0.87, 0.72, 0.53) }, - { "cadetblue", Color(0.37, 0.62, 0.63) }, - { "chartreuse", Color(0.50, 1.00, 0.00) }, - { "chocolate", Color(0.82, 0.41, 0.12) }, - { "coral", Color(1.00, 0.50, 0.31) }, - { "cornflower", Color(0.39, 0.58, 0.93) }, - { "cornsilk", Color(1.00, 0.97, 0.86) }, - { "crimson", Color(0.86, 0.08, 0.24) }, - { "cyan", Color(0.00, 1.00, 1.00) }, - { "darkblue", Color(0.00, 0.00, 0.55) }, - { "darkcyan", Color(0.00, 0.55, 0.55) }, - { "darkgoldenrod", Color(0.72, 0.53, 0.04) }, - { "darkgray", Color(0.66, 0.66, 0.66) }, - { "darkgreen", Color(0.00, 0.39, 0.00) }, - { "darkkhaki", Color(0.74, 0.72, 0.42) }, - { "darkmagenta", Color(0.55, 0.00, 0.55) }, - { "darkolivegreen", Color(0.33, 0.42, 0.18) }, - { "darkorange", Color(1.00, 0.55, 0.00) }, - { "darkorchid", Color(0.60, 0.20, 0.80) }, - { "darkred", Color(0.55, 0.00, 0.00) }, - { "darksalmon", Color(0.91, 0.59, 0.48) }, - { "darkseagreen", Color(0.56, 0.74, 0.56) }, - { "darkslateblue", Color(0.28, 0.24, 0.55) }, - { "darkslategray", Color(0.18, 0.31, 0.31) }, - { "darkturquoise", Color(0.00, 0.81, 0.82) }, - { "darkviolet", Color(0.58, 0.00, 0.83) }, - { "deeppink", Color(1.00, 0.08, 0.58) }, - { "deepskyblue", Color(0.00, 0.75, 1.00) }, - { "dimgray", Color(0.41, 0.41, 0.41) }, - { "dodgerblue", Color(0.12, 0.56, 1.00) }, - { "firebrick", Color(0.70, 0.13, 0.13) }, - { "floralwhite", Color(1.00, 0.98, 0.94) }, - { "forestgreen", Color(0.13, 0.55, 0.13) }, - { "fuchsia", Color(1.00, 0.00, 1.00) }, - { "gainsboro", Color(0.86, 0.86, 0.86) }, - { "ghostwhite", Color(0.97, 0.97, 1.00) }, - { "gold", Color(1.00, 0.84, 0.00) }, - { "goldenrod", Color(0.85, 0.65, 0.13) }, - { "gray", Color(0.75, 0.75, 0.75) }, - { "green", Color(0.00, 1.00, 0.00) }, - { "greenyellow", Color(0.68, 1.00, 0.18) }, - { "honeydew", Color(0.94, 1.00, 0.94) }, - { "hotpink", Color(1.00, 0.41, 0.71) }, - { "indianred", Color(0.80, 0.36, 0.36) }, - { "indigo", Color(0.29, 0.00, 0.51) }, - { "ivory", Color(1.00, 1.00, 0.94) }, - { "khaki", Color(0.94, 0.90, 0.55) }, - { "lavender", Color(0.90, 0.90, 0.98) }, - { "lavenderblush", Color(1.00, 0.94, 0.96) }, - { "lawngreen", Color(0.49, 0.99, 0.00) }, - { "lemonchiffon", Color(1.00, 0.98, 0.80) }, - { "lightblue", Color(0.68, 0.85, 0.90) }, - { "lightcoral", Color(0.94, 0.50, 0.50) }, - { "lightcyan", Color(0.88, 1.00, 1.00) }, - { "lightgoldenrod", Color(0.98, 0.98, 0.82) }, - { "lightgray", Color(0.83, 0.83, 0.83) }, - { "lightgreen", Color(0.56, 0.93, 0.56) }, - { "lightpink", Color(1.00, 0.71, 0.76) }, - { "lightsalmon", Color(1.00, 0.63, 0.48) }, - { "lightseagreen", Color(0.13, 0.70, 0.67) }, - { "lightskyblue", Color(0.53, 0.81, 0.98) }, - { "lightslategray", Color(0.47, 0.53, 0.60) }, - { "lightsteelblue", Color(0.69, 0.77, 0.87) }, - { "lightyellow", Color(1.00, 1.00, 0.88) }, - { "lime", Color(0.00, 1.00, 0.00) }, - { "limegreen", Color(0.20, 0.80, 0.20) }, - { "linen", Color(0.98, 0.94, 0.90) }, - { "magenta", Color(1.00, 0.00, 1.00) }, - { "maroon", Color(0.69, 0.19, 0.38) }, - { "mediumaquamarine", Color(0.40, 0.80, 0.67) }, - { "mediumblue", Color(0.00, 0.00, 0.80) }, - { "mediumorchid", Color(0.73, 0.33, 0.83) }, - { "mediumpurple", Color(0.58, 0.44, 0.86) }, - { "mediumseagreen", Color(0.24, 0.70, 0.44) }, - { "mediumslateblue", Color(0.48, 0.41, 0.93) }, - { "mediumspringgreen", Color(0.00, 0.98, 0.60) }, - { "mediumturquoise", Color(0.28, 0.82, 0.80) }, - { "mediumvioletred", Color(0.78, 0.08, 0.52) }, - { "midnightblue", Color(0.10, 0.10, 0.44) }, - { "mintcream", Color(0.96, 1.00, 0.98) }, - { "mistyrose", Color(1.00, 0.89, 0.88) }, - { "moccasin", Color(1.00, 0.89, 0.71) }, - { "navajowhite", Color(1.00, 0.87, 0.68) }, - { "navyblue", Color(0.00, 0.00, 0.50) }, - { "oldlace", Color(0.99, 0.96, 0.90) }, - { "olive", Color(0.50, 0.50, 0.00) }, - { "olivedrab", Color(0.42, 0.56, 0.14) }, - { "orange", Color(1.00, 0.65, 0.00) }, - { "orangered", Color(1.00, 0.27, 0.00) }, - { "orchid", Color(0.85, 0.44, 0.84) }, - { "palegoldenrod", Color(0.93, 0.91, 0.67) }, - { "palegreen", Color(0.60, 0.98, 0.60) }, - { "paleturquoise", Color(0.69, 0.93, 0.93) }, - { "palevioletred", Color(0.86, 0.44, 0.58) }, - { "papayawhip", Color(1.00, 0.94, 0.84) }, - { "peachpuff", Color(1.00, 0.85, 0.73) }, - { "peru", Color(0.80, 0.52, 0.25) }, - { "pink", Color(1.00, 0.75, 0.80) }, - { "plum", Color(0.87, 0.63, 0.87) }, - { "powderblue", Color(0.69, 0.88, 0.90) }, - { "purple", Color(0.63, 0.13, 0.94) }, - { "rebeccapurple", Color(0.40, 0.20, 0.60) }, - { "red", Color(1.00, 0.00, 0.00) }, - { "rosybrown", Color(0.74, 0.56, 0.56) }, - { "royalblue", Color(0.25, 0.41, 0.88) }, - { "saddlebrown", Color(0.55, 0.27, 0.07) }, - { "salmon", Color(0.98, 0.50, 0.45) }, - { "sandybrown", Color(0.96, 0.64, 0.38) }, - { "seagreen", Color(0.18, 0.55, 0.34) }, - { "seashell", Color(1.00, 0.96, 0.93) }, - { "sienna", Color(0.63, 0.32, 0.18) }, - { "silver", Color(0.75, 0.75, 0.75) }, - { "skyblue", Color(0.53, 0.81, 0.92) }, - { "slateblue", Color(0.42, 0.35, 0.80) }, - { "slategray", Color(0.44, 0.50, 0.56) }, - { "snow", Color(1.00, 0.98, 0.98) }, - { "springgreen", Color(0.00, 1.00, 0.50) }, - { "steelblue", Color(0.27, 0.51, 0.71) }, - { "tan", Color(0.82, 0.71, 0.55) }, - { "teal", Color(0.00, 0.50, 0.50) }, - { "thistle", Color(0.85, 0.75, 0.85) }, - { "tomato", Color(1.00, 0.39, 0.28) }, - { "transparent", Color(1.00, 1.00, 1.00, 0.00) }, - { "turquoise", Color(0.25, 0.88, 0.82) }, - { "violet", Color(0.93, 0.51, 0.93) }, - { "webgray", Color(0.50, 0.50, 0.50) }, - { "webgreen", Color(0.00, 0.50, 0.00) }, - { "webmaroon", Color(0.50, 0.00, 0.00) }, - { "webpurple", Color(0.50, 0.00, 0.50) }, - { "wheat", Color(0.96, 0.87, 0.70) }, - { "white", Color(1.00, 1.00, 1.00) }, - { "whitesmoke", Color(0.96, 0.96, 0.96) }, - { "yellow", Color(1.00, 1.00, 0.00) }, - { "yellowgreen", Color(0.60, 0.80, 0.20) }, + { "ALICE_BLUE", Color(0.94, 0.97, 1.00) }, + { "ANTIQUE_WHITE", Color(0.98, 0.92, 0.84) }, + { "AQUA", Color(0.00, 1.00, 1.00) }, + { "AQUAMARINE", Color(0.50, 1.00, 0.83) }, + { "AZURE", Color(0.94, 1.00, 1.00) }, + { "BEIGE", Color(0.96, 0.96, 0.86) }, + { "BISQUE", Color(1.00, 0.89, 0.77) }, + { "BLACK", Color(0.00, 0.00, 0.00) }, + { "BLANCHED_ALMOND", Color(1.00, 0.92, 0.80) }, + { "BLUE", Color(0.00, 0.00, 1.00) }, + { "BLUE_VIOLET", Color(0.54, 0.17, 0.89) }, + { "BROWN", Color(0.65, 0.16, 0.16) }, + { "BURLYWOOD", Color(0.87, 0.72, 0.53) }, + { "CADET_BLUE", Color(0.37, 0.62, 0.63) }, + { "CHARTREUSE", Color(0.50, 1.00, 0.00) }, + { "CHOCOLATE", Color(0.82, 0.41, 0.12) }, + { "CORAL", Color(1.00, 0.50, 0.31) }, + { "CORNFLOWER_BLUE", Color(0.39, 0.58, 0.93) }, + { "CORNSILK", Color(1.00, 0.97, 0.86) }, + { "CRIMSON", Color(0.86, 0.08, 0.24) }, + { "CYAN", Color(0.00, 1.00, 1.00) }, + { "DARK_BLUE", Color(0.00, 0.00, 0.55) }, + { "DARK_CYAN", Color(0.00, 0.55, 0.55) }, + { "DARK_GOLDENROD", Color(0.72, 0.53, 0.04) }, + { "DARK_GRAY", Color(0.66, 0.66, 0.66) }, + { "DARK_GREEN", Color(0.00, 0.39, 0.00) }, + { "DARK_KHAKI", Color(0.74, 0.72, 0.42) }, + { "DARK_MAGENTA", Color(0.55, 0.00, 0.55) }, + { "DARK_OLIVE_GREEN", Color(0.33, 0.42, 0.18) }, + { "DARK_ORANGE", Color(1.00, 0.55, 0.00) }, + { "DARK_ORCHID", Color(0.60, 0.20, 0.80) }, + { "DARK_RED", Color(0.55, 0.00, 0.00) }, + { "DARK_SALMON", Color(0.91, 0.59, 0.48) }, + { "DARK_SEA_GREEN", Color(0.56, 0.74, 0.56) }, + { "DARK_SLATE_BLUE", Color(0.28, 0.24, 0.55) }, + { "DARK_SLATE_GRAY", Color(0.18, 0.31, 0.31) }, + { "DARK_TURQUOISE", Color(0.00, 0.81, 0.82) }, + { "DARK_VIOLET", Color(0.58, 0.00, 0.83) }, + { "DEEP_PINK", Color(1.00, 0.08, 0.58) }, + { "DEEP_SKY_BLUE", Color(0.00, 0.75, 1.00) }, + { "DIM_GRAY", Color(0.41, 0.41, 0.41) }, + { "DODGER_BLUE", Color(0.12, 0.56, 1.00) }, + { "FIREBRICK", Color(0.70, 0.13, 0.13) }, + { "FLORAL_WHITE", Color(1.00, 0.98, 0.94) }, + { "FOREST_GREEN", Color(0.13, 0.55, 0.13) }, + { "FUCHSIA", Color(1.00, 0.00, 1.00) }, + { "GAINSBORO", Color(0.86, 0.86, 0.86) }, + { "GHOST_WHITE", Color(0.97, 0.97, 1.00) }, + { "GOLD", Color(1.00, 0.84, 0.00) }, + { "GOLDENROD", Color(0.85, 0.65, 0.13) }, + { "GRAY", Color(0.75, 0.75, 0.75) }, + { "GREEN", Color(0.00, 1.00, 0.00) }, + { "GREEN_YELLOW", Color(0.68, 1.00, 0.18) }, + { "HONEYDEW", Color(0.94, 1.00, 0.94) }, + { "HOT_PINK", Color(1.00, 0.41, 0.71) }, + { "INDIAN_RED", Color(0.80, 0.36, 0.36) }, + { "INDIGO", Color(0.29, 0.00, 0.51) }, + { "IVORY", Color(1.00, 1.00, 0.94) }, + { "KHAKI", Color(0.94, 0.90, 0.55) }, + { "LAVENDER", Color(0.90, 0.90, 0.98) }, + { "LAVENDER_BLUSH", Color(1.00, 0.94, 0.96) }, + { "LAWN_GREEN", Color(0.49, 0.99, 0.00) }, + { "LEMON_CHIFFON", Color(1.00, 0.98, 0.80) }, + { "LIGHT_BLUE", Color(0.68, 0.85, 0.90) }, + { "LIGHT_CORAL", Color(0.94, 0.50, 0.50) }, + { "LIGHT_CYAN", Color(0.88, 1.00, 1.00) }, + { "LIGHT_GOLDENROD", Color(0.98, 0.98, 0.82) }, + { "LIGHT_GRAY", Color(0.83, 0.83, 0.83) }, + { "LIGHT_GREEN", Color(0.56, 0.93, 0.56) }, + { "LIGHT_PINK", Color(1.00, 0.71, 0.76) }, + { "LIGHT_SALMON", Color(1.00, 0.63, 0.48) }, + { "LIGHT_SEA_GREEN", Color(0.13, 0.70, 0.67) }, + { "LIGHT_SKY_BLUE", Color(0.53, 0.81, 0.98) }, + { "LIGHT_SLATE_GRAY", Color(0.47, 0.53, 0.60) }, + { "LIGHT_STEEL_BLUE", Color(0.69, 0.77, 0.87) }, + { "LIGHT_YELLOW", Color(1.00, 1.00, 0.88) }, + { "LIME", Color(0.00, 1.00, 0.00) }, + { "LIME_GREEN", Color(0.20, 0.80, 0.20) }, + { "LINEN", Color(0.98, 0.94, 0.90) }, + { "MAGENTA", Color(1.00, 0.00, 1.00) }, + { "MAROON", Color(0.69, 0.19, 0.38) }, + { "MEDIUM_AQUAMARINE", Color(0.40, 0.80, 0.67) }, + { "MEDIUM_BLUE", Color(0.00, 0.00, 0.80) }, + { "MEDIUM_ORCHID", Color(0.73, 0.33, 0.83) }, + { "MEDIUM_PURPLE", Color(0.58, 0.44, 0.86) }, + { "MEDIUM_SEA_GREEN", Color(0.24, 0.70, 0.44) }, + { "MEDIUM_SLATE_BLUE", Color(0.48, 0.41, 0.93) }, + { "MEDIUM_SPRING_GREEN", Color(0.00, 0.98, 0.60) }, + { "MEDIUM_TURQUOISE", Color(0.28, 0.82, 0.80) }, + { "MEDIUM_VIOLET_RED", Color(0.78, 0.08, 0.52) }, + { "MIDNIGHT_BLUE", Color(0.10, 0.10, 0.44) }, + { "MINT_CREAM", Color(0.96, 1.00, 0.98) }, + { "MISTY_ROSE", Color(1.00, 0.89, 0.88) }, + { "MOCCASIN", Color(1.00, 0.89, 0.71) }, + { "NAVAJO_WHITE", Color(1.00, 0.87, 0.68) }, + { "NAVY_BLUE", Color(0.00, 0.00, 0.50) }, + { "OLD_LACE", Color(0.99, 0.96, 0.90) }, + { "OLIVE", Color(0.50, 0.50, 0.00) }, + { "OLIVE_DRAB", Color(0.42, 0.56, 0.14) }, + { "ORANGE", Color(1.00, 0.65, 0.00) }, + { "ORANGE_RED", Color(1.00, 0.27, 0.00) }, + { "ORCHID", Color(0.85, 0.44, 0.84) }, + { "PALE_GOLDENROD", Color(0.93, 0.91, 0.67) }, + { "PALE_GREEN", Color(0.60, 0.98, 0.60) }, + { "PALE_TURQUOISE", Color(0.69, 0.93, 0.93) }, + { "PALE_VIOLET_RED", Color(0.86, 0.44, 0.58) }, + { "PAPAYA_WHIP", Color(1.00, 0.94, 0.84) }, + { "PEACH_PUFF", Color(1.00, 0.85, 0.73) }, + { "PERU", Color(0.80, 0.52, 0.25) }, + { "PINK", Color(1.00, 0.75, 0.80) }, + { "PLUM", Color(0.87, 0.63, 0.87) }, + { "POWDER_BLUE", Color(0.69, 0.88, 0.90) }, + { "PURPLE", Color(0.63, 0.13, 0.94) }, + { "REBECCA_PURPLE", Color(0.40, 0.20, 0.60) }, + { "RED", Color(1.00, 0.00, 0.00) }, + { "ROSY_BROWN", Color(0.74, 0.56, 0.56) }, + { "ROYAL_BLUE", Color(0.25, 0.41, 0.88) }, + { "SADDLE_BROWN", Color(0.55, 0.27, 0.07) }, + { "SALMON", Color(0.98, 0.50, 0.45) }, + { "SANDY_BROWN", Color(0.96, 0.64, 0.38) }, + { "SEA_GREEN", Color(0.18, 0.55, 0.34) }, + { "SEASHELL", Color(1.00, 0.96, 0.93) }, + { "SIENNA", Color(0.63, 0.32, 0.18) }, + { "SILVER", Color(0.75, 0.75, 0.75) }, + { "SKY_BLUE", Color(0.53, 0.81, 0.92) }, + { "SLATE_BLUE", Color(0.42, 0.35, 0.80) }, + { "SLATE_GRAY", Color(0.44, 0.50, 0.56) }, + { "SNOW", Color(1.00, 0.98, 0.98) }, + { "SPRING_GREEN", Color(0.00, 1.00, 0.50) }, + { "STEEL_BLUE", Color(0.27, 0.51, 0.71) }, + { "TAN", Color(0.82, 0.71, 0.55) }, + { "TEAL", Color(0.00, 0.50, 0.50) }, + { "THISTLE", Color(0.85, 0.75, 0.85) }, + { "TOMATO", Color(1.00, 0.39, 0.28) }, + { "TRANSPARENT", Color(1.00, 1.00, 1.00, 0.00) }, + { "TURQUOISE", Color(0.25, 0.88, 0.82) }, + { "VIOLET", Color(0.93, 0.51, 0.93) }, + { "WEB_GRAY", Color(0.50, 0.50, 0.50) }, + { "WEB_GREEN", Color(0.00, 0.50, 0.00) }, + { "WEB_MAROON", Color(0.50, 0.00, 0.00) }, + { "WEB_PURPLE", Color(0.50, 0.00, 0.50) }, + { "WHEAT", Color(0.96, 0.87, 0.70) }, + { "WHITE", Color(1.00, 1.00, 1.00) }, + { "WHITE_SMOKE", Color(0.96, 0.96, 0.96) }, + { "YELLOW", Color(1.00, 1.00, 0.00) }, + { "YELLOW_GREEN", Color(0.60, 0.80, 0.20) }, { nullptr, Color() }, }; diff --git a/core/object/script_language.h b/core/object/script_language.h index f9898ccd0c..bb46c718b2 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -303,6 +303,7 @@ public: void get_core_type_words(List<String> *p_core_type_words) const; virtual void get_reserved_words(List<String> *p_words) const = 0; + virtual bool is_control_flow_keyword(String p_string) const = 0; virtual void get_comment_delimiters(List<String> *p_delimiters) const = 0; virtual void get_string_delimiters(List<String> *p_delimiters) const = 0; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const = 0; diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2fb2dd4a30..3c7e2a0719 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -361,6 +361,79 @@ Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // l return new_arr; } +Array Array::filter(const Callable &p_callable) const { + Array new_arr; + new_arr.resize(size()); + int accepted_count = 0; + + for (int i = 0; i < size(); i++) { + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *)); + argptrs[0] = &get(i); + + Variant result; + Callable::CallError ce; + p_callable.call(argptrs, 1, result, ce); + if (ce.error != Callable::CallError::CALL_OK) { + ERR_FAIL_V_MSG(Array(), "Error calling method from 'filter': " + Variant::get_callable_error_text(p_callable, argptrs, 1, ce)); + } + + if (result.operator bool()) { + new_arr[accepted_count] = get(i); + accepted_count++; + } + } + + new_arr.resize(accepted_count); + + return new_arr; +} + +Array Array::map(const Callable &p_callable) const { + Array new_arr; + new_arr.resize(size()); + + for (int i = 0; i < size(); i++) { + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *)); + argptrs[0] = &get(i); + + Variant result; + Callable::CallError ce; + p_callable.call(argptrs, 1, result, ce); + if (ce.error != Callable::CallError::CALL_OK) { + ERR_FAIL_V_MSG(Array(), "Error calling method from 'map': " + Variant::get_callable_error_text(p_callable, argptrs, 1, ce)); + } + + new_arr[i] = result; + } + + return new_arr; +} + +Variant Array::reduce(const Callable &p_callable, const Variant &p_accum) const { + int start = 0; + Variant ret = p_accum; + if (ret == Variant() && size() > 0) { + ret = front(); + start = 1; + } + + for (int i = start; i < size(); i++) { + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * 2); + argptrs[0] = &ret; + argptrs[1] = &get(i); + + Variant result; + Callable::CallError ce; + p_callable.call(argptrs, 2, result, ce); + if (ce.error != Callable::CallError::CALL_OK) { + ERR_FAIL_V_MSG(Variant(), "Error calling method from 'reduce': " + Variant::get_callable_error_text(p_callable, argptrs, 2, ce)); + } + ret = result; + } + + return ret; +} + struct _ArrayVariantSort { _FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const { bool valid = false; diff --git a/core/variant/array.h b/core/variant/array.h index 5ce977ee4b..540dcb1f4e 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -101,6 +101,9 @@ public: Array duplicate(bool p_deep = false) const; Array slice(int p_begin, int p_end, int p_step = 1, bool p_deep = false) const; + Array filter(const Callable &p_callable) const; + Array map(const Callable &p_callable) const; + Variant reduce(const Callable &p_callable, const Variant &p_accum) const; bool operator<(const Array &p_array) const; bool operator<=(const Array &p_array) const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 455e924568..efaaa8cd19 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1745,6 +1745,9 @@ static void _register_variant_builtin_methods() { bind_method(Array, reverse, sarray(), varray()); bind_method(Array, duplicate, sarray("deep"), varray(false)); bind_method(Array, slice, sarray("begin", "end", "step", "deep"), varray(1, false)); + bind_method(Array, filter, sarray("method"), varray()); + bind_method(Array, map, sarray("method"), varray()); + bind_method(Array, reduce, sarray("method", "accum"), varray(Variant())); bind_method(Array, max, sarray(), varray()); bind_method(Array, min, sarray(), varray()); diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 38b74cb436..624b51e463 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -258,6 +258,24 @@ [/codeblocks] </description> </method> + <method name="filter" qualifiers="const"> + <return type="Array"> + </return> + <argument index="0" name="method" type="Callable"> + </argument> + <description> + Calls the provided [Callable] on each element in the array and returns a new array with the elements for which the method returned [code]true[/code]. + The callable's method should take one [Variant] parameter (the current array element) and return a boolean value. + [codeblock] + func _ready(): + print([1, 2, 3].filter(remove_1)) # Prints [2, 3]. + print([1, 2, 3].filter(func(number): return number != 1)) # Same as above, but using lambda function. + + func remove_1(number): + return number != 1 + [/codeblock] + </description> + </method> <method name="find" qualifiers="const"> <return type="int"> </return> @@ -356,6 +374,24 @@ Returns [code]true[/code] if the array is empty. </description> </method> + <method name="map" qualifiers="const"> + <return type="Array"> + </return> + <argument index="0" name="method" type="Callable"> + </argument> + <description> + Calls the provided [Callable] for each element in the array and returns a new array filled with values returned by the method. + The callable's method should take one [Variant] parameter (the current array element) and can return any [Variant]. + [codeblock] + func _ready(): + print([1, 2, 3].map(negate)) # Prints [-1, -2, -3]. + print([1, 2, 3].map(func(number): return -number)) # Same as above, but using lambda function. + + func negate(number): + return -number + [/codeblock] + </description> + </method> <method name="max" qualifiers="const"> <return type="Variant"> </return> @@ -468,6 +504,26 @@ [b]Note:[/b] On large arrays, this method is much slower than [method push_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method push_front] will be. </description> </method> + <method name="reduce" qualifiers="const"> + <return type="Variant"> + </return> + <argument index="0" name="method" type="Callable"> + </argument> + <argument index="1" name="accum" type="Variant" default="null"> + </argument> + <description> + Calls the provided [Callable] for each element in array and accumulates the result in [code]accum[/code]. + The callable's method takes two arguments: the current value of [code]accum[/code] and the current array element. If [code]accum[/code] is [code]null[/code] (default value), the iteration will start from the second element, with the first one used as initial value of [code]accum[/code]. + [codeblock] + func _ready(): + print([1, 2, 3].reduce(sum, 10)) # Prints 16. + print([1, 2, 3].reduce(func(accum, number): return accum + number, 10)) # Same as above, but using lambda function. + + func sum(accum, number): + return accum + number + [/codeblock] + </description> + </method> <method name="remove"> <return type="void"> </return> diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml index 5aa2d699a8..0b31352611 100644 --- a/doc/classes/ButtonGroup.xml +++ b/doc/classes/ButtonGroup.xml @@ -28,6 +28,15 @@ <members> <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> </members> + <signals> + <signal name="pressed"> + <argument index="0" name="button" type="Object"> + </argument> + <description> + Emitted when one of the buttons of the group is pressed. + </description> + </signal> + </signals> <constants> </constants> </class> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index d645588af2..6133bb8d8c 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -564,442 +564,442 @@ </member> </members> <constants> - <constant name="aliceblue" value="Color( 0.94, 0.97, 1, 1 )"> + <constant name="ALICE_BLUE" value="Color( 0.94, 0.97, 1, 1 )"> Alice blue color. </constant> - <constant name="antiquewhite" value="Color( 0.98, 0.92, 0.84, 1 )"> + <constant name="ANTIQUE_WHITE" value="Color( 0.98, 0.92, 0.84, 1 )"> Antique white color. </constant> - <constant name="aqua" value="Color( 0, 1, 1, 1 )"> + <constant name="AQUA" value="Color( 0, 1, 1, 1 )"> Aqua color. </constant> - <constant name="aquamarine" value="Color( 0.5, 1, 0.83, 1 )"> + <constant name="AQUAMARINE" value="Color( 0.5, 1, 0.83, 1 )"> Aquamarine color. </constant> - <constant name="azure" value="Color( 0.94, 1, 1, 1 )"> + <constant name="AZURE" value="Color( 0.94, 1, 1, 1 )"> Azure color. </constant> - <constant name="beige" value="Color( 0.96, 0.96, 0.86, 1 )"> + <constant name="BEIGE" value="Color( 0.96, 0.96, 0.86, 1 )"> Beige color. </constant> - <constant name="bisque" value="Color( 1, 0.89, 0.77, 1 )"> + <constant name="BISQUE" value="Color( 1, 0.89, 0.77, 1 )"> Bisque color. </constant> - <constant name="black" value="Color( 0, 0, 0, 1 )"> + <constant name="BLACK" value="Color( 0, 0, 0, 1 )"> Black color. </constant> - <constant name="blanchedalmond" value="Color( 1, 0.92, 0.8, 1 )"> - Blanche almond color. + <constant name="BLANCHED_ALMOND" value="Color( 1, 0.92, 0.8, 1 )"> + Blanched almond color. </constant> - <constant name="blue" value="Color( 0, 0, 1, 1 )"> + <constant name="BLUE" value="Color( 0, 0, 1, 1 )"> Blue color. </constant> - <constant name="blueviolet" value="Color( 0.54, 0.17, 0.89, 1 )"> + <constant name="BLUE_VIOLET" value="Color( 0.54, 0.17, 0.89, 1 )"> Blue violet color. </constant> - <constant name="brown" value="Color( 0.65, 0.16, 0.16, 1 )"> + <constant name="BROWN" value="Color( 0.65, 0.16, 0.16, 1 )"> Brown color. </constant> - <constant name="burlywood" value="Color( 0.87, 0.72, 0.53, 1 )"> - Burly wood color. + <constant name="BURLYWOOD" value="Color( 0.87, 0.72, 0.53, 1 )"> + Burlywood color. </constant> - <constant name="cadetblue" value="Color( 0.37, 0.62, 0.63, 1 )"> + <constant name="CADET_BLUE" value="Color( 0.37, 0.62, 0.63, 1 )"> Cadet blue color. </constant> - <constant name="chartreuse" value="Color( 0.5, 1, 0, 1 )"> + <constant name="CHARTREUSE" value="Color( 0.5, 1, 0, 1 )"> Chartreuse color. </constant> - <constant name="chocolate" value="Color( 0.82, 0.41, 0.12, 1 )"> + <constant name="CHOCOLATE" value="Color( 0.82, 0.41, 0.12, 1 )"> Chocolate color. </constant> - <constant name="coral" value="Color( 1, 0.5, 0.31, 1 )"> + <constant name="CORAL" value="Color( 1, 0.5, 0.31, 1 )"> Coral color. </constant> - <constant name="cornflower" value="Color( 0.39, 0.58, 0.93, 1 )"> - Cornflower color. + <constant name="CORNFLOWER_BLUE" value="Color( 0.39, 0.58, 0.93, 1 )"> + Cornflower blue color. </constant> - <constant name="cornsilk" value="Color( 1, 0.97, 0.86, 1 )"> - Corn silk color. + <constant name="CORNSILK" value="Color( 1, 0.97, 0.86, 1 )"> + Cornsilk color. </constant> - <constant name="crimson" value="Color( 0.86, 0.08, 0.24, 1 )"> + <constant name="CRIMSON" value="Color( 0.86, 0.08, 0.24, 1 )"> Crimson color. </constant> - <constant name="cyan" value="Color( 0, 1, 1, 1 )"> + <constant name="CYAN" value="Color( 0, 1, 1, 1 )"> Cyan color. </constant> - <constant name="darkblue" value="Color( 0, 0, 0.55, 1 )"> + <constant name="DARK_BLUE" value="Color( 0, 0, 0.55, 1 )"> Dark blue color. </constant> - <constant name="darkcyan" value="Color( 0, 0.55, 0.55, 1 )"> + <constant name="DARK_CYAN" value="Color( 0, 0.55, 0.55, 1 )"> Dark cyan color. </constant> - <constant name="darkgoldenrod" value="Color( 0.72, 0.53, 0.04, 1 )"> + <constant name="DARK_GOLDENROD" value="Color( 0.72, 0.53, 0.04, 1 )"> Dark goldenrod color. </constant> - <constant name="darkgray" value="Color( 0.66, 0.66, 0.66, 1 )"> + <constant name="DARK_GRAY" value="Color( 0.66, 0.66, 0.66, 1 )"> Dark gray color. </constant> - <constant name="darkgreen" value="Color( 0, 0.39, 0, 1 )"> + <constant name="DARK_GREEN" value="Color( 0, 0.39, 0, 1 )"> Dark green color. </constant> - <constant name="darkkhaki" value="Color( 0.74, 0.72, 0.42, 1 )"> + <constant name="DARK_KHAKI" value="Color( 0.74, 0.72, 0.42, 1 )"> Dark khaki color. </constant> - <constant name="darkmagenta" value="Color( 0.55, 0, 0.55, 1 )"> + <constant name="DARK_MAGENTA" value="Color( 0.55, 0, 0.55, 1 )"> Dark magenta color. </constant> - <constant name="darkolivegreen" value="Color( 0.33, 0.42, 0.18, 1 )"> + <constant name="DARK_OLIVE_GREEN" value="Color( 0.33, 0.42, 0.18, 1 )"> Dark olive green color. </constant> - <constant name="darkorange" value="Color( 1, 0.55, 0, 1 )"> + <constant name="DARK_ORANGE" value="Color( 1, 0.55, 0, 1 )"> Dark orange color. </constant> - <constant name="darkorchid" value="Color( 0.6, 0.2, 0.8, 1 )"> + <constant name="DARK_ORCHID" value="Color( 0.6, 0.2, 0.8, 1 )"> Dark orchid color. </constant> - <constant name="darkred" value="Color( 0.55, 0, 0, 1 )"> + <constant name="DARK_RED" value="Color( 0.55, 0, 0, 1 )"> Dark red color. </constant> - <constant name="darksalmon" value="Color( 0.91, 0.59, 0.48, 1 )"> + <constant name="DARK_SALMON" value="Color( 0.91, 0.59, 0.48, 1 )"> Dark salmon color. </constant> - <constant name="darkseagreen" value="Color( 0.56, 0.74, 0.56, 1 )"> + <constant name="DARK_SEA_GREEN" value="Color( 0.56, 0.74, 0.56, 1 )"> Dark sea green color. </constant> - <constant name="darkslateblue" value="Color( 0.28, 0.24, 0.55, 1 )"> + <constant name="DARK_SLATE_BLUE" value="Color( 0.28, 0.24, 0.55, 1 )"> Dark slate blue color. </constant> - <constant name="darkslategray" value="Color( 0.18, 0.31, 0.31, 1 )"> + <constant name="DARK_SLATE_GRAY" value="Color( 0.18, 0.31, 0.31, 1 )"> Dark slate gray color. </constant> - <constant name="darkturquoise" value="Color( 0, 0.81, 0.82, 1 )"> + <constant name="DARK_TURQUOISE" value="Color( 0, 0.81, 0.82, 1 )"> Dark turquoise color. </constant> - <constant name="darkviolet" value="Color( 0.58, 0, 0.83, 1 )"> + <constant name="DARK_VIOLET" value="Color( 0.58, 0, 0.83, 1 )"> Dark violet color. </constant> - <constant name="deeppink" value="Color( 1, 0.08, 0.58, 1 )"> + <constant name="DEEP_PINK" value="Color( 1, 0.08, 0.58, 1 )"> Deep pink color. </constant> - <constant name="deepskyblue" value="Color( 0, 0.75, 1, 1 )"> + <constant name="DEEP_SKY_BLUE" value="Color( 0, 0.75, 1, 1 )"> Deep sky blue color. </constant> - <constant name="dimgray" value="Color( 0.41, 0.41, 0.41, 1 )"> + <constant name="DIM_GRAY" value="Color( 0.41, 0.41, 0.41, 1 )"> Dim gray color. </constant> - <constant name="dodgerblue" value="Color( 0.12, 0.56, 1, 1 )"> + <constant name="DODGER_BLUE" value="Color( 0.12, 0.56, 1, 1 )"> Dodger blue color. </constant> - <constant name="firebrick" value="Color( 0.7, 0.13, 0.13, 1 )"> + <constant name="FIREBRICK" value="Color( 0.7, 0.13, 0.13, 1 )"> Firebrick color. </constant> - <constant name="floralwhite" value="Color( 1, 0.98, 0.94, 1 )"> + <constant name="FLORAL_WHITE" value="Color( 1, 0.98, 0.94, 1 )"> Floral white color. </constant> - <constant name="forestgreen" value="Color( 0.13, 0.55, 0.13, 1 )"> + <constant name="FOREST_GREEN" value="Color( 0.13, 0.55, 0.13, 1 )"> Forest green color. </constant> - <constant name="fuchsia" value="Color( 1, 0, 1, 1 )"> + <constant name="FUCHSIA" value="Color( 1, 0, 1, 1 )"> Fuchsia color. </constant> - <constant name="gainsboro" value="Color( 0.86, 0.86, 0.86, 1 )"> + <constant name="GAINSBORO" value="Color( 0.86, 0.86, 0.86, 1 )"> Gainsboro color. </constant> - <constant name="ghostwhite" value="Color( 0.97, 0.97, 1, 1 )"> + <constant name="GHOST_WHITE" value="Color( 0.97, 0.97, 1, 1 )"> Ghost white color. </constant> - <constant name="gold" value="Color( 1, 0.84, 0, 1 )"> + <constant name="GOLD" value="Color( 1, 0.84, 0, 1 )"> Gold color. </constant> - <constant name="goldenrod" value="Color( 0.85, 0.65, 0.13, 1 )"> + <constant name="GOLDENROD" value="Color( 0.85, 0.65, 0.13, 1 )"> Goldenrod color. </constant> - <constant name="gray" value="Color( 0.75, 0.75, 0.75, 1 )"> + <constant name="GRAY" value="Color( 0.75, 0.75, 0.75, 1 )"> Gray color. </constant> - <constant name="green" value="Color( 0, 1, 0, 1 )"> + <constant name="GREEN" value="Color( 0, 1, 0, 1 )"> Green color. </constant> - <constant name="greenyellow" value="Color( 0.68, 1, 0.18, 1 )"> + <constant name="GREEN_YELLOW" value="Color( 0.68, 1, 0.18, 1 )"> Green yellow color. </constant> - <constant name="honeydew" value="Color( 0.94, 1, 0.94, 1 )"> + <constant name="HONEYDEW" value="Color( 0.94, 1, 0.94, 1 )"> Honeydew color. </constant> - <constant name="hotpink" value="Color( 1, 0.41, 0.71, 1 )"> + <constant name="HOT_PINK" value="Color( 1, 0.41, 0.71, 1 )"> Hot pink color. </constant> - <constant name="indianred" value="Color( 0.8, 0.36, 0.36, 1 )"> + <constant name="INDIAN_RED" value="Color( 0.8, 0.36, 0.36, 1 )"> Indian red color. </constant> - <constant name="indigo" value="Color( 0.29, 0, 0.51, 1 )"> + <constant name="INDIGO" value="Color( 0.29, 0, 0.51, 1 )"> Indigo color. </constant> - <constant name="ivory" value="Color( 1, 1, 0.94, 1 )"> + <constant name="IVORY" value="Color( 1, 1, 0.94, 1 )"> Ivory color. </constant> - <constant name="khaki" value="Color( 0.94, 0.9, 0.55, 1 )"> + <constant name="KHAKI" value="Color( 0.94, 0.9, 0.55, 1 )"> Khaki color. </constant> - <constant name="lavender" value="Color( 0.9, 0.9, 0.98, 1 )"> + <constant name="LAVENDER" value="Color( 0.9, 0.9, 0.98, 1 )"> Lavender color. </constant> - <constant name="lavenderblush" value="Color( 1, 0.94, 0.96, 1 )"> + <constant name="LAVENDER_BLUSH" value="Color( 1, 0.94, 0.96, 1 )"> Lavender blush color. </constant> - <constant name="lawngreen" value="Color( 0.49, 0.99, 0, 1 )"> + <constant name="LAWN_GREEN" value="Color( 0.49, 0.99, 0, 1 )"> Lawn green color. </constant> - <constant name="lemonchiffon" value="Color( 1, 0.98, 0.8, 1 )"> + <constant name="LEMON_CHIFFON" value="Color( 1, 0.98, 0.8, 1 )"> Lemon chiffon color. </constant> - <constant name="lightblue" value="Color( 0.68, 0.85, 0.9, 1 )"> + <constant name="LIGHT_BLUE" value="Color( 0.68, 0.85, 0.9, 1 )"> Light blue color. </constant> - <constant name="lightcoral" value="Color( 0.94, 0.5, 0.5, 1 )"> + <constant name="LIGHT_CORAL" value="Color( 0.94, 0.5, 0.5, 1 )"> Light coral color. </constant> - <constant name="lightcyan" value="Color( 0.88, 1, 1, 1 )"> + <constant name="LIGHT_CYAN" value="Color( 0.88, 1, 1, 1 )"> Light cyan color. </constant> - <constant name="lightgoldenrod" value="Color( 0.98, 0.98, 0.82, 1 )"> + <constant name="LIGHT_GOLDENROD" value="Color( 0.98, 0.98, 0.82, 1 )"> Light goldenrod color. </constant> - <constant name="lightgray" value="Color( 0.83, 0.83, 0.83, 1 )"> + <constant name="LIGHT_GRAY" value="Color( 0.83, 0.83, 0.83, 1 )"> Light gray color. </constant> - <constant name="lightgreen" value="Color( 0.56, 0.93, 0.56, 1 )"> + <constant name="LIGHT_GREEN" value="Color( 0.56, 0.93, 0.56, 1 )"> Light green color. </constant> - <constant name="lightpink" value="Color( 1, 0.71, 0.76, 1 )"> + <constant name="LIGHT_PINK" value="Color( 1, 0.71, 0.76, 1 )"> Light pink color. </constant> - <constant name="lightsalmon" value="Color( 1, 0.63, 0.48, 1 )"> + <constant name="LIGHT_SALMON" value="Color( 1, 0.63, 0.48, 1 )"> Light salmon color. </constant> - <constant name="lightseagreen" value="Color( 0.13, 0.7, 0.67, 1 )"> + <constant name="LIGHT_SEA_GREEN" value="Color( 0.13, 0.7, 0.67, 1 )"> Light sea green color. </constant> - <constant name="lightskyblue" value="Color( 0.53, 0.81, 0.98, 1 )"> + <constant name="LIGHT_SKY_BLUE" value="Color( 0.53, 0.81, 0.98, 1 )"> Light sky blue color. </constant> - <constant name="lightslategray" value="Color( 0.47, 0.53, 0.6, 1 )"> + <constant name="LIGHT_SLATE_GRAY" value="Color( 0.47, 0.53, 0.6, 1 )"> Light slate gray color. </constant> - <constant name="lightsteelblue" value="Color( 0.69, 0.77, 0.87, 1 )"> + <constant name="LIGHT_STEEL_BLUE" value="Color( 0.69, 0.77, 0.87, 1 )"> Light steel blue color. </constant> - <constant name="lightyellow" value="Color( 1, 1, 0.88, 1 )"> + <constant name="LIGHT_YELLOW" value="Color( 1, 1, 0.88, 1 )"> Light yellow color. </constant> - <constant name="lime" value="Color( 0, 1, 0, 1 )"> + <constant name="LIME" value="Color( 0, 1, 0, 1 )"> Lime color. </constant> - <constant name="limegreen" value="Color( 0.2, 0.8, 0.2, 1 )"> + <constant name="LIME_GREEN" value="Color( 0.2, 0.8, 0.2, 1 )"> Lime green color. </constant> - <constant name="linen" value="Color( 0.98, 0.94, 0.9, 1 )"> + <constant name="LINEN" value="Color( 0.98, 0.94, 0.9, 1 )"> Linen color. </constant> - <constant name="magenta" value="Color( 1, 0, 1, 1 )"> + <constant name="MAGENTA" value="Color( 1, 0, 1, 1 )"> Magenta color. </constant> - <constant name="maroon" value="Color( 0.69, 0.19, 0.38, 1 )"> + <constant name="MAROON" value="Color( 0.69, 0.19, 0.38, 1 )"> Maroon color. </constant> - <constant name="mediumaquamarine" value="Color( 0.4, 0.8, 0.67, 1 )"> + <constant name="MEDIUM_AQUAMARINE" value="Color( 0.4, 0.8, 0.67, 1 )"> Medium aquamarine color. </constant> - <constant name="mediumblue" value="Color( 0, 0, 0.8, 1 )"> + <constant name="MEDIUM_BLUE" value="Color( 0, 0, 0.8, 1 )"> Medium blue color. </constant> - <constant name="mediumorchid" value="Color( 0.73, 0.33, 0.83, 1 )"> + <constant name="MEDIUM_ORCHID" value="Color( 0.73, 0.33, 0.83, 1 )"> Medium orchid color. </constant> - <constant name="mediumpurple" value="Color( 0.58, 0.44, 0.86, 1 )"> + <constant name="MEDIUM_PURPLE" value="Color( 0.58, 0.44, 0.86, 1 )"> Medium purple color. </constant> - <constant name="mediumseagreen" value="Color( 0.24, 0.7, 0.44, 1 )"> + <constant name="MEDIUM_SEA_GREEN" value="Color( 0.24, 0.7, 0.44, 1 )"> Medium sea green color. </constant> - <constant name="mediumslateblue" value="Color( 0.48, 0.41, 0.93, 1 )"> + <constant name="MEDIUM_SLATE_BLUE" value="Color( 0.48, 0.41, 0.93, 1 )"> Medium slate blue color. </constant> - <constant name="mediumspringgreen" value="Color( 0, 0.98, 0.6, 1 )"> + <constant name="MEDIUM_SPRING_GREEN" value="Color( 0, 0.98, 0.6, 1 )"> Medium spring green color. </constant> - <constant name="mediumturquoise" value="Color( 0.28, 0.82, 0.8, 1 )"> + <constant name="MEDIUM_TURQUOISE" value="Color( 0.28, 0.82, 0.8, 1 )"> Medium turquoise color. </constant> - <constant name="mediumvioletred" value="Color( 0.78, 0.08, 0.52, 1 )"> + <constant name="MEDIUM_VIOLET_RED" value="Color( 0.78, 0.08, 0.52, 1 )"> Medium violet red color. </constant> - <constant name="midnightblue" value="Color( 0.1, 0.1, 0.44, 1 )"> + <constant name="MIDNIGHT_BLUE" value="Color( 0.1, 0.1, 0.44, 1 )"> Midnight blue color. </constant> - <constant name="mintcream" value="Color( 0.96, 1, 0.98, 1 )"> + <constant name="MINT_CREAM" value="Color( 0.96, 1, 0.98, 1 )"> Mint cream color. </constant> - <constant name="mistyrose" value="Color( 1, 0.89, 0.88, 1 )"> + <constant name="MISTY_ROSE" value="Color( 1, 0.89, 0.88, 1 )"> Misty rose color. </constant> - <constant name="moccasin" value="Color( 1, 0.89, 0.71, 1 )"> + <constant name="MOCCASIN" value="Color( 1, 0.89, 0.71, 1 )"> Moccasin color. </constant> - <constant name="navajowhite" value="Color( 1, 0.87, 0.68, 1 )"> + <constant name="NAVAJO_WHITE" value="Color( 1, 0.87, 0.68, 1 )"> Navajo white color. </constant> - <constant name="navyblue" value="Color( 0, 0, 0.5, 1 )"> + <constant name="NAVY_BLUE" value="Color( 0, 0, 0.5, 1 )"> Navy blue color. </constant> - <constant name="oldlace" value="Color( 0.99, 0.96, 0.9, 1 )"> + <constant name="OLD_LACE" value="Color( 0.99, 0.96, 0.9, 1 )"> Old lace color. </constant> - <constant name="olive" value="Color( 0.5, 0.5, 0, 1 )"> + <constant name="OLIVE" value="Color( 0.5, 0.5, 0, 1 )"> Olive color. </constant> - <constant name="olivedrab" value="Color( 0.42, 0.56, 0.14, 1 )"> + <constant name="OLIVE_DRAB" value="Color( 0.42, 0.56, 0.14, 1 )"> Olive drab color. </constant> - <constant name="orange" value="Color( 1, 0.65, 0, 1 )"> + <constant name="ORANGE" value="Color( 1, 0.65, 0, 1 )"> Orange color. </constant> - <constant name="orangered" value="Color( 1, 0.27, 0, 1 )"> + <constant name="ORANGE_RED" value="Color( 1, 0.27, 0, 1 )"> Orange red color. </constant> - <constant name="orchid" value="Color( 0.85, 0.44, 0.84, 1 )"> + <constant name="ORCHID" value="Color( 0.85, 0.44, 0.84, 1 )"> Orchid color. </constant> - <constant name="palegoldenrod" value="Color( 0.93, 0.91, 0.67, 1 )"> + <constant name="PALE_GOLDENROD" value="Color( 0.93, 0.91, 0.67, 1 )"> Pale goldenrod color. </constant> - <constant name="palegreen" value="Color( 0.6, 0.98, 0.6, 1 )"> + <constant name="PALE_GREEN" value="Color( 0.6, 0.98, 0.6, 1 )"> Pale green color. </constant> - <constant name="paleturquoise" value="Color( 0.69, 0.93, 0.93, 1 )"> + <constant name="PALE_TURQUOISE" value="Color( 0.69, 0.93, 0.93, 1 )"> Pale turquoise color. </constant> - <constant name="palevioletred" value="Color( 0.86, 0.44, 0.58, 1 )"> + <constant name="PALE_VIOLET_RED" value="Color( 0.86, 0.44, 0.58, 1 )"> Pale violet red color. </constant> - <constant name="papayawhip" value="Color( 1, 0.94, 0.84, 1 )"> + <constant name="PAPAYA_WHIP" value="Color( 1, 0.94, 0.84, 1 )"> Papaya whip color. </constant> - <constant name="peachpuff" value="Color( 1, 0.85, 0.73, 1 )"> + <constant name="PEACH_PUFF" value="Color( 1, 0.85, 0.73, 1 )"> Peach puff color. </constant> - <constant name="peru" value="Color( 0.8, 0.52, 0.25, 1 )"> + <constant name="PERU" value="Color( 0.8, 0.52, 0.25, 1 )"> Peru color. </constant> - <constant name="pink" value="Color( 1, 0.75, 0.8, 1 )"> + <constant name="PINK" value="Color( 1, 0.75, 0.8, 1 )"> Pink color. </constant> - <constant name="plum" value="Color( 0.87, 0.63, 0.87, 1 )"> + <constant name="PLUM" value="Color( 0.87, 0.63, 0.87, 1 )"> Plum color. </constant> - <constant name="powderblue" value="Color( 0.69, 0.88, 0.9, 1 )"> + <constant name="POWDER_BLUE" value="Color( 0.69, 0.88, 0.9, 1 )"> Powder blue color. </constant> - <constant name="purple" value="Color( 0.63, 0.13, 0.94, 1 )"> + <constant name="PURPLE" value="Color( 0.63, 0.13, 0.94, 1 )"> Purple color. </constant> - <constant name="rebeccapurple" value="Color( 0.4, 0.2, 0.6, 1 )"> + <constant name="REBECCA_PURPLE" value="Color( 0.4, 0.2, 0.6, 1 )"> Rebecca purple color. </constant> - <constant name="red" value="Color( 1, 0, 0, 1 )"> + <constant name="RED" value="Color( 1, 0, 0, 1 )"> Red color. </constant> - <constant name="rosybrown" value="Color( 0.74, 0.56, 0.56, 1 )"> + <constant name="ROSY_BROWN" value="Color( 0.74, 0.56, 0.56, 1 )"> Rosy brown color. </constant> - <constant name="royalblue" value="Color( 0.25, 0.41, 0.88, 1 )"> + <constant name="ROYAL_BLUE" value="Color( 0.25, 0.41, 0.88, 1 )"> Royal blue color. </constant> - <constant name="saddlebrown" value="Color( 0.55, 0.27, 0.07, 1 )"> + <constant name="SADDLE_BROWN" value="Color( 0.55, 0.27, 0.07, 1 )"> Saddle brown color. </constant> - <constant name="salmon" value="Color( 0.98, 0.5, 0.45, 1 )"> + <constant name="SALMON" value="Color( 0.98, 0.5, 0.45, 1 )"> Salmon color. </constant> - <constant name="sandybrown" value="Color( 0.96, 0.64, 0.38, 1 )"> + <constant name="SANDY_BROWN" value="Color( 0.96, 0.64, 0.38, 1 )"> Sandy brown color. </constant> - <constant name="seagreen" value="Color( 0.18, 0.55, 0.34, 1 )"> + <constant name="SEA_GREEN" value="Color( 0.18, 0.55, 0.34, 1 )"> Sea green color. </constant> - <constant name="seashell" value="Color( 1, 0.96, 0.93, 1 )"> + <constant name="SEASHELL" value="Color( 1, 0.96, 0.93, 1 )"> Seashell color. </constant> - <constant name="sienna" value="Color( 0.63, 0.32, 0.18, 1 )"> + <constant name="SIENNA" value="Color( 0.63, 0.32, 0.18, 1 )"> Sienna color. </constant> - <constant name="silver" value="Color( 0.75, 0.75, 0.75, 1 )"> + <constant name="SILVER" value="Color( 0.75, 0.75, 0.75, 1 )"> Silver color. </constant> - <constant name="skyblue" value="Color( 0.53, 0.81, 0.92, 1 )"> + <constant name="SKY_BLUE" value="Color( 0.53, 0.81, 0.92, 1 )"> Sky blue color. </constant> - <constant name="slateblue" value="Color( 0.42, 0.35, 0.8, 1 )"> + <constant name="SLATE_BLUE" value="Color( 0.42, 0.35, 0.8, 1 )"> Slate blue color. </constant> - <constant name="slategray" value="Color( 0.44, 0.5, 0.56, 1 )"> + <constant name="SLATE_GRAY" value="Color( 0.44, 0.5, 0.56, 1 )"> Slate gray color. </constant> - <constant name="snow" value="Color( 1, 0.98, 0.98, 1 )"> + <constant name="SNOW" value="Color( 1, 0.98, 0.98, 1 )"> Snow color. </constant> - <constant name="springgreen" value="Color( 0, 1, 0.5, 1 )"> + <constant name="SPRING_GREEN" value="Color( 0, 1, 0.5, 1 )"> Spring green color. </constant> - <constant name="steelblue" value="Color( 0.27, 0.51, 0.71, 1 )"> + <constant name="STEEL_BLUE" value="Color( 0.27, 0.51, 0.71, 1 )"> Steel blue color. </constant> - <constant name="tan" value="Color( 0.82, 0.71, 0.55, 1 )"> + <constant name="TAN" value="Color( 0.82, 0.71, 0.55, 1 )"> Tan color. </constant> - <constant name="teal" value="Color( 0, 0.5, 0.5, 1 )"> + <constant name="TEAL" value="Color( 0, 0.5, 0.5, 1 )"> Teal color. </constant> - <constant name="thistle" value="Color( 0.85, 0.75, 0.85, 1 )"> + <constant name="THISTLE" value="Color( 0.85, 0.75, 0.85, 1 )"> Thistle color. </constant> - <constant name="tomato" value="Color( 1, 0.39, 0.28, 1 )"> + <constant name="TOMATO" value="Color( 1, 0.39, 0.28, 1 )"> Tomato color. </constant> - <constant name="transparent" value="Color( 1, 1, 1, 0 )"> - Transparent color (white with no alpha). + <constant name="TRANSPARENT" value="Color( 1, 1, 1, 0 )"> + Transparent color (white with zero alpha). </constant> - <constant name="turquoise" value="Color( 0.25, 0.88, 0.82, 1 )"> + <constant name="TURQUOISE" value="Color( 0.25, 0.88, 0.82, 1 )"> Turquoise color. </constant> - <constant name="violet" value="Color( 0.93, 0.51, 0.93, 1 )"> + <constant name="VIOLET" value="Color( 0.93, 0.51, 0.93, 1 )"> Violet color. </constant> - <constant name="webgray" value="Color( 0.5, 0.5, 0.5, 1 )"> + <constant name="WEB_GRAY" value="Color( 0.5, 0.5, 0.5, 1 )"> Web gray color. </constant> - <constant name="webgreen" value="Color( 0, 0.5, 0, 1 )"> + <constant name="WEB_GREEN" value="Color( 0, 0.5, 0, 1 )"> Web green color. </constant> - <constant name="webmaroon" value="Color( 0.5, 0, 0, 1 )"> + <constant name="WEB_MAROON" value="Color( 0.5, 0, 0, 1 )"> Web maroon color. </constant> - <constant name="webpurple" value="Color( 0.5, 0, 0.5, 1 )"> + <constant name="WEB_PURPLE" value="Color( 0.5, 0, 0.5, 1 )"> Web purple color. </constant> - <constant name="wheat" value="Color( 0.96, 0.87, 0.7, 1 )"> + <constant name="WHEAT" value="Color( 0.96, 0.87, 0.7, 1 )"> Wheat color. </constant> - <constant name="white" value="Color( 1, 1, 1, 1 )"> + <constant name="WHITE" value="Color( 1, 1, 1, 1 )"> White color. </constant> - <constant name="whitesmoke" value="Color( 0.96, 0.96, 0.96, 1 )"> + <constant name="WHITE_SMOKE" value="Color( 0.96, 0.96, 0.96, 1 )"> White smoke color. </constant> - <constant name="yellow" value="Color( 1, 1, 0, 1 )"> + <constant name="YELLOW" value="Color( 1, 1, 0, 1 )"> Yellow color. </constant> - <constant name="yellowgreen" value="Color( 0.6, 0.8, 0.2, 1 )"> + <constant name="YELLOW_GREEN" value="Color( 0.6, 0.8, 0.2, 1 )"> Yellow green color. </constant> </constants> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 8c90108aef..d997073849 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -143,7 +143,7 @@ Returns the command-line arguments passed to the engine. Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments. You can also incorporate environment variables using the [method get_environment] method. - You can set [code]editor/main_run_args[/code] in the Project Settings to define command-line arguments to be passed by the editor when running the project. + You can set [member ProjectSettings.editor/run/main_run_args] to define command-line arguments to be passed by the editor when running the project. Here's a minimal example on how to parse command-line arguments into a dictionary using the [code]--key=value[/code] form for arguments: [codeblocks] [gdscript] diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 005873c2ff..3200f789b8 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -542,6 +542,14 @@ <member name="editor/node_naming/name_num_separator" type="int" setter="" getter="" default="0"> What to use to separate node name from number. This is mostly an editor setting. </member> + <member name="editor/run/main_run_args" type="String" setter="" getter="" default=""""> + The command-line arguments to append to Godot's own command line when running the project. This doesn't affect the editor itself. + It is possible to make another executable run Godot by using the [code]%command%[/code] placeholder. The placeholder will be replaced with Godot's own command line. Program-specific arguments should be placed [i]before[/i] the placeholder, whereas Godot-specific arguments should be placed [i]after[/i] the placeholder. + For example, this can be used to force the project to run on the dedicated GPU in a NVIDIA Optimus system on Linux: + [codeblock] + prime-run %command% + [/codeblock] + </member> <member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray( "gd", "shader" )"> Text-based file extensions to include in the script editor's "Find in Files" feature. You can add e.g. [code]tscn[/code] if you wish to also parse your scene files, especially if you use built-in scripts which are serialized in the scene files. </member> diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 9949fd8199..c0d5716c4e 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -730,10 +730,6 @@ void ActionMapEditor::_add_action_pressed() { } void ActionMapEditor::_add_action(const String &p_name) { - if (!allow_editing_actions) { - return; - } - if (p_name == "" || !_is_action_name_valid(p_name)) { show_message(TTR("Invalid action name. it cannot be.is_empty()() nor contain '/', ':', '=', '\\' or '\"'")); return; @@ -744,10 +740,6 @@ void ActionMapEditor::_add_action(const String &p_name) { } void ActionMapEditor::_action_edited() { - if (!allow_editing_actions) { - return; - } - TreeItem *ti = action_tree->get_edited(); if (!ti) { return; @@ -812,10 +804,6 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i } break; case ActionMapEditor::BUTTON_REMOVE_ACTION: { - if (!allow_editing_actions) { - break; - } - // Send removed action name String name = item->get_meta("__name"); emit_signal("action_removed", name); @@ -848,11 +836,11 @@ void ActionMapEditor::_tree_item_activated() { _tree_button_pressed(item, 2, BUTTON_EDIT_EVENT); } -void ActionMapEditor::set_show_uneditable(bool p_show) { - show_uneditable = p_show; - show_uneditable_actions_checkbox->set_pressed(p_show); +void ActionMapEditor::set_show_builtin_actions(bool p_show) { + show_builtin_actions = p_show; + show_builtin_actions_checkbutton->set_pressed(p_show); - // Prevent unnecessary updates of action list when cache is.is_empty()(). + // Prevent unnecessary updates of action list when cache is empty. if (!actions_cache.is_empty()) { update_action_list(); } @@ -1022,7 +1010,7 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info continue; } - if (!action_info.editable && !show_uneditable) { + if (!action_info.editable && !show_builtin_actions) { continue; } @@ -1080,15 +1068,6 @@ void ActionMapEditor::show_message(const String &p_message) { message->popup_centered(Size2(300, 100) * EDSCALE); } -void ActionMapEditor::set_allow_editing_actions(bool p_allow) { - allow_editing_actions = p_allow; - add_hbox->set_visible(p_allow); -} - -void ActionMapEditor::set_toggle_editable_label(const String &p_label) { - show_uneditable_actions_checkbox->set_text(p_label); -} - void ActionMapEditor::use_external_search_box(LineEdit *p_searchbox) { memdelete(action_list_search); action_list_search = p_searchbox; @@ -1096,8 +1075,7 @@ void ActionMapEditor::use_external_search_box(LineEdit *p_searchbox) { } ActionMapEditor::ActionMapEditor() { - allow_editing_actions = true; - show_uneditable = true; + show_builtin_actions = false; // Main Vbox Container VBoxContainer *main_vbox = memnew(VBoxContainer); @@ -1114,11 +1092,11 @@ ActionMapEditor::ActionMapEditor() { action_list_search->connect("text_changed", callable_mp(this, &ActionMapEditor::_search_term_updated)); top_hbox->add_child(action_list_search); - show_uneditable_actions_checkbox = memnew(CheckBox); - show_uneditable_actions_checkbox->set_pressed(false); - show_uneditable_actions_checkbox->set_text(TTR("Show Uneditable Actions")); - show_uneditable_actions_checkbox->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_uneditable)); - top_hbox->add_child(show_uneditable_actions_checkbox); + show_builtin_actions_checkbutton = memnew(CheckButton); + show_builtin_actions_checkbutton->set_pressed(false); + show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions")); + show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions)); + top_hbox->add_child(show_builtin_actions_checkbutton); // Adding Action line edit + button add_hbox = memnew(HBoxContainer); @@ -1132,7 +1110,7 @@ ActionMapEditor::ActionMapEditor() { add_hbox->add_child(add_edit); Button *add_button = memnew(Button); - add_button->set_text("Add"); + add_button->set_text(TTR("Add")); add_button->connect("pressed", callable_mp(this, &ActionMapEditor::_add_action_pressed)); add_hbox->add_child(add_button); diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index f1f7bffef4..fb097ddfdd 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -156,11 +156,10 @@ private: // Filtering and Adding actions - bool show_uneditable; - CheckBox *show_uneditable_actions_checkbox; + bool show_builtin_actions; + CheckButton *show_builtin_actions_checkbutton; LineEdit *action_list_search; - bool allow_editing_actions; HBoxContainer *add_hbox; LineEdit *add_edit; @@ -190,10 +189,7 @@ public: void update_action_list(const Vector<ActionInfo> &p_action_infos = Vector<ActionInfo>()); void show_message(const String &p_message); - void set_show_uneditable(bool p_show); - void set_allow_editing_actions(bool p_allow); - - void set_toggle_editable_label(const String &p_label); + void set_show_builtin_actions(bool p_show); void use_external_search_box(LineEdit *p_searchbox); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 711072f4b2..1c0a55e4ec 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -708,7 +708,6 @@ CreateDialog::CreateDialog() { search_hb->add_child(search_box); favorite = memnew(Button); - favorite->set_flat(true); favorite->set_toggle_mode(true); favorite->set_tooltip(TTR("(Un)favorite selected item.")); favorite->connect("pressed", callable_mp(this, &CreateDialog::_favorite_toggled)); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 602035634a..7c485d53c5 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -75,6 +75,8 @@ void EditorLog::_notification(int p_what) { collapse_button->set_icon(get_theme_icon("CombineLines", "EditorIcons")); show_search_button->set_icon(get_theme_icon("Search", "EditorIcons")); + _load_state(); + } else if (p_what == NOTIFICATION_THEME_CHANGED) { Ref<Font> df_output_code = get_theme_font("output_source", "EditorFonts"); if (df_output_code.is_valid()) { @@ -89,9 +91,56 @@ void EditorLog::_notification(int p_what) { void EditorLog::_set_collapse(bool p_collapse) { collapse = p_collapse; + _start_state_save_timer(); _rebuild_log(); } +void EditorLog::_start_state_save_timer() { + if (!is_loading_state) { + save_state_timer->start(); + } +} + +void EditorLog::_save_state() { + Ref<ConfigFile> config; + config.instance(); + // Load and amend existing config if it exists. + config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + + const String section = "editor_log"; + for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) { + config->set_value(section, "log_filter_" + itos(E->key()), E->get()->is_active()); + } + + config->set_value(section, "collapse", collapse); + config->set_value(section, "show_search", search_box->is_visible()); + + config->save(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); +} + +void EditorLog::_load_state() { + is_loading_state = true; + + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); + + if (err == OK) { + const String section = "editor_log"; + for (Map<MessageType, LogFilter *>::Element *E = type_filter_map.front(); E; E = E->next()) { + E->get()->set_active(config->get_value(section, "log_filter_" + itos(E->key()), false)); + } + + collapse = config->get_value(section, "collapse", false); + collapse_button->set_pressed(collapse); + bool show_search = config->get_value(section, "show_search", true); + search_box->set_visible(show_search); + show_search_button->set_pressed(show_search); + } + + is_loading_state = false; +} + void EditorLog::_clear_request() { log->clear(); messages.clear(); @@ -175,7 +224,7 @@ void EditorLog::_rebuild_log() { void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { // Only add the message to the log if it passes the filters. - bool filter_active = type_filter_map[p_message.type]->active; + bool filter_active = type_filter_map[p_message.type]->is_active(); String search_text = search_box->get_text(); bool search_match = search_text == String() || p_message.text.findn(search_text) > -1; @@ -230,7 +279,8 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { } void EditorLog::_set_filter_active(bool p_active, MessageType p_message_type) { - type_filter_map[p_message_type]->active = p_active; + type_filter_map[p_message_type]->set_active(p_active); + _start_state_save_timer(); _rebuild_log(); } @@ -239,6 +289,7 @@ void EditorLog::_set_search_visible(bool p_visible) { if (p_visible) { search_box->grab_focus(); } + _start_state_save_timer(); } void EditorLog::_search_changed(const String &p_text) { @@ -257,6 +308,12 @@ void EditorLog::_bind_methods() { } EditorLog::EditorLog() { + save_state_timer = memnew(Timer); + save_state_timer->set_wait_time(2); + save_state_timer->set_one_shot(true); + save_state_timer->connect("timeout", callable_mp(this, &EditorLog::_save_state)); + add_child(save_state_timer); + HBoxContainer *hb = this; VBoxContainer *vb_left = memnew(VBoxContainer); diff --git a/editor/editor_log.h b/editor/editor_log.h index 89d00d0fa0..3b6476634a 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -72,11 +72,11 @@ private: private: // Force usage of set method since it has functionality built-in. int message_count = 0; + bool active = true; public: MessageType type; Button *toggle_button = nullptr; - bool active = true; void initialize_button(const String &p_tooltip, Callable p_toggled_callback) { toggle_button = memnew(Button); @@ -100,6 +100,15 @@ private: toggle_button->set_text(itos(message_count)); } + bool is_active() { + return active; + } + + void set_active(bool p_active) { + toggle_button->set_pressed(p_active); + active = p_active; + } + LogFilter(MessageType p_type) : type(p_type) { } @@ -124,6 +133,9 @@ private: // Warnings or Errors are encounetered. Button *tool_button; + bool is_loading_state = false; // Used to disable saving requests while loading (some signals from buttons will try trigger a save, which happens during loading). + Timer *save_state_timer; + static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type); ErrorHandlerList eh; @@ -147,6 +159,10 @@ private: void _set_collapse(bool p_collapse); + void _start_state_save_timer(); + void _save_state(); + void _load_state(); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 91fa653aed..7e39c4c654 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4320,6 +4320,8 @@ void EditorNode::_save_docks() { } Ref<ConfigFile> config; config.instance(); + // Load and amend existing config if it exists. + config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); _save_docks_to_config(config, "docks"); _save_open_scenes_to_config(config, "EditorNode"); @@ -5835,8 +5837,6 @@ EditorNode::EditorNode() { register_exporters(); - GLOBAL_DEF("editor/run/main_run_args", ""); - ClassDB::set_class_enabled("RootMotionView", true); //defs here, use EDITOR_GET in logic @@ -6448,7 +6448,6 @@ EditorNode::EditorNode() { // Toggle for video driver video_driver = memnew(OptionButton); - video_driver->set_flat(true); video_driver->set_focus_mode(Control::FOCUS_NONE); video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected)); video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts")); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index de688f2709..fb2980c948 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -575,7 +575,6 @@ EditorPropertyArray::EditorPropertyArray() { object.instance(); page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); edit = memnew(Button); - edit->set_flat(true); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed)); @@ -1070,7 +1069,6 @@ EditorPropertyDictionary::EditorPropertyDictionary() { object.instance(); page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); edit = memnew(Button); - edit->set_flat(true); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_edit_pressed)); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index e46f4eb65a..5e6d2ab69c 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -183,15 +183,50 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L args.push_back(p_scene); } + String exec = OS::get_singleton()->get_executable_path(); + if (p_custom_args != "") { - Vector<String> cargs = p_custom_args.split(" ", false); - for (int i = 0; i < cargs.size(); i++) { - args.push_back(cargs[i].replace(" ", "%20")); + // Allow the user to specify a command to run, similar to Steam's launch options. + // In this case, Godot will no longer be run directly; it's up to the underlying command + // to run it. For instance, this can be used on Linux to force a running project + // to use Optimus using `prime-run` or similar. + // Example: `prime-run %command% --time-scale 0.5` + const int placeholder_pos = p_custom_args.find("%command%"); + + Vector<String> custom_args; + + if (placeholder_pos != -1) { + // Prepend executable-specific custom arguments. + // If nothing is placed before `%command%`, behave as if no placeholder was specified. + Vector<String> exec_args = p_custom_args.substr(0, placeholder_pos).split(" ", false); + if (exec_args.size() >= 1) { + exec = exec_args[0]; + exec_args.remove(0); + + // Append the Godot executable name before we append executable arguments + // (since the order is reversed when using `push_front()`). + args.push_front(OS::get_singleton()->get_executable_path()); + } + + for (int i = exec_args.size() - 1; i >= 0; i--) { + // Iterate backwards as we're pushing items in the reverse order. + args.push_front(exec_args[i].replace(" ", "%20")); + } + + // Append Godot-specific custom arguments. + custom_args = p_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false); + for (int i = 0; i < custom_args.size(); i++) { + args.push_back(custom_args[i].replace(" ", "%20")); + } + } else { + // Append Godot-specific custom arguments. + custom_args = p_custom_args.split(" ", false); + for (int i = 0; i < custom_args.size(); i++) { + args.push_back(custom_args[i].replace(" ", "%20")); + } } } - String exec = OS::get_singleton()->get_executable_path(); - printf("Running: %s", exec.utf8().get_data()); for (List<String>::Element *E = args.front(); E; E = E->next()) { printf(" %s", E->get().utf8().get_data()); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index dd733aab8b..fdca508c9e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -437,7 +437,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Theme _initial_set("interface/theme/preset", "Default"); - hints["interface/theme/preset"] = PropertyInfo(Variant::STRING, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Alien,Arc,Godot 2,Grey,Light,Solarized (Dark),Solarized (Light),Custom", PROPERTY_USAGE_DEFAULT); + hints["interface/theme/preset"] = PropertyInfo(Variant::STRING, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Breeze Dark,Godot 2,Grey,Light,Solarized (Dark),Solarized (Light),Custom", PROPERTY_USAGE_DEFAULT); _initial_set("interface/theme/icon_and_font_color", 0); hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT); _initial_set("interface/theme/base_color", Color(0.2, 0.23, 0.31)); @@ -450,14 +450,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/theme/icon_saturation"] = PropertyInfo(Variant::FLOAT, "interface/theme/icon_saturation", PROPERTY_HINT_RANGE, "0,2,0.01", PROPERTY_USAGE_DEFAULT); _initial_set("interface/theme/relationship_line_opacity", 0.1); hints["interface/theme/relationship_line_opacity"] = PropertyInfo(Variant::FLOAT, "interface/theme/relationship_line_opacity", PROPERTY_HINT_RANGE, "0.00, 1, 0.01"); - _initial_set("interface/theme/highlight_tabs", false); - _initial_set("interface/theme/border_size", 1); - _initial_set("interface/theme/use_graph_node_headers", false); + _initial_set("interface/theme/border_size", 0); hints["interface/theme/border_size"] = PropertyInfo(Variant::INT, "interface/theme/border_size", PROPERTY_HINT_RANGE, "0,2,1", PROPERTY_USAGE_DEFAULT); + _initial_set("interface/theme/corner_radius", 3); + hints["interface/theme/corner_radius"] = PropertyInfo(Variant::INT, "interface/theme/corner_radius", PROPERTY_HINT_RANGE, "0,6,1", PROPERTY_USAGE_DEFAULT); _initial_set("interface/theme/additional_spacing", 0); hints["interface/theme/additional_spacing"] = PropertyInfo(Variant::FLOAT, "interface/theme/additional_spacing", PROPERTY_HINT_RANGE, "0,5,0.1", PROPERTY_USAGE_DEFAULT); _initial_set("interface/theme/custom_theme", ""); - hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT); + hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); // Scene tabs _initial_set("interface/scene_tabs/show_thumbnail_on_hover", true); @@ -787,6 +787,7 @@ void EditorSettings::_load_default_text_editor_theme() { _initial_set("text_editor/highlighting/symbol_color", Color(0.73, 0.87, 1.0)); _initial_set("text_editor/highlighting/keyword_color", Color(1.0, 1.0, 0.7)); + _initial_set("text_editor/highlighting/control_flow_keyword_color", Color(1.0, 0.85, 0.7)); _initial_set("text_editor/highlighting/base_type_color", Color(0.64, 1.0, 0.83)); _initial_set("text_editor/highlighting/engine_type_color", Color(0.51, 0.83, 1.0)); _initial_set("text_editor/highlighting/user_type_color", Color(0.42, 0.67, 0.93)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7cc9ebd63e..d5ad638436 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -65,9 +65,12 @@ static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_ return style; } -static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { +static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, int p_corner_width = 0) { Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); style->set_bg_color(p_color); + // Adjust level of detail based on the corners' effective sizes. + style->set_corner_detail(Math::ceil(1.5 * p_corner_width * EDSCALE)); + style->set_corner_radius_all(p_corner_width); style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); @@ -286,9 +289,9 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<Theme> theme = Ref<Theme>(memnew(Theme)); - const float default_contrast = 0.25; + const float default_contrast = 0.3; - //Theme settings + // Theme settings Color accent_color = EDITOR_GET("interface/theme/accent_color"); Color base_color = EDITOR_GET("interface/theme/base_color"); float contrast = EDITOR_GET("interface/theme/contrast"); @@ -297,56 +300,47 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { String preset = EDITOR_GET("interface/theme/preset"); - bool highlight_tabs = EDITOR_GET("interface/theme/highlight_tabs"); int border_size = EDITOR_GET("interface/theme/border_size"); - - bool use_gn_headers = EDITOR_GET("interface/theme/use_graph_node_headers"); + int corner_radius = EDITOR_GET("interface/theme/corner_radius"); Color preset_accent_color; Color preset_base_color; float preset_contrast = 0; - // Please, use alphabet order if you've added new theme here(After "Default" and "Custom") + // Please use alphabetical order if you're adding a new theme here + // (after "Custom") - if (preset == "Default") { - preset_accent_color = Color(0.41, 0.61, 0.91); - preset_base_color = Color(0.2, 0.23, 0.31); - preset_contrast = default_contrast; - } else if (preset == "Custom") { + if (preset == "Custom") { accent_color = EDITOR_GET("interface/theme/accent_color"); base_color = EDITOR_GET("interface/theme/base_color"); contrast = EDITOR_GET("interface/theme/contrast"); - } else if (preset == "Alien") { - preset_accent_color = Color(0.11, 1.0, 0.6); - preset_base_color = Color(0.18, 0.22, 0.25); - preset_contrast = 0.25; - } else if (preset == "Arc") { - preset_accent_color = Color(0.32, 0.58, 0.89); - preset_base_color = Color(0.22, 0.24, 0.29); - preset_contrast = 0.25; + } else if (preset == "Breeze Dark") { + preset_accent_color = Color(0.26, 0.76, 1.00); + preset_base_color = Color(0.24, 0.26, 0.28); + preset_contrast = default_contrast; } else if (preset == "Godot 2") { preset_accent_color = Color(0.53, 0.67, 0.89); preset_base_color = Color(0.24, 0.23, 0.27); - preset_contrast = 0.25; + preset_contrast = default_contrast; } else if (preset == "Grey") { - preset_accent_color = Color(0.72, 0.89, 1.0); + preset_accent_color = Color(0.72, 0.89, 1.00); preset_base_color = Color(0.24, 0.24, 0.24); - preset_contrast = 0.2; + preset_contrast = default_contrast; } else if (preset == "Light") { - preset_accent_color = Color(0.13, 0.44, 1.0); - preset_base_color = Color(1, 1, 1); + preset_accent_color = Color(0.18, 0.50, 1.00); + preset_base_color = Color(1.00, 1.00, 1.00); preset_contrast = 0.08; } else if (preset == "Solarized (Dark)") { preset_accent_color = Color(0.15, 0.55, 0.82); - preset_base_color = Color(0.03, 0.21, 0.26); - preset_contrast = 0.23; + preset_base_color = Color(0.04, 0.23, 0.27); + preset_contrast = default_contrast; } else if (preset == "Solarized (Light)") { preset_accent_color = Color(0.15, 0.55, 0.82); preset_base_color = Color(0.99, 0.96, 0.89); - preset_contrast = 0.06; + preset_contrast = 0.08; } else { // Default - preset_accent_color = Color(0.41, 0.61, 0.91); - preset_base_color = Color(0.2, 0.23, 0.31); + preset_accent_color = Color(0.44, 0.73, 0.98); + preset_base_color = Color(0.21, 0.24, 0.29); preset_contrast = default_contrast; } @@ -358,12 +352,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color); EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast); } + EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset); EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color); EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color); EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast); - //Colors + // Colors bool dark_theme = EditorSettings::get_singleton()->is_dark_theme(); const Color dark_color_1 = base_color.lerp(Color(0, 0, 0, 1), contrast); @@ -372,14 +367,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color background_color = dark_color_2; - // white (dark theme) or black (light theme), will be used to generate the rest of the colors + // White (dark theme) or black (light theme), will be used to generate the rest of the colors const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0); const Color contrast_color_1 = base_color.lerp(mono_color, MAX(contrast, default_contrast)); const Color contrast_color_2 = base_color.lerp(mono_color, MAX(contrast * 1.5, default_contrast * 1.5)); const Color font_color = mono_color.lerp(base_color, 0.25); - const Color font_hover_color = mono_color.lerp(base_color, 0.15); + const Color font_hover_color = mono_color.lerp(base_color, 0.125); const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); const Color selection_color = accent_color * Color(1, 1, 1, 0.4); const Color disabled_color = mono_color.inverted().lerp(base_color, 0.7); @@ -393,8 +388,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { icon_pressed_color.a = 1.0; const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1); - - const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2); + const Color highlight_color = Color(accent_color.r, accent_color.g, accent_color.b, 0.275); float prev_icon_saturation = theme->has_color("icon_saturation", "Editor") ? theme->get_color("icon_saturation", "Editor").r : 1.0; @@ -447,35 +441,35 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("thumb_size", "Editor", thumb_size); theme->set_constant("dark_theme", "Editor", dark_theme); - //Register icons + font + // Register icons + font - // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons + // The resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons. if (p_theme != nullptr && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme && prev_icon_saturation == icon_saturation) { - // register already generated icons + // Register already generated icons. for (int i = 0; i < editor_icons_count; i++) { theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons")); } } else { editor_register_and_generate_icons(theme, dark_theme, thumb_size, false, icon_saturation); } - // thumbnail size has changed, so we regenerate the medium sizes + // Thumbnail size has changed, so we regenerate the medium sizes if (p_theme != nullptr && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true); } editor_register_fonts(theme); - // Highlighted tabs and border width - Color tab_color = highlight_tabs ? base_color.lerp(font_color, contrast) : base_color; // Ensure borders are visible when using an editor scale below 100%. - const int border_width = CLAMP(border_size, 0, 3) * MAX(1, EDSCALE); - + const int border_width = CLAMP(border_size, 0, 2) * MAX(1, EDSCALE); + const int corner_width = CLAMP(corner_radius, 0, 6) * EDSCALE; const int default_margin_size = 4; - const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3); + const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 2); - // styleboxes - // this is the most commonly used stylebox, variations should be made as duplicate of this - Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size); + // Styleboxes + // This is the most commonly used stylebox, variations should be made as duplicate of this + Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size, corner_width); + // Work around issue about antialiased edges being blurrier (GH-35279). + style_default->set_anti_aliased(false); style_default->set_border_width_all(border_width); style_default->set_border_color(base_color); style_default->set_draw_center(true); @@ -483,11 +477,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Button and widgets const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing"); + const Vector2 widget_default_margin = Vector2(extra_spacing + 6, extra_spacing + default_margin_size + 1) * EDSCALE; + Ref<StyleBoxFlat> style_widget = style_default->duplicate(); - style_widget->set_default_margin(SIDE_LEFT, (extra_spacing + 6) * EDSCALE); - style_widget->set_default_margin(SIDE_TOP, (extra_spacing + default_margin_size) * EDSCALE); - style_widget->set_default_margin(SIDE_RIGHT, (extra_spacing + 6) * EDSCALE); - style_widget->set_default_margin(SIDE_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE); + style_widget->set_default_margin(SIDE_LEFT, widget_default_margin.x); + style_widget->set_default_margin(SIDE_TOP, widget_default_margin.y); + style_widget->set_default_margin(SIDE_RIGHT, widget_default_margin.x); + style_widget->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); style_widget->set_bg_color(dark_color_1); style_widget->set_border_color(dark_color_2); @@ -496,69 +492,82 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_widget_disabled->set_bg_color(disabled_bg_color); Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate(); + style_widget_focus->set_draw_center(false); + style_widget_focus->set_border_width_all(Math::round(2 * MAX(1, EDSCALE))); style_widget_focus->set_border_color(accent_color); Ref<StyleBoxFlat> style_widget_pressed = style_widget->duplicate(); - style_widget_pressed->set_border_color(accent_color); + style_widget_pressed->set_bg_color(dark_color_1.darkened(0.125)); Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate(); - style_widget_hover->set_border_color(contrast_color_1); + style_widget_hover->set_bg_color(mono_color * Color(1, 1, 1, 0.11)); + style_widget_hover->set_border_color(mono_color * Color(1, 1, 1, 0.05)); - // style for windows, popups, etc.. + // Style for windows, popups, etc.. Ref<StyleBoxFlat> style_popup = style_default->duplicate(); - const int popup_margin_size = default_margin_size * EDSCALE * 2; + const int popup_margin_size = default_margin_size * EDSCALE * 3; style_popup->set_default_margin(SIDE_LEFT, popup_margin_size); style_popup->set_default_margin(SIDE_TOP, popup_margin_size); style_popup->set_default_margin(SIDE_RIGHT, popup_margin_size); style_popup->set_default_margin(SIDE_BOTTOM, popup_margin_size); style_popup->set_border_color(contrast_color_1); - style_popup->set_border_width_all(MAX(EDSCALE, border_width)); const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1); style_popup->set_shadow_color(shadow_color); style_popup->set_shadow_size(4 * EDSCALE); Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine)); style_popup_separator->set_color(separator_color); - style_popup_separator->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width)); - style_popup_separator->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width)); - style_popup_separator->set_thickness(MAX(EDSCALE, border_width)); + style_popup_separator->set_grow_begin(popup_margin_size - MAX(Math::round(EDSCALE), border_width)); + style_popup_separator->set_grow_end(popup_margin_size - MAX(Math::round(EDSCALE), border_width)); + style_popup_separator->set_thickness(MAX(Math::round(EDSCALE), border_width)); Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine)); - style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width)); + style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(Math::round(EDSCALE), border_width)); style_popup_labeled_separator_left->set_color(separator_color); - style_popup_labeled_separator_left->set_thickness(MAX(EDSCALE, border_width)); + style_popup_labeled_separator_left->set_thickness(MAX(Math::round(EDSCALE), border_width)); Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine)); - style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width)); + style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(Math::round(EDSCALE), border_width)); style_popup_labeled_separator_right->set_color(separator_color); - style_popup_labeled_separator_right->set_thickness(MAX(EDSCALE, border_width)); + style_popup_labeled_separator_right->set_thickness(MAX(Math::round(EDSCALE), border_width)); Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size); // Tabs - const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE; - const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE; - Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate(); - style_tab_selected->set_border_width_all(border_width); - style_tab_selected->set_border_width(SIDE_BOTTOM, 0); - style_tab_selected->set_border_color(dark_color_3); - style_tab_selected->set_expand_margin_size(SIDE_BOTTOM, border_width); - style_tab_selected->set_default_margin(SIDE_LEFT, tab_default_margin_side); - style_tab_selected->set_default_margin(SIDE_RIGHT, tab_default_margin_side); - style_tab_selected->set_default_margin(SIDE_BOTTOM, tab_default_margin_vertical); - style_tab_selected->set_default_margin(SIDE_TOP, tab_default_margin_vertical); - style_tab_selected->set_bg_color(tab_color); + // Add a highlight line at the top of the selected tab. + style_tab_selected->set_border_width_all(0); + style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE)); + // Make the highlight line prominent, but not too prominent as to not be distracting. + style_tab_selected->set_border_color(dark_color_2.lerp(accent_color, 0.75)); + // Don't round the top corners to avoid creating a small blank space between the tabs and the main panel. + // This also makes the top highlight look better. + style_tab_selected->set_corner_radius_all(0); + + // Prevent visible artifacts and cover the top-left rounded corner of the panel below the tab if selected + // We can't prevent them with both rounded corners and non-zero border width, though + style_tab_selected->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); + + style_tab_selected->set_default_margin(SIDE_LEFT, widget_default_margin.x + 2 * EDSCALE); + style_tab_selected->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 2 * EDSCALE); + style_tab_selected->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); + style_tab_selected->set_default_margin(SIDE_TOP, widget_default_margin.y); + style_tab_selected->set_bg_color(base_color); Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate(); style_tab_unselected->set_bg_color(dark_color_1); + style_tab_unselected->set_expand_margin_size(SIDE_BOTTOM, 0); + // Add some spacing between unselected tabs to make them easier to distinguish from each other style_tab_unselected->set_border_color(dark_color_2); + style_tab_unselected->set_border_width(SIDE_LEFT, Math::round(2 * EDSCALE)); + style_tab_unselected->set_border_width(SIDE_RIGHT, Math::round(2 * EDSCALE)); Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate(); style_tab_disabled->set_bg_color(disabled_bg_color); - style_tab_disabled->set_border_color(disabled_color); + style_tab_disabled->set_expand_margin_size(SIDE_BOTTOM, 0); + style_tab_disabled->set_border_color(disabled_bg_color); // Editor background Color background_color_opaque = background_color; @@ -566,10 +575,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size)); // Focus - Ref<StyleBoxFlat> style_focus = style_default->duplicate(); - style_focus->set_draw_center(false); - style_focus->set_border_color(contrast_color_2); - theme->set_stylebox("Focus", "EditorStyles", style_focus); + theme->set_stylebox("Focus", "EditorStyles", style_widget_focus); // Menu Ref<StyleBoxFlat> style_menu = style_widget->duplicate(); @@ -585,33 +591,25 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Play button group theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty); - //MenuButton - Ref<StyleBoxFlat> style_menu_hover_border = style_widget->duplicate(); - style_menu_hover_border->set_draw_center(false); - style_menu_hover_border->set_border_width_all(0); - style_menu_hover_border->set_border_width(SIDE_BOTTOM, border_width); - style_menu_hover_border->set_border_color(accent_color); - - Ref<StyleBoxFlat> style_menu_hover_bg = style_widget->duplicate(); - style_menu_hover_bg->set_border_width_all(0); - style_menu_hover_bg->set_bg_color(dark_color_1); - theme->set_stylebox("normal", "MenuButton", style_menu); - theme->set_stylebox("hover", "MenuButton", style_menu); + theme->set_stylebox("hover", "MenuButton", style_widget_hover); theme->set_stylebox("pressed", "MenuButton", style_menu); theme->set_stylebox("focus", "MenuButton", style_menu); theme->set_stylebox("disabled", "MenuButton", style_menu); theme->set_stylebox("normal", "PopupMenu", style_menu); - theme->set_stylebox("hover", "PopupMenu", style_menu_hover_bg); - theme->set_stylebox("pressed", "PopupMenu", style_menu); + + Ref<StyleBoxFlat> style_menu_hover = style_widget_hover->duplicate(); + // Don't use rounded corners for hover highlights since the StyleBox touches the PopupMenu's edges. + style_menu_hover->set_corner_radius_all(0); + theme->set_stylebox("hover", "PopupMenu", style_menu_hover); theme->set_stylebox("focus", "PopupMenu", style_menu); theme->set_stylebox("disabled", "PopupMenu", style_menu); theme->set_color("font_color", "MenuButton", font_color); theme->set_color("font_hover_color", "MenuButton", font_hover_color); - theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border); + theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover); // Buttons theme->set_stylebox("normal", "Button", style_widget); @@ -646,7 +644,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_disabled_color", "OptionButton", font_disabled_color); theme->set_color("icon_hover_color", "OptionButton", icon_hover_color); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); - theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE); + theme->set_constant("arrow_margin", "OptionButton", widget_default_margin.x - 2 * EDSCALE); theme->set_constant("modulate_arrow", "OptionButton", true); theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE); @@ -672,7 +670,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_disabled_color", "CheckButton", font_disabled_color); theme->set_color("icon_hover_color", "CheckButton", icon_hover_color); - theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE); + theme->set_constant("hseparation", "CheckButton", 8 * EDSCALE); theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE); // Checkbox @@ -697,7 +695,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_disabled_color", "CheckBox", font_disabled_color); theme->set_color("icon_hover_color", "CheckBox", icon_hover_color); - theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE); + theme->set_constant("hseparation", "CheckBox", 8 * EDSCALE); theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE); // PopupDialog @@ -794,12 +792,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate(); - style_tree_bg->set_bg_color(dark_color_1); + // Make Trees easier to distinguish from other controls by using a darker background color. + style_tree_bg->set_bg_color(dark_color_1.lerp(dark_color_2, 0.5)); style_tree_bg->set_border_color(dark_color_3); theme->set_stylebox("bg", "Tree", style_tree_bg); - const Color guide_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.05); - Color relationship_line_color = Color(mono_color.r, mono_color.g, mono_color.b, relationship_line_opacity); + const Color guide_color = mono_color * Color(1, 1, 1, 0.05); + Color relationship_line_color = mono_color * Color(1, 1, 1, relationship_line_opacity); // Tree theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons")); @@ -808,7 +807,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon("GuiTreeArrowLeft", "EditorIcons")); theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons")); theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons")); - theme->set_stylebox("bg_focus", "Tree", style_focus); + theme->set_stylebox("bg_focus", "Tree", style_widget_focus); theme->set_stylebox("custom_button", "Tree", make_empty_stylebox()); theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox()); theme->set_stylebox("custom_button_hover", "Tree", style_widget); @@ -819,8 +818,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("guide_color", "Tree", guide_color); theme->set_color("relationship_line_color", "Tree", relationship_line_color); theme->set_color("drop_position_color", "Tree", accent_color); - theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE); - theme->set_constant("hseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE); + theme->set_constant("vseparation", "Tree", widget_default_margin.y - EDSCALE); + theme->set_constant("hseparation", "Tree", 6 * EDSCALE); + theme->set_constant("guide_width", "Tree", border_width); theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE); theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE); theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01); @@ -829,7 +829,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("scroll_speed", "Tree", 12); Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate(); - style_tree_btn->set_bg_color(contrast_color_1); + style_tree_btn->set_bg_color(highlight_color); style_tree_btn->set_border_width_all(0); theme->set_stylebox("button_pressed", "Tree", style_tree_btn); @@ -882,14 +882,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor); theme->set_stylebox("selected_focus", "ItemList", style_tree_focus); theme->set_stylebox("selected", "ItemList", style_tree_selected); - theme->set_stylebox("bg_focus", "ItemList", style_focus); + theme->set_stylebox("bg_focus", "ItemList", style_widget_focus); theme->set_stylebox("bg", "ItemList", style_itemlist_bg); theme->set_color("font_color", "ItemList", font_color); theme->set_color("font_selected_color", "ItemList", mono_color); theme->set_color("guide_color", "ItemList", guide_color); - theme->set_constant("vseparation", "ItemList", 3 * EDSCALE); - theme->set_constant("hseparation", "ItemList", 3 * EDSCALE); - theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE); + theme->set_constant("vseparation", "ItemList", widget_default_margin.y - EDSCALE); + theme->set_constant("hseparation", "ItemList", 6 * EDSCALE); + theme->set_constant("icon_margin", "ItemList", 6 * EDSCALE); theme->set_constant("line_separation", "ItemList", 3 * EDSCALE); // Tabs & TabContainer @@ -940,8 +940,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); // Separators - theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width)); - theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true)); + theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width))); + theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width), 0, 0, true)); // Debugger @@ -956,9 +956,23 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); // LineEdit - theme->set_stylebox("normal", "LineEdit", style_widget); + + Ref<StyleBoxFlat> style_line_edit = style_widget->duplicate(); + // Add a bottom line to make LineEdits more visible, especially in sectioned inspectors + // such as the Project Settings. + style_line_edit->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE)); + style_line_edit->set_border_color(dark_color_2); + // Don't round the bottom corner to make the line look sharper. + style_tab_selected->set_corner_radius(CORNER_BOTTOM_LEFT, 0); + style_tab_selected->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); + + Ref<StyleBoxFlat> style_line_edit_disabled = style_line_edit->duplicate(); + style_line_edit_disabled->set_border_color(disabled_color); + style_line_edit_disabled->set_bg_color(disabled_bg_color); + + theme->set_stylebox("normal", "LineEdit", style_line_edit); theme->set_stylebox("focus", "LineEdit", style_widget_focus); - theme->set_stylebox("read_only", "LineEdit", style_widget_disabled); + theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled); theme->set_icon("clear", "LineEdit", theme->get_icon("GuiClose", "EditorIcons")); theme->set_color("read_only", "LineEdit", font_disabled_color); theme->set_color("font_color", "LineEdit", font_color); @@ -969,9 +983,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("clear_button_color_pressed", "LineEdit", accent_color); // TextEdit - theme->set_stylebox("normal", "TextEdit", style_widget); - theme->set_stylebox("focus", "TextEdit", style_widget_hover); - theme->set_stylebox("read_only", "TextEdit", style_widget_disabled); + theme->set_stylebox("normal", "TextEdit", style_line_edit); + theme->set_stylebox("focus", "TextEdit", style_widget_focus); + theme->set_stylebox("read_only", "TextEdit", style_line_edit_disabled); theme->set_constant("side_margin", "TabContainer", 0); theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons")); theme->set_icon("space", "TextEdit", theme->get_icon("GuiSpace", "EditorIcons")); @@ -1014,14 +1028,22 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE); theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE); - // WindowDialog + // Window + + // Prevent corner artifacts between window title and body. + Ref<StyleBoxFlat> style_window_title = style_default->duplicate(); + style_window_title->set_corner_radius(CORNER_TOP_LEFT, 0); + style_window_title->set_corner_radius(CORNER_TOP_RIGHT, 0); + // Prevent visible line between window title and body. + style_window_title->set_expand_margin_size(SIDE_BOTTOM, 2 * EDSCALE); + theme->set_stylebox("panel", "Window", style_window_title); + Ref<StyleBoxFlat> style_window = style_popup->duplicate(); - style_window->set_border_color(tab_color); + style_window->set_border_color(base_color); style_window->set_border_width(SIDE_TOP, 24 * EDSCALE); style_window->set_expand_margin_size(SIDE_TOP, 24 * EDSCALE); - - theme->set_stylebox("panel", "Window", style_default); theme->set_stylebox("panel_window", "Window", style_window); + theme->set_color("title_color", "Window", font_color); theme->set_icon("close", "Window", theme->get_icon("GuiClose", "EditorIcons")); theme->set_icon("close_highlight", "Window", theme->get_icon("GuiClose", "EditorIcons")); @@ -1032,10 +1054,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_font("title_font", "Window", theme->get_font("title", "EditorFonts")); theme->set_font_size("title_font_size", "Window", theme->get_font_size("title_size", "EditorFonts")); - // complex window, for now only Editor settings and Project settings + // Complex window (currently only Editor Settings and Project Settings) Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); style_complex_window->set_bg_color(dark_color_2); - style_complex_window->set_border_color(highlight_tabs ? tab_color : dark_color_2); + style_complex_window->set_border_color(dark_color_2); theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window); theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window); theme->set_stylebox("panel", "EditorAbout", style_complex_window); @@ -1069,18 +1091,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // HSlider theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); - theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2)); - theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); + theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width)); + theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width)); theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); // VSlider theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); - theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0)); - theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); + theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width)); + theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width)); theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); - //RichTextLabel + // RichTextLabel theme->set_color("default_color", "RichTextLabel", font_color); theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0)); theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE); @@ -1092,7 +1114,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("headline_color", "EditorHelp", mono_color); // Panel - theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4)); + theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width)); theme->set_stylebox("panel_fg", "Panel", style_default); // Label @@ -1113,16 +1135,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // TooltipPanel Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate(); - float v = MAX(border_size * EDSCALE, 1.0); - style_tooltip->set_default_margin(SIDE_LEFT, v); - style_tooltip->set_default_margin(SIDE_TOP, v); - style_tooltip->set_default_margin(SIDE_RIGHT, v); - style_tooltip->set_default_margin(SIDE_BOTTOM, v); - style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9)); - style_tooltip->set_border_width_all(border_width); - style_tooltip->set_border_color(mono_color); - theme->set_color("font_color", "TooltipLabel", font_color.inverted()); - theme->set_color("font_shadow_color", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1)); + style_tooltip->set_shadow_size(0); + style_tooltip->set_default_margin(SIDE_LEFT, default_margin_size * EDSCALE); + style_tooltip->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE * 0.5); + style_tooltip->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); + style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5); + style_tooltip->set_bg_color(mono_color.inverted() * Color(1, 1, 1, 0.8)); + style_tooltip->set_border_width_all(0); + theme->set_color("font_color", "TooltipLabel", font_hover_color); + theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0)); theme->set_stylebox("panel", "TooltipPanel", style_tooltip); // PopupPanel @@ -1189,23 +1210,20 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color); // GraphNode - const float mv = dark_theme ? 0.0 : 1.0; - const float mv2 = 1.0 - mv; const int gn_margin_side = 28; - Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5); + + Ref<StyleBoxFlat> graphsb = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.7), gn_margin_side, 24, gn_margin_side, 5, corner_width); graphsb->set_border_width_all(border_width); - graphsb->set_border_color(Color(mv2, mv2, mv2, 0.9)); - Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5); - graphsbselected->set_border_width_all(border_width); + graphsb->set_border_color(dark_color_3); + Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.9), gn_margin_side, 24, gn_margin_side, 5, corner_width); + graphsbselected->set_border_width_all(2 * EDSCALE + border_width); graphsbselected->set_border_color(Color(accent_color.r, accent_color.g, accent_color.b, 0.9)); - graphsbselected->set_shadow_size(8 * EDSCALE); - graphsbselected->set_shadow_color(shadow_color); - Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.3), gn_margin_side, 24, gn_margin_side, 5, corner_width); graphsbcomment->set_border_width_all(border_width); - graphsbcomment->set_border_color(Color(mv2, mv2, mv2, 0.9)); - Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5); + graphsbcomment->set_border_color(dark_color_3); + Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.4), gn_margin_side, 24, gn_margin_side, 5, corner_width); graphsbcommentselected->set_border_width_all(border_width); - graphsbcommentselected->set_border_color(Color(mv2, mv2, mv2, 0.9)); + graphsbcommentselected->set_border_color(dark_color_3); Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate(); graphsbbreakpoint->set_draw_center(false); graphsbbreakpoint->set_border_color(warning_color); @@ -1214,21 +1232,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { graphsbposition->set_draw_center(false); graphsbposition->set_border_color(error_color); graphsbposition->set_shadow_color(error_color * Color(1.0, 1.0, 1.0, 0.2)); - Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.7), gn_margin_side, 24, gn_margin_side, 5, corner_width); smgraphsb->set_border_width_all(border_width); - smgraphsb->set_border_color(Color(mv2, mv2, mv2, 0.9)); - Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5); - smgraphsbselected->set_border_width_all(border_width); + smgraphsb->set_border_color(dark_color_3); + Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(dark_color_3 * Color(1, 1, 1, 0.9), gn_margin_side, 24, gn_margin_side, 5, corner_width); + smgraphsbselected->set_border_width_all(2 * EDSCALE + border_width); smgraphsbselected->set_border_color(Color(accent_color.r, accent_color.g, accent_color.b, 0.9)); smgraphsbselected->set_shadow_size(8 * EDSCALE); smgraphsbselected->set_shadow_color(shadow_color); - if (use_gn_headers) { - graphsb->set_border_width(SIDE_TOP, 24 * EDSCALE); - graphsbselected->set_border_width(SIDE_TOP, 24 * EDSCALE); - graphsbcomment->set_border_width(SIDE_TOP, 24 * EDSCALE); - graphsbcommentselected->set_border_width(SIDE_TOP, 24 * EDSCALE); - } + graphsb->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbselected->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbcomment->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbcommentselected->set_border_width(SIDE_TOP, 24 * EDSCALE); theme->set_stylebox("frame", "GraphNode", graphsb); theme->set_stylebox("selectedframe", "GraphNode", graphsbselected); @@ -1239,7 +1255,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb); theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected); - Color default_node_color = Color(mv2, mv2, mv2); + Color default_node_color = dark_color_1.inverted(); theme->set_color("title_color", "GraphNode", default_node_color); default_node_color.a = 0.7; theme->set_color("close_color", "GraphNode", default_node_color); @@ -1257,7 +1273,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons")); // GridContainer - theme->set_constant("vseparation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE); + theme->set_constant("vseparation", "GridContainer", Math::round(widget_default_margin.y - 2 * EDSCALE)); // FileDialog theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons")); @@ -1306,6 +1322,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color symbol_color = Color(0.34, 0.57, 1.0).lerp(mono_color, dark_theme ? 0.5 : 0.3); const Color keyword_color = Color(1.0, 0.44, 0.52); + const Color control_flow_keyword_color = dark_theme ? Color(1.0, 0.55, 0.8) : Color(0.8, 0.4, 0.6); const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38); const Color type_color = basetype_color.lerp(mono_color, dark_theme ? 0.4 : 0.3); const Color usertype_color = basetype_color.lerp(mono_color, dark_theme ? 0.7 : 0.5); @@ -1344,6 +1361,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { if (text_editor_color_theme == "Adaptive") { setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true); setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true); + setting->set_initial_value("text_editor/highlighting/control_flow_keyword_color", control_flow_keyword_color, true); setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true); setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); setting->set_initial_value("text_editor/highlighting/user_type_color", usertype_color, true); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 09424647fe..6cd45fdf97 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2806,7 +2806,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { toolbar_hbc->add_child(current_path); button_reload = memnew(Button); - button_reload->set_flat(true); button_reload->connect("pressed", callable_mp(this, &FileSystemDock::_rescan)); button_reload->set_focus_mode(FOCUS_NONE); button_reload->set_tooltip(TTR("Re-Scan Filesystem")); @@ -2814,7 +2813,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { toolbar_hbc->add_child(button_reload); button_toggle_display_mode = memnew(Button); - button_toggle_display_mode->set_flat(true); button_toggle_display_mode->set_toggle_mode(true); button_toggle_display_mode->connect("toggled", callable_mp(this, &FileSystemDock::_toggle_split_mode)); button_toggle_display_mode->set_focus_mode(FOCUS_NONE); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index fbcd76a95f..6265dfc2e4 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -535,7 +535,6 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { } else { backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); } - backward_button->set_flat(true); backward_button->set_tooltip(TTR("Go to the previous edited object in history.")); backward_button->set_disabled(true); backward_button->connect("pressed", callable_mp(this, &InspectorDock::_edit_back)); @@ -548,7 +547,6 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { } else { forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); } - forward_button->set_flat(true); forward_button->set_tooltip(TTR("Go to the next edited object in history.")); forward_button->set_disabled(true); forward_button->connect("pressed", callable_mp(this, &InspectorDock::_edit_forward)); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 48fb507bb1..78c30df04b 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -231,18 +231,16 @@ void AnimationNodeBlendTreeEditor::_update_graph() { mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E->get()), CONNECT_DEFERRED); } - if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); - Color c = sb->get_border_color(); - Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0); - mono_color.a = 0.85; - c = mono_color; - - node->add_theme_color_override("title_color", c); - c.a = 0.7; - node->add_theme_color_override("close_color", c); - node->add_theme_color_override("resizer_color", c); - } + Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + Color c = sb->get_border_color(); + Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0); + mono_color.a = 0.85; + c = mono_color; + + node->add_theme_color_override("title_color", c); + c.a = 0.7; + node->add_theme_color_override("close_color", c); + node->add_theme_color_override("resizer_color", c); } List<AnimationNodeBlendTree::NodeConnection> connections; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index fd47d9964e..a0d9afee74 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -240,7 +240,6 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons preview.video_link = p_url; preview.is_video = p_video; preview.button = memnew(Button); - preview.button->set_flat(true); preview.button->set_icon(previews->get_theme_icon("ThumbnailWait", "EditorIcons")); preview.button->set_toggle_mode(true); preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click), varray(p_id)); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 139569ac8a..91022ccb2c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5770,6 +5770,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { updating_scroll = false; + // Add some margin to the left for better aesthetics. + // This prevents the first button's hover/pressed effect from "touching" the panel's border, + // which looks ugly. + Control *margin_left = memnew(Control); + hb->add_child(margin_left); + margin_left->set_custom_minimum_size(Size2(2, 0) * EDSCALE); + select_button = memnew(Button); select_button->set_flat(true); hb->add_child(select_button); @@ -6006,7 +6013,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_loc_button = memnew(Button); key_loc_button->set_toggle_mode(true); - key_loc_button->set_flat(true); key_loc_button->set_pressed(true); key_loc_button->set_focus_mode(FOCUS_NONE); key_loc_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_POS)); @@ -6015,7 +6021,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_rot_button = memnew(Button); key_rot_button->set_toggle_mode(true); - key_rot_button->set_flat(true); key_rot_button->set_pressed(true); key_rot_button->set_focus_mode(FOCUS_NONE); key_rot_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_ROT)); @@ -6024,14 +6029,12 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_scale_button = memnew(Button); key_scale_button->set_toggle_mode(true); - key_scale_button->set_flat(true); key_scale_button->set_focus_mode(FOCUS_NONE); key_scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_SCALE)); key_scale_button->set_tooltip(TTR("Scale mask for inserting keys.")); animation_hb->add_child(key_scale_button); key_insert_button = memnew(Button); - key_insert_button->set_flat(true); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_KEY)); key_insert_button->set_tooltip(TTR("Insert keys (based on mask).")); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a319a595c7..18cc5d43fb 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -487,10 +487,15 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size List<String> kwors; scr->get_language()->get_reserved_words(&kwors); + Set<String> control_flow_keywords; Set<String> keywords; for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - keywords.insert(E->get()); + if (scr->get_language()->is_control_flow_keyword(E->get())) { + control_flow_keywords.insert(E->get()); + } else { + keywords.insert(E->get()); + } } int line = 0; @@ -502,6 +507,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Color bg_color = EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"); Color keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/control_flow_keyword_color"); Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"); Color symbol_color = EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"); Color comment_color = EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"); @@ -523,6 +529,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size col = x0; bool prev_is_text = false; + bool in_control_flow_keyword = false; bool in_keyword = false; bool in_comment = false; for (int i = 0; i < code.length(); i++) { @@ -541,6 +548,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size if (c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t')) { //make symbol a little visible color = symbol_color; + in_control_flow_keyword = false; in_keyword = false; } else if (!prev_is_text && _is_text_char(c)) { int pos = i; @@ -549,7 +557,9 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size pos++; } String word = code.substr(i, pos - i); - if (keywords.has(word)) { + if (control_flow_keywords.has(word)) { + in_control_flow_keyword = true; + } else if (keywords.has(word)) { in_keyword = true; } @@ -557,11 +567,12 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size in_keyword = false; } - if (in_keyword) { + if (in_control_flow_keyword) { + color = control_flow_keyword_color; + } else if (in_keyword) { color = keyword_color; } } - Color ul = color; ul.a *= 0.5; img->set_pixel(col, y0 + line * 2, bg_color.blend(ul)); @@ -572,6 +583,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size col++; } else { prev_is_text = false; + in_control_flow_keyword = false; in_keyword = false; if (c == '\n') { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 023d91be30..81f1852fba 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6692,6 +6692,13 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.resize(1); String sct; + // Add some margin to the left for better aesthetics. + // This prevents the first button's hover/pressed effect from "touching" the panel's border, + // which looks ugly. + Control *margin_left = memnew(Control); + hbc_menu->add_child(margin_left); + margin_left->set_custom_minimum_size(Size2(2, 0) * EDSCALE); + tool_button[TOOL_MODE_SELECT] = memnew(Button); hbc_menu->add_child(tool_button[TOOL_MODE_SELECT]); tool_button[TOOL_MODE_SELECT]->set_toggle_mode(true); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 50f4d8493f..1e6237ced1 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -205,7 +205,6 @@ void EditorPropertyRootMotion::update_property() { assign->set_flat(false); return; } - assign->set_flat(true); Node *base_node = nullptr; if (base_hint != NodePath()) { @@ -247,14 +246,12 @@ EditorPropertyRootMotion::EditorPropertyRootMotion() { HBoxContainer *hbc = memnew(HBoxContainer); add_child(hbc); assign = memnew(Button); - assign->set_flat(true); assign->set_h_size_flags(SIZE_EXPAND_FILL); assign->set_clip_text(true); assign->connect("pressed", callable_mp(this, &EditorPropertyRootMotion::_node_assign)); hbc->add_child(assign); clear = memnew(Button); - clear->set_flat(true); clear->connect("pressed", callable_mp(this, &EditorPropertyRootMotion::_node_clear)); hbc->add_child(clear); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index ed34a6182e..adfeead33b 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -140,10 +140,15 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Reserved words. */ const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), keyword_color); + if (script->get_language()->is_control_flow_keyword(E->get())) { + highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + highlighter->add_keyword_color(E->get(), keyword_color); + } } /* Member types. */ @@ -1832,7 +1837,6 @@ void ScriptEditor::_update_help_overview() { void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled"); - bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script"); int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size"); Color hot_color = get_theme_color("accent_color", "Editor"); @@ -1847,11 +1851,7 @@ void ScriptEditor::_update_script_colors() { script_list->set_item_custom_bg_color(i, Color(0, 0, 0, 0)); - bool current = tab_container->get_current_tab() == c; - if (current && highlight_current) { - script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/script_list/current_script_background_color")); - - } else if (script_temperature_enabled) { + if (script_temperature_enabled) { if (!n->has_meta("__editor_pass")) { continue; } @@ -3680,9 +3680,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("text_editor/external/use_external_editor", false); EDITOR_DEF("text_editor/external/exec_path", ""); EDITOR_DEF("text_editor/script_list/script_temperature_enabled", true); - EDITOR_DEF("text_editor/script_list/highlight_current_script", true); EDITOR_DEF("text_editor/script_list/script_temperature_history_size", 15); - EDITOR_DEF("text_editor/script_list/current_script_background_color", Color(1, 1, 1, 0.3)); EDITOR_DEF("text_editor/script_list/group_help_pages", true); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/script_list/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path,None")); EDITOR_DEF("text_editor/script_list/sort_scripts_by", 0); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index ed3b746678..3cdba9cf16 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -141,9 +141,14 @@ void ShaderTextEditor::_load_theme_settings() { List<String> keywords; ShaderLanguage::get_keyword_list(&keywords); const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } // Colorize built-ins like `COLOR` differently to make them easier diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index acc77bd098..1d4c23fee6 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -736,6 +736,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); Color text_color = EDITOR_GET("text_editor/highlighting/text_color"); Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); Color function_color = EDITOR_GET("text_editor/highlighting/function_color"); @@ -746,7 +747,11 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) { - expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + expression_syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts")); @@ -1175,26 +1180,15 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) { } void VisualShaderEditor::_update_created_node(GraphNode *node) { - if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); - Color c = sb->get_border_color(); - Color ic; - Color mono_color; - if (((c.r + c.g + c.b) / 3) < 0.7) { - mono_color = Color(1.0, 1.0, 1.0); - ic = Color(0.0, 0.0, 0.0, 0.7); - } else { - mono_color = Color(0.0, 0.0, 0.0); - ic = Color(1.0, 1.0, 1.0, 0.7); - } - mono_color.a = 0.85; - c = mono_color; + const Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + Color c = sb->get_border_color(); + const Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0, 0.85) : Color(0.0, 0.0, 0.0, 0.85); + c = mono_color; - node->add_theme_color_override("title_color", c); - c.a = 0.7; - node->add_theme_color_override("close_color", c); - node->add_theme_color_override("resizer_color", ic); - } + node->add_theme_color_override("title_color", c); + c.a = 0.7; + node->add_theme_color_override("close_color", c); + node->add_theme_color_override("resizer_color", c); } void VisualShaderEditor::_update_uniforms(bool p_update_refs) { @@ -2803,6 +2797,7 @@ void VisualShaderEditor::_notification(int p_what) { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); Color text_color = EDITOR_GET("text_editor/highlighting/text_color"); Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); Color function_color = EDITOR_GET("text_editor/highlighting/function_color"); @@ -2812,7 +2807,11 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + if (ShaderLanguage::is_control_flow_keyword(E->get())) { + syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + } else { + syntax_highlighter->add_keyword_color(E->get(), keyword_color); + } } preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index faec3355ac..76290b4b62 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -649,8 +649,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { action_map->connect("action_removed", callable_mp(this, &ProjectSettingsEditor::_action_removed)); action_map->connect("action_renamed", callable_mp(this, &ProjectSettingsEditor::_action_renamed)); action_map->connect("action_reordered", callable_mp(this, &ProjectSettingsEditor::_action_reordered)); - action_map->set_toggle_editable_label(TTR("Show Built-in Actions")); - action_map->set_show_uneditable(false); tab_container->add_child(action_map); localization_editor = memnew(LocalizationEditor); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 1a010b9168..8b0d9ae0fc 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1823,7 +1823,6 @@ CustomPropertyEditor::CustomPropertyEditor() { Vector<Variant> binds; binds.push_back(i); action_buttons[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), binds); - action_buttons[i]->set_flat(true); } color_picker = nullptr; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 49c231de69..4068a102df 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2587,14 +2587,16 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } } - if (profile_allow_script_editing) { + if (profile_allow_editing) { menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/cut_node"), TOOL_CUT); menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/copy_node"), TOOL_COPY); if (selection.size() == 1 && !node_clipboard.is_empty()) { menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/paste_node"), TOOL_PASTE); } menu->add_separator(); + } + if (profile_allow_script_editing) { bool add_separator = false; if (full_selection.size() == 1) { @@ -2622,7 +2624,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } } - if (add_separator) { + if (add_separator && profile_allow_editing) { menu->add_separator(); } } @@ -3042,7 +3044,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel ED_SHORTCUT("scene_tree/rename", TTR("Rename"), KEY_F2); ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_SHIFT | KEY_F2); ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A); - ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene")); + ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_A); ED_SHORTCUT("scene_tree/expand_collapse_all", TTR("Expand/Collapse All")); ED_SHORTCUT("scene_tree/cut_node", TTR("Cut"), KEY_MASK_CMD | KEY_X); ED_SHORTCUT("scene_tree/copy_node", TTR("Copy"), KEY_MASK_CMD | KEY_C); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index f3addd8904..c2bfdaae96 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -838,7 +838,6 @@ ScriptCreateDialog::ScriptCreateDialog() { parent_search_button->connect("pressed", callable_mp(this, &ScriptCreateDialog::_browse_class_in_tree)); hb->add_child(parent_search_button); parent_browse_button = memnew(Button); - parent_browse_button->set_flat(true); parent_browse_button->connect("pressed", callable_mp(this, &ScriptCreateDialog::_browse_path), varray(true, false)); hb->add_child(parent_browse_button); gc->add_child(memnew(Label(TTR("Inherits:")))); @@ -877,7 +876,6 @@ ScriptCreateDialog::ScriptCreateDialog() { file_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(file_path); path_button = memnew(Button); - path_button->set_flat(true); path_button->connect("pressed", callable_mp(this, &ScriptCreateDialog::_browse_path), varray(false, true)); hb->add_child(path_button); gc->add_child(memnew(Label(TTR("Path:")))); diff --git a/misc/dist/html/fixed-size.html b/misc/dist/html/fixed-size.html deleted file mode 100644 index 9d0a946497..0000000000 --- a/misc/dist/html/fixed-size.html +++ /dev/null @@ -1,389 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <link id='-gd-engine-icon' rel='icon' type='image/png' href='favicon.png' /> - <title>$GODOT_PROJECT_NAME</title> - <style type="text/css"> - - body { - margin: 0; - border: 0 none; - padding: 0; - text-align: center; - background-color: #222226; - font-family: 'Noto Sans', Arial, sans-serif; - } - - - /* Godot Engine default theme style - * ================================ */ - - .godot { - color: #e0e0e0; - background-color: #3b3943; - background-image: linear-gradient(to bottom, #403e48, #35333c); - border: 1px solid #45434e; - box-shadow: 0 0 1px 1px #2f2d35; - } - - button.godot { - font-family: 'Droid Sans', Arial, sans-serif; /* override user agent style */ - padding: 1px 5px; - background-color: #37353f; - background-image: linear-gradient(to bottom, #413e49, #3a3842); - border: 1px solid #514f5d; - border-radius: 1px; - box-shadow: 0 0 1px 1px #2a2930; - } - - button.godot:hover { - color: #f0f0f0; - background-color: #44414e; - background-image: linear-gradient(to bottom, #494652, #423f4c); - border: 1px solid #5a5667; - box-shadow: 0 0 1px 1px #26252b; - } - - button.godot:active { - color: #fff; - background-color: #3e3b46; - background-image: linear-gradient(to bottom, #36343d, #413e49); - border: 1px solid #4f4c59; - box-shadow: 0 0 1px 1px #26252b; - } - - button.godot:disabled { - color: rgba(230, 230, 230, 0.2); - background-color: #3d3d3d; - background-image: linear-gradient(to bottom, #434343, #393939); - border: 1px solid #474747; - box-shadow: 0 0 1px 1px #2d2b33; - } - - - /* Canvas / wrapper - * ================ */ - - #container { - display: inline-block; /* scale with canvas */ - vertical-align: top; /* prevent extra height */ - position: relative; /* root for absolutely positioned overlay */ - margin: 0; - border: 0 none; - padding: 0; - background-color: #0c0c0c; - } - - #canvas { - display: block; - margin: 0 auto; - color: white; - } - - #canvas:focus { - outline: none; - } - - - /* Status display - * ============== */ - - #status { - position: absolute; - left: 0; - top: 0; - right: 0; - bottom: 0; - display: flex; - justify-content: center; - align-items: center; - /* don't consume click events - make children visible explicitly */ - visibility: hidden; - } - - #status-progress { - width: 244px; - height: 7px; - background-color: #38363A; - border: 1px solid #444246; - padding: 1px; - box-shadow: 0 0 2px 1px #1B1C22; - border-radius: 2px; - visibility: visible; - } - - #status-progress-inner { - height: 100%; - width: 0; - box-sizing: border-box; - transition: width 0.5s linear; - background-color: #202020; - border: 1px solid #222223; - box-shadow: 0 0 1px 1px #27282E; - border-radius: 3px; - } - - #status-indeterminate { - visibility: visible; - position: relative; - } - - #status-indeterminate > div { - width: 3px; - height: 0; - border-style: solid; - border-width: 6px 2px 0 2px; - border-color: #2b2b2b transparent transparent transparent; - transform-origin: center 14px; - position: absolute; - } - - #status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); } - #status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); } - #status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); } - #status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); } - #status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); } - #status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); } - #status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); } - #status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); } - - #status-notice { - margin: 0 100px; - line-height: 1.3; - visibility: visible; - padding: 4px 6px; - visibility: visible; - } - - - /* Debug output - * ============ */ - - #output-panel { - display: none; - max-width: 700px; - font-size: small; - margin: 6px auto 0; - padding: 0 4px 4px; - text-align: left; - line-height: 2.2; - } - - #output-header { - display: flex; - justify-content: space-between; - align-items: center; - } - - #output-container { - padding: 6px; - background-color: #2c2a32; - box-shadow: inset 0 0 1px 1px #232127; - color: #bbb; - } - - #output-scroll { - line-height: 1; - height: 12em; - overflow-y: scroll; - white-space: pre-wrap; - font-size: small; - font-family: "Lucida Console", Monaco, monospace; - } - </style> -$GODOT_HEAD_INCLUDE -</head> -<body> - <div id="container"> - <canvas id="canvas" width="640" height="480"> - HTML5 canvas appears to be unsupported in the current browser.<br /> - Please try updating or use a different browser. - </canvas> - <div id="status"> - <div id='status-progress' style='display: none;' oncontextmenu="event.preventDefault();"><div id ='status-progress-inner'></div></div> - <div id='status-indeterminate' style='display: none;' oncontextmenu="event.preventDefault();"> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - </div> - <div id="status-notice" class="godot" style='display: none;'></div> - </div> - </div> - <div id="output-panel" class="godot"> - <div id="output-header"> - Output: - <button id='output-clear' class='godot' type='button' autocomplete='off'>Clear</button> - </div> - <div id="output-container"><div id="output-scroll"></div></div> - </div> - - <script type="text/javascript" src="$GODOT_BASENAME.js"></script> - <script type="text/javascript">//<![CDATA[ - - var engine = new Engine; - - (function() { - const EXECUTABLE_NAME = '$GODOT_BASENAME'; - const MAIN_PACK = '$GODOT_BASENAME.pck'; - const EXTRA_ARGS = JSON.parse('$GODOT_ARGS'); - const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED; - const INDETERMINATE_STATUS_STEP_MS = 100; - - var canvas = document.getElementById('canvas'); - var statusProgress = document.getElementById('status-progress'); - var statusProgressInner = document.getElementById('status-progress-inner'); - var statusIndeterminate = document.getElementById('status-indeterminate'); - var statusNotice = document.getElementById('status-notice'); - - var initializing = true; - var statusMode = 'hidden'; - var indeterminiateStatusAnimationId = 0; - - function setStatusMode(mode) { - if (statusMode === mode || !initializing) - return; - [statusProgress, statusIndeterminate, statusNotice].forEach(elem => { - elem.style.display = 'none'; - }); - if (indeterminiateStatusAnimationId !== 0) { - cancelAnimationFrame(indeterminiateStatusAnimationId); - indeterminiateStatusAnimationId = 0; - } - switch (mode) { - case 'progress': - statusProgress.style.display = 'block'; - break; - case 'indeterminate': - statusIndeterminate.style.display = 'block'; - indeterminiateStatusAnimationId = requestAnimationFrame(animateStatusIndeterminate); - break; - case 'notice': - statusNotice.style.display = 'block'; - break; - case 'hidden': - break; - default: - throw new Error("Invalid status mode"); - } - statusMode = mode; - } - - function animateStatusIndeterminate(ms) { - var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8); - if (statusIndeterminate.children[i].style.borderTopColor == '') { - Array.prototype.slice.call(statusIndeterminate.children).forEach(child => { - child.style.borderTopColor = ''; - }); - statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf'; - } - requestAnimationFrame(animateStatusIndeterminate); - } - - function setStatusNotice(text) { - while (statusNotice.lastChild) { - statusNotice.removeChild(statusNotice.lastChild); - } - var lines = text.split('\n'); - lines.forEach((line, index) => { - statusNotice.appendChild(document.createTextNode(line)); - statusNotice.appendChild(document.createElement('br')); - }); - }; - - engine.setProgressFunc((current, total) => { - if (total > 0) { - statusProgressInner.style.width = current/total * 100 + '%'; - setStatusMode('progress'); - if (current === total) { - // wait for progress bar animation - setTimeout(() => { - setStatusMode('indeterminate'); - }, 500); - } - } else { - setStatusMode('indeterminate'); - } - }); - - if (DEBUG_ENABLED) { - var outputRoot = document.getElementById("output-panel"); - var outputScroll = document.getElementById("output-scroll"); - var OUTPUT_MSG_COUNT_MAX = 400; - - document.getElementById('output-clear').addEventListener('click', () => { - while (outputScroll.firstChild) { - outputScroll.firstChild.remove(); - } - }); - - outputRoot.style.display = 'block'; - - function print(text) { - while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) { - outputScroll.firstChild.remove(); - } - var msg = document.createElement("div"); - if (String.prototype.trim.call(text).startsWith("**ERROR**")) { - msg.style.color = "#d44"; - } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) { - msg.style.color = "#ccc000"; - } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) { - msg.style.color = "#c6d"; - } - msg.textContent = text; - var scrollToBottom = outputScroll.scrollHeight - (outputScroll.clientHeight + outputScroll.scrollTop) < 10; - outputScroll.appendChild(msg); - if (scrollToBottom) { - outputScroll.scrollTop = outputScroll.scrollHeight; - } - }; - - function printError(text) { - if (!String.prototype.trim.call(text).startsWith('**ERROR**: ')) { - text = '**ERROR**: ' + text; - } - print(text); - } - - engine.setStdoutFunc(text => { - print(text); - console.log(text); - }); - - engine.setStderrFunc(text => { - printError(text); - console.warn(text); - }); - } - - function displayFailureNotice(err) { - var msg = err.message || err; - if (DEBUG_ENABLED) { - printError(msg); - } - console.error(msg); - setStatusNotice(msg); - setStatusMode('notice'); - initializing = false; - }; - - if (!Engine.isWebGLAvailable()) { - displayFailureNotice("WebGL not available"); - } else { - setStatusMode('indeterminate'); - engine.setCanvas(canvas); - engine.startGame(EXECUTABLE_NAME, MAIN_PACK, EXTRA_ARGS).then(() => { - setStatusMode('hidden'); - initializing = false; - }, displayFailureNotice); - } - })(); - //]]></script> -</body> -</html> diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 3283f28de5..46af70f73c 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1289,6 +1289,10 @@ void NativeScriptLanguage::finish() { void NativeScriptLanguage::get_reserved_words(List<String> *p_words) const { } +bool NativeScriptLanguage::is_control_flow_keyword(String p_keyword) const { + return false; +} + void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { } diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 4bd54f9c46..ca5e76e43e 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -336,6 +336,7 @@ public: virtual Error execute_file(const String &p_path); virtual void finish(); virtual void get_reserved_words(List<String> *p_words) const; + virtual bool is_control_flow_keyword(String p_keyword) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 3ed1dcaca9..1360cf0299 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -77,6 +77,10 @@ void PluginScriptLanguage::get_reserved_words(List<String> *p_words) const { } } +bool PluginScriptLanguage::is_control_flow_keyword(String p_keyword) const { + return false; +} + void PluginScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { if (_desc.comment_delimiters) { const char **w = _desc.comment_delimiters; diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h index 226b039265..957bf355ca 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ b/modules/gdnative/pluginscript/pluginscript_language.h @@ -71,6 +71,7 @@ public: /* EDITOR FUNCTIONS */ virtual void get_reserved_words(List<String> *p_words) const; + virtual bool is_control_flow_keyword(String p_keyword) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index ccc942d86b..ca646dff15 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -485,10 +485,15 @@ void GDScriptSyntaxHighlighter::_update_cache() { /* Reserved words. */ const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); + const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keyword_list; gdscript->get_reserved_words(&keyword_list); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - keywords[E->get()] = keyword_color; + if (gdscript->is_control_flow_keyword(E->get())) { + keywords[E->get()] = control_flow_keyword_color; + } else { + keywords[E->get()] = keyword_color; + } } /* Comments */ diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 5f590383d0..859c1acde9 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2135,6 +2135,19 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { } } +bool GDScriptLanguage::is_control_flow_keyword(String p_keyword) const { + return p_keyword == "break" || + p_keyword == "continue" || + p_keyword == "elif" || + p_keyword == "else" || + p_keyword == "if" || + p_keyword == "for" || + p_keyword == "match" || + p_keyword == "pass" || + p_keyword == "return" || + p_keyword == "while"; +} + bool GDScriptLanguage::handles_global_class_type(const String &p_type) const { return p_type == "GDScript"; } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 98da5ad4cb..6df66e876d 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -461,6 +461,7 @@ public: /* EDITOR FUNCTIONS */ virtual void get_reserved_words(List<String> *p_words) const; + virtual bool is_control_flow_keyword(String p_keywords) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual String _get_processed_template(const String &p_template, const String &p_base_class_name) const; diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 099abd35a7..6ae825d2bd 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2998,6 +2998,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol is_function = true; [[fallthrough]]; } + case GDScriptParser::COMPLETION_CALL_ARGUMENTS: case GDScriptParser::COMPLETION_IDENTIFIER: { GDScriptParser::DataType base_type; if (context.current_class) { diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 2e6388d92f..3f14156dfa 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -643,6 +643,8 @@ GDScriptTokenizer::Token GDScriptTokenizer::number() { push_error(error); } previous_was_underscore = true; + } else { + previous_was_underscore = false; } _advance(); } @@ -714,6 +716,8 @@ GDScriptTokenizer::Token GDScriptTokenizer::number() { push_error(error); } previous_was_underscore = true; + } else { + previous_was_underscore = false; } _advance(); } diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index e63b6ab20e..15236d900d 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -49,8 +49,9 @@ void ExtendGDScriptParser::update_diagnostics() { diagnostic.code = -1; lsp::Range range; lsp::Position pos; - int line = LINE_NUMBER_TO_INDEX(error.line); - const String &line_text = get_lines()[line]; + const PackedStringArray lines = get_lines(); + int line = CLAMP(LINE_NUMBER_TO_INDEX(error.line), 0, lines.size() - 1); + const String &line_text = lines[line]; pos.line = line; pos.character = line_text.length() - line_text.strip_edges(true, false).length(); range.start = pos; @@ -361,24 +362,73 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN r_symbol.detail += " -> " + p_func->get_datatype().to_string(); } - for (int i = 0; i < p_func->body->locals.size(); i++) { - const SuiteNode::Local &local = p_func->body->locals[i]; - lsp::DocumentSymbol symbol; - symbol.name = local.name; - symbol.kind = local.type == SuiteNode::Local::CONSTANT ? lsp::SymbolKind::Constant : lsp::SymbolKind::Variable; - symbol.range.start.line = LINE_NUMBER_TO_INDEX(local.start_line); - symbol.range.start.character = LINE_NUMBER_TO_INDEX(local.start_column); - symbol.range.end.line = LINE_NUMBER_TO_INDEX(local.end_line); - symbol.range.end.character = LINE_NUMBER_TO_INDEX(local.end_column); - symbol.uri = uri; - symbol.script_path = path; - symbol.detail = SuiteNode::Local::CONSTANT ? "const " : "var "; - symbol.detail += symbol.name; - if (local.get_datatype().is_hard_type()) { - symbol.detail += ": " + local.get_datatype().to_string(); + List<GDScriptParser::SuiteNode *> function_nodes; + + List<GDScriptParser::Node *> node_stack; + node_stack.push_back(p_func->body); + + while (!node_stack.is_empty()) { + GDScriptParser::Node *node = node_stack[0]; + node_stack.pop_front(); + + switch (node->type) { + case GDScriptParser::TypeNode::IF: { + GDScriptParser::IfNode *if_node = (GDScriptParser::IfNode *)node; + node_stack.push_back(if_node->true_block); + if (if_node->false_block) { + node_stack.push_back(if_node->false_block); + } + } break; + + case GDScriptParser::TypeNode::FOR: { + GDScriptParser::ForNode *for_node = (GDScriptParser::ForNode *)node; + node_stack.push_back(for_node->loop); + } break; + + case GDScriptParser::TypeNode::WHILE: { + GDScriptParser::WhileNode *while_node = (GDScriptParser::WhileNode *)node; + node_stack.push_back(while_node->loop); + } break; + + case GDScriptParser::TypeNode::MATCH_BRANCH: { + GDScriptParser::MatchBranchNode *match_node = (GDScriptParser::MatchBranchNode *)node; + node_stack.push_back(match_node->block); + } break; + + case GDScriptParser::TypeNode::SUITE: { + GDScriptParser::SuiteNode *suite_node = (GDScriptParser::SuiteNode *)node; + function_nodes.push_back(suite_node); + for (int i = 0; i < suite_node->statements.size(); ++i) { + node_stack.push_back(suite_node->statements[i]); + } + } break; + + default: + continue; + } + } + + for (List<GDScriptParser::SuiteNode *>::Element *N = function_nodes.front(); N; N = N->next()) { + const GDScriptParser::SuiteNode *suite_node = N->get(); + for (int i = 0; i < suite_node->locals.size(); i++) { + const SuiteNode::Local &local = suite_node->locals[i]; + lsp::DocumentSymbol symbol; + symbol.name = local.name; + symbol.kind = local.type == SuiteNode::Local::CONSTANT ? lsp::SymbolKind::Constant : lsp::SymbolKind::Variable; + symbol.range.start.line = LINE_NUMBER_TO_INDEX(local.start_line); + symbol.range.start.character = LINE_NUMBER_TO_INDEX(local.start_column); + symbol.range.end.line = LINE_NUMBER_TO_INDEX(local.end_line); + symbol.range.end.character = LINE_NUMBER_TO_INDEX(local.end_column); + symbol.uri = uri; + symbol.script_path = path; + symbol.detail = local.type == SuiteNode::Local::CONSTANT ? "const " : "var "; + symbol.detail += symbol.name; + if (local.get_datatype().is_hard_type()) { + symbol.detail += ": " + local.get_datatype().to_string(); + } + symbol.documentation = parse_documentation(LINE_NUMBER_TO_INDEX(local.start_line)); + r_symbol.children.push_back(symbol); } - symbol.documentation = parse_documentation(LINE_NUMBER_TO_INDEX(local.start_line)); - r_symbol.children.push_back(symbol); } } diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 69cad1a335..9b7b2b36b4 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -42,6 +42,7 @@ #include "scene/resources/packed_scene.h" void GDScriptWorkspace::_bind_methods() { + ClassDB::bind_method(D_METHOD("didDeleteFiles"), &GDScriptWorkspace::did_delete_files); ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol); ClassDB::bind_method(D_METHOD("parse_script", "path", "content"), &GDScriptWorkspace::parse_script); ClassDB::bind_method(D_METHOD("parse_local_script", "path"), &GDScriptWorkspace::parse_local_script); @@ -51,6 +52,16 @@ void GDScriptWorkspace::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_script_api", "path"), &GDScriptWorkspace::generate_script_api); } +void GDScriptWorkspace::did_delete_files(const Dictionary &p_params) { + Array files = p_params["files"]; + for (int i = 0; i < files.size(); ++i) { + Dictionary file = files[i]; + String uri = file["uri"]; + String path = get_file_path(uri); + parse_script(path, ""); + } +} + void GDScriptWorkspace::remove_cache_parser(const String &p_path) { Map<String, ExtendGDScriptParser *>::Element *parser = parse_results.find(p_path); Map<String, ExtendGDScriptParser *>::Element *script = scripts.find(p_path); diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index 7fd8bfcf20..27616a2989 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -89,6 +89,7 @@ public: void resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list); Dictionary generate_script_api(const String &p_path); Error resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature); + void did_delete_files(const Dictionary &p_params); GDScriptWorkspace(); ~GDScriptWorkspace(); diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 6635098be2..47bcfeaefc 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -1528,6 +1528,114 @@ struct SignatureHelp { } }; +/** + * A pattern to describe in which file operation requests or notifications + * the server is interested in. + */ +struct FileOperationPattern { + /** + * The glob pattern to match. + */ + String glob = "**/*.gd"; + + /** + * Whether to match `file`s or `folder`s with this pattern. + * + * Matches both if undefined. + */ + String matches = "file"; + + Dictionary to_json() const { + Dictionary dict; + + dict["glob"] = glob; + dict["matches"] = matches; + + return dict; + } +}; + +/** + * A filter to describe in which file operation requests or notifications + * the server is interested in. + */ +struct FileOperationFilter { + /** + * The actual file operation pattern. + */ + FileOperationPattern pattern; + + Dictionary to_json() const { + Dictionary dict; + + dict["pattern"] = pattern.to_json(); + + return dict; + } +}; + +/** + * The options to register for file operations. + */ +struct FileOperationRegistrationOptions { + /** + * The actual filters. + */ + Vector<FileOperationFilter> filters; + + FileOperationRegistrationOptions() { + filters.push_back(FileOperationFilter()); + } + + Dictionary to_json() const { + Dictionary dict; + + Array filts; + for (int i = 0; i < filters.size(); i++) { + filts.push_back(filters[i].to_json()); + } + dict["filters"] = filts; + + return dict; + } +}; + +/** + * The server is interested in file notifications/requests. + */ +struct FileOperations { + /** + * The server is interested in receiving didDeleteFiles file notifications. + */ + FileOperationRegistrationOptions didDelete; + + Dictionary to_json() const { + Dictionary dict; + + dict["didDelete"] = didDelete.to_json(); + + return dict; + } +}; + +/** + * Workspace specific server capabilities + */ +struct Workspace { + /** + * The server is interested in file notifications/requests. + */ + FileOperations fileOperations; + + Dictionary to_json() const { + Dictionary dict; + + dict["fileOperations"] = fileOperations.to_json(); + + return dict; + } +}; + struct ServerCapabilities { /** * Defines how text documents are synced. Is either a detailed structure defining each notification or @@ -1590,6 +1698,11 @@ struct ServerCapabilities { bool workspaceSymbolProvider = true; /** + * The server supports workspace folder. + */ + Workspace workspace; + + /** * The server provides code actions. The `CodeActionOptions` return type is only * valid if the client signals code action literal support via the property * `textDocument.codeAction.codeActionLiteralSupport`. @@ -1676,6 +1789,7 @@ struct ServerCapabilities { dict["documentHighlightProvider"] = documentHighlightProvider; dict["documentSymbolProvider"] = documentSymbolProvider; dict["workspaceSymbolProvider"] = workspaceSymbolProvider; + dict["workspace"] = workspace.to_json(); dict["codeActionProvider"] = codeActionProvider; dict["documentFormattingProvider"] = documentFormattingProvider; dict["documentRangeFormattingProvider"] = documentRangeFormattingProvider; diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 09f3ea1f50..ffb04bfd37 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -304,6 +304,26 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const { } } +bool CSharpLanguage::is_control_flow_keyword(String p_keyword) const { + return p_keyword == "break" || + p_keyword == "case" || + p_keyword == "catch" || + p_keyword == "continue" || + p_keyword == "default" || + p_keyword == "do" || + p_keyword == "else" || + p_keyword == "finally" || + p_keyword == "for" || + p_keyword == "foreach" || + p_keyword == "goto" || + p_keyword == "if" || + p_keyword == "return" || + p_keyword == "switch" || + p_keyword == "throw" || + p_keyword == "try" || + p_keyword == "while"; +} + void CSharpLanguage::get_comment_delimiters(List<String> *p_delimiters) const { p_delimiters->push_back("//"); // single-line comment p_delimiters->push_back("/* */"); // delimited comment diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index dd93a86d7a..992c7e93c8 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -470,6 +470,7 @@ public: /* EDITOR FUNCTIONS */ void get_reserved_words(List<String> *p_words) const override; + bool is_control_flow_keyword(String p_keyword) const; void get_comment_delimiters(List<String> *p_delimiters) const override; void get_string_delimiters(List<String> *p_delimiters) const override; Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const override; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 0c333d06ef..2a9f834aac 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -681,7 +681,7 @@ namespace Godot name = name.Replace("_", String.Empty); name = name.Replace("'", String.Empty); name = name.Replace(".", String.Empty); - name = name.ToLower(); + name = name.ToUpper(); if (!Colors.namedColors.ContainsKey(name)) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index d05a0414aa..4bb727bd35 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -9,301 +9,301 @@ namespace Godot /// </summary> public static class Colors { - // Color names and values are derived from core/color_names.inc + // Color names and values are derived from core/math/color_names.inc internal static readonly Dictionary<string, Color> namedColors = new Dictionary<string, Color> { - {"aliceblue", new Color(0.94f, 0.97f, 1.00f)}, - {"antiquewhite", new Color(0.98f, 0.92f, 0.84f)}, - {"aqua", new Color(0.00f, 1.00f, 1.00f)}, - {"aquamarine", new Color(0.50f, 1.00f, 0.83f)}, - {"azure", new Color(0.94f, 1.00f, 1.00f)}, - {"beige", new Color(0.96f, 0.96f, 0.86f)}, - {"bisque", new Color(1.00f, 0.89f, 0.77f)}, - {"black", new Color(0.00f, 0.00f, 0.00f)}, - {"blanchedalmond", new Color(1.00f, 0.92f, 0.80f)}, - {"blue", new Color(0.00f, 0.00f, 1.00f)}, - {"blueviolet", new Color(0.54f, 0.17f, 0.89f)}, - {"brown", new Color(0.65f, 0.16f, 0.16f)}, - {"burlywood", new Color(0.87f, 0.72f, 0.53f)}, - {"cadetblue", new Color(0.37f, 0.62f, 0.63f)}, - {"chartreuse", new Color(0.50f, 1.00f, 0.00f)}, - {"chocolate", new Color(0.82f, 0.41f, 0.12f)}, - {"coral", new Color(1.00f, 0.50f, 0.31f)}, - {"cornflower", new Color(0.39f, 0.58f, 0.93f)}, - {"cornsilk", new Color(1.00f, 0.97f, 0.86f)}, - {"crimson", new Color(0.86f, 0.08f, 0.24f)}, - {"cyan", new Color(0.00f, 1.00f, 1.00f)}, - {"darkblue", new Color(0.00f, 0.00f, 0.55f)}, - {"darkcyan", new Color(0.00f, 0.55f, 0.55f)}, - {"darkgoldenrod", new Color(0.72f, 0.53f, 0.04f)}, - {"darkgray", new Color(0.66f, 0.66f, 0.66f)}, - {"darkgreen", new Color(0.00f, 0.39f, 0.00f)}, - {"darkkhaki", new Color(0.74f, 0.72f, 0.42f)}, - {"darkmagenta", new Color(0.55f, 0.00f, 0.55f)}, - {"darkolivegreen", new Color(0.33f, 0.42f, 0.18f)}, - {"darkorange", new Color(1.00f, 0.55f, 0.00f)}, - {"darkorchid", new Color(0.60f, 0.20f, 0.80f)}, - {"darkred", new Color(0.55f, 0.00f, 0.00f)}, - {"darksalmon", new Color(0.91f, 0.59f, 0.48f)}, - {"darkseagreen", new Color(0.56f, 0.74f, 0.56f)}, - {"darkslateblue", new Color(0.28f, 0.24f, 0.55f)}, - {"darkslategray", new Color(0.18f, 0.31f, 0.31f)}, - {"darkturquoise", new Color(0.00f, 0.81f, 0.82f)}, - {"darkviolet", new Color(0.58f, 0.00f, 0.83f)}, - {"deeppink", new Color(1.00f, 0.08f, 0.58f)}, - {"deepskyblue", new Color(0.00f, 0.75f, 1.00f)}, - {"dimgray", new Color(0.41f, 0.41f, 0.41f)}, - {"dodgerblue", new Color(0.12f, 0.56f, 1.00f)}, - {"firebrick", new Color(0.70f, 0.13f, 0.13f)}, - {"floralwhite", new Color(1.00f, 0.98f, 0.94f)}, - {"forestgreen", new Color(0.13f, 0.55f, 0.13f)}, - {"fuchsia", new Color(1.00f, 0.00f, 1.00f)}, - {"gainsboro", new Color(0.86f, 0.86f, 0.86f)}, - {"ghostwhite", new Color(0.97f, 0.97f, 1.00f)}, - {"gold", new Color(1.00f, 0.84f, 0.00f)}, - {"goldenrod", new Color(0.85f, 0.65f, 0.13f)}, - {"gray", new Color(0.75f, 0.75f, 0.75f)}, - {"green", new Color(0.00f, 1.00f, 0.00f)}, - {"greenyellow", new Color(0.68f, 1.00f, 0.18f)}, - {"honeydew", new Color(0.94f, 1.00f, 0.94f)}, - {"hotpink", new Color(1.00f, 0.41f, 0.71f)}, - {"indianred", new Color(0.80f, 0.36f, 0.36f)}, - {"indigo", new Color(0.29f, 0.00f, 0.51f)}, - {"ivory", new Color(1.00f, 1.00f, 0.94f)}, - {"khaki", new Color(0.94f, 0.90f, 0.55f)}, - {"lavender", new Color(0.90f, 0.90f, 0.98f)}, - {"lavenderblush", new Color(1.00f, 0.94f, 0.96f)}, - {"lawngreen", new Color(0.49f, 0.99f, 0.00f)}, - {"lemonchiffon", new Color(1.00f, 0.98f, 0.80f)}, - {"lightblue", new Color(0.68f, 0.85f, 0.90f)}, - {"lightcoral", new Color(0.94f, 0.50f, 0.50f)}, - {"lightcyan", new Color(0.88f, 1.00f, 1.00f)}, - {"lightgoldenrod", new Color(0.98f, 0.98f, 0.82f)}, - {"lightgray", new Color(0.83f, 0.83f, 0.83f)}, - {"lightgreen", new Color(0.56f, 0.93f, 0.56f)}, - {"lightpink", new Color(1.00f, 0.71f, 0.76f)}, - {"lightsalmon", new Color(1.00f, 0.63f, 0.48f)}, - {"lightseagreen", new Color(0.13f, 0.70f, 0.67f)}, - {"lightskyblue", new Color(0.53f, 0.81f, 0.98f)}, - {"lightslategray", new Color(0.47f, 0.53f, 0.60f)}, - {"lightsteelblue", new Color(0.69f, 0.77f, 0.87f)}, - {"lightyellow", new Color(1.00f, 1.00f, 0.88f)}, - {"lime", new Color(0.00f, 1.00f, 0.00f)}, - {"limegreen", new Color(0.20f, 0.80f, 0.20f)}, - {"linen", new Color(0.98f, 0.94f, 0.90f)}, - {"magenta", new Color(1.00f, 0.00f, 1.00f)}, - {"maroon", new Color(0.69f, 0.19f, 0.38f)}, - {"mediumaquamarine", new Color(0.40f, 0.80f, 0.67f)}, - {"mediumblue", new Color(0.00f, 0.00f, 0.80f)}, - {"mediumorchid", new Color(0.73f, 0.33f, 0.83f)}, - {"mediumpurple", new Color(0.58f, 0.44f, 0.86f)}, - {"mediumseagreen", new Color(0.24f, 0.70f, 0.44f)}, - {"mediumslateblue", new Color(0.48f, 0.41f, 0.93f)}, - {"mediumspringgreen", new Color(0.00f, 0.98f, 0.60f)}, - {"mediumturquoise", new Color(0.28f, 0.82f, 0.80f)}, - {"mediumvioletred", new Color(0.78f, 0.08f, 0.52f)}, - {"midnightblue", new Color(0.10f, 0.10f, 0.44f)}, - {"mintcream", new Color(0.96f, 1.00f, 0.98f)}, - {"mistyrose", new Color(1.00f, 0.89f, 0.88f)}, - {"moccasin", new Color(1.00f, 0.89f, 0.71f)}, - {"navajowhite", new Color(1.00f, 0.87f, 0.68f)}, - {"navyblue", new Color(0.00f, 0.00f, 0.50f)}, - {"oldlace", new Color(0.99f, 0.96f, 0.90f)}, - {"olive", new Color(0.50f, 0.50f, 0.00f)}, - {"olivedrab", new Color(0.42f, 0.56f, 0.14f)}, - {"orange", new Color(1.00f, 0.65f, 0.00f)}, - {"orangered", new Color(1.00f, 0.27f, 0.00f)}, - {"orchid", new Color(0.85f, 0.44f, 0.84f)}, - {"palegoldenrod", new Color(0.93f, 0.91f, 0.67f)}, - {"palegreen", new Color(0.60f, 0.98f, 0.60f)}, - {"paleturquoise", new Color(0.69f, 0.93f, 0.93f)}, - {"palevioletred", new Color(0.86f, 0.44f, 0.58f)}, - {"papayawhip", new Color(1.00f, 0.94f, 0.84f)}, - {"peachpuff", new Color(1.00f, 0.85f, 0.73f)}, - {"peru", new Color(0.80f, 0.52f, 0.25f)}, - {"pink", new Color(1.00f, 0.75f, 0.80f)}, - {"plum", new Color(0.87f, 0.63f, 0.87f)}, - {"powderblue", new Color(0.69f, 0.88f, 0.90f)}, - {"purple", new Color(0.63f, 0.13f, 0.94f)}, - {"rebeccapurple", new Color(0.40f, 0.20f, 0.60f)}, - {"red", new Color(1.00f, 0.00f, 0.00f)}, - {"rosybrown", new Color(0.74f, 0.56f, 0.56f)}, - {"royalblue", new Color(0.25f, 0.41f, 0.88f)}, - {"saddlebrown", new Color(0.55f, 0.27f, 0.07f)}, - {"salmon", new Color(0.98f, 0.50f, 0.45f)}, - {"sandybrown", new Color(0.96f, 0.64f, 0.38f)}, - {"seagreen", new Color(0.18f, 0.55f, 0.34f)}, - {"seashell", new Color(1.00f, 0.96f, 0.93f)}, - {"sienna", new Color(0.63f, 0.32f, 0.18f)}, - {"silver", new Color(0.75f, 0.75f, 0.75f)}, - {"skyblue", new Color(0.53f, 0.81f, 0.92f)}, - {"slateblue", new Color(0.42f, 0.35f, 0.80f)}, - {"slategray", new Color(0.44f, 0.50f, 0.56f)}, - {"snow", new Color(1.00f, 0.98f, 0.98f)}, - {"springgreen", new Color(0.00f, 1.00f, 0.50f)}, - {"steelblue", new Color(0.27f, 0.51f, 0.71f)}, - {"tan", new Color(0.82f, 0.71f, 0.55f)}, - {"teal", new Color(0.00f, 0.50f, 0.50f)}, - {"thistle", new Color(0.85f, 0.75f, 0.85f)}, - {"tomato", new Color(1.00f, 0.39f, 0.28f)}, - {"transparent", new Color(1.00f, 1.00f, 1.00f, 0.00f)}, - {"turquoise", new Color(0.25f, 0.88f, 0.82f)}, - {"violet", new Color(0.93f, 0.51f, 0.93f)}, - {"webgreen", new Color(0.00f, 0.50f, 0.00f)}, - {"webgray", new Color(0.50f, 0.50f, 0.50f)}, - {"webmaroon", new Color(0.50f, 0.00f, 0.00f)}, - {"webpurple", new Color(0.50f, 0.00f, 0.50f)}, - {"wheat", new Color(0.96f, 0.87f, 0.70f)}, - {"white", new Color(1.00f, 1.00f, 1.00f)}, - {"whitesmoke", new Color(0.96f, 0.96f, 0.96f)}, - {"yellow", new Color(1.00f, 1.00f, 0.00f)}, - {"yellowgreen", new Color(0.60f, 0.80f, 0.20f)}, + {"ALICEBLUE", new Color(0.94f, 0.97f, 1.00f)}, + {"ANTIQUEWHITE", new Color(0.98f, 0.92f, 0.84f)}, + {"AQUA", new Color(0.00f, 1.00f, 1.00f)}, + {"AQUAMARINE", new Color(0.50f, 1.00f, 0.83f)}, + {"AZURE", new Color(0.94f, 1.00f, 1.00f)}, + {"BEIGE", new Color(0.96f, 0.96f, 0.86f)}, + {"BISQUE", new Color(1.00f, 0.89f, 0.77f)}, + {"BLACK", new Color(0.00f, 0.00f, 0.00f)}, + {"BLANCHEDALMOND", new Color(1.00f, 0.92f, 0.80f)}, + {"BLUE", new Color(0.00f, 0.00f, 1.00f)}, + {"BLUEVIOLET", new Color(0.54f, 0.17f, 0.89f)}, + {"BROWN", new Color(0.65f, 0.16f, 0.16f)}, + {"BURLYWOOD", new Color(0.87f, 0.72f, 0.53f)}, + {"CADETBLUE", new Color(0.37f, 0.62f, 0.63f)}, + {"CHARTREUSE", new Color(0.50f, 1.00f, 0.00f)}, + {"CHOCOLATE", new Color(0.82f, 0.41f, 0.12f)}, + {"CORAL", new Color(1.00f, 0.50f, 0.31f)}, + {"CORNFLOWERBLUE", new Color(0.39f, 0.58f, 0.93f)}, + {"CORNSILK", new Color(1.00f, 0.97f, 0.86f)}, + {"CRIMSON", new Color(0.86f, 0.08f, 0.24f)}, + {"CYAN", new Color(0.00f, 1.00f, 1.00f)}, + {"DARKBLUE", new Color(0.00f, 0.00f, 0.55f)}, + {"DARKCYAN", new Color(0.00f, 0.55f, 0.55f)}, + {"DARKGOLDENROD", new Color(0.72f, 0.53f, 0.04f)}, + {"DARKGRAY", new Color(0.66f, 0.66f, 0.66f)}, + {"DARKGREEN", new Color(0.00f, 0.39f, 0.00f)}, + {"DARKKHAKI", new Color(0.74f, 0.72f, 0.42f)}, + {"DARKMAGENTA", new Color(0.55f, 0.00f, 0.55f)}, + {"DARKOLIVEGREEN", new Color(0.33f, 0.42f, 0.18f)}, + {"DARKORANGE", new Color(1.00f, 0.55f, 0.00f)}, + {"DARKORCHID", new Color(0.60f, 0.20f, 0.80f)}, + {"DARKRED", new Color(0.55f, 0.00f, 0.00f)}, + {"DARKSALMON", new Color(0.91f, 0.59f, 0.48f)}, + {"DARKSEAGREEN", new Color(0.56f, 0.74f, 0.56f)}, + {"DARKSLATEBLUE", new Color(0.28f, 0.24f, 0.55f)}, + {"DARKSLATEGRAY", new Color(0.18f, 0.31f, 0.31f)}, + {"DARKTURQUOISE", new Color(0.00f, 0.81f, 0.82f)}, + {"DARKVIOLET", new Color(0.58f, 0.00f, 0.83f)}, + {"DEEPPINK", new Color(1.00f, 0.08f, 0.58f)}, + {"DEEPSKYBLUE", new Color(0.00f, 0.75f, 1.00f)}, + {"DIMGRAY", new Color(0.41f, 0.41f, 0.41f)}, + {"DODGERBLUE", new Color(0.12f, 0.56f, 1.00f)}, + {"FIREBRICK", new Color(0.70f, 0.13f, 0.13f)}, + {"FLORALWHITE", new Color(1.00f, 0.98f, 0.94f)}, + {"FORESTGREEN", new Color(0.13f, 0.55f, 0.13f)}, + {"FUCHSIA", new Color(1.00f, 0.00f, 1.00f)}, + {"GAINSBORO", new Color(0.86f, 0.86f, 0.86f)}, + {"GHOSTWHITE", new Color(0.97f, 0.97f, 1.00f)}, + {"GOLD", new Color(1.00f, 0.84f, 0.00f)}, + {"GOLDENROD", new Color(0.85f, 0.65f, 0.13f)}, + {"GRAY", new Color(0.75f, 0.75f, 0.75f)}, + {"GREEN", new Color(0.00f, 1.00f, 0.00f)}, + {"GREENYELLOW", new Color(0.68f, 1.00f, 0.18f)}, + {"HONEYDEW", new Color(0.94f, 1.00f, 0.94f)}, + {"HOTPINK", new Color(1.00f, 0.41f, 0.71f)}, + {"INDIANRED", new Color(0.80f, 0.36f, 0.36f)}, + {"INDIGO", new Color(0.29f, 0.00f, 0.51f)}, + {"IVORY", new Color(1.00f, 1.00f, 0.94f)}, + {"KHAKI", new Color(0.94f, 0.90f, 0.55f)}, + {"LAVENDER", new Color(0.90f, 0.90f, 0.98f)}, + {"LAVENDERBLUSH", new Color(1.00f, 0.94f, 0.96f)}, + {"LAWNGREEN", new Color(0.49f, 0.99f, 0.00f)}, + {"LEMONCHIFFON", new Color(1.00f, 0.98f, 0.80f)}, + {"LIGHTBLUE", new Color(0.68f, 0.85f, 0.90f)}, + {"LIGHTCORAL", new Color(0.94f, 0.50f, 0.50f)}, + {"LIGHTCYAN", new Color(0.88f, 1.00f, 1.00f)}, + {"LIGHTGOLDENROD", new Color(0.98f, 0.98f, 0.82f)}, + {"LIGHTGRAY", new Color(0.83f, 0.83f, 0.83f)}, + {"LIGHTGREEN", new Color(0.56f, 0.93f, 0.56f)}, + {"LIGHTPINK", new Color(1.00f, 0.71f, 0.76f)}, + {"LIGHTSALMON", new Color(1.00f, 0.63f, 0.48f)}, + {"LIGHTSEAGREEN", new Color(0.13f, 0.70f, 0.67f)}, + {"LIGHTSKYBLUE", new Color(0.53f, 0.81f, 0.98f)}, + {"LIGHTSLATEGRAY", new Color(0.47f, 0.53f, 0.60f)}, + {"LIGHTSTEELBLUE", new Color(0.69f, 0.77f, 0.87f)}, + {"LIGHTYELLOW", new Color(1.00f, 1.00f, 0.88f)}, + {"LIME", new Color(0.00f, 1.00f, 0.00f)}, + {"LIMEGREEN", new Color(0.20f, 0.80f, 0.20f)}, + {"LINEN", new Color(0.98f, 0.94f, 0.90f)}, + {"MAGENTA", new Color(1.00f, 0.00f, 1.00f)}, + {"MAROON", new Color(0.69f, 0.19f, 0.38f)}, + {"MEDIUMAQUAMARINE", new Color(0.40f, 0.80f, 0.67f)}, + {"MEDIUMBLUE", new Color(0.00f, 0.00f, 0.80f)}, + {"MEDIUMORCHID", new Color(0.73f, 0.33f, 0.83f)}, + {"MEDIUMPURPLE", new Color(0.58f, 0.44f, 0.86f)}, + {"MEDIUMSEAGREEN", new Color(0.24f, 0.70f, 0.44f)}, + {"MEDIUMSLATEBLUE", new Color(0.48f, 0.41f, 0.93f)}, + {"MEDIUMSPRINGGREEN", new Color(0.00f, 0.98f, 0.60f)}, + {"MEDIUMTURQUOISE", new Color(0.28f, 0.82f, 0.80f)}, + {"MEDIUMVIOLETRED", new Color(0.78f, 0.08f, 0.52f)}, + {"MIDNIGHTBLUE", new Color(0.10f, 0.10f, 0.44f)}, + {"MINTCREAM", new Color(0.96f, 1.00f, 0.98f)}, + {"MISTYROSE", new Color(1.00f, 0.89f, 0.88f)}, + {"MOCCASIN", new Color(1.00f, 0.89f, 0.71f)}, + {"NAVAJOWHITE", new Color(1.00f, 0.87f, 0.68f)}, + {"NAVYBLUE", new Color(0.00f, 0.00f, 0.50f)}, + {"OLDLACE", new Color(0.99f, 0.96f, 0.90f)}, + {"OLIVE", new Color(0.50f, 0.50f, 0.00f)}, + {"OLIVEDRAB", new Color(0.42f, 0.56f, 0.14f)}, + {"ORANGE", new Color(1.00f, 0.65f, 0.00f)}, + {"ORANGERED", new Color(1.00f, 0.27f, 0.00f)}, + {"ORCHID", new Color(0.85f, 0.44f, 0.84f)}, + {"PALEGOLDENROD", new Color(0.93f, 0.91f, 0.67f)}, + {"PALEGREEN", new Color(0.60f, 0.98f, 0.60f)}, + {"PALETURQUOISE", new Color(0.69f, 0.93f, 0.93f)}, + {"PALEVIOLETRED", new Color(0.86f, 0.44f, 0.58f)}, + {"PAPAYAWHIP", new Color(1.00f, 0.94f, 0.84f)}, + {"PEACHPUFF", new Color(1.00f, 0.85f, 0.73f)}, + {"PERU", new Color(0.80f, 0.52f, 0.25f)}, + {"PINK", new Color(1.00f, 0.75f, 0.80f)}, + {"PLUM", new Color(0.87f, 0.63f, 0.87f)}, + {"POWDERBLUE", new Color(0.69f, 0.88f, 0.90f)}, + {"PURPLE", new Color(0.63f, 0.13f, 0.94f)}, + {"REBECCAPURPLE", new Color(0.40f, 0.20f, 0.60f)}, + {"RED", new Color(1.00f, 0.00f, 0.00f)}, + {"ROSYBROWN", new Color(0.74f, 0.56f, 0.56f)}, + {"ROYALBLUE", new Color(0.25f, 0.41f, 0.88f)}, + {"SADDLEBROWN", new Color(0.55f, 0.27f, 0.07f)}, + {"SALMON", new Color(0.98f, 0.50f, 0.45f)}, + {"SANDYBROWN", new Color(0.96f, 0.64f, 0.38f)}, + {"SEAGREEN", new Color(0.18f, 0.55f, 0.34f)}, + {"SEASHELL", new Color(1.00f, 0.96f, 0.93f)}, + {"SIENNA", new Color(0.63f, 0.32f, 0.18f)}, + {"SILVER", new Color(0.75f, 0.75f, 0.75f)}, + {"SKYBLUE", new Color(0.53f, 0.81f, 0.92f)}, + {"SLATEBLUE", new Color(0.42f, 0.35f, 0.80f)}, + {"SLATEGRAY", new Color(0.44f, 0.50f, 0.56f)}, + {"SNOW", new Color(1.00f, 0.98f, 0.98f)}, + {"SPRINGGREEN", new Color(0.00f, 1.00f, 0.50f)}, + {"STEELBLUE", new Color(0.27f, 0.51f, 0.71f)}, + {"TAN", new Color(0.82f, 0.71f, 0.55f)}, + {"TEAL", new Color(0.00f, 0.50f, 0.50f)}, + {"THISTLE", new Color(0.85f, 0.75f, 0.85f)}, + {"TOMATO", new Color(1.00f, 0.39f, 0.28f)}, + {"TRANSPARENT", new Color(1.00f, 1.00f, 1.00f, 0.00f)}, + {"TURQUOISE", new Color(0.25f, 0.88f, 0.82f)}, + {"VIOLET", new Color(0.93f, 0.51f, 0.93f)}, + {"WEBGRAY", new Color(0.50f, 0.50f, 0.50f)}, + {"WEBGREEN", new Color(0.00f, 0.50f, 0.00f)}, + {"WEBMAROON", new Color(0.50f, 0.00f, 0.00f)}, + {"WEBPURPLE", new Color(0.50f, 0.00f, 0.50f)}, + {"WHEAT", new Color(0.96f, 0.87f, 0.70f)}, + {"WHITE", new Color(1.00f, 1.00f, 1.00f)}, + {"WHITESMOKE", new Color(0.96f, 0.96f, 0.96f)}, + {"YELLOW", new Color(1.00f, 1.00f, 0.00f)}, + {"YELLOWGREEN", new Color(0.60f, 0.80f, 0.20f)}, }; - public static Color AliceBlue { get { return namedColors["aliceblue"]; } } - public static Color AntiqueWhite { get { return namedColors["antiquewhite"]; } } - public static Color Aqua { get { return namedColors["aqua"]; } } - public static Color Aquamarine { get { return namedColors["aquamarine"]; } } - public static Color Azure { get { return namedColors["azure"]; } } - public static Color Beige { get { return namedColors["beige"]; } } - public static Color Bisque { get { return namedColors["bisque"]; } } - public static Color Black { get { return namedColors["black"]; } } - public static Color BlanchedAlmond { get { return namedColors["blanchedalmond"]; } } - public static Color Blue { get { return namedColors["blue"]; } } - public static Color BlueViolet { get { return namedColors["blueviolet"]; } } - public static Color Brown { get { return namedColors["brown"]; } } - public static Color BurlyWood { get { return namedColors["burlywood"]; } } - public static Color CadetBlue { get { return namedColors["cadetblue"]; } } - public static Color Chartreuse { get { return namedColors["chartreuse"]; } } - public static Color Chocolate { get { return namedColors["chocolate"]; } } - public static Color Coral { get { return namedColors["coral"]; } } - public static Color Cornflower { get { return namedColors["cornflower"]; } } - public static Color Cornsilk { get { return namedColors["cornsilk"]; } } - public static Color Crimson { get { return namedColors["crimson"]; } } - public static Color Cyan { get { return namedColors["cyan"]; } } - public static Color DarkBlue { get { return namedColors["darkblue"]; } } - public static Color DarkCyan { get { return namedColors["darkcyan"]; } } - public static Color DarkGoldenrod { get { return namedColors["darkgoldenrod"]; } } - public static Color DarkGray { get { return namedColors["darkgray"]; } } - public static Color DarkGreen { get { return namedColors["darkgreen"]; } } - public static Color DarkKhaki { get { return namedColors["darkkhaki"]; } } - public static Color DarkMagenta { get { return namedColors["darkmagenta"]; } } - public static Color DarkOliveGreen { get { return namedColors["darkolivegreen"]; } } - public static Color DarkOrange { get { return namedColors["darkorange"]; } } - public static Color DarkOrchid { get { return namedColors["darkorchid"]; } } - public static Color DarkRed { get { return namedColors["darkred"]; } } - public static Color DarkSalmon { get { return namedColors["darksalmon"]; } } - public static Color DarkSeaGreen { get { return namedColors["darkseagreen"]; } } - public static Color DarkSlateBlue { get { return namedColors["darkslateblue"]; } } - public static Color DarkSlateGray { get { return namedColors["darkslategray"]; } } - public static Color DarkTurquoise { get { return namedColors["darkturquoise"]; } } - public static Color DarkViolet { get { return namedColors["darkviolet"]; } } - public static Color DeepPink { get { return namedColors["deeppink"]; } } - public static Color DeepSkyBlue { get { return namedColors["deepskyblue"]; } } - public static Color DimGray { get { return namedColors["dimgray"]; } } - public static Color DodgerBlue { get { return namedColors["dodgerblue"]; } } - public static Color Firebrick { get { return namedColors["firebrick"]; } } - public static Color FloralWhite { get { return namedColors["floralwhite"]; } } - public static Color ForestGreen { get { return namedColors["forestgreen"]; } } - public static Color Fuchsia { get { return namedColors["fuchsia"]; } } - public static Color Gainsboro { get { return namedColors["gainsboro"]; } } - public static Color GhostWhite { get { return namedColors["ghostwhite"]; } } - public static Color Gold { get { return namedColors["gold"]; } } - public static Color Goldenrod { get { return namedColors["goldenrod"]; } } - public static Color Gray { get { return namedColors["gray"]; } } - public static Color Green { get { return namedColors["green"]; } } - public static Color GreenYellow { get { return namedColors["greenyellow"]; } } - public static Color Honeydew { get { return namedColors["honeydew"]; } } - public static Color HotPink { get { return namedColors["hotpink"]; } } - public static Color IndianRed { get { return namedColors["indianred"]; } } - public static Color Indigo { get { return namedColors["indigo"]; } } - public static Color Ivory { get { return namedColors["ivory"]; } } - public static Color Khaki { get { return namedColors["khaki"]; } } - public static Color Lavender { get { return namedColors["lavender"]; } } - public static Color LavenderBlush { get { return namedColors["lavenderblush"]; } } - public static Color LawnGreen { get { return namedColors["lawngreen"]; } } - public static Color LemonChiffon { get { return namedColors["lemonchiffon"]; } } - public static Color LightBlue { get { return namedColors["lightblue"]; } } - public static Color LightCoral { get { return namedColors["lightcoral"]; } } - public static Color LightCyan { get { return namedColors["lightcyan"]; } } - public static Color LightGoldenrod { get { return namedColors["lightgoldenrod"]; } } - public static Color LightGray { get { return namedColors["lightgray"]; } } - public static Color LightGreen { get { return namedColors["lightgreen"]; } } - public static Color LightPink { get { return namedColors["lightpink"]; } } - public static Color LightSalmon { get { return namedColors["lightsalmon"]; } } - public static Color LightSeaGreen { get { return namedColors["lightseagreen"]; } } - public static Color LightSkyBlue { get { return namedColors["lightskyblue"]; } } - public static Color LightSlateGray { get { return namedColors["lightslategray"]; } } - public static Color LightSteelBlue { get { return namedColors["lightsteelblue"]; } } - public static Color LightYellow { get { return namedColors["lightyellow"]; } } - public static Color Lime { get { return namedColors["lime"]; } } - public static Color Limegreen { get { return namedColors["limegreen"]; } } - public static Color Linen { get { return namedColors["linen"]; } } - public static Color Magenta { get { return namedColors["magenta"]; } } - public static Color Maroon { get { return namedColors["maroon"]; } } - public static Color MediumAquamarine { get { return namedColors["mediumaquamarine"]; } } - public static Color MediumBlue { get { return namedColors["mediumblue"]; } } - public static Color MediumOrchid { get { return namedColors["mediumorchid"]; } } - public static Color MediumPurple { get { return namedColors["mediumpurple"]; } } - public static Color MediumSeaGreen { get { return namedColors["mediumseagreen"]; } } - public static Color MediumSlateBlue { get { return namedColors["mediumslateblue"]; } } - public static Color MediumSpringGreen { get { return namedColors["mediumspringgreen"]; } } - public static Color MediumTurquoise { get { return namedColors["mediumturquoise"]; } } - public static Color MediumVioletRed { get { return namedColors["mediumvioletred"]; } } - public static Color MidnightBlue { get { return namedColors["midnightblue"]; } } - public static Color MintCream { get { return namedColors["mintcream"]; } } - public static Color MistyRose { get { return namedColors["mistyrose"]; } } - public static Color Moccasin { get { return namedColors["moccasin"]; } } - public static Color NavajoWhite { get { return namedColors["navajowhite"]; } } - public static Color NavyBlue { get { return namedColors["navyblue"]; } } - public static Color OldLace { get { return namedColors["oldlace"]; } } - public static Color Olive { get { return namedColors["olive"]; } } - public static Color OliveDrab { get { return namedColors["olivedrab"]; } } - public static Color Orange { get { return namedColors["orange"]; } } - public static Color OrangeRed { get { return namedColors["orangered"]; } } - public static Color Orchid { get { return namedColors["orchid"]; } } - public static Color PaleGoldenrod { get { return namedColors["palegoldenrod"]; } } - public static Color PaleGreen { get { return namedColors["palegreen"]; } } - public static Color PaleTurquoise { get { return namedColors["paleturquoise"]; } } - public static Color PaleVioletRed { get { return namedColors["palevioletred"]; } } - public static Color PapayaWhip { get { return namedColors["papayawhip"]; } } - public static Color PeachPuff { get { return namedColors["peachpuff"]; } } - public static Color Peru { get { return namedColors["peru"]; } } - public static Color Pink { get { return namedColors["pink"]; } } - public static Color Plum { get { return namedColors["plum"]; } } - public static Color PowderBlue { get { return namedColors["powderblue"]; } } - public static Color Purple { get { return namedColors["purple"]; } } - public static Color RebeccaPurple { get { return namedColors["rebeccapurple"]; } } - public static Color Red { get { return namedColors["red"]; } } - public static Color RosyBrown { get { return namedColors["rosybrown"]; } } - public static Color RoyalBlue { get { return namedColors["royalblue"]; } } - public static Color SaddleBrown { get { return namedColors["saddlebrown"]; } } - public static Color Salmon { get { return namedColors["salmon"]; } } - public static Color SandyBrown { get { return namedColors["sandybrown"]; } } - public static Color SeaGreen { get { return namedColors["seagreen"]; } } - public static Color SeaShell { get { return namedColors["seashell"]; } } - public static Color Sienna { get { return namedColors["sienna"]; } } - public static Color Silver { get { return namedColors["silver"]; } } - public static Color SkyBlue { get { return namedColors["skyblue"]; } } - public static Color SlateBlue { get { return namedColors["slateblue"]; } } - public static Color SlateGray { get { return namedColors["slategray"]; } } - public static Color Snow { get { return namedColors["snow"]; } } - public static Color SpringGreen { get { return namedColors["springgreen"]; } } - public static Color SteelBlue { get { return namedColors["steelblue"]; } } - public static Color Tan { get { return namedColors["tan"]; } } - public static Color Teal { get { return namedColors["teal"]; } } - public static Color Thistle { get { return namedColors["thistle"]; } } - public static Color Tomato { get { return namedColors["tomato"]; } } - public static Color Transparent { get { return namedColors["transparent"]; } } - public static Color Turquoise { get { return namedColors["turquoise"]; } } - public static Color Violet { get { return namedColors["violet"]; } } - public static Color WebGreen { get { return namedColors["webgreen"]; } } - public static Color WebGray { get { return namedColors["webgray"]; } } - public static Color WebMaroon { get { return namedColors["webmaroon"]; } } - public static Color WebPurple { get { return namedColors["webpurple"]; } } - public static Color Wheat { get { return namedColors["wheat"]; } } - public static Color White { get { return namedColors["white"]; } } - public static Color WhiteSmoke { get { return namedColors["whitesmoke"]; } } - public static Color Yellow { get { return namedColors["yellow"]; } } - public static Color YellowGreen { get { return namedColors["yellowgreen"]; } } + public static Color AliceBlue { get { return namedColors["ALICEBLUE"]; } } + public static Color AntiqueWhite { get { return namedColors["ANTIQUEWHITE"]; } } + public static Color Aqua { get { return namedColors["AQUA"]; } } + public static Color Aquamarine { get { return namedColors["AQUAMARINE"]; } } + public static Color Azure { get { return namedColors["AZURE"]; } } + public static Color Beige { get { return namedColors["BEIGE"]; } } + public static Color Bisque { get { return namedColors["BISQUE"]; } } + public static Color Black { get { return namedColors["BLACK"]; } } + public static Color BlanchedAlmond { get { return namedColors["BLANCHEDALMOND"]; } } + public static Color Blue { get { return namedColors["BLUE"]; } } + public static Color BlueViolet { get { return namedColors["BLUEVIOLET"]; } } + public static Color Brown { get { return namedColors["BROWN"]; } } + public static Color Burlywood { get { return namedColors["BURLYWOOD"]; } } + public static Color CadetBlue { get { return namedColors["CADETBLUE"]; } } + public static Color Chartreuse { get { return namedColors["CHARTREUSE"]; } } + public static Color Chocolate { get { return namedColors["CHOCOLATE"]; } } + public static Color Coral { get { return namedColors["CORAL"]; } } + public static Color CornflowerBlue { get { return namedColors["CORNFLOWERBLUE"]; } } + public static Color Cornsilk { get { return namedColors["CORNSILK"]; } } + public static Color Crimson { get { return namedColors["CRIMSON"]; } } + public static Color Cyan { get { return namedColors["CYAN"]; } } + public static Color DarkBlue { get { return namedColors["DARKBLUE"]; } } + public static Color DarkCyan { get { return namedColors["DARKCYAN"]; } } + public static Color DarkGoldenrod { get { return namedColors["DARKGOLDENROD"]; } } + public static Color DarkGray { get { return namedColors["DARKGRAY"]; } } + public static Color DarkGreen { get { return namedColors["DARKGREEN"]; } } + public static Color DarkKhaki { get { return namedColors["DARKKHAKI"]; } } + public static Color DarkMagenta { get { return namedColors["DARKMAGENTA"]; } } + public static Color DarkOliveGreen { get { return namedColors["DARKOLIVEGREEN"]; } } + public static Color DarkOrange { get { return namedColors["DARKORANGE"]; } } + public static Color DarkOrchid { get { return namedColors["DARKORCHID"]; } } + public static Color DarkRed { get { return namedColors["DARKRED"]; } } + public static Color DarkSalmon { get { return namedColors["DARKSALMON"]; } } + public static Color DarkSeaGreen { get { return namedColors["DARKSEAGREEN"]; } } + public static Color DarkSlateBlue { get { return namedColors["DARKSLATEBLUE"]; } } + public static Color DarkSlateGray { get { return namedColors["DARKSLATEGRAY"]; } } + public static Color DarkTurquoise { get { return namedColors["DARKTURQUOISE"]; } } + public static Color DarkViolet { get { return namedColors["DARKVIOLET"]; } } + public static Color DeepPink { get { return namedColors["DEEPPINK"]; } } + public static Color DeepSkyBlue { get { return namedColors["DEEPSKYBLUE"]; } } + public static Color DimGray { get { return namedColors["DIMGRAY"]; } } + public static Color DodgerBlue { get { return namedColors["DODGERBLUE"]; } } + public static Color Firebrick { get { return namedColors["FIREBRICK"]; } } + public static Color FloralWhite { get { return namedColors["FLORALWHITE"]; } } + public static Color ForestGreen { get { return namedColors["FORESTGREEN"]; } } + public static Color Fuchsia { get { return namedColors["FUCHSIA"]; } } + public static Color Gainsboro { get { return namedColors["GAINSBORO"]; } } + public static Color GhostWhite { get { return namedColors["GHOSTWHITE"]; } } + public static Color Gold { get { return namedColors["GOLD"]; } } + public static Color Goldenrod { get { return namedColors["GOLDENROD"]; } } + public static Color Gray { get { return namedColors["GRAY"]; } } + public static Color Green { get { return namedColors["GREEN"]; } } + public static Color GreenYellow { get { return namedColors["GREENYELLOW"]; } } + public static Color Honeydew { get { return namedColors["HONEYDEW"]; } } + public static Color HotPink { get { return namedColors["HOTPINK"]; } } + public static Color IndianRed { get { return namedColors["INDIANRED"]; } } + public static Color Indigo { get { return namedColors["INDIGO"]; } } + public static Color Ivory { get { return namedColors["IVORY"]; } } + public static Color Khaki { get { return namedColors["KHAKI"]; } } + public static Color Lavender { get { return namedColors["LAVENDER"]; } } + public static Color LavenderBlush { get { return namedColors["LAVENDERBLUSH"]; } } + public static Color LawnGreen { get { return namedColors["LAWNGREEN"]; } } + public static Color LemonChiffon { get { return namedColors["LEMONCHIFFON"]; } } + public static Color LightBlue { get { return namedColors["LIGHTBLUE"]; } } + public static Color LightCoral { get { return namedColors["LIGHTCORAL"]; } } + public static Color LightCyan { get { return namedColors["LIGHTCYAN"]; } } + public static Color LightGoldenrod { get { return namedColors["LIGHTGOLDENROD"]; } } + public static Color LightGray { get { return namedColors["LIGHTGRAY"]; } } + public static Color LightGreen { get { return namedColors["LIGHTGREEN"]; } } + public static Color LightPink { get { return namedColors["LIGHTPINK"]; } } + public static Color LightSalmon { get { return namedColors["LIGHTSALMON"]; } } + public static Color LightSeaGreen { get { return namedColors["LIGHTSEAGREEN"]; } } + public static Color LightSkyBlue { get { return namedColors["LIGHTSKYBLUE"]; } } + public static Color LightSlateGray { get { return namedColors["LIGHTSLATEGRAY"]; } } + public static Color LightSteelBlue { get { return namedColors["LIGHTSTEELBLUE"]; } } + public static Color LightYellow { get { return namedColors["LIGHTYELLOW"]; } } + public static Color Lime { get { return namedColors["LIME"]; } } + public static Color LimeGreen { get { return namedColors["LIMEGREEN"]; } } + public static Color Linen { get { return namedColors["LINEN"]; } } + public static Color Magenta { get { return namedColors["MAGENTA"]; } } + public static Color Maroon { get { return namedColors["MAROON"]; } } + public static Color MediumAquamarine { get { return namedColors["MEDIUMAQUAMARINE"]; } } + public static Color MediumBlue { get { return namedColors["MEDIUMBLUE"]; } } + public static Color MediumOrchid { get { return namedColors["MEDIUMORCHID"]; } } + public static Color MediumPurple { get { return namedColors["MEDIUMPURPLE"]; } } + public static Color MediumSeaGreen { get { return namedColors["MEDIUMSEAGREEN"]; } } + public static Color MediumSlateBlue { get { return namedColors["MEDIUMSLATEBLUE"]; } } + public static Color MediumSpringGreen { get { return namedColors["MEDIUMSPRINGGREEN"]; } } + public static Color MediumTurquoise { get { return namedColors["MEDIUMTURQUOISE"]; } } + public static Color MediumVioletRed { get { return namedColors["MEDIUMVIOLETRED"]; } } + public static Color MidnightBlue { get { return namedColors["MIDNIGHTBLUE"]; } } + public static Color MintCream { get { return namedColors["MINTCREAM"]; } } + public static Color MistyRose { get { return namedColors["MISTYROSE"]; } } + public static Color Moccasin { get { return namedColors["MOCCASIN"]; } } + public static Color NavajoWhite { get { return namedColors["NAVAJOWHITE"]; } } + public static Color NavyBlue { get { return namedColors["NAVYBLUE"]; } } + public static Color OldLace { get { return namedColors["OLDLACE"]; } } + public static Color Olive { get { return namedColors["OLIVE"]; } } + public static Color OliveDrab { get { return namedColors["OLIVEDRAB"]; } } + public static Color Orange { get { return namedColors["ORANGE"]; } } + public static Color OrangeRed { get { return namedColors["ORANGERED"]; } } + public static Color Orchid { get { return namedColors["ORCHID"]; } } + public static Color PaleGoldenrod { get { return namedColors["PALEGOLDENROD"]; } } + public static Color PaleGreen { get { return namedColors["PALEGREEN"]; } } + public static Color PaleTurquoise { get { return namedColors["PALETURQUOISE"]; } } + public static Color PaleVioletRed { get { return namedColors["PALEVIOLETRED"]; } } + public static Color PapayaWhip { get { return namedColors["PAPAYAWHIP"]; } } + public static Color PeachPuff { get { return namedColors["PEACHPUFF"]; } } + public static Color Peru { get { return namedColors["PERU"]; } } + public static Color Pink { get { return namedColors["PINK"]; } } + public static Color Plum { get { return namedColors["PLUM"]; } } + public static Color PowderBlue { get { return namedColors["POWDERBLUE"]; } } + public static Color Purple { get { return namedColors["PURPLE"]; } } + public static Color RebeccaPurple { get { return namedColors["REBECCAPURPLE"]; } } + public static Color Red { get { return namedColors["RED"]; } } + public static Color RosyBrown { get { return namedColors["ROSYBROWN"]; } } + public static Color RoyalBlue { get { return namedColors["ROYALBLUE"]; } } + public static Color SaddleBrown { get { return namedColors["SADDLEBROWN"]; } } + public static Color Salmon { get { return namedColors["SALMON"]; } } + public static Color SandyBrown { get { return namedColors["SANDYBROWN"]; } } + public static Color SeaGreen { get { return namedColors["SEAGREEN"]; } } + public static Color Seashell { get { return namedColors["SEASHELL"]; } } + public static Color Sienna { get { return namedColors["SIENNA"]; } } + public static Color Silver { get { return namedColors["SILVER"]; } } + public static Color SkyBlue { get { return namedColors["SKYBLUE"]; } } + public static Color SlateBlue { get { return namedColors["SLATEBLUE"]; } } + public static Color SlateGray { get { return namedColors["SLATEGRAY"]; } } + public static Color Snow { get { return namedColors["SNOW"]; } } + public static Color SpringGreen { get { return namedColors["SPRINGGREEN"]; } } + public static Color SteelBlue { get { return namedColors["STEELBLUE"]; } } + public static Color Tan { get { return namedColors["TAN"]; } } + public static Color Teal { get { return namedColors["TEAL"]; } } + public static Color Thistle { get { return namedColors["THISTLE"]; } } + public static Color Tomato { get { return namedColors["TOMATO"]; } } + public static Color Transparent { get { return namedColors["TRANSPARENT"]; } } + public static Color Turquoise { get { return namedColors["TURQUOISE"]; } } + public static Color Violet { get { return namedColors["VIOLET"]; } } + public static Color WebGray { get { return namedColors["WEBGRAY"]; } } + public static Color WebGreen { get { return namedColors["WEBGREEN"]; } } + public static Color WebMaroon { get { return namedColors["WEBMAROON"]; } } + public static Color WebPurple { get { return namedColors["WEBPURPLE"]; } } + public static Color Wheat { get { return namedColors["WHEAT"]; } } + public static Color White { get { return namedColors["WHITE"]; } } + public static Color WhiteSmoke { get { return namedColors["WHITESMOKE"]; } } + public static Color Yellow { get { return namedColors["YELLOW"]; } } + public static Color YellowGreen { get { return namedColors["YELLOWGREEN"]; } } } } diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 765a5fe023..b863f622bd 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2336,6 +2336,10 @@ void VisualScriptLanguage::finish() { void VisualScriptLanguage::get_reserved_words(List<String> *p_words) const { } +bool VisualScriptLanguage::is_control_flow_keyword(String p_keyword) const { + return false; +} + void VisualScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const { } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 72362e0ef4..cc78b3242d 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -586,6 +586,7 @@ public: /* EDITOR FUNCTIONS */ virtual void get_reserved_words(List<String> *p_words) const; + virtual bool is_control_flow_keyword(String p_keyword) const; virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 527eb0abc9..dc400982e8 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -740,21 +740,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Color c = sbf->get_border_color(); Color ic = c; - c.a = 1; - if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Color mono_color; - if (((c.r + c.g + c.b) / 3) < 0.7) { - mono_color = Color(1.0, 1.0, 1.0); - ic = Color(0.0, 0.0, 0.0, 0.7); - } else { - mono_color = Color(0.0, 0.0, 0.0); - ic = Color(1.0, 1.0, 1.0, 0.7); - } - mono_color.a = 0.85; - c = mono_color; - } gnode->add_theme_color_override("title_color", c); - c.a = 0.7; + c.a = 1; gnode->add_theme_color_override("close_color", c); gnode->add_theme_color_override("resizer_color", ic); gnode->add_theme_style_override("frame", sbf); @@ -3623,32 +3610,33 @@ void VisualScriptEditor::_notification(int p_what) { bool dark_theme = tm->get_constant("dark_theme", "Editor"); - List<Pair<String, Color>> colors; if (dark_theme) { - colors.push_back(Pair<String, Color>("flow_control", Color(0.96, 0.96, 0.96))); - colors.push_back(Pair<String, Color>("functions", Color(0.96, 0.52, 0.51))); - colors.push_back(Pair<String, Color>("data", Color(0.5, 0.96, 0.81))); - colors.push_back(Pair<String, Color>("operators", Color(0.67, 0.59, 0.87))); - colors.push_back(Pair<String, Color>("custom", Color(0.5, 0.73, 0.96))); - colors.push_back(Pair<String, Color>("constants", Color(0.96, 0.5, 0.69))); + node_colors["flow_control"] = Color(0.96, 0.96, 0.96); + node_colors["functions"] = Color(0.96, 0.52, 0.51); + node_colors["data"] = Color(0.5, 0.96, 0.81); + node_colors["operators"] = Color(0.67, 0.59, 0.87); + node_colors["custom"] = Color(0.5, 0.73, 0.96); + node_colors["constants"] = Color(0.96, 0.5, 0.69); } else { - colors.push_back(Pair<String, Color>("flow_control", Color(0.26, 0.26, 0.26))); - colors.push_back(Pair<String, Color>("functions", Color(0.95, 0.4, 0.38))); - colors.push_back(Pair<String, Color>("data", Color(0.07, 0.73, 0.51))); - colors.push_back(Pair<String, Color>("operators", Color(0.51, 0.4, 0.82))); - colors.push_back(Pair<String, Color>("custom", Color(0.31, 0.63, 0.95))); - colors.push_back(Pair<String, Color>("constants", Color(0.94, 0.18, 0.49))); + node_colors["flow_control"] = Color(0.26, 0.26, 0.26); + node_colors["functions"] = Color(0.95, 0.4, 0.38); + node_colors["data"] = Color(0.07, 0.73, 0.51); + node_colors["operators"] = Color(0.51, 0.4, 0.82); + node_colors["custom"] = Color(0.31, 0.63, 0.95); + node_colors["constants"] = Color(0.94, 0.18, 0.49); } - for (List<Pair<String, Color>>::Element *E = colors.front(); E; E = E->next()) { - Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); + for (Map<StringName, Color>::Element *E = node_colors.front(); E; E = E->next()) { + const Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); + if (!sb.is_null()) { Ref<StyleBoxFlat> frame_style = sb->duplicate(); - Color c = sb->get_border_color(); - Color cn = E->get().second; - cn.a = c.a; - frame_style->set_border_color(cn); - node_styles[E->get().first] = frame_style; + // Adjust the border color to be close to the GraphNode's background color. + // This keeps the node's title area from being too distracting. + Color color = dark_theme ? E->get().darkened(0.75) : E->get().lightened(0.75); + color.a = 0.9; + frame_style->set_border_color(color); + node_styles[E->key()] = frame_style; } } diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index bb6f194286..fc9a2df60f 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -135,6 +135,7 @@ class VisualScriptEditor : public ScriptEditorBase { Vector<Pair<Variant::Type, String>> args; }; + Map<StringName, Color> node_colors; HashMap<StringName, Ref<StyleBox>> node_styles; void _update_graph_connections(); diff --git a/platform/javascript/http_client.h.inc b/platform/javascript/http_client.h.inc index 842a93fcba..6544d41c98 100644 --- a/platform/javascript/http_client.h.inc +++ b/platform/javascript/http_client.h.inc @@ -34,7 +34,8 @@ Error make_request(Method p_method, const String &p_url, const Vector<String> &p static void _parse_headers(int p_len, const char **p_headers, void *p_ref); int js_id = 0; -int read_limit = 4096; +// 64 KiB by default (favors fast download speeds at the cost of memory usage). +int read_limit = 65536; Status status = STATUS_DISCONNECTED; String host; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 826fd0189b..ac067aa001 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -155,6 +155,9 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) { } status.pressed = !status.pressed; _unpress_group(); + if (button_group.is_valid()) { + button_group->emit_signal("pressed", this); + } _toggled(status.pressed); _pressed(); } @@ -218,6 +221,9 @@ void BaseButton::set_pressed(bool p_pressed) { if (p_pressed) { _unpress_group(); + if (button_group.is_valid()) { + button_group->emit_signal("pressed", this); + } } _toggled(status.pressed); @@ -487,6 +493,7 @@ BaseButton *ButtonGroup::get_pressed_button() { void ButtonGroup::_bind_methods() { ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button); ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons); + ADD_SIGNAL(MethodInfo("pressed", PropertyInfo(Variant::OBJECT, "button"))); } ButtonGroup::ButtonGroup() { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index b78f9cad24..114abbd4da 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -189,6 +189,18 @@ void ColorPicker::set_pick_color(const Color &p_color) { _set_pick_color(p_color, true); //because setters can't have more arguments } +void ColorPicker::set_old_color(const Color &p_color) { + old_color = p_color; +} + +void ColorPicker::set_display_old_color(bool p_enabled) { + display_old_color = p_enabled; +} + +bool ColorPicker::is_displaying_old_color() const { + return display_old_color; +} + void ColorPicker::set_edit_alpha(bool p_show) { edit_alpha = p_show; _update_controls(); @@ -459,17 +471,39 @@ void ColorPicker::_update_text_value() { } void ColorPicker::_sample_draw() { - const Rect2 r = Rect2(Point2(), Size2(sample->get_size().width, sample->get_size().height * 0.95)); + // Covers the right half of the sample if the old color is being displayed, + // or the whole sample if it's not being displayed. + Rect2 rect_new; + + if (display_old_color) { + rect_new = Rect2(Point2(sample->get_size().width * 0.5, 0), Size2(sample->get_size().width * 0.5, sample->get_size().height * 0.95)); + + // Draw both old and new colors for easier comparison (only if spawned from a ColorPickerButton). + const Rect2 rect_old = Rect2(Point2(), Size2(sample->get_size().width * 0.5, sample->get_size().height * 0.95)); + + if (display_old_color && old_color.a < 1.0) { + sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), rect_old, true); + } + + sample->draw_rect(rect_old, old_color); + + if (old_color.r > 1 || old_color.g > 1 || old_color.b > 1) { + // Draw an indicator to denote that the old color is "overbright" and can't be displayed accurately in the preview. + sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2()); + } + } else { + rect_new = Rect2(Point2(), Size2(sample->get_size().width, sample->get_size().height * 0.95)); + } if (color.a < 1.0) { - sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), r, true); + sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), rect_new, true); } - sample->draw_rect(r, color); + sample->draw_rect(rect_new, color); if (color.r > 1 || color.g > 1 || color.b > 1) { - // Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview - sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2()); + // Draw an indicator to denote that the new color is "overbright" and can't be displayed accurately in the preview. + sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2(uv_edit->get_size().width * 0.5, 0)); } } @@ -1174,6 +1208,11 @@ ColorPicker::ColorPicker() : ///////////////// +void ColorPickerButton::_about_to_popup() { + set_pressed(true); + picker->set_old_color(color); +} + void ColorPickerButton::_color_changed(const Color &p_color) { color = p_color; update(); @@ -1286,10 +1325,11 @@ void ColorPickerButton::_update_picker() { popup->add_child(picker); add_child(popup); picker->connect("color_changed", callable_mp(this, &ColorPickerButton::_color_changed)); - popup->connect("about_to_popup", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); + popup->connect("about_to_popup", callable_mp(this, &ColorPickerButton::_about_to_popup)); popup->connect("popup_hide", callable_mp(this, &ColorPickerButton::_modal_closed)); picker->set_pick_color(color); picker->set_edit_alpha(edit_alpha); + picker->set_display_old_color(true); emit_signal("picker_created"); } } @@ -1301,6 +1341,7 @@ void ColorPickerButton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_popup"), &ColorPickerButton::get_popup); ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha); ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha); + ClassDB::bind_method(D_METHOD("_about_to_popup"), &ColorPickerButton::_about_to_popup); ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color"))); ADD_SIGNAL(MethodInfo("popup_closed")); diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index a0d2aa95ca..13fe5fd60e 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -86,6 +86,8 @@ private: PickerShapeType picker_type = SHAPE_HSV_WHEEL; Color color; + Color old_color; + bool display_old_color = false; bool raw_mode_enabled = false; bool hsv_mode_enabled = false; bool deferred_mode_enabled = false; @@ -131,6 +133,10 @@ public: void _set_pick_color(const Color &p_color, bool p_update_sliders); void set_pick_color(const Color &p_color); Color get_pick_color() const; + void set_old_color(const Color &p_color); + + void set_display_old_color(bool p_enabled); + bool is_displaying_old_color() const; void set_picker_shape(PickerShapeType p_picker_type); PickerShapeType get_picker_shape() const; @@ -171,6 +177,7 @@ class ColorPickerButton : public Button { Color color; bool edit_alpha = true; + void _about_to_popup(); void _color_changed(const Color &p_color); void _modal_closed(); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index ff9dafa0f9..acf0641005 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -394,6 +394,7 @@ void TabContainer::_notification(int p_what) { Vector<int> tab_widths; for (int i = first_tab_cache; i < tabs.size(); i++) { if (get_tab_hidden(i)) { + tab_widths.push_back(0); continue; } int tab_width = _get_tab_width(i); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 00056cd912..d10ce584b7 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1672,7 +1672,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 float line_width = 1.0; #ifdef TOOLS_ENABLED - line_width *= EDSCALE; + line_width *= Math::round(EDSCALE); #endif Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs; diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index c30bd7927d..ff682a40f4 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -663,6 +663,8 @@ void SurfaceTool::deindex() { } void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, LocalVector<Vertex> *r_vertex, LocalVector<int> *r_index, uint32_t &lformat) { + ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::_create_list() must be a valid object of type Mesh"); + Array arr = p_existing->surface_get_arrays(p_surface); ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX); _create_list_from_arrays(arr, r_vertex, r_index, lformat); @@ -824,6 +826,8 @@ void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) { } void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) { + ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::create_from() must be a valid object of type Mesh"); + clear(); primitive = p_existing->surface_get_primitive_type(p_surface); _create_list(p_existing, p_surface, &vertex_array, &index_array, format); @@ -831,6 +835,8 @@ void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) { } void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_surface, const String &p_blend_shape_name) { + ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::create_from_blend_shape() must be a valid object of type Mesh"); + clear(); primitive = p_existing->surface_get_primitive_type(p_surface); Array arr = p_existing->surface_get_blend_shape_arrays(p_surface); @@ -851,6 +857,8 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur } void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform) { + ERR_FAIL_NULL_MSG(p_existing, "First argument in SurfaceTool::append_from() must be a valid object of type Mesh"); + if (vertex_array.size() == 0) { primitive = p_existing->surface_get_primitive_type(p_surface); format = 0; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 0d6d3f5e13..a81306b97d 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -2969,6 +2969,20 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) { } } +bool ShaderLanguage::is_control_flow_keyword(String p_keyword) { + return p_keyword == "break" || + p_keyword == "case" || + p_keyword == "continue" || + p_keyword == "default" || + p_keyword == "do" || + p_keyword == "else" || + p_keyword == "for" || + p_keyword == "if" || + p_keyword == "return" || + p_keyword == "switch" || + p_keyword == "while"; +} + void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) { Set<String> kws; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 470f3d38d5..e00f4dce19 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -748,6 +748,7 @@ public: static uint32_t get_type_size(DataType p_type); static void get_keyword_list(List<String> *r_keywords); + static bool is_control_flow_keyword(String p_keyword); static void get_builtin_funcs(List<String> *r_keywords); struct BuiltInInfo { |