diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index efaa2eb6..923cf72f 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -335,7 +335,6 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,1000000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/separate_distraction_mode", false); _initial_set("interface/editor/automatically_open_screenshots", true); - _initial_set("interface/editor/hide_console_window", true); // GOBLIN ENGINE _initial_set("interface/editor/save_each_scene_on_quit", true); // Regression _initial_set("interface/editor/quit_confirmation", true); diff --git a/modules/goblin/rand.cpp b/modules/goblin/rand.cpp index b8fbe10d..f05c9efa 100644 --- a/modules/goblin/rand.cpp +++ b/modules/goblin/rand.cpp @@ -1,6 +1,7 @@ #include "rand.h" #include "core/os/os.h" #include "modules/regex/regex.h" +#include "core/crypto/crypto.h" #include @@ -233,7 +234,24 @@ Variant Rand::roll_notation(const String dice_notation) { } Color Rand::color() { - return Color(); + Color color; + color.set_hsv(randf(), randf_range(0.0, 1.0), randf_range(0.0, 1.0)); + return color; +} + +String Rand::uuid_v4() { + Ref crypto = Ref(Crypto::create()); + PoolByteArray data = crypto->generate_random_bytes(16); + + data.set(6, (data[6] & 0x0f) | 0x40); + data.set(8, (data[8] & 0x3f) | 0x80); + + PoolByteArray::Read r = data.read(); + return String::hex_encode_buffer(&r[0], 16) + .insert(8, "-") + .insert(13, "-") + .insert(18, "-") + .insert(23, "-"); } void Rand::_bind_methods() { @@ -245,6 +263,8 @@ void Rand::_bind_methods() { ClassDB::bind_method(D_METHOD("decision", "probability"), &Rand::decision); ClassDB::bind_method(D_METHOD("roll", "count", "faces"), &Rand::roll); ClassDB::bind_method(D_METHOD("roll_notation", "dice_notation"), &Rand::roll_notation); + ClassDB::bind_method(D_METHOD("color"), &Rand::color); + ClassDB::bind_method(D_METHOD("uuid_v4"), &Rand::uuid_v4); ADD_PROPERTY_DEFAULT("seed", 0); ADD_PROPERTY_DEFAULT("state", 0); diff --git a/modules/goblin/rand.h b/modules/goblin/rand.h index 759e10b0..1b097c2d 100644 --- a/modules/goblin/rand.h +++ b/modules/goblin/rand.h @@ -23,6 +23,7 @@ class Rand : public RandomNumberGenerator { Variant roll(uint32_t count, uint32_t sides); Variant roll_notation(const String notation); Color color(); + String uuid_v4(); Rand(); ~Rand() {};