コード例 #1
0
void Quadruplicate::render()
{
	if (hasState(Item::SPAWNING) || hasState(Item::WAITING) || hasState(Item::EXPIRED))
		graphics_.render(point_.getX(), point_.getY());


	for (size_t i = 0; i < SIZE_ && hasState(Item::TAKEN); i++)
		copies_[i].render();
	
}
コード例 #2
0
ファイル: uiwidget.cpp プロジェクト: Pucker/otclient
void UIWidget::updateStyle()
{
    if(m_destroyed)
        return;

    if(m_loadingStyle && !m_updateStyleScheduled) {
        UIWidgetPtr self = static_self_cast<UIWidget>();
        g_dispatcher.addEvent([self] {
            self->m_updateStyleScheduled = false;
            self->updateStyle();
        });
        m_updateStyleScheduled = true;
        return;
    }

    if(!m_style)
        return;

    OTMLNodePtr newStateStyle = OTMLNode::create();

    // copy only the changed styles from default style
    if(m_stateStyle) {
        for(OTMLNodePtr node : m_stateStyle->children()) {
            if(OTMLNodePtr otherNode = m_style->get(node->tag()))
                newStateStyle->addChild(otherNode->clone());
        }
    }

    // checks for states combination
    for(const OTMLNodePtr& style : m_style->children()) {
        if(stdext::starts_with(style->tag(), "$")) {
            std::string statesStr = style->tag().substr(1);
            std::vector<std::string> statesSplit = stdext::split(statesStr, " ");

            bool match = true;
            for(std::string stateStr : statesSplit) {
                if(stateStr.length() == 0)
                    continue;

                bool notstate = (stateStr[0] == '!');
                if(notstate)
                    stateStr = stateStr.substr(1);

                bool stateOn = hasState(Fw::translateState(stateStr));
                if((!notstate && !stateOn) || (notstate && stateOn))
                    match = false;
            }

            // merge states styles
            if(match) {
                newStateStyle->merge(style);
            }
        }
    }

    //TODO: prevent setting already set proprieties

    applyStyle(newStateStyle);
    m_stateStyle = newStateStyle;
}
コード例 #3
0
ファイル: OISBKeyboard.cpp プロジェクト: fire-archive/oisb
	Keyboard::Keyboard(OIS::Keyboard* keyboard):
		mKeyboard(keyboard)
	{
		for (unsigned int i = 0; i < 256; ++i)
		{
			String name = mKeyboard->getAsString(static_cast<OIS::KeyCode>(i));
			if (name == "")
			{
				name = "Unknown";
			}

            if (!hasState(name))
			{
				mKeys[i] = new DigitalState(this, name);
                //mKeys[i]->_setScanCode(static_cast<OIS::KeyCode>(i));
                //mKeys[i]->_setCharCode(
				addState(mKeys[i]);
			}
            else
			{
                std::stringstream s;

                s << i;
                String i_str = s.str();

				name += " (" + i_str + ")";
				mKeys[i] = new DigitalState(this, name);
				addState(mKeys[i]);
			}
		}
	}
