Example #1
0
void BarWidget::setAlarmEnabled(bool enable)
{
    m_bar->setAlarmEnabled(enable);
    m_alarmEnable->setChecked(enable);
    m_alarmLevel->setEnabled(enable);
    emit scriptEvent(getTitle() + "_alarmEnabled");
}
Example #2
0
DataWidget *WidgetArea::addWidget(QPoint pos, quint8 type, bool show)
{
    DataWidget *w = sWidgetFactory.getWidget(type, this);
    if(!w)
        return NULL;

    quint32 id = getNewId();
    w->setId(id);

    w->setUp(m_storage);

    w->move(pos);
    if(show)
        w->show();

    m_widgets.insert(id, w);

    connect(w,          SIGNAL(removeWidget(quint32)),              SLOT(removeWidget(quint32)));
    connect(w,          SIGNAL(updateMarker(DataWidget*)),          SLOT(updateMarker(DataWidget*)));
    connect(w,          SIGNAL(clearPlacementLines()),              SLOT(clearPlacementLines()));
    connect(w,          SIGNAL(updateData()),                       SIGNAL(updateData()));
    connect(w,   SIGNAL(mouseStatus(bool,data_widget_info,qint32)), SIGNAL(mouseStatus(bool,data_widget_info,qint32)));
    connect(w,          SIGNAL(SendData(QByteArray)),   m_analyzer, SIGNAL(SendData(QByteArray)));
    connect(w,          SIGNAL(toggleSelection(bool)),              SLOT(toggleSelection(bool)));
    connect(this,       SIGNAL(setTitleVisibility(bool)),        w, SLOT(setTitleVisibility(bool)));
    connect(w,  SIGNAL(addChildTab(ChildTab*,QString)), m_analyzer, SLOT(addChildTab(ChildTab*,QString)));
    connect(w,  SIGNAL(removeChildTab(ChildTab*)),      m_analyzer, SLOT(removeChildTab(ChildTab*)));
    connect(w,          SIGNAL(addUndoAct(UndoAction*)),&m_undoStack,SLOT(addAction(UndoAction*)));
    connect(m_analyzer, SIGNAL(rawData(QByteArray)),             w, SIGNAL(rawData(QByteArray)));
    connect(this,       SIGNAL(setLocked(bool)),                 w, SLOT(setLocked(bool)));

    //events
    connect(this,       SIGNAL(onWidgetAdd(DataWidget*)),        w, SLOT(onWidgetAdd(DataWidget*)));
    connect(this,       SIGNAL(onWidgetRemove(DataWidget*)),     w, SLOT(onWidgetRemove(DataWidget*)));
    connect(this,       SIGNAL(onScriptEvent(QString)),          w, SLOT(onScriptEvent(QString)));
    connect(this,       SIGNAL(onScriptEvent(QString,QVariantList)), w, SLOT(onScriptEvent(QString, QVariantList)));
    connect(w,          SIGNAL(scriptEvent(QString)),         this, SIGNAL(onScriptEvent(QString)));
    connect(w,          SIGNAL(scriptEvent(QString, QVariantList)),this, SIGNAL(onScriptEvent(QString, QVariantList)));

    emit onWidgetAdd(w);

    m_analyzer->setDataChanged();

    w->setTitleVisibility(m_actTitleVisibility->isChecked());
    return w;
}
Example #3
0
void BarWidget::setValuePrivate(double val)
{
    if(m_eval.isActive())
    {
        QVariant res = m_eval.evaluate(QString::number(val));
        if(res.isValid())
            val = res.toDouble();
    }

    m_bar->setValue(val);
    m_label->setText(QString::number(val));

    emit scriptEvent(getTitle() + "_valueChanged");

    if(m_bar->alarmEnabled() && val >= m_bar->alarmLevel())
        emit scriptEvent(getTitle() + "_alarm");
}
Example #4
0
static void sendNodeEventToLua(Node* node, int action)
{
    auto scriptEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    
    BasicScriptData data(node,(void*)&action);
    ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
    
    scriptEngine->sendEvent(&scriptEvent);
}
Example #5
0
bool ScriptEngineManager::sendActionEventToJS(Action* actionObject, int eventType, void* param)
{
    auto scriptEngine = getInstance()->getScriptEngine();
    
    ActionObjectScriptData data(actionObject,(int*)&eventType, param);
    ScriptEvent scriptEvent(kScriptActionEvent,(void*)&data);
    if (scriptEngine->sendEvent(&scriptEvent))
        return true;
    
    return false;
}
void ScriptEngineManager::sendNodeEventToLua(Node* node, int action)
{
    if (ShareInstance == nullptr)
        return;
    
    auto scriptEngine = ShareInstance->getScriptEngine();

    BasicScriptData data(node,(void*)&action);
    ScriptEvent scriptEvent(kNodeEvent,(void*)&data);

    scriptEngine->sendEvent(&scriptEvent);
}
Example #7
0
int Layer::executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, Event* event)
{
#if CC_ENABLE_SCRIPT_BINDING
    if (kScriptTypeLua == _scriptType)
    {
        TouchesScriptData data(eventType, this, touches, event);
        ScriptEvent scriptEvent(kTouchesEvent, &data);
        return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
#endif
    return 0;
}
void Node::onExitTransitionDidStart()
{
    for( const auto &child: _children)
        child->onExitTransitionDidStart();
    
    if (_scriptType != kScriptTypeNone)
    {
        int action = kNodeOnExitTransitionDidStart;
        BasicScriptData data(this,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
}
Example #9
0
int Layer::executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch, Event* event)
{
#if CC_ENABLE_SCRIPT_BINDING
    if (kScriptTypeLua == _scriptType)
    {
        TouchScriptData data(eventType, this, touch, event);
        ScriptEvent scriptEvent(kTouchEvent, &data);
        return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
#endif
    //can not reach it
    return 0;
}
Example #10
0
bool ScriptEngineManager::sendNodeEventToJSExtended(Node* node, int action)
{
    auto scriptEngine = getInstance()->getScriptEngine();
    
    if (!scriptEngine->isCalledFromScript())
    {
        BasicScriptData data(node,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        if (scriptEngine->sendEvent(&scriptEvent))
            return true;
    }
    
    return false;
}
Example #11
0
void Node::onEnterTransitionDidFinish()
{
    _isTransitionFinished = true;

    if (_scriptType != kScriptTypeNone)
    {
        int action = kNodeOnEnterTransitionDidFinish;
        BasicScriptData data(this,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
    
    for( const auto &child: _children)
        child->onEnterTransitionDidFinish();
}
Example #12
0
void Node::onExit()
{
    this->pause();

    _running = false;

    for( const auto &child: _children)
        child->onExit();
    
    if (_scriptType != kScriptTypeNone)
    {
        int action = kNodeOnExit;
        BasicScriptData data(this,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
}
Example #13
0
//------------------------------------------------------------------------
IMPLEMENT_RMI(CGameRules, ClTaggedEntity)
{
	if (!params.entityId)
		return true;

	SEntityEvent scriptEvent( ENTITY_EVENT_SCRIPT_EVENT );
	scriptEvent.nParam[0] = (INT_PTR)"OnGPSTagged";
	scriptEvent.nParam[1] = IEntityClass::EVT_BOOL;
	bool bValue = true;
	scriptEvent.nParam[2] = (INT_PTR)&bValue;

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(params.entityId);
	if (pEntity)
		pEntity->SendEvent( scriptEvent );

	return true;
}
Example #14
0
void MenuItem::activate()
{
    if (_enabled)
    {
        if( _callback )
        {
            _callback(this);
        }

        if (kScriptTypeNone != _scriptType)
        {
            BasicScriptData data(this);
            ScriptEvent scriptEvent(kMenuClickedEvent,&data);
            ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
        }
    }
}
void MenuItem::activate()
{
    if (_enabled)
    {
        if( _callback )
        {
            _callback(this);
        }
#if CC_ENABLE_SCRIPT_BINDING
        if (kScriptTypeLua == _scriptType)
        {
            BasicScriptData data(this);
            ScriptEvent scriptEvent(kMenuClickedEvent, &data);
            ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
        }
#endif
    }
}
Example #16
0
void Node::cleanup()
{
    // actions
    this->stopAllActions();
    this->unscheduleAllSelectors();
    
    if ( _scriptType != kScriptTypeNone)
    {
        int action = kNodeOnCleanup;
        BasicScriptData data(this,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
    }
    
    // timers
    for( const auto &child: _children)
        child->cleanup();
}
Example #17
0
static bool sendNodeEventToJS(Node* node, int action)
{
    auto scriptEngine = ScriptEngineManager::getInstance()->getScriptEngine();

    if (scriptEngine->isCalledFromScript())
    {
        scriptEngine->setCalledFromScript(false);
    }
    else
    {
        BasicScriptData data(node,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        if (scriptEngine->sendEvent(&scriptEvent))
            return true;
    }
    
    return false;
}
Example #18
0
bool ScriptEngineManager::sendNodeEventToJS(Node* node, int action)
{
    auto scriptEngine = getInstance()->getScriptEngine();
    
    if (scriptEngine->isCalledFromScript())
    {
        // Should only be invoked at root class Node
        scriptEngine->setCalledFromScript(false);
    }
    else
    {
        BasicScriptData data(node,(void*)&action);
        ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
        if (scriptEngine->sendEvent(&scriptEvent))
            return true;
    }
    
    return false;
}
Example #19
0
//------------------------------------------------------------------------
IMPLEMENT_RMI(CGameRules, ClTaggedEntity)
{
	if (!params.entityId)
		return true;

	//SAFE_HUD_FUNC(GetRadar()->AddTaggedEntity(params.entityId)); //we have no tagging anymore, just temp and non-temp adding
	SAFE_HUD_FUNC(GetRadar()->AddEntityToRadar(params.entityId));

	SEntityEvent scriptEvent( ENTITY_EVENT_SCRIPT_EVENT );
	scriptEvent.nParam[0] = (INT_PTR)"OnGPSTagged";
	scriptEvent.nParam[1] = IEntityClass::EVT_BOOL;
	bool bValue = true;
	scriptEvent.nParam[2] = (INT_PTR)&bValue;

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(params.entityId);
	if (pEntity)
		pEntity->SendEvent( scriptEvent );

	return true;
}
Example #20
0
void BarWidget::setRange(double min, double max)
{
    m_bar->setScale(min, max);

    emit scriptEvent(getTitle() + "_rangeChanged");
}
Example #21
0
void BarWidget::setAlarmLevel(double val)
{
    m_bar->setAlarmLevel(val);

    emit scriptEvent(getTitle() + "_alarmLevelChanged");
}