summaryrefslogtreecommitdiff
path: root/editor/project_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r--editor/project_manager.cpp52
1 files changed, 34 insertions, 18 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 2d3b3a2200..a3d3d42110 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -203,10 +203,23 @@ private:
f->store_line("\n");
f->store_line("name=\"" + project_name->get_text() + "\"");
f->store_line("icon=\"res://icon.png\"");
-
+ f->store_line("[rendering]");
+ f->store_line("viewport/default_environment=\"res://default_env.tres\"");
memdelete(f);
ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons"));
+
+ f = FileAccess::open(dir.plus_file("/default_env.tres"), FileAccess::WRITE);
+ if (!f) {
+ error->set_text(TTR("Couldn't create project.godot in project path."));
+ } else {
+ f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]");
+ f->store_line("[sub_resource type=\"ProceduralSky\" id=1]");
+ f->store_line("[resource]");
+ f->store_line("background_mode = 2");
+ f->store_line("background_sky = SubResource( 1 )");
+ memdelete(f);
+ }
}
} else if (mode == MODE_INSTALL) {
@@ -503,14 +516,16 @@ void ProjectManager::_update_project_buttons() {
run_btn->set_disabled(!has_runnable_scene);
}
-void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) {
+void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
+
+ Ref<InputEventMouseButton> mb = p_ev;
- if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
String clicked = p_hb->get_meta("name");
String clicked_main_scene = p_hb->get_meta("main_scene");
- if (p_ev.key.mod.shift && selected_list.size() > 0 && last_clicked != "" && clicked != last_clicked) {
+ if (mb->get_shift() && selected_list.size() > 0 && last_clicked != "" && clicked != last_clicked) {
int clicked_id = -1;
int last_clicked_id = -1;
@@ -527,7 +542,7 @@ void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) {
for (int i = 0; i < scroll_childs->get_child_count(); ++i) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (!hb) continue;
- if (i != clicked_id && (i < min || i > max) && !p_ev.key.mod.control) {
+ if (i != clicked_id && (i < min || i > max) && !mb->get_control()) {
selected_list.erase(hb->get_meta("name"));
} else if (i >= min && i <= max) {
selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
@@ -535,14 +550,14 @@ void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) {
}
}
- } else if (selected_list.has(clicked) && p_ev.key.mod.control) {
+ } else if (selected_list.has(clicked) && mb->get_control()) {
selected_list.erase(clicked);
} else {
last_clicked = clicked;
- if (p_ev.key.mod.control || selected_list.size() == 0) {
+ if (mb->get_control() || selected_list.size() == 0) {
selected_list.insert(clicked, clicked_main_scene);
} else {
selected_list.clear();
@@ -552,23 +567,23 @@ void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) {
_update_project_buttons();
- if (p_ev.mouse_button.doubleclick)
+ if (mb->is_doubleclick())
_open_project(); //open if doubleclicked
}
}
-void ProjectManager::_unhandled_input(const InputEvent &p_ev) {
+void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
- if (p_ev.type == InputEvent::KEY) {
+ Ref<InputEventKey> k = p_ev;
- const InputEventKey &k = p_ev.key;
+ if (k.is_valid()) {
- if (!k.pressed)
+ if (!k->is_pressed())
return;
bool scancode_handled = true;
- switch (k.scancode) {
+ switch (k->get_scancode()) {
case KEY_RETURN: {
@@ -606,7 +621,7 @@ void ProjectManager::_unhandled_input(const InputEvent &p_ev) {
} break;
case KEY_UP: {
- if (k.mod.shift)
+ if (k->get_shift())
break;
if (selected_list.size()) {
@@ -645,7 +660,7 @@ void ProjectManager::_unhandled_input(const InputEvent &p_ev) {
}
case KEY_DOWN: {
- if (k.mod.shift)
+ if (k->get_shift())
break;
bool found = selected_list.empty();
@@ -679,7 +694,7 @@ void ProjectManager::_unhandled_input(const InputEvent &p_ev) {
} break;
case KEY_F: {
- if (k.mod.command)
+ if (k->get_command())
this->project_filter->search_box->grab_focus();
else
scancode_handled = false;
@@ -899,8 +914,9 @@ void ProjectManager::_on_project_created(const String &dir) {
_update_scroll_pos(dir);
} else {
_load_recent_projects();
- scroll->connect("draw", this, "_update_scroll_pos", varray(dir), CONNECT_ONESHOT);
+ _update_scroll_pos(dir);
}
+ _open_project();
}
void ProjectManager::_update_scroll_pos(const String &dir) {
@@ -1454,7 +1470,7 @@ ProjectListFilter::ProjectListFilter() {
_current_filter = FILTER_NAME;
filter_option = memnew(OptionButton);
- filter_option->set_custom_minimum_size(Size2(80, 10));
+ filter_option->set_custom_minimum_size(Size2(80 * EDSCALE, 10 * EDSCALE));
filter_option->set_clip_text(true);
filter_option->connect("item_selected", this, "_filter_option_selected");
add_child(filter_option);