Beispiel #1
0
void vToken::Compress( char *p )
{
	vString buf;

	for ( int i=0;i<m_in.GetLength();i++)
	{
	  BOOL b= FALSE;
	  for ( int j=0;j<strlen(p);j++)
	    if (p[j]==m_in[i]) { b= TRUE; break;}

	  if ( b==FALSE ) buf = buf+vString(m_in[i]);
	}
	m_in	= buf;
}
Beispiel #2
0
void Game::GameScene::Init(){

	// スクリーンの設定
	{
		ANAS::Screen::Adjust( 0, 0, ANAS::SO_DEFAULT );
		ANAS::Screen::ApplyToViewPort( pContainer->pGraphic );
		ANAS::Screen::ApplyToTouchScreen( pContainer->pInput );
	}

	// シェーダーの読み込み
	ANAS::ResourceHolder *pHolder = pResource->Get("SimpleShader");
	if( pHolder == NULL )
	{
		ANAS::Log::i("Scene Init", "Create Shader");

		ANAS::AssetData vString( pContainer->pActivity->assetManager );
		vString.Load( "simple2d.vsh" );
				
		ANAS::AssetData fString( pContainer->pActivity->assetManager );
		fString.Load( "simple2d.fsh" );

		pSimple2D = new Simple2D( vString.GetData(), fString.GetData() );
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::bind( &ANAS::ShaderBase::Init, pSimple2D)) );

		// リソースマネージャへ登録
		pResource->Set( "SimpleShader", new ANAS::ResourceItem<Simple2D>(pSimple2D) );

	} else {
		ANAS::Log::i("Scene Init", "Get Exist Shader");

		// ホルダーから取得
		pSimple2D = ((ANAS::ResourceItem<Simple2D>*)pHolder)->Get();
	}


	// スプライトの初期化
	{

		// Tile
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mTileSprite, pSimple2D) )) );
		mTileSprite.Scale[0] = TileSize;
		mTileSprite.Scale[1] = TileSize;

		// Bomb
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mBombSprite, pSimple2D) )) );
		mBombSprite.Scale[0] = TileSize;
		mBombSprite.Scale[1] = TileSize;

		// Shadow
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mShadowSprite, pSimple2D) )) );
		mShadowSprite.Scale[0] = TileSize*2;
		mShadowSprite.Scale[1] = TileSize*2;

		// BombLine
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mBombLineSprite, pSimple2D) )) );
		mBombLineSprite.Scale[0] = 256;
		mBombLineSprite.Scale[1] = 256;

		// Enemy
		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mEnemySprite, pSimple2D) )) );
		mEnemySprite.Scale[0] = Enemy::ImageSize;
		mEnemySprite.Scale[1] = Enemy::ImageSize;
	}
	
	// テクスチャの初期化
	{
				
		// Tile
		ANAS::AssetData aTile( pContainer->pActivity->assetManager );
		aTile.Load( "tile.png" );
		mTileImage.Load<ANAS::IFT_PNG>( aTile.GetData() );

		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mTileTexture, mTileImage.Get(), 2,2) )) );
		mTileTexture.SetFilter(GL_NEAREST, GL_NEAREST);

		// Bomb
		ANAS::AssetData aBomb( pContainer->pActivity->assetManager );
		aBomb.Load( "bomb.png" );
		mBombImage.Load<ANAS::IFT_PNG>( aBomb.GetData() );

		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mBombTexture, mBombImage.Get(), 128, 128) )) );

		// Shadow
		ANAS::AssetData aShadow( pContainer->pActivity->assetManager );
		aShadow.Load( "shadow.png" );
		mShadowImage.Load<ANAS::IFT_PNG>( aShadow.GetData() );

		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mShadowTexture, mShadowImage.Get(), 16, 16) )) );

		// BombLine
		ANAS::AssetData aBombLine( pContainer->pActivity->assetManager );
		aBombLine.Load( "line.png" );
		mBombLineImage.Load<ANAS::IFT_PNG>( aBombLine.GetData() );

		pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mBombLineTexture, mBombLineImage.Get(), 256, 256) )) );


		for(int i=0; i<1; i++){
			ANAS::AssetData aEnemy( pContainer->pActivity->assetManager );
			aEnemy.Load( Enemy::ImageName[i] );

			mEnemyImage[i].Load<ANAS::IFT_PNG>( aEnemy.GetData() );

			pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mEnemyTexture[i], mEnemyImage[i].Get(), 256, 256) )) );
		}
	}



	
	/*
	ANAS::Sound *pSound = new ANAS::Sound();
	ANAS::AssetData TestSound( pContainer->pActivity->assetManager );
	int dst[3];
	TestSound.GetFileDescriptor( "data.mp3", &dst[0], &dst[1], &dst[2] );

	ANAS::Log::i( "ASSET",(boost::format("%1%:%2%:%3%")%dst[0]%dst[1]%dst[2]).str().c_str() );

	pSound->Load( dst[0], dst[1], dst[2] );
	*/

	AttackIntervalCounter = AttackInterval;

	// set flag initialized.
	SetInitialized();
}
Beispiel #3
0
void wxAnyTestCase::wxVariantConversions()
{
#if wxUSE_VARIANT
    //
    // Test various conversions to and from wxVariant
    //
    bool res;

    // Prepare wxVariants
    wxVariant vLong(123L);
    wxVariant vString("ABC");
    wxVariant vDouble(TEST_FLOAT_CONST);
    wxVariant vBool((bool)true);
    wxVariant vChar('A');
#ifdef wxLongLong_t
    wxVariant vLongLong(wxLongLong(wxLL(0xAABBBBCCCC)));
    wxVariant vULongLong(wxULongLong(wxULL(123456)));
#endif
    wxArrayString arrstr;
    arrstr.push_back("test string");
    wxVariant vArrayString(arrstr);
    wxVariant vDateTime(m_testDateTime);
    wxVariant vVoidPtr(dummyVoidPointer);
    wxVariant vCustomType(new wxMyVariantData(MyClass(101)));
    wxVariant vList;

    vList.NullList();
    vList.Append(15);
    vList.Append("abc");

    // Convert to wxAnys, and then back to wxVariants
    wxVariant variant;

    wxAny any(vLong);
    CPPUNIT_ASSERT(any == 123L);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant == 123L);

    // Make sure integer variant has correct type information
    CPPUNIT_ASSERT(variant.GetLong() == 123);
    CPPUNIT_ASSERT(variant.GetType() == "long");

    // Unsigned long wxAny should convert to "ulonglong" wxVariant
    any = 1000UL;
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
    CPPUNIT_ASSERT(variant.GetLong() == 1000);

    any = vString;
    CPPUNIT_ASSERT(any == "ABC");
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetString() == "ABC");

    // Must be able to build string wxVariant from wxAny built from
    // string literal
    any = "ABC";
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "string");
    CPPUNIT_ASSERT(variant.GetString() == "ABC");
    any = L"ABC";
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "string");
#if wxUSE_UNICODE
    CPPUNIT_ASSERT(variant.GetString() == L"ABC");
