コード例 #1
0
void VisualScriptTypeCast::set_base_script(const String &p_path) {

	if (script == p_path)
		return;

	script = p_path;
	_change_notify();
	ports_changed_notify();
}
コード例 #2
0
void VisualScriptSequence::set_steps(int p_steps) {

	ERR_FAIL_COND(p_steps < 1);
	if (steps == p_steps)
		return;

	steps = p_steps;
	ports_changed_notify();
}
コード例 #3
0
void VisualScriptTypeCast::set_base_type(const StringName &p_type) {

	if (base_type == p_type)
		return;

	base_type = p_type;
	_change_notify();
	ports_changed_notify();
}
コード例 #4
0
void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) {

	if (call_mode == p_mode)
		return;

	call_mode = p_mode;

	_change_notify();
	ports_changed_notify();
}
コード例 #5
0
void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) {

	if (base_path == p_type)
		return;

	base_path = p_type;

	_change_notify();
	ports_changed_notify();
}
コード例 #6
0
void VisualScriptYieldSignal::set_signal(const StringName &p_type) {

	if (signal == p_type)
		return;

	signal = p_type;

	_change_notify();
	ports_changed_notify();
}
コード例 #7
0
bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) {

	if (String(p_name) == "case_count") {
		case_values.resize(p_value);
		_change_notify();
		ports_changed_notify();
		return true;
	}

	if (String(p_name).begins_with("case/")) {

		int idx = String(p_name).get_slice("/", 1).to_int();
		ERR_FAIL_INDEX_V(idx, case_values.size(), false);

		case_values[idx].type = Variant::Type(int(p_value));
		_change_notify();
		ports_changed_notify();

		return true;
	}

	return false;
}
コード例 #8
0
bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_value) {

	if (String(p_name) == "expression") {
		expression = p_value;
		expression_dirty = true;
		ports_changed_notify();
		return true;
	}

	if (String(p_name) == "out_type") {
		output_type = Variant::Type(int(p_value));
		expression_dirty = true;
		ports_changed_notify();
		return true;
	}
	if (String(p_name) == "sequenced") {
		sequenced = p_value;
		ports_changed_notify();
		return true;
	}

	if (String(p_name) == "input_count") {

		int from = inputs.size();
		inputs.resize(int(p_value));
		for (int i = from; i < inputs.size(); i++) {
			inputs[i].name = String::chr('a' + i);
			if (from == 0) {
				inputs[i].type = output_type;
			} else {
				inputs[i].type = inputs[from - 1].type;
			}
		}
		expression_dirty = true;
		ports_changed_notify();
		_change_notify();
		return true;
	}

	if (String(p_name).begins_with("input_")) {

		int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int();
		ERR_FAIL_INDEX_V(idx, inputs.size(), false);

		String what = String(p_name).get_slice("/", 1);

		if (what == "type") {

			inputs[idx].type = Variant::Type(int(p_value));
		} else if (what == "name") {

			inputs[idx].name = p_value;
		} else {
			return false;
		}

		expression_dirty = true;
		ports_changed_notify();
		return true;
	}

	return false;
}
コード例 #9
0
bool VisualScriptInputFilter::_set(const StringName& p_name, const Variant& p_value) {

	if (p_name=="filter_count") {
		filters.resize(p_value);
		_change_notify();
		ports_changed_notify();
		return true;
	}


	if (String(p_name).begins_with("filter_")) {

		int idx = String(p_name).replace_first("filters_","").get_slice("/",0).to_int();

		ERR_FAIL_INDEX_V(idx,filters.size(),false);

		String what = String(p_name).get_slice("/",1);


		if (what=="type") {
			filters[idx]=InputEvent();
			filters[idx].type=InputEvent::Type(int(p_value));
			if (filters[idx].type==InputEvent::JOYSTICK_MOTION) {
				filters[idx].joy_motion.axis_value=0.5; //for treshold
			} else if (filters[idx].type==InputEvent::KEY) {
				filters[idx].key.pressed=true; //put these as true to make it more user friendly
			} else if (filters[idx].type==InputEvent::MOUSE_BUTTON) {
				filters[idx].mouse_button.pressed=true;
			} else if (filters[idx].type==InputEvent::JOYSTICK_BUTTON) {
				filters[idx].joy_button.pressed=true;
			} else if (filters[idx].type==InputEvent::SCREEN_TOUCH) {
				filters[idx].screen_touch.pressed=true;
			} else if (filters[idx].type==InputEvent::ACTION) {
				filters[idx].action.pressed=true;
			}
			_change_notify();
			ports_changed_notify();

			return true;
		}
		if (what=="device") {
			filters[idx].device=p_value;
			ports_changed_notify();
			return true;
		}

		switch(filters[idx].type) {

			case InputEvent::KEY: {

				if (what=="scancode") {
					String sc = p_value;
					if (sc==String()) {
						filters[idx].key.scancode=0;
					} else {
						filters[idx].key.scancode=find_keycode(p_value);
					}

				} else if (what=="unicode") {

					String uc = p_value;

					if (uc==String()) {
						filters[idx].key.unicode=0;
					} else {
						filters[idx].key.unicode=uc[0];
					}

				} else if (what=="pressed") {

					filters[idx].key.pressed=p_value;
				} else if (what=="echo") {

					filters[idx].key.echo=p_value;

				} else if (what=="mod_alt") {
					filters[idx].key.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].key.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].key.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].key.mod.meta=p_value;
				} else {
					return false;
				}
				ports_changed_notify();

				return true;
			} break;
			case InputEvent::MOUSE_MOTION: {


				if (what=="button_mask") {
					filters[idx].mouse_motion.button_mask=p_value;

				} else if (what=="mod_alt") {
					filters[idx].mouse_motion.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].mouse_motion.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].mouse_motion.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].mouse_motion.mod.meta=p_value;
				} else {
					return false;
				}

				ports_changed_notify();
				return true;

			} break;
			case InputEvent::MOUSE_BUTTON: {

				if (what=="button_index") {
					filters[idx].mouse_button.button_index=p_value;
				} else if (what=="pressed") {
					filters[idx].mouse_button.pressed=p_value;
				} else if (what=="doubleclicked") {
					filters[idx].mouse_button.doubleclick=p_value;

				} else if (what=="mod_alt") {
					filters[idx].mouse_button.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].mouse_button.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].mouse_button.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].mouse_button.mod.meta=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;

			} break;
			case InputEvent::JOYSTICK_MOTION: {

				if (what=="axis") {
					filters[idx].joy_motion.axis=int(p_value)<<1|filters[idx].joy_motion.axis;
				} else if (what=="mode") {
					filters[idx].joy_motion.axis|=int(p_value);
				} else if (what=="treshold") {
					filters[idx].joy_motion.axis_value=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;


			} break;
			case InputEvent::JOYSTICK_BUTTON: {

				if (what=="button_index") {
					filters[idx].joy_button.button_index=p_value;
				} else if (what=="pressed") {
					filters[idx].joy_button.pressed=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;

			} break;
			case InputEvent::SCREEN_TOUCH: {

				if (what=="finger_index") {
					filters[idx].screen_touch.index=p_value;
				} else if (what=="pressed") {
					filters[idx].screen_touch.pressed=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;
			} break;
			case InputEvent::SCREEN_DRAG: {
				if (what=="finger_index") {
					filters[idx].screen_drag.index=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;
			} break;
			case InputEvent::ACTION: {


				if (what=="action_name") {

					List<PropertyInfo> pinfo;
					Globals::get_singleton()->get_property_list(&pinfo);
					int index=1;

					for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
						const PropertyInfo &pi=E->get();

						if (!pi.name.begins_with("input/"))
							continue;

						String name = pi.name.substr(pi.name.find("/")+1,pi.name.length());
						if (name==String(p_value)) {

							filters[idx].action.action=index;
							ports_changed_notify();
							return true;
						}

						index++;
					}

					filters[idx].action.action=0;
					ports_changed_notify();

					return false;

				} else if (what=="pressed") {

					filters[idx].action.pressed=p_value;
					ports_changed_notify();
					return true;
				}


			} break;

		}
	}
	return false;
}