MyGUI::Widget* StashPanel::getWidgetSlotByScreenPosition(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(); return widget; } } return 0; }
bool InventoryPanel::hitTestSlots(const MyGUI::types::TRect<int>& _value) { int slot_count = this->mslot_container_panel_2_Widget->getChildCount(); for (int i = 0; i < slot_count; i++) { MyGUI::Widget* widget = this->mslot_container_panel_2_Widget->getChildAt(i); if (widget->getAbsoluteRect().intersect(_value)) return true; } return false; }
void StashPanel::setHoverSlotsColor(const MyGUI::types::TRect<int>& _value , MyGUI::Colour color) { 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); MyGUI::IntRect rectangle = widget->getAbsoluteRect(); MyGUI::IntSize _size = widget->getSize(); MyGUI::IntPoint center_rectangle = MyGUI::IntPoint(rectangle.left + (_size.width / 2), rectangle.top + (_size.height / 2)); //((center_rectangle.left > _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top > _value.top) && (center_rectangle.top < _value.bottom)); if (((center_rectangle.left >= _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top >= _value.top) && (center_rectangle.top < _value.bottom))) { //en el check de arriba, algunos son con igual y otros no porque sino se seleccionan mal, o 2 de 4 o 6 de 4 ! widget->setColour(color); } } }
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; }