#endif

    any = vDouble;
    double d = wxANY_AS(any, double);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(variant.GetDouble(),
                                 TEST_FLOAT_CONST,
                                 FEQ_DELTA);

    any = vBool;
    CPPUNIT_ASSERT(wxANY_AS(any, bool) == true);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetBool() == true);

    any = wxAny(vChar);
    //CPPUNIT_ASSERT(wxANY_AS(any, wxUniChar) == 'A');
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetChar() == 'A');

#ifdef wxLongLong_t
    any = wxAny(vLongLong);
    CPPUNIT_ASSERT(any == wxLL(0xAABBBBCCCC));
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "longlong");
    CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xAABBBBCCCC)));

#if LONG_MAX == wxINT64_MAX
    // As a sanity check, test that wxVariant of type 'long' converts
    // seamlessly to 'longlong' (on some 64-bit systems)
    any = 0xAABBBBCCCCL;
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xAABBBBCCCC)));
#endif

    any = wxAny(vULongLong);
    CPPUNIT_ASSERT(any == wxLL(123456));
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
    CPPUNIT_ASSERT(variant.GetULongLong() == wxULongLong(wxULL(123456)));
#endif

    // Cannot test equality for the rest, just test that they convert
    // back correctly.
    any = wxAny(vArrayString);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    wxArrayString arrstr2 = variant.GetArrayString();
    CPPUNIT_ASSERT(arrstr2 == arrstr);

    any = m_testDateTime;
    CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
    any = wxAny(vDateTime);
    CPPUNIT_ASSERT(wxANY_AS(any, wxDateTime) == m_testDateTime);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant == m_testDateTime);

    any = wxAny(vVoidPtr);
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetVoidPtr() == dummyVoidPointer);

    any = wxAny(vList);
    CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxAnyList));
    wxAnyList anyList = wxANY_AS(any, wxAnyList);
    CPPUNIT_ASSERT(anyList.GetCount() == 2);
    CPPUNIT_ASSERT(wxANY_AS((*anyList[0]), int) == 15);
    CPPUNIT_ASSERT(wxANY_AS((*anyList[1]), wxString) == "abc");
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "list");
    CPPUNIT_ASSERT(variant.GetCount() == 2);
    CPPUNIT_ASSERT(variant[0].GetLong() == 15);
    CPPUNIT_ASSERT(variant[1].GetString() == "abc");

    any = wxAny(vCustomType);
    CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxVariantData*));
    res = any.GetAs(&variant);
    CPPUNIT_ASSERT(res);
    CPPUNIT_ASSERT(variant.GetType() == "MyClass");

