Example #1
0
//----------------------------------------------------------------//
void MOAIApp::NotifyDialogDismissed ( int dialogResult ) {

	if ( ! mDialogCallback.IsNil() ) {
		MOAILuaStateHandle state = mDialogCallback.GetSelf ();
		
		state.Push ( dialogResult );
		state.DebugCall ( 1, 0 );
		
		mDialogCallback.Clear();
	}
}
Example #2
0
//----------------------------------------------------------------//
cc8* MOAILuaObject::GetLuaClassName () {

	MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();
	cc8* classname = this->TypeName ();
	
	if ( this->mMemberTable ) {
		state.Push ( this );
		lua_getfield ( state, -1, "getClassName" );
		
		if ( state.IsType ( -1, LUA_TFUNCTION )) {
			lua_pushvalue ( state, -2 );
			state.DebugCall ( 1, 1 );
			classname = state.GetValue < cc8* >( -1, "" );
		}
	}
	return classname;
}
Example #3
0
//----------------------------------------------------------------//
static int _cpCollisionFunc ( cpArbiter* arb, void* data, u32 eventType, bool checkResult ) {

	MOAICpCollisionHandler* handler = ( MOAICpCollisionHandler* )data;
	if ( handler->mMask & eventType ) {

		// this can be called during shutdown, so make sure the runtime is still valid
		if ( MOAILuaRuntime::IsValid ()) {

			MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();
			if ( handler->mHandler.PushRef ( state )) {
				
				cpShape* a;
				cpShape* b;
				cpArbiterGetShapes ( arb, &a, &b );
				
				if ( a && b ) {
					
					state.Push ( eventType );
					(( MOAICpShape* )a->data )->PushLuaUserdata ( state );
					(( MOAICpShape* )b->data )->PushLuaUserdata ( state );
					
					MOAICpArbiter* arbiter = handler->mSpace->GetArbiter ();
					arbiter->SetArbiter ( arb );
					arbiter->PushLuaUserdata ( state );
					
					state.DebugCall ( 4, 1 );
					
					//lua_call ( state, 4, 1 );
					
					if ( checkResult ) {
						bool result = state.GetValue < bool >( -1, true );
						return result ? cpTrue : cpFalse;
					}
				}
			}
		}
	}
	return cpTrue;
}
Example #4
0
//----------------------------------------------------------------//
void MOAISerializer::WriteTableInits ( USStream& stream ) {

	if ( !this->mTableMap.size ()) return;

	stream.Print ( "\t--Initializing Tables\n" );
	stream.Print ( "\tlocal table\n\n" );

	MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();

	TableMapIt tableIt = this->mTableMap.begin ();
	for ( ; tableIt != this->mTableMap.end (); ++tableIt ) {
		
		uintptr tableID = tableIt->first;
		stream.Print ( "\ttable = objects [ 0x%08X ]\n", tableID );
		
		MOAILuaRef& tableRef = tableIt->second;
		state.Push ( tableRef );
		this->WriteTableInitializer ( stream, state, -1, "table" );
		state.Pop ( 1 );
		
		stream.Print ( "\n" );
	}
}