void TCreateProjectDatabase::SetDatabaseVersion( String versionString )
{
	int point = versionString.Pos( "." );
	if( point == 0 )
	{
		dbMajorVersion = versionString;
		dbMinorVersion = 0;
	}
	else
	{	dbMajorVersion = versionString.SubString( 1, point - 1 );
		dbMinorVersion = versionString.SubString( point + 1, 2 );
	}
}
Example #2
0
String TForm3::Format(String s)
{
if (s.Trim()=="") {return s;}
int length=LE->Text.Length();
//1 произвести замены
bool replace=false;
for (int i=1; i<SG->RowCount-1&&!replace; i++)
	{
	String r=Replace(s,SG->Cells[0][i],SG->Cells[1][i]);
	if (s!=r)
		{
		replace=true;
		s=r;
		}
	}
if (replace)
	{
	s=Replace(s,".","");
	s=Replace(s,"-","");
	s=Replace(s,",","");
	s=Replace(s,":","");

		//2 форматировать как на образце
		int k=0;
		for (int i=1; i<=length; i++)
			{
			if (LE->Text.SubString(i,1)!="_")
				{
				s.Insert(LE->Text.SubString(i,1),i+k);
				//k++;
				}
			}
	}
return s.SubString(1,length);
}
Example #3
0
void __fastcall TForm1::FileOpen1Accept(TObject *Sender)
{
String a = FileOpen1->Dialog->FileName;
if (a!=""){
// Öffnen
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *Liste = new TStringList();
Liste->LoadFromFile(a);

Max = StrToInt(Liste->Strings[0]);
Edit1->Text=Liste->Strings[1];
ListBox1->Clear();
Liste->Delete(0);
Liste->Delete(0);
for (int i=0;i<Max;i++){
ListBox1->Items->Add(Liste->Strings[i*67]);

for (int b=0;b<66;b++){
Data[i][b] = StrToInt(Liste->Strings[i*67 + b + 1]);
}
}
ListBox1->ItemIndex=0;
Selected = ListBox1->ItemIndex;
Load_Dat(Selected);
}
}
Example #4
0
	Ptr<Mesh> Mesh::AssimpLoader::Load(const String& path)
	{
		auto exceptionManager = ExceptionManager::GetInstance();
		this->path = &path;
		this->dir = path.SubString(0, path.LastIndexOf(TEXT('/')));

		Assimp::Importer importer;
		const aiScene* aiscene = importer.ReadFile(path.ToStdString(),
			aiProcess_MakeLeftHanded | aiProcess_Triangulate | aiProcess_CalcTangentSpace
			| aiProcess_GenNormals | aiProcess_ValidateDataStructure | aiProcess_ImproveCacheLocality
			| aiProcess_RemoveRedundantMaterials | aiProcess_FindDegenerates | aiProcess_SortByPType
			| aiProcess_FindInvalidData | aiProcess_GenUVCoords | aiProcess_TransformUVCoords
			| aiProcess_OptimizeMeshes | aiProcess_FixInfacingNormals
			| aiProcess_JoinIdenticalVertices | aiProcess_PreTransformVertices);
		if (aiscene == nullptr)
		{
			exceptionManager->PushException(Ptr<Exception>::New(aiGetErrorString()));
			return nullptr;
		}

		Ptr<Mesh> mesh = this->LoadAssimpNode(aiscene->mRootNode, aiscene);
		if (mesh == nullptr)
			return nullptr;
		mesh->filePath = path;
		return mesh;
	}
