summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-05-01 17:44:52 +0200
committerRémi Verschelde <rverschelde@gmail.com>2017-05-01 17:50:19 +0200
commit7ce8342ac5c0e0a302559d3ef561ffd9dc74ff2c (patch)
tree7548791d163e1468ba9794b6ab3eee427f891e1a /main
parentde7eba887e9fe940dac0958836fa8fb778628d2a (diff)
Rename project file to "project.godot"
Slimmed down variant from the reverted #8375. The rationale behind the name change is to give Godot's project file a unique extension (".godot") that can be registered on the OS to be associated with the Godot binary (OS registration not implemented here). This PR also adds the possibility to start the game or editor if launched with the project.godot passed as argument, which paves the way for allowing a similar behaviour on a double-click in the OS file manager (code originally by @Hinsbart). Closes #6915.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/main/main.cpp b/main/main.cpp
index ad7ca84d6b..33095e8599 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -129,7 +129,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n");
OS::get_singleton()->print("Usage: %s [options] [scene]\n", p_binary);
OS::get_singleton()->print("Options:\n");
- OS::get_singleton()->print("\t-path [dir] : Path to a game, containing godot.cfg\n");
+ OS::get_singleton()->print("\t-path [dir] : Path to a game, containing project.godot\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n");
#endif
@@ -447,6 +447,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else {
goto error;
}
+ } else if (I->get().ends_with("project.godot")) {
+ String path;
+ String file = I->get();
+ int sep = MAX(file.find_last("/"), file.find_last("\\"));
+ if (sep == -1)
+ path = ".";
+ else {
+ path = file.substr(0, sep);
+ }
+ if (OS::get_singleton()->set_cwd(path) == OK) {
+ // path already specified, don't override
+ } else {
+ game_path = path;
+ }
+#ifdef TOOLS_ENABLED
+ editor = true;
+#endif
} else if (I->get() == "-bp") { // /breakpoints
if (I->next()) {
@@ -673,7 +690,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
else
input_map->load_from_globals(); //keys for game
- if (video_driver == "") // specified in godot.cfg
+ if (video_driver == "") // specified in project.godot
video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0)));
if (!force_res && use_custom_res && globals->has("display/window/width"))
@@ -725,7 +742,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
/* Determine Video Driver */
- if (audio_driver == "") { // specified in godot.cfg
+ if (audio_driver == "") { // specified in project.godot
audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0));
}