//--------------------------------------------------------------------------- void TfrmMain::apply(::Move& move) { TStringsEnumerator *e = move.getEffects()->GetEnumerator(); while(e->MoveNext()) { if(e->Current[1] == '!') { Memo5->Lines->Delete(Memo5->Lines->IndexOf(e->Current.SubString(2,e->Current.Length())) ); } else //add something { Memo5->Lines->Add(e->Current); } } TStringList *tmpState = new TStringList(); TStringsEnumerator *eM = Memo5->Lines->GetEnumerator(); while(eM->MoveNext()) { tmpState->Add(eM->Current); } Memo5->Clear(); tmpState->Sort(); Memo5->Lines->AddStrings(tmpState); tmpState->Free(); eM->Free(); }
::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; }
//--------------------------------------------------------------------------- void __fastcall TFormMain::ExportCFileClick(TObject *Sender) { if (ExportDialog->Execute()) { TStringList* SL = new TStringList; __try { ChangeFileExt(ExtractFileName(ExportDialog->FileName), ""); SL->Add(Format("YETI_ROM rom_map_t %s = {", ARRAYOFCONST(( ChangeFileExt(ExtractFileName(ExportDialog->FileName), ""))))); SL->Add(Format("\"%s\",\"%s\",\"%s\",{", ARRAYOFCONST(( "Test Map", "Derek J. Evans", "Welcome to Yeti3D")))); for (int y = 0; y < YETI_MAP_HEIGHT; y++) { SL->Add("{"); for (int x = 0; x < YETI_MAP_WIDTH; x++) { cell_t* cell = &yeti->cells[y][x]; SL->Add(Format("{%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d},", ARRAYOFCONST(( cell->swi, cell->ent, cell->top, cell->mid, cell->bot, cell->lit, cell->wtx, cell->ttx, cell->mtx, cell->btx, 0, // Reserved 1 0 // Reserved 2 )))); } String S = SL->Strings[SL->Count - 1]; SL->Strings[SL->Count - 1] = S.SubString(1, S.Length() - 1); SL->Add("},"); } String S = SL->Strings[SL->Count - 1]; SL->Strings[SL->Count - 1] = S.SubString(1, S.Length() - 1); SL->Add("}};"); SL->SaveToFile(ExportDialog->FileName); } __finally { SL->Free(); } }
void __fastcall TForm1::StringToRegion(String AString, String &Guid,int &Major, int &Minor) { AString = StringReplace(AString,";"," ", TReplaceFlags() << rfReplaceAll); TStringList *LSplitted; LSplitted = new TStringList; try { LSplitted->DelimitedText = AString; Guid = LSplitted->Strings[0]; Major = StrToInt(LSplitted->Strings[1]); Minor = StrToInt(LSplitted->Strings[2]); } __finally { LSplitted->Free(); } };