void SocketTest::httpClientTest() {
	Connector connector(GetConfig()["HTTPReplyHost"]["ip"].AsString(), GetConfig()["HTTPReplyHost"]["port"].AsLong());
	Socket *socket = connector.MakeSocket(); //lint !e578

	assertEqual( GetConfig()["HTTPReplyHost"]["ip"].AsString(), connector.GetAddress());
	assertEqual( GetConfig()["HTTPReplyHost"]["port"].AsLong(), connector.fPort);
	assertEqual( (long)NULL, (long)connector.fSocket);

	if (t_assertm( socket != NULL, (const char *)connector.GetAddress() )) { // fails without HTTP Server
		long socketfd = socket->GetFd();
		t_assert( socketfd > 0L);

		// this one sets the connect timeout
		socket->SetTimeout(GetConfig()["GetStreamTimeout"].AsLong(5000L));
		std::iostream *Ios = socket->GetStream();
		t_assert( Ios != NULL);
		if (Ios) {
			String query("GET / HTTP/1.0");
			String reply;
			long lRetCode;
			if (t_assertm(socket->IsReadyForWriting(GetConfig()["ReadyForWritingTimeout"].AsLong(5000L), lRetCode), TString("expected no timeout for sending http request to [") << connector.GetAddress() << ':' << connector.fPort << "]")
					&& t_assert(lRetCode > 0)) {
				(*Ios) << query << std::endl << std::endl;
				t_assert(!!(*Ios));
				// make sure Ios is valid
				if (t_assertm(socket->IsReadyForReading(GetConfig()["ReadyForReadingTimeout"].AsLong(5000L), lRetCode), TString("expected no timeout for reading HTTP reply [") << connector.GetAddress() << ':' << connector.fPort << "]")
						&& t_assert(lRetCode > 0)) {
					(*Ios) >> reply;
					assertEqual( "HTTP", reply.SubString(0, 4));
					// test first line of reply by http server
					t_assert(!!(*Ios));
				}
			}
Example #6
0
::Move Parser::getMove(String move)
{
	TStringList *tmpArgs = new TStringList();
	tmpArgs->Delimiter = ',';
	tmpArgs->DelimitedText = move.SubString(move.Pos("(")+1,move.Pos(")")-move.Pos("(") - 1);
	::Move tmpMove(tmpArgs->Strings[0],tmpArgs->Strings[1],tmpArgs->Strings[2]);
	tmpArgs->Free();

	return tmpMove;
}
Example #7
0
//---------------------------------------------------------------------------
void __fastcall TSplashForm::FormCreate(TObject *Sender)
{
    if(!InterfaceModule->SkinManager->Active)
        Panel->BevelKind = bkFlat;

    StrID->Caption = DCMAP_VERSION_FAMILY;

    String ver = DCMAP_VERSION;
    int rev = StrToInt(ver.SubString(ver.Length()-2,3));
    if(rev)
    {
        RevisionLabel->Caption = "revision "+IntToStr(rev);
    }
    else RevisionLabel->Caption = "";
}
Example #8
0
void __fastcall TForm1::FileSaveAs1Accept(TObject *Sender)
{
String a = FileSaveAs1->Dialog->FileName;
if (a!=""){
// Speichern
if (ExtractFileExt(a).UpperCase()!=".AD")a=a.SubString(1,a.Length()-ExtractFileExt(a).Length())+".ad";
TStringList *List = new TStringList();
List->Add(IntToStr(Max));
List->Add(Edit1->Text);
for (int i=0;i<Max;i++){
List->Add(ListBox1->Items->Strings[i]);
for (int b=0;b<66;b++){
List->Add(IntToStr(Data[i][b]));
}
}
List->SaveToFile(a);
}
}
Example #9
0
	bool MetaLexer::Parse(String str, LexStream & stream)
	{
		TokensParsed = 0;
		if (!dfa)
			return false;
		int ptr = 0;
		int lastAcceptState = -1;
		int lastAcceptPtr = -1;
		int lastTokenPtr = 0;
		int state = dfa->StartState;
		while (ptr<str.Length())
		{
			if (dfa->Tags[state]->IsFinal)
			{
				lastAcceptState = state;
				lastAcceptPtr = ptr;
			}
			Word charClass = (*dfa->CharTable)[str[ptr]];
			if (charClass == 0xFFFF)
			{
				LexerError err;
				err.Text = String(L"Illegal character \'") + str[ptr] + L"\'";
				err.Position = ptr;
				Errors.Add(err);
				ptr++;
				continue;
			}
			int nextState = dfa->DFA[state][charClass];
			if (nextState >= 0)
			{
				state = nextState;
				ptr++;
			}
			else
			{
				if (lastAcceptState != -1)
				{
					state = lastAcceptState;
					ptr = lastAcceptPtr;
					if (!Ignore[dfa->Tags[state]->TerminalIdentifiers[0]])
					{
						LexToken tk;
						tk.Str = str.SubString(lastTokenPtr, ptr-lastTokenPtr);
						tk.TypeID = dfa->Tags[state]->TerminalIdentifiers[0];
						tk.Position = lastTokenPtr;
						stream.AddLast(tk);
					}
					TokensParsed ++;
					lastTokenPtr = ptr;
					state = dfa->StartState;
					lastAcceptState = -1;
					lastAcceptPtr = -1;
				}
				else
				{
					LexerError err;
					err.Text = L"Illegal token \'" +
						str.SubString(lastTokenPtr, ptr-lastTokenPtr) + L"\'";
					err.Position = ptr;
					Errors.Add(err);
					ptr++;
					lastAcceptState = lastAcceptPtr = -1;
					lastTokenPtr = ptr;
					state = dfa->StartState;
					continue;
				}
			}
		}

		if (dfa->Tags[state]->IsFinal &&
			!Ignore[dfa->Tags[state]->TerminalIdentifiers[0]])
		{
			LexToken tk;
			tk.Str = str.SubString(lastTokenPtr, ptr-lastTokenPtr);
			tk.TypeID = dfa->Tags[state]->TerminalIdentifiers[0];
			stream.AddLast(tk);
			TokensParsed ++;
		}
		return (Errors.Count() == 0);
	}
void WillowGame::DrawHUD()
{
	// Time

	int minutes = (int) m_Time / 60;
	int seconds = (int) m_Time % 60;

	int digit1(0), digit2(0);

	String stringSeconds;
	stringSeconds = String("") + seconds;
	if(stringSeconds.GetLength() > 1)
	{
		digit1 = stringSeconds.SubString(0,1).ToInteger();
		digit2 = stringSeconds.SubString(1).ToInteger();
	}
	else
	{
		digit2 = stringSeconds.ToInteger();
	}

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateIdentityMatrix());
	//GAME_ENGINE->DrawString(String("") + minutes + " " + seconds,250,100);

	RECT clipGoldTime;
	clipGoldTime.left = m_BmpGoldTimePtr->GetWidth()/2;
	clipGoldTime.right = m_BmpGoldTimePtr->GetWidth();
	clipGoldTime.top = 0;
	clipGoldTime.bottom = m_BmpGoldTimePtr->GetHeight();

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-100,12));
	GAME_ENGINE->DrawBitmap(m_BmpGoldTimePtr,0,0,clipGoldTime);

	clipGoldTime.left = 0;
	clipGoldTime.right = m_BmpGoldTimePtr->GetWidth()/2;

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-240,12));
	GAME_ENGINE->DrawBitmap(m_BmpGoldTimePtr,0,0,clipGoldTime);

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(10,12));
	GAME_ENGINE->DrawBitmap(m_BmpVitalPtr,0,0);

	int startclip(0);
	int width = m_BmpNumbersPtr->GetWidth()/11;
	int height = m_BmpNumbersPtr->GetHeight()/2;

	switch(minutes)
	{
	case 3:
		startclip = 4;
		break;
	case 2:
		startclip = 3;
		break;
	case 1:
		startclip = 2;
		break;
	case 0:
		startclip = 1;
		break;
	}

	RECT clipminutes;
	clipminutes.left = width * startclip;
	clipminutes.right = clipminutes.left + width;
	clipminutes.top = 0;
	clipminutes.bottom = height;

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-60,12));
	GAME_ENGINE->DrawBitmap(m_BmpNumbersPtr,0,0,clipminutes);

	RECT colon;
	colon.left = 0;
	colon.right = width;
	colon.top = 0;
	colon.bottom = height;

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-60 + width,12));
	GAME_ENGINE->DrawBitmap(m_BmpNumbersPtr,0,0,colon);

	RECT clipdigit1;
	clipdigit1.left = (digit1 + 1) * width;
	clipdigit1.right = clipdigit1.left + width;
	clipdigit1.top = 0;
	clipdigit1.bottom = height;

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-60 + width*2,12));
	GAME_ENGINE->DrawBitmap(m_BmpNumbersPtr,0,0,clipdigit1);

	RECT clipdigit2;
	clipdigit2.left = (digit2 + 1) * width;
	clipdigit2.right = clipdigit2.left + width;
	clipdigit2.top = 0;
	clipdigit2.bottom = height;

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-60 + width*3,12));
	GAME_ENGINE->DrawBitmap(m_BmpNumbersPtr,0,0,clipdigit2);

	// Gold

	String money = String("") + m_MoneyCount;

	for(int i = 0; i < money.GetLength(); ++i)
	{
		int digitgold = money.SubString(i,1).ToInteger();

		RECT clipgold;
		clipgold.left = (digitgold + 1) * width;
		clipgold.right = clipgold.left + width;
		clipgold.top = height;
		clipgold.bottom = clipgold.top + height;

		GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(GAME_ENGINE->GetWidth()-165 + width*i,12));
		GAME_ENGINE->DrawBitmap(m_BmpNumbersPtr,0,0,clipgold);
	}

	// bottom HUD

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateTranslationMatrix(0,GAME_ENGINE->GetHeight()-16));
	GAME_ENGINE->DrawBitmap(m_BmpBottombarPtr,0,0);

	GAME_ENGINE->SetTransformMatrix(MATRIX3X2::CreateIdentityMatrix());
	int middlebar = GAME_ENGINE->GetHeight()-m_BmpBottombarPtr->GetHeight()/2 - 1;
	int firepower = m_WillowPtr->GetFirePower();
	if(firepower >= 100) firepower = 100;
	GAME_ENGINE->FillRect(12,middlebar,10 + firepower * 1.5,middlebar + 2);
}