#endif // wxUSE_VARIANT
}
Beispiel #4
0
void vToken::Load(char *psz)
{
  vToken::Load(vString(psz));
}
Beispiel #5
0
// "<babo>" --> don't find <> in string.
void vToken::FindNP(char *sep,char strbracket)
{
#ifndef VTFIX
	for (int i=0;i<m_arg.GetSize();i++)
        m_arg[i].Close();
	m_arg.RemoveAll();	
#endif
	nMaxArg	= 0;

	char *p	= (char*)m_in.GetBuffer();
	char *ret = p;
	int max=0;
	if (p)	max= strlen(p);
	else	return;

	int ni	= 0;
	int ne	= 0;

	BOOL bString = FALSE;

	while(*p!=0 )
	{	
		// find first '('
		//while( *p!=0 && *p!=sep[0] )
		while( *p!=0  )
		{
			if ( bString==FALSE)
			if (*p==sep[0])	break;
			if ( *p==strbracket)	bString =!bString;
			p++,ni++;
		}
		if ( ni>=max )	
		{
			if ( *ret!=0)	Add(vString(ret));
			return;
		}
		
		// non p
		if ( ni>0 && ne+1!=ni)	
		{
			*p	= 0;
			if ( *ret!=0)
			{
				Add(vString(ret));
				p++;
				ret	= p;
			}
		}
		else	ret	= p+1;

		// find second ')'
		ni++;
		//while( *p!=0 && *p!=sep[1])		p++,ni++;
		while( *p!=0  )
		{
			if ( bString==FALSE)
			if (*p==sep[1])	break;
			if ( *p==strbracket)	bString =!bString;
			p++,ni++;
		}
		*p	= 0;
		ne	= ni;

		Add( vString(sep)+vString(ret));
		ni++;
		p++;
		ret	= p;
	}
}
Beispiel #6
0
vToken::vToken( char *s )
{
	RemoveAll();
	m_in	= vString(s);
}
Beispiel #7
0
void vToken::SetSeparatorString( char *sep ,char bStrBracket)
{
#ifndef VTFIX
	for (int i=0;i<m_arg.GetSize();i++)
		m_arg[i].Close();
	m_arg.RemoveAll();	
#endif
	nMaxArg = 0;

	// add string bracket.
	char *pSep	= new char [strlen(sep)+1+1];
	strcpy(pSep,sep);
	pSep[strlen(pSep)] = bStrBracket;

	// separate tokens.
	char *p	= (char*)m_in.GetBuffer();
	if (p==NULL)	return;

	char *ret;
	int max = strlen(p);
	int ni	= 0;

	// copy
	char *pcopy	= new char[max+1];
	strcpy(pcopy,p);
	pcopy[max]	= 0;

	while(*p!=0 )
	{	
		ret	= strtok(p,pSep);

		if ( *p==bStrBracket)
		{
                        memmove(p,&pcopy[ni],max-ni);
                        int i;
                        for (i=ni+1;i<max;i++)
			if ( pcopy[i]==bStrBracket)
			{
				break;
			}
			
                        char *ptemp = new char[i-ni+2];
			memmove(ptemp,p,i-ni+1);
			ptemp[i-ni+1] = 0;
			Add(vString(ptemp));
                        delete ptemp;

			p+=i-ni+1;
			ni+=i-ni+1;
			continue;
		}

		if ( ret==NULL )	break;		

		Add(vString(ret));
				
		ni+=strlen(p);
		p+=strlen(p);
		
		p++;
		ni++;

		if ( ni>=max )	break;
	}

	if ( pSep)	delete pSep;
	if (pcopy)	delete pcopy;
}
Beispiel #8
0
void vToken::SetSeparator( char *sep ,char *pOP,BOOL bEmpty)
{
#ifndef VTFIX
	for (int i=0;i<m_arg.GetSize();i++)
		m_arg[i].Close();
	m_arg.RemoveAll();	
#endif
	nMaxArg = 0;

	// separate tokens.
	char *p	= (char*)m_in.GetBuffer();
	char *ret;
	int max = strlen(p);
	int ni	= 0;

	// copy
	char *pcopy	= new char[max+1];
	strcpy(pcopy,p);
	pcopy[max]	= 0;

	// synth
	char newsep[100];
	strcpy(newsep,sep);
	strcat(newsep,pOP);

	/*
	// find former part. ex) when " (1+2)", ( cannot be neglected!.
	ret	= strtok(p,newsep);
	if ( strlen(ret)!=strlen(p))
	{
		ret	= strtok(p,sep);
		for ( int i=0;i<strlen(ret);i++)
		for ( int j=0;j<strlen(pOP);j++)
			if ( ret[i]==pOP[j]	)	Add(pOP[j]);
	}
	strcpy(p,pcopy);	
	*/

	// general separating routine
	while(*p!=0 )
	{	
		ret	= strtok(p,newsep);
		if ( ret==NULL)
		{			
			for ( int i=0;i<strlen(p);i++)
			for ( int j=0;j<strlen(pOP);j++)
				if ( p[i]==pOP[j]	)	
					Add(vString(pOP[j]));
			break;
		}
		
		char *p2 = p;
		while( strlen(ret)!=strlen(p2))
		{
			for ( int j=0;j<strlen(pOP);j++)
			if ( *p2==pOP[j]	)	
				Add(vString(pOP[j]));
			p2++;
		}
		strcpy(p,&pcopy[ni]);	
		
		ret	= strtok(p,newsep);
		Add(vString(ret));

		int n	= ni+strlen(p);
		for ( int i=0;i<strlen(pOP);i++)
		if ( pcopy[n]==pOP[i] )	
		{
			Add(vString(pOP[i]));
			break;
		}
		
		ni+=strlen(p);
		p+=strlen(p);
		
		p++;
		ni++;

		if ( ni>=max )	break;
	}

	delete pcopy;

	if ( bEmpty)
	for (int i=0;i<GetSize();i++)
	{
		CString tmp = m_arg[i];

		BOOL bSep = FALSE;
		int j;
		for ( j=0;j<strlen(pOP);j++)
		if ( tmp==pOP[j])
		{
			bSep = TRUE;
			break;
		}

		if ( bSep)
		{
			CString tmp2;
			if ( i+1<GetSize())	tmp2 = m_arg[i+1];

			if ( tmp2.IsEmpty())	
			{
				Add("");
				return;
			}
			else
			{
				for ( j=0;j<strlen(pOP);j++)
				if ( tmp2==pOP[j])
				{
					InsertAt("",i+1);
					i++;
					break;
				}	
			}
		}
	}
}