Esempio n. 1
0
bool CBoxBehaviorState::IsPutable(CCSprite* sprite, CCPoint touchPos, CCPoint& avaliablePos)
{
	auto arr = CObjectManager::getInstance()->getBox2dSprite();
	CCPoint setPos;
	bool bIsEnable = true;
	CCRect rect;

	for (int i = 0; i <= 20; i++)
	{
		for (int j = 0; j <= 20; j++)
		{
			CCRect r;
			r.setRect(i * 105 + CScrollManager::getInstance()->getDeltaPosition().x, j * 105 + CScrollManager::getInstance()->getDeltaPosition().y, 105, 105);

			if (r.containsPoint(touchPos))
			{
				setPos = ccp(r.getMidX(), r.getMidY());
				rect = r;
			}
		}
	}

	for (int i = 0; i < arr->getSize(); i++)
	{
		auto anothersprite = arr->getObjectAt(i)->getSpritePtr();

		if (rect.intersectsRect(anothersprite->getBoundingBox()))
			bIsEnable = false;
	}

	avaliablePos = setPos;
	return bIsEnable;
}
Esempio n. 2
0
void ObjectMatrix::saveDataMatrix(const char* path)
{
    ARFF file;
  //  std::vector <std::string> classLabels; classLabels.reserve(0);
   // std::vector <std::string> comment
    //std::vector <int> tmp; // assume v has the elements
    /*if (getPrintClass())
    {
       /*for (int i = 0; i < DataObjects.size(); i++) //pass only unique class labels that will be printed in @Attribute Class section
        {
            bool notFound = true;
            int tmpLabel = DataObjects.at(i).getClassLabel();
            for (int j = 0; j < classLabels.size(); j++)
                if (tmpLabel == classLabels.at(j))
                {
                    notFound = false;
                    break;
                }
            if (notFound)*/
          //  for (int j = 0; j < classLabels.size(); j++)
              //  classLabels.push_back(tmpLabel);
              //  classLabels = attributeStringClasses;
        //}
       // classLabels = attributeClasses;

    std::vector <std::string> attributeLabels; attributeLabels.reserve(0);

    if (!additionalAttributes.empty())
    {
        for (int i = 0; i < getObjectAt(0).getFeatureCount() - additionalAttributes.size(); i++)
            attributeLabels.push_back("atr" + std::to_string(static_cast<long long>(i+1)) + " REAL");

        for (int i = 0; i < additionalAttributes.size(); i++)
            {
            attributeLabels.push_back(additionalAttributes.at(i) + " REAL");
           // std::cout << attributeStringClasses.at(i);
            }
    }
    else
    {
        for (int i = 0; i < getObjectAt(0).getFeatureCount(); i++)
            attributeLabels.push_back("atr" + std::to_string(static_cast<long long>(i+1)) + " REAL");
    }
    file.writeData(path, this->comments, this->DataObjects, attributeStringClasses, attributeLabels);
}
Esempio n. 3
0
void Area::click(int x, int y) {
	Common::StackLock lock(_mutex);

	NWN::Object *o = getObjectAt(x, y);
	if (!o)
		return;

	o->click(_module->getPC());
}
Esempio n. 4
0
void Area::click(int x, int y) {
	Common::StackLock lock(_mutex);

	Jade::Object *o = getObjectAt(x, y);
	if (!o)
		return;

	o->runScript(kScriptOnClick, o, _module->getPC());
	o->runScript(kScriptOnUse, o, _module->getPC());
}
Esempio n. 5
0
void Area::checkActive() {
	if (!_loaded || _highlightAll)
		return;

	Common::StackLock lock(_mutex);

	int x, y;
	CursorMan.getPosition(x, y);

	setActive(getObjectAt(x, y));
}
Esempio n. 6
0
void Area::checkActive(int x, int y) {
	if (_highlightAll)
		return;

	Common::StackLock lock(_mutex);

	if ((x < 0) || (y < 0))
		CursorMan.getPosition(x, y);

	setActive(getObjectAt(x, y));
}
Esempio n. 7
0
// -----------------------------------------------------------------
// Name : onCatchButtonEvent
//  Called by Input Engine.
//  Must return true if event is consumed ; false to let the event be catched by other modules
//  Transfer the message to top frame under mouse
// -----------------------------------------------------------------
bool InterfaceManager::onCatchButtonEvent(ButtonAction * pEvent)
{
    if (pEvent->eButton == ButtonStart && pEvent->eEvent == Event_Down) {
        return onClickStart();
    }
    if (pEvent->eEvent == Event_Down)
    {
        // Reset clicked objects
        if (pEvent->eButton == Button1) {
            m_pClickedObjects[0] = NULL;
        } else if (pEvent->eButton == Button2) {
            m_pClickedObjects[1] = NULL;
        }

        int xoffset, yoffset;
        guiComponent * pObj1 = getObjectAt(pEvent->xPos - pEvent->xOffset, pEvent->yPos - pEvent->yOffset, &xoffset, &yoffset);
        pEvent->xOffset += xoffset;
        pEvent->yOffset += yoffset;
        if (pObj1 == NULL) {
            return false; // not concerned
        }
        if (!pObj1->isEnabled()) {
            return true;  // event is for us, but do nothing
        }

        if ((pObj1->getType() & GOTYPE_FRAME) && pEvent->eButton == Button1) {
            bringFrameAbove((guiFrame*)pObj1);
        }

        // Send event
        guiObject * pObj = pObj1->onButtonEvent(pEvent);
        // Store object for dragging (only for main buttons)
        if (pEvent->eButton == Button1) {
            m_pClickedObjects[0] = pObj;
        } else if (pEvent->eButton == Button2) {
            m_pClickedObjects[1] = pObj;
        }
        // else, don't care about dragging, so just forget pObj.
        return true;
    }
    else
    {
        guiObject ** pObj = (pEvent->eButton == Button1) ? &(m_pClickedObjects[0]) : ((pEvent->eButton == Button2) ? &(m_pClickedObjects[1]) : NULL);
        if (pObj != NULL && *pObj != NULL)
        {
            *pObj = (*pObj)->onButtonEvent(pEvent);
            if (*pObj != NULL && ((*pObj)->getType() & GOTYPE_FRAME) && pEvent->eEvent == Event_Drag) {
                ((guiFrame*) (*pObj))->checkPositionIfDragged();
            }
        }
        return true;
    }
}
Esempio n. 8
0
// -----------------------------------------------------------------
// Name : onCursorMoveEvent
// -----------------------------------------------------------------
bool InterfaceManager::onCursorMoveEvent(int xPxl, int yPxl)
{
    int xoffset, yoffset;
    guiComponent * pObj = getObjectAt(xPxl, yPxl, &xoffset, &yoffset);
    if (pObj == NULL)
    {
        if (m_pPointedObject != NULL)
        {
            m_pPointedObject->onCursorMoveOutEvent();
            m_pPointedObject = NULL;
            m_pTooltip->setVisible(false);
        }
        return false;
    }
    xPxl -= xoffset;
    yPxl -= yoffset;

    guiObject * pPointed = pObj->onCursorMoveEvent(xPxl, yPxl);
    if (pPointed == NULL)
    {
        if (m_pPointedObject != NULL)
        {
            m_pPointedObject->onCursorMoveOutEvent();
            m_pPointedObject = NULL;
            m_pTooltip->setVisible(false);
        }
    }
    else if (pPointed != m_pPointedObject)
    {
        if (m_pPointedObject != NULL) {
            m_pPointedObject->onCursorMoveOutEvent();
        }
        m_pTooltip->setVisible(false);
        m_pPointedObject = pPointed;
        if (m_fTooltipTime > 0) {
            m_fTooltipTime = 0.5f;
        } else {
            m_fTooltipTime = 0.2f;
        }
    }
    return true;
}