Component* Component::getNextSiblingInNegY(void) const { Component* TestComponent(NULL); if(getParentContainer() != NULL) { for(UInt32 i(0) ; getParentContainer()->getMFChildren()->size(); ++i) { if(getParentContainer()->getChildren(i)->getPosition().y() <= getPosition().y() && (TestComponent == NULL || getParentContainer()->getChildren(i)->getPosition().y() >= TestComponent->getPosition().y())) { TestComponent = getParentContainer()->getChildren(i); } } } if(TestComponent != this) { return TestComponent; } else { return NULL; } }
Component* Component::getPrevDepthFirstComponent(void) const { if(getParentContainer() != NULL) { Component* TestComp(getPrevSibling()); if(TestComp == NULL) { TestComp = getParentContainer(); while(TestComp != NULL && TestComp->getPrevSibling() == NULL) { TestComp = TestComp->getParentContainer(); } if(TestComp != NULL) { TestComp = TestComp->getPrevSibling(); } } if(TestComp != NULL && TestComp->getType().isDerivedFrom(ComponentContainer::getClassType())) { return TestComp->getRightmostDecendent(); } else { return TestComp; } } return NULL; }
void Component::updateContainerLayout(void) { if(getParentContainer() != NULL) { dynamic_cast<ComponentContainer*>(getParentContainer())->updateLayout(); } }
void Component::scrollToPoint(const Pnt2f& PointInComponent) { if(getParentContainer() != NULL && getParentContainer()->getType() == UIViewport::getClassType()) { dynamic_cast<UIViewport*>(getParentContainer())->setViewPosition(PointInComponent); } }
Component* Component::getPrevSibling(void) const { if(getParentContainer() != NULL) { return getParentContainer()->getPrevSiblingOfChild(const_cast<Component* const>(this)); } return NULL; }
void Component::getBoundsRenderingSurfaceSpace(Pnt2f& TopLeft, Pnt2f& BottomRight) const { Pnt2f ParentContainerTopLeft(0,0),ParentContainerBottomRight(0,0); if(getParentContainer() != NULL) { dynamic_cast<ComponentContainer*>(getParentContainer())->getBoundsRenderingSurfaceSpace(ParentContainerTopLeft, ParentContainerBottomRight); } TopLeft = ParentContainerTopLeft + Vec2f(getPosition()); BottomRight = TopLeft + getSize(); }
void CardLayout::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if((whichField & CardFieldMask) && getParentContainer() != NULL) { getParentContainer()->updateLayout(); } }
void MenuBar::updateClipBounds(void) { Pnt2f TopLeft, BottomRight; if(getParentWindow() == NULL) { //If I have no parent container use my bounds getBounds(TopLeft, BottomRight); } else { //Get the intersection of: //My Bounds //My Parent Containers Clip Bounds //My Parent Containers Inset Bounds Pnt2f MyTopLeft,MyBottomRight; getBounds(MyTopLeft,MyBottomRight); //Update my Parent ComponentContainer's Clip Bounds //dynamic_cast<ComponentContainer*>(getParentWindow())->updateClipBounds(); //Get Parent ComponentContainer's Clip Bounds Pnt2f ContainerClipTopLeft, ContainerClipBottomRight; dynamic_cast<InternalWindow*>(getParentContainer())->getMenuBarBounds(ContainerClipTopLeft,ContainerClipBottomRight); //Parent ComponentContainer's Clip Bounds are in the Parent ComponentContainer's Coordinate space //We need to convert them to this Components Coordinate space ContainerClipTopLeft -= Vec2f(getPosition()); ContainerClipBottomRight -= Vec2f(getPosition()); //Get Parent ComponentContainer's MenuBar Bounds Pnt2f ContainerInsetTopLeft, ContainerInsetBottomRight; dynamic_cast<InternalWindow*>(getParentContainer())->getMenuBarBounds(ContainerInsetTopLeft, ContainerInsetBottomRight); //Parent ComponentContainer's Inset Bounds are in the Parent ComponentContainer's Coordinate space //We need to convert them to this Components Coordinate space ContainerInsetTopLeft -= Vec2f(getPosition()); ContainerInsetBottomRight -= Vec2f(getPosition()); //Get the intersection of my bounds with my parent containers clip bounds quadIntersection(MyTopLeft,MyBottomRight, ContainerClipTopLeft,ContainerClipBottomRight, TopLeft, BottomRight); quadIntersection(TopLeft,BottomRight, ContainerInsetTopLeft,ContainerInsetBottomRight, TopLeft, BottomRight); } //The Clip Bounds calculated are in my Parent Containers coordinate space //Translate these bounds into my own coordinate space setClipTopLeft(TopLeft); setClipBottomRight(BottomRight); }
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream) { bool ret = Item::unserializeItemNode(f, node, propStream); if(ret){ unsigned long type; NODE nodeItem = f.getChildNode(node, type); while(nodeItem){ //load container items if(type == OTBM_ITEM){ PropStream itemPropStream; f.getProps(nodeItem, itemPropStream); Item* item = Item::CreateItem(itemPropStream); if(!item){ return false; } if(!item->unserializeItemNode(f, nodeItem, itemPropStream)){ return false; } addItem(item); //deepness if (item->getContainer()){ if (getParentContainer()) item->getContainer()->setDeepness(getDeepness() + 1); else{ //we only update deepness when a container get inside of another, so it means that deepness is not updated setDeepness(1); item->getContainer()->setDeepness(2); } } updateAmountOfItems(item->getTotalAmountOfItemsInside()); total_weight += item->getWeight(); if(Container* parent_container = getParentContainer()) { parent_container->updateItemWeight(item->getWeight()); } } else /*unknown type*/ return false; nodeItem = f.getNextNode(nodeItem, type); } return true; } return false; }
void ContainerItemButton::OnRemoveItem(wxCommandEvent& WXUNUSED(event)) { ASSERT(edit_item); int ret = gui.PopupDialog(GetParent(), wxT("Remove Item"), wxT("Are you sure you want to remove this item from the container?"), wxYES | wxNO); if(ret == wxID_YES) { Container* container = getParentContainer(); ItemVector& v = container->getVector(); ItemVector::iterator item_index = v.begin(); while(item_index != v.end()) { if(*item_index == edit_item) { break; } ++item_index; } ASSERT(item_index != v.end()); v.erase(item_index); delete edit_item; UpdateParentContainerWindow(); } }
void Container::__internalAddThing(uint32_t #ifdef __DEBUG_MOVESYS__ index #endif , Thing* thing) { #ifdef __DEBUG_MOVESYS__ std::clog << "[Container::__internalAddThing] index: " << index << std::endl; #endif if(!thing) return; Item* item = thing->getItem(); if(item == NULL) { #ifdef __DEBUG_MOVESYS__ std::clog << "Failure: [Container::__internalAddThing] item == NULL" << std::endl; #endif return; } itemlist.push_front(item); item->setParent(this); totalWeight += item->getWeight(); if(Container* parentContainer = getParentContainer()) parentContainer->updateItemWeight(item->getWeight()); }
void Container::updateItemWeight(double diff) { total_weight += diff; if(Container* parent_container = getParentContainer()) { parent_container->updateItemWeight(diff); } }
void Container::__replaceThing(uint32_t index, Thing* thing) { Item* item = thing->getItem(); if (!item) { return /*RET_NOTPOSSIBLE*/; } Item* replacedItem = getItemByIndex(index); if (!replacedItem) { return /*RET_NOTPOSSIBLE*/; } totalWeight -= replacedItem->getWeight(); totalWeight += item->getWeight(); if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(-replacedItem->getWeight() + item->getWeight()); } itemlist[index] = item; item->setParent(this); //send change to client if (getParent()) { const ItemType& oldType = Item::items[replacedItem->getID()]; const ItemType& newType = Item::items[item->getID()]; onUpdateContainerItem(index, replacedItem, oldType, item, newType); } replacedItem->setParent(NULL); }
void Container::__replaceThing(uint32_t index, Thing* thing) { Item* item = thing->getItem(); if (!item) { return /*RET_NOTPOSSIBLE*/; } Item* replacedItem = getItemByIndex(index); if (!replacedItem) { return /*RET_NOTPOSSIBLE*/; } totalWeight -= replacedItem->getWeight(); totalWeight += item->getWeight(); if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(-replacedItem->getWeight() + item->getWeight()); } itemlist[index] = item; item->setParent(this); //send change to client if (getParent()) { onUpdateContainerItem(index, replacedItem, item); } replacedItem->setParent(nullptr); }
void Container::__updateThing(Thing* thing, uint16_t itemId, uint32_t count) { int32_t index = __getIndexOfThing(thing); if (index == -1) { return /*RET_NOTPOSSIBLE*/; } Item* item = thing->getItem(); if (item == NULL) { return /*RET_NOTPOSSIBLE*/; } const ItemType& oldType = Item::items[item->getID()]; const ItemType& newType = Item::items[itemId]; const double oldWeight = item->getWeight(); item->setID(itemId); item->setSubType(count); const double diffWeight = -oldWeight + item->getWeight(); totalWeight += diffWeight; if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(diffWeight); } //send change to client if (getParent()) { onUpdateContainerItem(index, item, oldType, item, newType); } }
void Container::updateItemWeight(int32_t diff) { totalWeight += diff; if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(diff); } }
void Container::updateAmountOfItems(int32_t diff) { amountOfItems += diff; if(Container* parent_container = getParentContainer()){ parent_container->updateAmountOfItems(diff); } }
//----------------------------------------------------------------------- void gkMovableShape::setAtlasQuad(const AtlasPacker::PackResult& quad) { mMaterial = static_cast<gkVtxTexture*>(quad.texture)->getMaterial(); RectF tex_coords = quad.node->getRect().contractedCopy(1).relativeTo( quad.texture->getWidth(), quad.texture->getHeight()); const BoundingBox& bb = getBoundingBox(); if (getParentContainer() && !(getParentContainer()->getVisible())) { mMULcolor.a = 0; mADDcolor.a = 0; } _lock(); // TOP-LEFT _addVertex( D3DXVECTOR2(bb.getMinX(), -bb.getMinY()), D3DXVECTOR2(tex_coords.left, tex_coords.top), //D3DXVECTOR2(0, 0), VTXCOLOR_TO_D3DXCOLOR(mMULcolor), VTXCOLOR_TO_D3DXCOLOR(mADDcolor)); // BOTTOM-LEFT _addVertex( D3DXVECTOR2(bb.getMinX(), -bb.getMaxY()), D3DXVECTOR2(tex_coords.left, tex_coords.bottom), //D3DXVECTOR2(0, 1), VTXCOLOR_TO_D3DXCOLOR(mMULcolor), VTXCOLOR_TO_D3DXCOLOR(mADDcolor)); // BOTTOM-RIGHT _addVertex( D3DXVECTOR2(bb.getMaxX(), -bb.getMaxY()), D3DXVECTOR2(tex_coords.right, tex_coords.bottom), //D3DXVECTOR2(1, 1), VTXCOLOR_TO_D3DXCOLOR(mMULcolor), VTXCOLOR_TO_D3DXCOLOR(mADDcolor)); // TOP-RIGHT _addVertex( D3DXVECTOR2(bb.getMaxX(), -bb.getMinY()), D3DXVECTOR2(tex_coords.right, tex_coords.top), //D3DXVECTOR2(1, 0), VTXCOLOR_TO_D3DXCOLOR(mMULcolor), VTXCOLOR_TO_D3DXCOLOR(mADDcolor)); _unlock(); }
void LLPanelSnapshot::goBack() { LLSideTrayPanelContainer* parent = getParentContainer(); if (parent) { parent->openPreviousPanel(); parent->getCurrentPanel()->onOpen(LLSD()); } }
void Container::__removeThing(Thing* thing, uint32_t count) { Item* item = thing->getItem(); if (item == NULL) { return /*RET_NOTPOSSIBLE*/; } int32_t index = __getIndexOfThing(thing); if (index == -1) { return /*RET_NOTPOSSIBLE*/; } if (item->isStackable() && count != item->getItemCount()) { uint8_t newCount = (uint8_t)std::max<int32_t>(0, item->getItemCount() - count); const double oldWeight = -item->getWeight(); item->setItemCount(newCount); const double diffWeight = oldWeight + item->getWeight(); totalWeight += diffWeight; //send change to client if (getParent()) { if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(diffWeight); } const ItemType& it = Item::items[item->getID()]; onUpdateContainerItem(index, item, it, item, it); } } else { //send change to client if (getParent()) { if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(-item->getWeight()); } onRemoveContainerItem(index, item); } totalWeight -= item->getWeight(); item->setParent(NULL); itemlist.erase(itemlist.begin() + index); } }
//----------------------------------------------------------------------- void gkMovableShape::_update(const float& delta_time) { Shape::_update(delta_time); const Matrix& mat = getWorldMatrix(); mWorldMatrix = D3DXMATRIX( mat.m[0][0], -mat.m[0][1], 0, mat.m[0][2], -mat.m[1][0], mat.m[1][1], 0, -mat.m[1][2], 0, 0, 1, 0, 0, 0, 0, 1); D3DXMatrixTranspose(&mWorldMatrix, &mWorldMatrix); mMULcolor = mTransform.getColor().mul; mADDcolor = mTransform.getColor().add; if (getParentContainer() && !(getParentContainer()->getVisible())) { mMULcolor.a = 0; mADDcolor.a = 0; } }
void ContainerItemButton::OnMouseDoubleLeftClick(wxMouseEvent& WXUNUSED(event)) { Container* container = getParentContainer(); bool can_add = container->getVolume() > (int)container->getVector().size(); if(edit_item) { wxCommandEvent unused; OnEditItem(unused); } else if(can_add) { wxCommandEvent unused; OnAddItem(unused); } }
void Component::updateClipBounds(void) { Pnt2f TopLeft, BottomRight; if((getParentContainer() == NULL && useBoundsForClipping()) || (getParentContainer() && getParentContainer()->getType() == RotatedComponent::getClassType())) { //If I have no parent container use my bounds getBounds(TopLeft, BottomRight); } else if(getParentContainer() != NULL) { //Get the intersection of: // My Bounds // My Parent Containers Clip Bounds // My Parent Containers Inset Bounds Pnt2f MyTopLeft,MyBottomRight; getBounds(MyTopLeft,MyBottomRight); //Get Parent ComponentContainer's Clip Bounds Pnt2f ContainerClipTopLeft, ContainerClipBottomRight; dynamic_cast<ComponentContainer*>(getParentContainer())->getClipBounds(ContainerClipTopLeft,ContainerClipBottomRight); //Parent ComponentContainer's Clip Bounds are in the Parent ComponentContainer's Coordinate space //We need to convert them to this Components Coordinate space ContainerClipTopLeft -= Vec2f(getPosition()); ContainerClipBottomRight -= Vec2f(getPosition()); //Get Parent ComponentContainer's Inset Bounds Pnt2f ContainerInsetTopLeft, ContainerInsetBottomRight; dynamic_cast<ComponentContainer*>(getParentContainer())->getInsideInsetsBounds(ContainerInsetTopLeft, ContainerInsetBottomRight); //Parent ComponentContainer's Inset Bounds are in the Parent ComponentContainer's Coordinate space //We need to convert them to this Components Coordinate space ContainerInsetTopLeft -= Vec2f(getPosition()); ContainerInsetBottomRight -= Vec2f(getPosition()); //Get the intersection of my bounds with my parent containers clip bounds quadIntersection(MyTopLeft,MyBottomRight, ContainerClipTopLeft,ContainerClipBottomRight, TopLeft, BottomRight); quadIntersection(TopLeft,BottomRight, ContainerInsetTopLeft,ContainerInsetBottomRight, TopLeft, BottomRight); } //The Clip Bounds calculated are in my Parent Containers coordinate space //Translate these bounds into my own coordinate space if(getClipTopLeft() != TopLeft) { setClipTopLeft(TopLeft); } if(getClipBottomRight() != BottomRight) { setClipBottomRight(BottomRight); } }
void Container::__internalAddThing(uint32_t index, Thing* thing) { Item* item = thing->getItem(); if (item == NULL) { return; } item->setParent(this); itemlist.push_front(item); totalWeight += item->getWeight(); if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(item->getWeight()); } }
void AbstractWindow::updateContainerLayout(void) { if(getParentContainer() != NULL) { Inherited::updateContainerLayout(); } else if(getSize() != getPreferredSize()) { Vec2f Size(osgMax(osgMin(getPreferredSize().x(), getMaxSize().x()), getMinSize().x()), osgMax(osgMin(getPreferredSize().y(), getMaxSize().y()), getMinSize().y())); if(getSize() != Size) { setSize(Size); } } }
void Container::__replaceThing(uint32_t index, Thing* thing) { Item* item = thing->getItem(); if(!item) { #ifdef __DEBUG_MOVESYS__ std::clog << "Failure: [Container::__replaceThing] item == NULL" << std::endl; #endif return /*RET_NOTPOSSIBLE*/; } uint32_t count = 0; ItemList::iterator cit = itemlist.end(); for(cit = itemlist.begin(); cit != itemlist.end(); ++cit) { if(count == index) break; ++count; } if(cit == itemlist.end()) { #ifdef __DEBUG_MOVESYS__ std::clog << "Failure: [Container::__updateThing] item not found" << std::endl; #endif return /*RET_NOTPOSSIBLE*/; } totalWeight -= (*cit)->getWeight(); totalWeight += item->getWeight(); if(Container* parentContainer = getParentContainer()) parentContainer->updateItemWeight(-(*cit)->getWeight() + item->getWeight()); itemlist.insert(cit, item); item->setParent(this); //send change to client if(getParent()) { const ItemType& oldType = Item::items[(*cit)->getID()]; const ItemType& newType = Item::items[item->getID()]; onUpdateContainerItem(index, *cit, oldType, item, newType); } (*cit)->setParent(NULL); itemlist.erase(cit); }
void ContainerItemButton::OnAddItem(wxCommandEvent& WXUNUSED(event)) { struct IsItem { static bool Pickupable(const ItemType& it) { return it.pickupable; } }; FindItemDialog* d = newd FindItemDialog(this->GetParent(), wxT("Choose Item to add")); d->setCondition(IsItem::Pickupable); int id = d->ShowModal(); d->Destroy(); if(id != 0) { Container* container = getParentContainer(); // Find the position where we should insert the item ItemVector& v = container->getVector(); ItemVector::iterator item_index = v.begin(); int i = 0; while(true) { if(item_index == v.end()) { // Insert at end of the vector break; } if(i == index) { // We found where to insert break; } ++i; ++item_index; } // Create and insert the item Item* item = Item::Create(id); v.insert(item_index, item); // Update view UpdateParentContainerWindow(); } }
void Container::__addThingBack(Thing* thing) { Item* item = thing->getItem(); if (item == NULL) { return /*RET_NOTPOSSIBLE*/; } item->setParent(this); itemlist.push_back(item); totalWeight += item->getWeight(); if (Container* parentContainer = getParentContainer()) { parentContainer->updateItemWeight(item->getWeight()); } //send change to client if (getParent() && (getParent() != VirtualCylinder::virtualCylinder)) { onAddContainerItem(item); } }
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream) { bool ret = Item::unserializeItemNode(f, node, propStream); if (!ret) { return false; } uint32_t type; NODE nodeItem = f.getChildNode(node, type); while (nodeItem) { //load container items if (type != OTBM_ITEM) { // unknown type return false; } PropStream itemPropStream; if (!f.getProps(nodeItem, itemPropStream)) { return false; } Item* item = Item::CreateItem(itemPropStream); if (!item) { return false; } if (!item->unserializeItemNode(f, nodeItem, itemPropStream)) { return false; } addItem(item); totalWeight += item->getWeight(); if (Container* parent_container = getParentContainer()) { parent_container->updateItemWeight(item->getWeight()); } nodeItem = f.getNextNode(nodeItem, type); } return true; }
void Container::__addThing(Creature*, int32_t index, Thing* thing) { if(index >= (int32_t)capacity()) { #ifdef __DEBUG_MOVESYS__ std::clog << "Failure: [Container::__addThing], index:" << index << ", index >= capacity()" << std::endl; #endif return /*RET_NOTPOSSIBLE*/; } Item* item = thing->getItem(); if(!item) { #ifdef __DEBUG_MOVESYS__ std::clog << "Failure: [Container::__addThing] item == NULL" << std::endl; #endif return /*RET_NOTPOSSIBLE*/; } #ifdef __DEBUG_MOVESYS__ if(index != INDEX_WHEREEVER && size() >= capacity()) { std::clog << "Failure: [Container::__addThing] size() >= capacity()" << std::endl; return /*RET_CONTAINERNOTENOUGHROOM*/; } #endif item->setParent(this); itemlist.push_front(item); totalWeight += item->getWeight(); if(Container* parentContainer = getParentContainer()) parentContainer->updateItemWeight(item->getWeight()); //send change to client if(getParent() && getParent() != VirtualCylinder::virtualCylinder) onAddContainerItem(item); }