summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/main/main.cpp b/main/main.cpp
index e9eca4af39..a4ef357543 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -122,13 +122,18 @@ static bool force_lowdpi = false;
static int init_screen = -1;
static bool use_vsync = true;
static bool editor = false;
-static bool project_manager = false;
static bool show_help = false;
static bool disable_render_loop = false;
static int fixed_fps = -1;
static OS::ProcessID allow_focus_steal_pid = 0;
+static bool project_manager = false;
+
+bool Main::is_project_manager() {
+ return project_manager;
+}
+
void initialize_physics() {
/// 3D Physics Server
@@ -514,12 +519,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
//video_mode.fullscreen=false;
init_fullscreen = true;
+#ifdef TOOLS_ENABLED
} else if (I->get() == "-e" || I->get() == "--editor") { // starts editor
editor = true;
} else if (I->get() == "-p" || I->get() == "--project-manager") { // starts project manager
project_manager = true;
+#endif
} else if (I->get() == "--no-window") { // disable window creation, Windows only
OS::get_singleton()->set_no_window_mode(true);
@@ -773,6 +780,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->add_logger(memnew(RotatedFileLogger(base_path, max_files)));
}
+#ifdef TOOLS_ENABLED
if (editor) {
Engine::get_singleton()->set_editor_hint(true);
main_args.push_back("--editor");
@@ -780,23 +788,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
init_maximized = true;
video_mode.maximized = true;
}
- use_custom_res = false;
}
- if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stdout"))) {
- quiet_stdout = true;
- }
- if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stderr"))) {
- _print_error_enabled = false;
- };
-
- if (quiet_stdout)
- _print_line_enabled = false;
-
- OS::get_singleton()->set_cmdline(execpath, main_args);
-
-#ifdef TOOLS_ENABLED
-
if (!project_manager) {
// Determine if the project manager should be requested
project_manager =
@@ -805,17 +798,26 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
(!ProjectSettings::get_singleton()->has_setting("application/run/main_scene") ||
String(ProjectSettings::get_singleton()->get("application/run/main_scene")) == "");
}
-
- if (project_manager) {
- use_custom_res = false; //project manager (run without arguments)
- }
-
#endif
- if (editor)
+ if (editor || project_manager) {
+ use_custom_res = false;
input_map->load_default(); //keys for editor
- else
+ } else {
input_map->load_from_globals(); //keys for game
+ }
+
+ if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stdout"))) {
+ quiet_stdout = true;
+ }
+ if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stderr"))) {
+ _print_error_enabled = false;
+ };
+
+ if (quiet_stdout)
+ _print_line_enabled = false;
+
+ OS::get_singleton()->set_cmdline(execpath, main_args);
//if (video_driver == "") // useless for now, so removing
// video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0)));
@@ -1097,7 +1099,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
MAIN_PRINT("Main: Create bootsplash");
#if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH)
- Ref<Image> splash = editor ? memnew(Image(boot_splash_editor_png)) : memnew(Image(boot_splash_png));
+ Ref<Image> splash = (editor || project_manager) ? memnew(Image(boot_splash_editor_png)) : memnew(Image(boot_splash_png));
#else
Ref<Image> splash = memnew(Image(boot_splash_png));
#endif
@@ -1123,7 +1125,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon", PropertyInfo(Variant::STRING, "application/config/icon", PROPERTY_HINT_FILE, "*.png,*.webp"));
if (bool(GLOBAL_DEF("display/window/handheld/emulate_touchscreen", false))) {
- if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) {
+ if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !(editor || project_manager)) {
//only if no touchscreen ui hint, set emulation
InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());
if (id)
@@ -1211,7 +1213,6 @@ bool Main::start() {
ERR_FAIL_COND_V(!_start_success, false);
bool hasicon = false;
- bool editor = false;
String doc_tool;
List<String> removal_docs;
bool doc_base = true;
@@ -1226,24 +1227,27 @@ bool Main::start() {
//parameters that do not have an argument to the right
if (args[i] == "--no-docbase") {
doc_base = false;
+#ifdef TOOLS_ENABLED
} else if (args[i] == "-e" || args[i] == "--editor") {
editor = true;
} else if (args[i] == "-p" || args[i] == "--project-manager") {
project_manager = true;
+#endif
} else if (args[i].length() && args[i][0] != '-' && game_path == "") {
game_path = args[i];
}
//parameters that have an argument to the right
else if (i < (args.size() - 1)) {
bool parsed_pair = true;
- if (args[i] == "--doctool") {
- doc_tool = args[i + 1];
- for (int j = i + 2; j < args.size(); j++)
- removal_docs.push_back(args[j]);
- } else if (args[i] == "-s" || args[i] == "--script") {
+ if (args[i] == "-s" || args[i] == "--script") {
script = args[i + 1];
} else if (args[i] == "--test") {
test = args[i + 1];
+#ifdef TOOLS_ENABLED
+ } else if (args[i] == "--doctool") {
+ doc_tool = args[i + 1];
+ for (int j = i + 2; j < args.size(); j++)
+ removal_docs.push_back(args[j]);
} else if (args[i] == "--export") {
editor = true; //needs editor
if (i + 1 < args.size()) {
@@ -1261,6 +1265,7 @@ bool Main::start() {
return false;
}
export_debug = true;
+#endif
} else {
// The parameter does not match anything known, don't skip the next argument
parsed_pair = false;
@@ -1441,7 +1446,7 @@ bool Main::start() {
{
}
- if (!editor) {
+ if (!editor && !project_manager) {
//standard helpers that can be changed from main config
String stretch_mode = GLOBAL_DEF("display/window/stretch/mode", "disabled");
@@ -1552,7 +1557,7 @@ bool Main::start() {
#endif
}
- if (!project_manager && !editor) {
+ if (!project_manager && !editor) { // game
if (game_path != "" || script != "") {
//autoload
List<PropertyInfo> props;
@@ -1634,7 +1639,6 @@ bool Main::start() {
sml->get_root()->add_child(E->get());
}
- //singletons
}
if (game_path != "") {