コード例 #1
0
ファイル: BaseGui.cpp プロジェクト: AditGame/Adit
BaseGui::BaseGui(std::string & layout)
{
	std::string mainWidgetName = "main";

	_layoutRoot = MyGUI::LayoutManager::getInstance().loadLayout(layout);
	_mainWidget = nullptr;
	for (MyGUI::VectorWidgetPtr::iterator it = _layoutRoot.begin(); it != _layoutRoot.end(); it++)
	{
		MyGUI::Widget* ptr = *it;
		if (ptr->getName() == mainWidgetName)
		{
			_mainWidget = ptr;
			return;
		}
	}
	std::cout << "Could not find widget named " + mainWidgetName + " in layout " + layout << std::endl;
}
コード例 #2
0
ファイル: StashPanel.cpp プロジェクト: Alex-G/MuOnline
	MyGUI::Widget* StashPanel::getWidgetSlotByScreenPosition_modified(const MyGUI::types::TPoint<int>&  _value)
	{
		int slot_count = this->mslot_container_panelWidget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
			if (widget->getAbsoluteRect().inside(_value))
			{
				MyGUI::types::TRect<int> big_rect = widget->getAbsoluteRect();
				MyGUI::types::TSize<int> big_size = widget->getSize();

				/********/
				/* 1  2 */
				/* 3  4 */
				/********/

				MyGUI::types::TRect<int> rect_1;
				rect_1.set(big_rect.left, big_rect.top, big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2);

				MyGUI::types::TRect<int> rect_2;
				rect_2.set(big_rect.left + big_size.width / 2, big_rect.top, big_rect.left + big_size.width, big_rect.top + big_size.height / 2);

				MyGUI::types::TRect<int> rect_3;
				rect_3.set(big_rect.left, big_rect.top + big_size.height / 2, big_rect.left + big_size.width / 2, big_rect.top + big_size.height);

				MyGUI::types::TRect<int> rect_4;
				rect_4.set(big_rect.left + big_size.width / 2, big_rect.top + big_size.height / 2, big_rect.left + big_size.width , big_rect.top + big_size.height);

				if (rect_1.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_1");
					return widget;
				}

				if (rect_2.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_2");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r, c+1);
							return ret;
						}
					}
				}

				if (rect_3.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_3");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c);
							return ret;
						}
					}
				}

				if (rect_4.inside(_value))
				{
					//LogManager::getSingletonPtr()->logMessage("rect_4");
					std::string name = widget->getName();
					std::vector<std::string> splitted = MyGUI::utility::split(name, "_");
					if (!splitted.empty())
					{
						std::string slot_num = splitted.at(3);
						std::vector<std::string> splitted_number = MyGUI::utility::split(slot_num, "x");
						if (!splitted_number.empty())
						{
							int r = StringConverter::parseInt(splitted_number.at(0));
							int c = StringConverter::parseInt(splitted_number.at(1));
							MyGUI::Widget* ret = this->getWidgetSlotByRC(r+1, c+1);
							return ret;
						}
					}
				}

				return widget; //should not return this !
			}
		}
		return 0;
	}