コード例 #4
0
ファイル: testprotocol.cpp プロジェクト: NIA/seismoreg
void TestProtocol::stopReceiving() {
    if(! hasState(Receiving) ) {
        // TODO: report warning: already stopped
        return;
    }
    disableTimer(dataTimer);
    removeState(Receiving);
}
コード例 #5
0
ファイル: testprotocol.cpp プロジェクト: NIA/seismoreg
void TestProtocol::startReceiving() {
    // TODO: move this logic to Protocol too?
    if(! hasState(ADCReady) ) {
        // TODO: report error: ADC not ready
        return;
    }
    if( hasState(Receiving) ) {
        // TODO: report warning: already receiving
        return;
    }
    addState(Receiving);
    connect(dataTimer, &QTimer::timeout, [=]() {
        TimeStampsVector t = SerialProtocol::generateTimeStamps(1000, dataSize);
        emit dataAvailable(t, generateRandom(t));
    });
    dataTimer->start(1000);
}
コード例 #6
0
//virtual 
bool LLViewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut)
{
	const OctreeNode* node = mOctreeNode;

	if (node->isEmpty())
	{	//don't do anything if there are no objects
		if (empty && mOctreeNode->getParent())
		{	//only root is allowed to be empty
			OCT_ERRS << "Empty leaf found in octree." << LL_ENDL;
		}
		return false;
	}

	LLVector4a& newMin = mObjectExtents[0];
	LLVector4a& newMax = mObjectExtents[1];
	
	if (hasState(OBJECT_DIRTY))
	{ //calculate new bounding box
		clearState(OBJECT_DIRTY);

		//initialize bounding box to first element
		OctreeNode::const_element_iter i = node->getDataBegin();
		LLViewerOctreeEntry* entry = *i;
		const LLVector4a* minMax = entry->getSpatialExtents();

		newMin = minMax[0];
		newMax = minMax[1];

		for (++i; i != node->getDataEnd(); ++i)
		{
			entry = *i;
			minMax = entry->getSpatialExtents();
			
			update_min_max(newMin, newMax, minMax[0]);
			update_min_max(newMin, newMax, minMax[1]);
		}
		
		mObjectBounds[0].setAdd(newMin, newMax);
		mObjectBounds[0].mul(0.5f);
		mObjectBounds[1].setSub(newMax, newMin);
		mObjectBounds[1].mul(0.5f);
	}
	
	if (empty)
	{
		minOut = newMin;
		maxOut = newMax;
	}
	else
	{
		minOut.setMin(minOut, newMin);
		maxOut.setMax(maxOut, newMax);
	}
		
	return TRUE;
}
コード例 #7
0
bool AIStateMachine::setState(AIState* state)
{
    if (hasState(state))
    {
        sendChangeStateMessage(state);
        return true;
    }

    return false;
}
コード例 #8
0
ファイル: fsm.cpp プロジェクト: lordhoto/hort
bool FSM::setState(StateID newState) {
	if (!hasState(newState)) {
		_curState = 0;
		_curStateID = kInvalidStateID;
		return false;
	} else {
		_curStateID = newState;
		_curState = _states.find(_curStateID)->second;
		return true;
	}
}
コード例 #9
0
State StateMachine::transistionTo(const int stateID){
    if(!hasState(stateID)){
        for(auto s : states){
            if(s.hasState( stateID)){
                //std::cout << "id: " << stateID << " " << s.getNextState().getLocation() << std::endl;
                return s.getNextState();
            }
        }
    }
    return getPendingState();
}
コード例 #10
0
void AIStateMachine::setStateInternal(AIState* state)
{
    GP_ASSERT(hasState(state));

    // Fire the exit event for the current state
    _currentState->exit(this);

    // Set the new state
    _currentState = state;

    // Fire the enter event for the new state
    _currentState->enter(this);
}
コード例 #11
0
ファイル: ThreatMap.cpp プロジェクト: JigglyPoofSWG/BSS
bool ThreatMap::setThreatState(CreatureObject* target, uint64 state, uint64 duration, uint64 cooldown) {
	Locker locker(&lockMutex);

	if((hasState(state) && isUniqueState(state))
			|| !cooldownTimerMap.isPast(String::valueOf(state)))
		return false;

	int idx = find(target);

	if (idx == -1) {
		ThreatMapEntry entry;
		entry.setThreatState(state);
		put(target, entry);
		registerObserver(target);

	} else {
		ThreatMapEntry* entry = &elementAt(idx).getValue();
		entry->setThreatState(state);
	}

	if(duration > 0) {
		Reference<ClearThreatStateTask*> clearThreat = new ClearThreatStateTask(self.get(), target, state);
		clearThreat->schedule(duration);
	}

	if(cooldown > 0) {
		cooldownTimerMap.updateToCurrentAndAddMili(String::valueOf(state), duration + cooldown);
	}

	if(isUniqueState(state)) {
		cooldownTimerMap.updateToCurrentTime("doEvaluation");
	}

#ifdef DEBUG
	System::out << "Setting threat state on "  << target->getObjectID() << ": " << state << endl;
#endif

	return true;
}
コード例 #12
0
ファイル: uiwidget.cpp プロジェクト: Pucker/otclient
void UIWidget::updateState(Fw::WidgetState state)
{
    if(m_destroyed)
        return;

    bool newStatus = true;
    bool oldStatus = hasState(state);
    bool updateChildren = false;

    switch(state) {
        case Fw::ActiveState: {
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            UIWidgetPtr parent;
            do {
                parent = widget->getParent();
                if(!widget->isExplicitlyEnabled() ||
                   ((parent && parent->getFocusedChild() != widget))) {
                    newStatus = false;
                    break;
                }
            } while((widget = parent));

            updateChildren = newStatus != oldStatus;
            break;
        }
        case Fw::FocusState: {
            newStatus = (getParent() && getParent()->getFocusedChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::HoverState: {
            newStatus = (g_ui.getHoveredWidget() == static_self_cast<UIWidget>() && isEnabled());
            break;
        }
        case Fw::PressedState: {
            newStatus = (g_ui.getPressedWidget() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::DraggingState: {
            newStatus = (g_ui.getDraggingWidget() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::DisabledState: {
            bool enabled = true;
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            do {
                if(!widget->isExplicitlyEnabled()) {
                    enabled = false;
                    break;
                }
            } while((widget = widget->getParent()));
            newStatus = !enabled;
            updateChildren = newStatus != oldStatus;
            break;
        }
        case Fw::FirstState: {
            newStatus = (getParent() && getParent()->getFirstChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::MiddleState: {
            newStatus = (getParent() && getParent()->getFirstChild() != static_self_cast<UIWidget>() && getParent()->getLastChild() != static_self_cast<UIWidget>());
            break;
        }
        case Fw::LastState: {
            newStatus = (getParent() && getParent()->getLastChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::AlternateState: {
            newStatus = (getParent() && (getParent()->getChildIndex(static_self_cast<UIWidget>()) % 2) == 1);
            break;
        }
        case Fw::HiddenState: {
            bool visible = true;
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            do {
                if(!widget->isExplicitlyVisible()) {
                    visible = false;
                    break;
                }
            } while((widget = widget->getParent()));
            newStatus = !visible;
            updateChildren = newStatus != oldStatus;
            break;
        }
        default:
            return;
    }

    if(updateChildren) {
        // do a backup of children list, because it may change while looping it
        UIWidgetList children = m_children;
        for(const UIWidgetPtr& child : children)
            child->updateState(state);
    }

    if(setState(state, newStatus)) {
        // disabled widgets cannot have hover state
        if(state == Fw::DisabledState && !newStatus && isHovered()) {
            g_ui.updateHoveredWidget();
        } else if(state == Fw::HiddenState) {
            onVisibilityChange(!newStatus);
        }
    }
}
コード例 #13
0
ファイル: AbstractFunction.cpp プロジェクト: HBMP/CGSamele
bool AbstractFunction::hasState() const
{
    return hasState(t_pos);
}
コード例 #14
0
ファイル: uicheckbox.cpp プロジェクト: brun123/otclient
bool UICheckBox::isChecked()
{
    return hasState(Fw::CheckedState);
}
コード例 #15
0
ファイル: uiwidget.cpp プロジェクト: AndreFaramir/otclient
void UIWidget::updateState(Fw::WidgetState state)
{
    bool newStatus = true;
    bool oldStatus = hasState(state);
    bool updateChildren = false;

    switch(state) {
        case Fw::ActiveState: {
            UIWidgetPtr widget = asUIWidget();
            UIWidgetPtr parent;
            do {
                parent = widget->getParent();
                if(!widget->isExplicitlyEnabled() ||
                   ((parent && parent->getFocusedChild() != widget))) {
                    newStatus = false;
                    break;
                }
            } while(widget = parent);

            updateChildren = true;
            break;
        }
        case Fw::FocusState: {
            newStatus = (getParent() && getParent()->getFocusedChild() == asUIWidget());
            break;
        }
        case Fw::HoverState: {
            updateChildren = true;
            Point mousePos = g_window.getMousePos();
            UIWidgetPtr widget = asUIWidget();
            UIWidgetPtr parent;
            do {
                parent = widget->getParent();
                if(!widget->isExplicitlyEnabled() || !widget->isExplicitlyVisible() || !widget->containsPoint(mousePos) ||
                   (parent && widget != parent->getChildByPos(mousePos))) {
                    newStatus = false;
                    break;
                }
            } while(widget = parent);
            break;
        }
        case Fw::PressedState: {
            newStatus = m_pressed;
            break;
        }
        case Fw::DisabledState: {
            bool enabled = true;
            updateChildren = true;
            UIWidgetPtr widget = asUIWidget();
            do {
                if(!widget->isExplicitlyEnabled()) {
                    enabled = false;
                    break;
                }
            } while(widget = widget->getParent());
            newStatus = !enabled;
            break;
        }
        case Fw::FirstState: {
            newStatus = (getParent() && getParent()->getFirstChild() == asUIWidget());
            break;
        }
        case Fw::MiddleState: {
            newStatus = (getParent() && getParent()->getFirstChild() != asUIWidget() && getParent()->getLastChild() != asUIWidget());
            break;
        }
        case Fw::LastState: {
            newStatus = (getParent() && getParent()->getLastChild() == asUIWidget());
            break;
        }
        case Fw::AlternateState: {
            newStatus = (getParent() && (getParent()->getChildIndex(asUIWidget()) % 2) == 1);
            break;
        }
        default:
            return;
    }

    if(updateChildren) {
        // do a backup of children list, because it may change while looping it
        UIWidgetList children = m_children;
        for(const UIWidgetPtr& child : children)
            child->updateState(state);
    }

    if(setState(state, newStatus)) {
        if(state == Fw::FocusState) {
            g_dispatcher.addEvent(std::bind(&UIWidget::onFocusChange, asUIWidget(), newStatus, m_lastFocusReason));
        } else if(state == Fw::HoverState)
            g_dispatcher.addEvent(std::bind(&UIWidget::onHoverChange, asUIWidget(), newStatus));
    }
}