当前位置: 首页>>代码示例>>C++>>正文


C++ HBoxContainer::get_meta方法代码示例

本文整理汇总了C++中HBoxContainer::get_meta方法的典型用法代码示例。如果您正苦于以下问题:C++ HBoxContainer::get_meta方法的具体用法?C++ HBoxContainer::get_meta怎么用?C++ HBoxContainer::get_meta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HBoxContainer的用法示例。


在下文中一共展示了HBoxContainer::get_meta方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _panel_input

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);
			}
		}

		_update_project_buttons();

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

	}
}
开发者ID:SPTelur,项目名称:godot,代码行数:54,代码来源:project_manager.cpp

示例2: _panel_draw

void ProjectManager::_panel_draw(Node *p_hb) {

	HBoxContainer *hb = p_hb->cast_to<HBoxContainer>();

	hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree"));

	if (selected_list.has(hb->get_meta("name"))) {
		hb->draw_style_box(get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0)));
	}
}
开发者ID:9cat,项目名称:godot,代码行数:10,代码来源:project_manager.cpp

示例3: _unhandled_input

void ProjectManager::_unhandled_input(const InputEvent& p_ev) {

	if (p_ev.type==InputEvent::KEY) {

		const InputEventKey &k = p_ev.key;

		if (!k.pressed)
			return;

		bool scancode_handled = true;

		switch (k.scancode) {

			case KEY_RETURN: {

				_open_project();
			} break;
			case KEY_HOME: {

				for (int i=0; i<scroll_childs->get_child_count(); i++) {

					HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
					if (hb) {
						selected_list.clear();
						selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
						scroll->set_v_scroll(0);
						_update_project_buttons();
						break;
					}
				}

			} break;
			case KEY_END: {

				for (int i=scroll_childs->get_child_count()-1; i>=0; i--) {

					HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
					if (hb) {
						selected_list.clear();
						selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
						scroll->set_v_scroll(scroll_childs->get_size().y);
						_update_project_buttons();
						break;
					}
				}

			} break;
			case KEY_UP: {

				if (k.mod.shift)
					break;

				if (selected_list.size()) {

					bool found = false;

					for (int i=scroll_childs->get_child_count()-1; i>=0; i--) {

						HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
						if (!hb) continue;

						String current = hb->get_meta("name");

						if (found) {
							selected_list.clear();
							selected_list.insert(current, hb->get_meta("main_scene"));

							int offset_diff = scroll->get_v_scroll() - hb->get_pos().y;

							if (offset_diff > 0)
								scroll->set_v_scroll(scroll->get_v_scroll() - offset_diff);

							_update_project_buttons();

							break;

						} else if (current==selected_list.back()->key()) {

							found = true;
						}
					}

					break;
				}
				// else fallthrough to key_down
			}
			case KEY_DOWN: {

				if (k.mod.shift)
					break;

				bool found = selected_list.empty();

				for (int i=0; i<scroll_childs->get_child_count(); i++) {

					HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
					if (!hb) continue;

					String current = hb->get_meta("name");

//.........这里部分代码省略.........
开发者ID:SPTelur,项目名称:godot,代码行数:101,代码来源:project_manager.cpp


注:本文中的HBoxContainer::get_meta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。