当前位置: 首页>>代码示例>>C++>>正文


C++ IUIElement::CallFunction方法代码示例

本文整理汇总了C++中IUIElement::CallFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ IUIElement::CallFunction方法的具体用法?C++ IUIElement::CallFunction怎么用?C++ IUIElement::CallFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUIElement的用法示例。


在下文中一共展示了IUIElement::CallFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CallFunction

//------------------------------------------------------------------------
int CScriptBind_UIAction::CallFunction( IFunctionHandler *pH, const char * elementName, int instanceID, const char* functionName )
{
	SUIArguments args;
	if (!SUIToLuaConversationHelper::LuaArgsToUIArgs(pH, 4, args))
	{
		UIACTION_WARNING( "LUA: Failed to call function %s on element %s: Invalid arguments", functionName, elementName );
		return pH->EndFunction(false);
	}

	IUIElement* pElement = GetElement( elementName, instanceID, true );
	if ( pElement )
	{
		const SUIEventDesc* pFctDesc = pElement->GetFunctionDesc( functionName );
		if ( pFctDesc )
		{
			TUIData res;
			bool bFctOk = true;
			if ( instanceID < 0 )
			{
				IUIElementIteratorPtr elements = pElement->GetInstances();
				while ( IUIElement* pInstance = elements->Next() )
					bFctOk &= pInstance->CallFunction( pFctDesc, args, &res);
			}
			else
			{
				bFctOk = pElement->CallFunction( pFctDesc, args, &res);
			}
			if ( bFctOk )
			{
				string sRes;
				res.GetValueWithConversion( sRes );
				return pH->EndFunction( sRes.c_str() );
			}
		}
		UIACTION_WARNING( "LUA: UIElement %s does not have function %s", elementName, functionName );
	}
	else if (IUIEventSystem* pEventSystem = GetEventSystem( elementName, IUIEventSystem::eEST_UI_TO_SYSTEM ))
	{
		uint eventid = pEventSystem->GetEventId( functionName );
		if ( eventid != ~0 )
		{
			SUIArguments res = pEventSystem->SendEvent( SUIEvent( eventid, args ) );
			SmartScriptTable table = gEnv->pScriptSystem->CreateTable();
			SUIToLuaConversationHelper::UIArgsToLuaTable(res, table);		
			return pH->EndFunction( table );
		}
		UIACTION_WARNING( "LUA: UIEventSystem %s does not have event %s", elementName, functionName );
	}
	else
	{
		UIACTION_WARNING( "LUA: UIElement or UIEventSystem %s does not exist", elementName );
	}
	return pH->EndFunction(false);
}
开发者ID:aronarts,项目名称:FireNET,代码行数:55,代码来源:ScriptBind_UIAction.cpp

示例2: ProcessEvent


//.........这里部分代码省略.........


                                // calculate ray dir
                                CCamera cam = gEnv->pRenderer->GetCamera();
                                if (pEntity->GetSlotFlags(m_dynTexGeomSlot) & ENTITY_SLOT_RENDER_NEAREST)
                                {
                                    ICVar *r_drawnearfov = gEnv->pConsole->GetCVar("r_DrawNearFoV");
                                    assert(r_drawnearfov);
                                    cam.SetFrustum(cam.GetViewSurfaceX(),cam.GetViewSurfaceZ(),DEG2RAD(r_drawnearfov->GetFVal()),cam.GetNearPlane(),cam.GetFarPlane(), cam.GetPixelAspectRatio());
                                }

                                Vec3 vPos0 = rayPos;
                                Vec3 vPos1 = rayPos + rayDir;

                                // translate into object space
                                const Matrix34 m = pEntity->GetWorldTM().GetInverted();
                                vPos0 = m * vPos0;
                                vPos1 = m * vPos1;

                                // walk through all sub objects
                                const int objCount = pObj->GetSubObjectCount();
                                for (int obj = 0; obj <= objCount && !hasHit; ++obj)
                                {
                                    Vec3 vP0, vP1;
                                    IStatObj* pSubObj = NULL;

                                    if (obj == objCount)
                                    {
                                        vP0 = vPos0;
                                        vP1 = vPos1;
                                        pSubObj = pObj;
                                    }
                                    else
                                    {
                                        IStatObj::SSubObject* pSub = pObj->GetSubObject(obj);
                                        const Matrix34 mm = pSub->tm.GetInverted();
                                        vP0 = mm * vPos0;
                                        vP1 = mm * vPos1;
                                        pSubObj = pSub->pStatObj;
                                    }

                                    IRenderMesh* pMesh = pSubObj ? pSubObj->GetRenderMesh() : NULL;
                                    if (pMesh)
                                    {
                                        const Ray ray(vP0, (vP1-vP0).GetNormalized() * maxRayDist);
                                        hasHit = RayIntersectMesh(pMesh, pMaterial, pElement, ray, hitpos, p0, p1, p2, uv0, uv1, uv2);
                                    }
                                }

                                // skip if not hit
                                if (!hasHit)
                                {
                                    ActivateOutput(pActInfo, EOP_Failed, 1);
                                    return;
                                }

                                // calculate vectors from hitpos to vertices p0, p1 and p2:
                                const Vec3 v0 = p0-hitpos;
                                const Vec3 v1 = p1-hitpos;
                                const Vec3 v2 = p2-hitpos;

                                // calculate factors
                                const float h = (p0-p1).Cross(p0-p2).GetLength();
                                const float f0 = v1.Cross(v2).GetLength() / h;
                                const float f1 = v2.Cross(v0).GetLength() / h;
                                const float f2 = v0.Cross(v1).GetLength() / h;

                                // find the uv corresponding to hitpos
                                Vec3 uv = uv0 * f0 + uv1 * f1 + uv2 * f2;

                                // translate to flash space
                                int x, y, width, height;
                                float aspect;
                                pElement->GetFlashPlayer()->GetViewport(x, y, width, height, aspect);
                                int iX = int_round(uv.x * (float)width);
                                int iY = int_round(uv.y * (float)height);

                                // call the function provided if it is present in the UIElement description
                                string funcName = GetPortString(pActInfo, EIP_CallFunction);
                                const SUIEventDesc* eventDesc = pElement->GetFunctionDesc(funcName);
                                if(eventDesc)
                                {
                                    SUIArguments arg;
                                    arg.AddArgument(iX);
                                    arg.AddArgument(iY);
                                    pElement->CallFunction(eventDesc->sName, arg);
                                }

                                ActivateOutput(pActInfo, EOP_Success, 1);
                            }
                        }
                    }
                }

                ActivateOutput(pActInfo, EOP_Failed, 1);
            }

            break;
        }
    }
开发者ID:souxiaosou,项目名称:FireNET,代码行数:101,代码来源:FlashUIDisplayNodes.cpp


注:本文中的IUIElement::CallFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。