Beispiel #1
0
void ProjectManager::_update_project_buttons()
{
	for(int i=0;i<scroll_childs->get_child_count();i++) {

		CanvasItem *item = scroll_childs->get_child(i)->cast_to<CanvasItem>();
		item->update();
	}

	bool has_runnable_scene = false;
	for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
		const String &selected_main = E->get();
		if (selected_main == "") continue;
		has_runnable_scene = true;
		break;
	}

	erase_btn->set_disabled(selected_list.size()<1);
	open_btn->set_disabled(selected_list.size()<1);
	run_btn->set_disabled(!has_runnable_scene);
}
Beispiel #2
0
void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) {

	if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.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) {

			int clicked_id = -1;
			int last_clicked_id = -1;
			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 (hb->get_meta("name") == clicked) clicked_id = i;
				if (hb->get_meta("name") == last_clicked) last_clicked_id = i;
			}

			if (last_clicked_id!=-1 && clicked_id!=-1) {
				int min = clicked_id < last_clicked_id? clicked_id : last_clicked_id;
				int max = clicked_id > last_clicked_id? clicked_id : last_clicked_id;
				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) {
						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"));
					}
				}
			}

		} else if (selected_list.has(clicked) && p_ev.key.mod.control) {

			selected_list.erase(clicked);

		} else {

			last_clicked = clicked;
			if (p_ev.key.mod.control || selected_list.size()==0) {
				selected_list.insert(clicked, clicked_main_scene);
			} else {
				selected_list.clear();
				selected_list.insert(clicked, clicked_main_scene);
			}
		}

		String single_selected = "";
		if (selected_list.size() == 1) {
			single_selected = selected_list.front()->key();
		}

		single_selected_main = "";
		for(int i=0;i<scroll_childs->get_child_count();i++) {
			CanvasItem *item = scroll_childs->get_child(i)->cast_to<CanvasItem>();
			item->update();

			if (single_selected!="" && single_selected == item->get_meta("name"))
				single_selected_main = item->get_meta("main_scene");
		}

		erase_btn->set_disabled(selected_list.size()<1);
		open_btn->set_disabled(selected_list.size()<1);
		run_btn->set_disabled(selected_list.size()<1 || (selected_list.size()==1 && single_selected_main==""));

		if (p_ev.mouse_button.doubleclick)
			_open_project(); //open if doubleclicked

	}
}