summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/input_default.cpp42
-rw-r--r--main/main.cpp55
-rw-r--r--main/main_builders.py4
-rw-r--r--main/tests/test_gdscript.cpp4
-rw-r--r--main/tests/test_physics.cpp1
-rw-r--r--main/tests/test_string.cpp18
6 files changed, 68 insertions, 56 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index a939d77a1e..a03d015fc3 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -726,14 +726,14 @@ InputDefault::InputDefault() {
if (entries[i] == "")
continue;
parse_mapping(entries[i]);
- };
- };
+ }
+ }
int i = 0;
while (DefaultControllerMappings::mappings[i]) {
parse_mapping(DefaultControllerMappings::mappings[i++]);
- };
+ }
}
void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
@@ -748,14 +748,14 @@ void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
if (joy.mapping == -1) {
_button_event(p_device, p_button, p_pressed);
return;
- };
+ }
const Map<int, JoyEvent>::Element *el = map_db[joy.mapping].buttons.find(p_button);
if (!el) {
//don't process un-mapped events for now, it could mess things up badly for devices with additional buttons/axis
//return _button_event(p_last_id, p_device, p_button, p_pressed);
return;
- };
+ }
JoyEvent map = el->get();
if (map.type == TYPE_BUTTON) {
@@ -767,14 +767,13 @@ void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
}
_button_event(p_device, map.index, p_pressed);
return;
- };
+ }
if (map.type == TYPE_AXIS) {
_axis_event(p_device, map.index, p_pressed ? 1.0 : 0.0);
- };
-
- return; // no event?
-};
+ }
+ // no event?
+}
void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
@@ -874,23 +873,22 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
return;
}
float deadzone = p_value.min == 0 ? 0.5f : 0.0f;
- bool pressed = p_value.value > deadzone ? true : false;
+ bool pressed = p_value.value > deadzone;
if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) {
// button already pressed or released, this is an axis bounce value
return;
- };
+ }
_button_event(p_device, map.index, pressed);
return;
- };
+ }
if (map.type == TYPE_AXIS) {
_axis_event(p_device, map.index, val);
return;
- };
+ }
//printf("invalid mapping\n");
- return;
-};
+}
void InputDefault::joy_hat(int p_device, int p_val) {
@@ -909,20 +907,20 @@ void InputDefault::joy_hat(int p_device, int p_val) {
if ((p_val & HAT_MASK_UP) != (cur_val & HAT_MASK_UP)) {
_button_event(p_device, map[HAT_UP].index, p_val & HAT_MASK_UP);
- };
+ }
if ((p_val & HAT_MASK_RIGHT) != (cur_val & HAT_MASK_RIGHT)) {
_button_event(p_device, map[HAT_RIGHT].index, p_val & HAT_MASK_RIGHT);
- };
+ }
if ((p_val & HAT_MASK_DOWN) != (cur_val & HAT_MASK_DOWN)) {
_button_event(p_device, map[HAT_DOWN].index, p_val & HAT_MASK_DOWN);
- };
+ }
if ((p_val & HAT_MASK_LEFT) != (cur_val & HAT_MASK_LEFT)) {
_button_event(p_device, map[HAT_LEFT].index, p_val & HAT_MASK_LEFT);
- };
+ }
joy_names[p_device].hat_current = p_val;
-};
+}
void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
@@ -933,7 +931,7 @@ void InputDefault::_button_event(int p_device, int p_index, bool p_pressed) {
ievent->set_pressed(p_pressed);
parse_input_event(ievent);
-};
+}
void InputDefault::_axis_event(int p_device, int p_axis, float p_value) {
diff --git a/main/main.cpp b/main/main.cpp
index a01d1abe43..ef5c4109db 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -599,6 +599,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
+ } else if (I->get() == "--export" || I->get() == "--export-debug") { // Export project
+
+ editor = true;
+ main_args.push_back(I->get());
#endif
} else if (I->get() == "--path") { // set path of project to start or edit
@@ -812,7 +816,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
int sp = bp.find_last(":");
if (sp == -1) {
ERR_EXPLAIN("Invalid breakpoint: '" + bp + "', expected file:line format.");
- ERR_CONTINUE(sp == -1);
+ ERR_CONTINUE(true);
}
script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp));
@@ -939,7 +943,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false);
video_mode.layered = GLOBAL_DEF("display/window/per_pixel_transparency/enabled", false);
- video_mode.layered_splash = GLOBAL_DEF("display/window/per_pixel_transparency/splash", false);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3);
@@ -1021,6 +1024,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/physics_fps", 60));
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", PropertyInfo(Variant::INT, "physics/common/physics_fps", PROPERTY_HINT_RANGE, "1,120,1,or_greater"));
Engine::get_singleton()->set_physics_jitter_fix(GLOBAL_DEF("physics/common/physics_jitter_fix", 0.5));
Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/settings/fps/force_fps", 0));
ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/fps/force_fps", PropertyInfo(Variant::INT, "debug/settings/fps/force_fps", PROPERTY_HINT_RANGE, "0,120,1,or_greater"));
@@ -1104,6 +1108,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
return err;
}
+ print_line(" "); //add a blank line for readability
+
if (init_use_custom_pos) {
OS::get_singleton()->set_window_position(init_custom_pos);
}
@@ -1154,6 +1160,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
if (show_logo) { //boot logo!
String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String());
bool boot_logo_scale = GLOBAL_DEF("application/boot_splash/fullsize", true);
+ bool boot_logo_filter = GLOBAL_DEF("application/boot_splash/use_filter", true);
ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/image", PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"));
Ref<Image> boot_logo;
@@ -1170,7 +1177,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color);
if (boot_logo.is_valid()) {
OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec();
- VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale);
+ VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter);
} else {
#ifndef NO_DEFAULT_BOOT_LOGO
@@ -1340,20 +1347,10 @@ bool Main::start() {
removal_docs.push_back(args[j]);
} else if (args[i] == "--export") {
editor = true; //needs editor
- if (i + 1 < args.size()) {
- _export_preset = args[i + 1];
- } else {
- ERR_PRINT("Export preset name not specified");
- return false;
- }
+ _export_preset = args[i + 1];
} else if (args[i] == "--export-debug") {
editor = true; //needs editor
- if (i + 1 < args.size()) {
- _export_preset = args[i + 1];
- } else {
- ERR_PRINT("Export preset name not specified");
- return false;
- }
+ _export_preset = args[i + 1];
export_debug = true;
#endif
} else {
@@ -1372,10 +1369,12 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (doc_tool != "") {
+ Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values
+
{
DirAccessRef da = DirAccess::open(doc_tool);
if (!da) {
- ERR_EXPLAIN("Argument supplied to --doctool must be a base godot build directory");
+ ERR_EXPLAIN("Argument supplied to --doctool must be a base Godot build directory");
ERR_FAIL_V(false);
}
}
@@ -1393,12 +1392,23 @@ bool Main::start() {
doc_data_classes[name] = path;
if (!checked_paths.has(path)) {
checked_paths.insert(path);
+
+ // Create the module documentation directory if it doesn't exist
+ DirAccess *da = DirAccess::create_for_path(path);
+ da->make_dir_recursive(path);
+ memdelete(da);
+
docsrc.load_classes(path);
print_line("Loading docs from: " + path);
}
}
String index_path = doc_tool.plus_file("doc/classes");
+ // Create the main documentation directory if it doesn't exist
+ DirAccess *da = DirAccess::create_for_path(index_path);
+ da->make_dir_recursive(index_path);
+ memdelete(da);
+
docsrc.load_classes(index_path);
checked_paths.insert(index_path);
print_line("Loading docs from: " + index_path);
@@ -1466,7 +1476,7 @@ bool Main::start() {
if (obj)
memdelete(obj);
ERR_EXPLAIN("Can't load script '" + script + "', it does not inherit from a MainLoop type");
- ERR_FAIL_COND_V(!script_loop, false);
+ ERR_FAIL_V(false);
}
script_loop->set_init_script(script_res);
@@ -1710,13 +1720,13 @@ bool Main::start() {
if (sep == -1) {
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- local_game_path = da->get_current_dir() + "/" + local_game_path;
+ local_game_path = da->get_current_dir().plus_file(local_game_path);
memdelete(da);
} else {
DirAccess *da = DirAccess::open(local_game_path.substr(0, sep));
if (da) {
- local_game_path = da->get_current_dir() + "/" + local_game_path.substr(sep + 1, local_game_path.length());
+ local_game_path = da->get_current_dir().plus_file(local_game_path.substr(sep + 1, local_game_path.length()));
memdelete(da);
}
}
@@ -1754,7 +1764,7 @@ bool Main::start() {
scene = scenedata->instance();
ERR_EXPLAIN("Failed loading scene: " + local_game_path);
- ERR_FAIL_COND_V(!scene, false)
+ ERR_FAIL_COND_V(!scene, false);
sml->add_current_scene(scene);
#ifdef OSX_ENABLED
@@ -1794,6 +1804,7 @@ bool Main::start() {
pmanager->add_child(progress_dialog);
sml->get_root()->add_child(pmanager);
OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN);
+ project_manager = true;
}
if (project_manager || editor) {
@@ -1803,6 +1814,10 @@ bool Main::start() {
StreamPeerSSL::load_certs_from_file(certs);
else
StreamPeerSSL::load_certs_from_memory(StreamPeerSSL::get_project_cert_array());
+
+ // Hide console window if requested (Windows-only)
+ bool hide_console = EditorSettings::get_singleton()->get_setting("interface/editor/hide_console_window");
+ OS::get_singleton()->set_console_visible(!hide_console);
}
#endif
}
diff --git a/main/main_builders.py b/main/main_builders.py
index 038a7d17f5..c48aaaa572 100644
--- a/main/main_builders.py
+++ b/main/main_builders.py
@@ -19,7 +19,7 @@ def make_splash(target, source, env):
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef BOOT_SPLASH_H\n")
g.write("#define BOOT_SPLASH_H\n")
- g.write('static const Color boot_splash_bg_color = Color::html("#232323");\n')
+ g.write('static const Color boot_splash_bg_color = Color(0.14, 0.14, 0.14);\n')
g.write("static const unsigned char boot_splash_png[] = {\n")
for i in range(len(buf)):
g.write(byte_to_str(buf[i]) + ",\n")
@@ -38,7 +38,7 @@ def make_splash_editor(target, source, env):
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef BOOT_SPLASH_EDITOR_H\n")
g.write("#define BOOT_SPLASH_EDITOR_H\n")
- g.write('static const Color boot_splash_editor_bg_color = Color::html("#232323");\n')
+ g.write('static const Color boot_splash_editor_bg_color = Color(0.14, 0.14, 0.14);\n')
g.write("static const unsigned char boot_splash_editor_png[] = {\n")
for i in range(len(buf)):
g.write(byte_to_str(buf[i]) + ",\n")
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index 87bd640001..e82af93293 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -911,7 +911,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
if (incr == 0) {
ERR_EXPLAIN("unhandled opcode: " + itos(code[ip]));
- ERR_BREAK(incr == 0);
+ ERR_BREAK(true);
}
ip += incr;
@@ -974,7 +974,7 @@ MainLoop *test(TestType p_type) {
if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER)
text = "'" + tk.get_token_identifier() + "' (identifier)";
else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) {
- Variant c = tk.get_token_constant();
+ const Variant &c = tk.get_token_constant();
if (c.get_type() == Variant::STRING)
text = "\"" + String(c) + "\"";
else
diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp
index 84f504a78d..6850c4d88a 100644
--- a/main/tests/test_physics.cpp
+++ b/main/tests/test_physics.cpp
@@ -329,7 +329,6 @@ public:
make_grid(5, 5, 2.5, 1, gxf);
test_fall();
quit = false;
- return;
}
virtual bool iteration(float p_time) {
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 531887a452..05df888f40 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -57,7 +57,7 @@ bool test_2() {
OS::get_singleton()->print("\n\nTest 2: Assign from string (operator=)\n");
String s = "Dolly";
- String t = s;
+ const String &t = s;
OS::get_singleton()->print("\tExpected: Dolly\n");
OS::get_singleton()->print("\tResulted: %ls\n", t.c_str());
@@ -70,7 +70,7 @@ bool test_3() {
OS::get_singleton()->print("\n\nTest 3: Assign from c-string (copycon)\n");
String s("Sheep");
- String t(s);
+ const String &t(s);
OS::get_singleton()->print("\tExpected: Sheep\n");
OS::get_singleton()->print("\tResulted: %ls\n", t.c_str());
@@ -1017,8 +1017,8 @@ bool test_32() {
STRIP_TEST(String("abca").lstrip("a") == "bca");
STRIP_TEST(String("abc").rstrip("a") == "abc");
STRIP_TEST(String("abca").rstrip("a") == "abc");
- // in utf-8 "¿" has the same first byte as "µ"
- // and the same second as "ÿ"
+ // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5)
+ // and the same second as "ÿ" (\u00ff)
STRIP_TEST(String::utf8("¿").lstrip(String::utf8("µÿ")) == String::utf8("¿"));
STRIP_TEST(String::utf8("¿").rstrip(String::utf8("µÿ")) == String::utf8("¿"));
STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("µÿ")) == String::utf8("¿ÿ"));
@@ -1046,8 +1046,8 @@ bool test_32() {
STRIP_TEST(String("abca").lstrip("qwajkl") == "bca");
STRIP_TEST(String("abc").rstrip("qwajkl") == "abc");
STRIP_TEST(String("abca").rstrip("qwajkl") == "abc");
- // in utf-8 "¿" has the same first byte as "µ"
- // and the same second as "ÿ"
+ // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5)
+ // and the same second as "ÿ" (\u00ff)
STRIP_TEST(String::utf8("¿").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿"));
STRIP_TEST(String::utf8("¿").rstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿"));
STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿ÿ"));
@@ -1062,14 +1062,14 @@ bool test_33() {
OS::get_singleton()->print("\n\nTest 33: parse_utf8(null, -1)\n");
String empty;
- return empty.parse_utf8(NULL, -1) == true;
+ return empty.parse_utf8(NULL, -1);
}
bool test_34() {
OS::get_singleton()->print("\n\nTest 34: Cyrillic to_lower()\n");
- String upper = L"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
- String lower = L"абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
+ String upper = String::utf8("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ");
+ String lower = String::utf8("абвгдеёжзийклмнопрстуфхцчшщъыьэюя");
String test = upper.to_lower();