//--------------------------------------------------------------------------- #include #include "Common.h" #pragma hdrstop #include "Texture_F.h" #include "Exception.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_TEXTUREFORM StringTable[0] #define IDS_FOUNDATION StringTable[1] #define IDS_DERIVATION StringTable[2] #define IDS_SPECIALITY StringTable[3] #define IDS_PLAIN StringTable[4] #define IDS_TWILL StringTable[5] #define IDS_SATIN StringTable[6] #define IDS_SPECIALTEXTURE StringTable[7] //--------------------------------------------------------------------------- TTextureForm *TextureForm; //--------------------------------------------------------------------------- __fastcall TTextureForm::TTextureForm(TComponent* Owner) : TForm(Owner) { //=============================== 2001.6.19 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è Texture = NULL; Bitmap = NULL; StringTable.Create(DirectoryBin, Language, "Texture"); //================================ } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FormCreate(TObject *Sender) { //=============================== 2001.6.19 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- bool __fastcall TTextureForm::InitForm() { RGBQUAD rgb[2]; Texture = new TTexture; if (Texture->Create(DirectoryTexture) == false) return false; Bitmap = new Graphics::TBitmap; Bitmap->PixelFormat = pf8bit; Bitmap->Width = TextureGrid->DefaultColWidth; Bitmap->Height = TextureGrid->DefaultRowHeight-20; rgb[0].rgbRed = 255; rgb[0].rgbGreen = 255; rgb[0].rgbBlue = 255; rgb[1].rgbRed =0; rgb[1].rgbGreen = 0; rgb[1].rgbBlue = 0; SetDIBColorTable(Bitmap->Canvas->Handle, 0, 2, rgb); TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Main.ini"); if (IniFile) { Left = IniFile->ReadInteger("TextureTable", "FormLeft", 10); Top = IniFile->ReadInteger("TextureTable", "FormTop", 50); Width = IniFile->ReadInteger("TextureTable", "FormWidth", 700); Height = IniFile->ReadInteger("TextureTable", "FormHeight", 800); delete IniFile; } Item = 0; Index = 0; ptsItem = 0; //=================================== SetSmallFont(Font); Caption = IDS_TEXTUREFORM; sbFound->Caption = IDS_FOUNDATION; sbDerive->Caption = IDS_DERIVATION; sbSpecial->Caption = IDS_SPECIALITY; PlainText->Caption = IDS_PLAIN; TwillText->Caption = IDS_TWILL; SatinText->Caption = IDS_SATIN; //=================================== FoundListFill(); return true; } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FormDestroy(TObject *Sender) { TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Main.ini"); if (IniFile) { if (Left<0) Left = 10; if (Top<0) Top = 10; IniFile->WriteInteger("TextureTable", "FormLeft", Left); IniFile->WriteInteger("TextureTable", "FormTop", Top); IniFile->WriteInteger("TextureTable", "FormWidth", Width); IniFile->WriteInteger("TextureTable", "FormHeight", Height); delete IniFile; } if (Bitmap) delete Bitmap; if (Texture) delete Texture; } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FormResize(TObject *Sender) { int h, lh , spbtnwidth; RGBQUAD rgb[2]; h = ClientHeight-116; lh = h/3; PlainListBox->Height = lh; TwillListBox->Height = lh; SatinListBox->Height = lh; PlainListBox->Width = lh; TwillListBox->Width = lh; SatinListBox->Width = lh; TextureGrid->DefaultColWidth = 150; TextureGrid->DefaultRowHeight = 150; Bitmap->Width = TextureGrid->DefaultColWidth; Bitmap->Height = TextureGrid->DefaultRowHeight-20; TextureGrid->ColCount = TextureGrid->Width/150; //Col-Row Count TextureGrid->RowCount = TextureGrid->Height/150; while(TextureGrid->ColCount*TextureGrid->RowCount < 25) TextureGrid->RowCount = TextureGrid->RowCount+1; if(TextureGrid->Width < 150) { // over at least One Column TextureForm->Width = TextureForm->Width + 150 - TextureGrid->Width; TextureGrid->ColCount = 1; } spbtnwidth = (Panel2->Width - 130)/3; //SpeedBtn Width sbFound->Width = spbtnwidth; sbDerive->Width = spbtnwidth; sbSpecial->Width = spbtnwidth; sbFound->Left = 0; //SpeedBtn Location sbDerive->Left = spbtnwidth; sbSpecial->Left = 2*spbtnwidth; sbZoomIn->Left = Panel2->Width - 100; ZoEdit->Left = Panel2->Width - 100 + sbZoomIn->Width; sbZoomout->Left = Panel2->Width - 100 + sbZoomIn->Width + ZoEdit->Width; rgb[0].rgbRed = 255; rgb[0].rgbGreen = 255; rgb[0].rgbBlue = 255; rgb[1].rgbRed =0; rgb[1].rgbGreen = 0; rgb[1].rgbBlue = 0; SetDIBColorTable(Bitmap->Canvas->Handle, 0, 2, rgb); TextureGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FormShow(TObject *Sender) { // FoundListFill(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::sbFoundClick(TObject *Sender) { Item = 0; ptsItem = 0; Index = 0; PlainText->Caption = IDS_PLAIN; TwillText->Enabled = true; SatinText->Enabled = true; FoundListFill(); TextureGrid->Repaint(); if (FOnButtonChange) FOnButtonChange(this); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::sbDeriveClick(TObject *Sender) { Item = 1; ptsItem = 0; Index = 0; PlainText->Caption = IDS_PLAIN; TwillText->Enabled = true; SatinText->Enabled = true; DerivListFill(); TextureGrid->Repaint(); if (FOnButtonChange) FOnButtonChange(this); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::sbSpecialClick(TObject *Sender) { Item = 2; ptsItem = 0; Index = 0; PlainText->Caption = IDS_SPECIALTEXTURE; TwillText->Enabled = false; SatinText->Enabled = false; SpecialListFill(); TextureGrid->Repaint(); if (FOnButtonChange) FOnButtonChange(this); } //---------------------------------------------------------------------------- void __fastcall TTextureForm::ListBoxClick(TObject *Sender) { if ((TListBox *) Sender==PlainListBox) ptsItem = 0; else if ((TListBox *) Sender==TwillListBox) ptsItem = 1; else if ((TListBox *) Sender==SatinListBox) ptsItem = 2; Unselected(); Index = ((TListBox *) Sender)->ItemIndex; TextureGrid->Repaint(); if (FOnListChange) FOnListChange(this); } //---------------------------------------------------------------------------- void __fastcall TTextureForm::sbZoomInClick(TObject *Sender) { Byte zoom; int temp; zoom = StrToInt(ZoEdit->Text); if (zoom<9) { zoom = zoom+1; temp = (int) zoom; ZoEdit->Text = temp; TextureGrid->Repaint(); if (FOnZoomChange) FOnZoomChange(this); } } //---------------------------------------------------------------------------- void __fastcall TTextureForm::sbZoomoutClick(TObject *Sender) { Byte zoom; int temp; zoom = StrToInt(ZoEdit->Text); if (zoom>1) { zoom = zoom-1; temp = (int) zoom; ZoEdit->Text = temp; TextureGrid->Repaint(); if (FOnZoomChange) FOnZoomChange(this); } } //---------------------------------------------------------------------------- void __fastcall TTextureForm::TextureGridDrawCell(TObject *Sender, int Col, int Row, TRect &Rect, TGridDrawState State) { if (Index!=-1) { switch (Item) { case 0: switch (ptsItem) { case 0: FoundDraw(0, Col, Row, Rect); break; case 1: FoundDraw(1, Col, Row, Rect); break; case 2: FoundDraw(2, Col, Row, Rect); break; } break; case 1: switch (ptsItem) { case 0: DerivDraw(0, Col, Row, Rect); break; case 1: DerivDraw(1, Col, Row, Rect); break; case 2: DerivDraw(2, Col, Row, Rect); break; } break; case 2: SpecialDraw(Col, Row, Rect); break; } } } //----------------------------------------------------------------------------- void __fastcall TTextureForm::TextureGridDblClick(TObject *Sender) { TFound *fd; TDeriv *dt; TSpecial *sp; int n = TextureGrid->Row*TextureGrid->ColCount+TextureGrid->Col; switch (Item) { case 0: fd = (TFound *) Texture->f[ptsItem]->Items[Index]; if (n>fd->data->Count-1) return; break; case 1: dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; if (n>dt->data->Count-1) return; break; case 2: sp = (TSpecial *) Texture->s->Items[Index]; if (n>sp->data->Count-1) return; break; } if (FOnChange) FOnChange(this); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::Splitter1Moved(TObject *Sender) { TextureGrid->ColCount = TextureGrid->Width/150; //Col-Row Count TextureGrid->RowCount = TextureGrid->Height/150; while(TextureGrid->ColCount*TextureGrid->RowCount < 25) TextureGrid->RowCount = TextureGrid->RowCount+1; if(TextureGrid->Width < 150) { // over at least One Column TextureForm->Width = TextureForm->Width + 150 - TextureGrid->Width; TextureGrid->ColCount = 1; } } //--------------------------------------------------------------------------- //// Private Method //////////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TTextureForm::FoundListFill() { int i, k, m; TFound *fd; PlainListBox->Clear(); TwillListBox->Clear(); SatinListBox->Clear(); for (k=0; k<3; k++) { m = Texture->f[k]->Count; for (i=0; if[k]->Items[i]; switch (k) { case 0: PlainListBox->Items->Add(Format(" %d x %d", OPENARRAY(TVarRec, (fd->size, fd->size)))); break; case 1: TwillListBox->Items->Add(Format(" %d x %d", OPENARRAY(TVarRec, (fd->size, fd->size)))); break; case 2: SatinListBox->Items->Add(Format(" %d x %d", OPENARRAY(TVarRec, (fd->size, fd->size)))); break; } } } PlainListBox->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TTextureForm::DerivListFill() { int i, k, m; TDeriv *dt; PlainListBox->Clear(); TwillListBox->Clear(); SatinListBox->Clear(); for (k=0; k<3; k++) { m = Texture->d[k]->Count; for (i=0; id[k]->Items[i]; switch (k) { case 0: PlainListBox->Items->Add(dt->name); break; case 1: TwillListBox->Items->Add(dt->name); break; case 2: SatinListBox->Items->Add(dt->name); break; } } } PlainListBox->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TTextureForm::SpecialListFill() { int i, m; TSpecial *sp; PlainListBox->Clear(); TwillListBox->Clear(); SatinListBox->Clear(); m = Texture->s->Count; for (i=0; is->Items[i]; PlainListBox->Items->Add(sp->name); } PlainListBox->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TTextureForm::Unselected() { switch (ptsItem) { case 0: TwillListBox->ItemIndex = -1; SatinListBox->ItemIndex = -1; break; case 1: PlainListBox->ItemIndex = -1; SatinListBox->ItemIndex = -1; break; case 2: PlainListBox->ItemIndex = -1; TwillListBox->ItemIndex = -1; break; } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FoundDraw(Byte pts, int Col, int Row, TRect dRect) { short dx, dy; TFound *fd; TTexBitData *bip; fd = (TFound *) Texture->f[pts]->Items[Index]; if (Col+Row*TextureGrid->ColCount<=fd->data->Count-1) { bip = (TTexBitData *) fd->data->Items[Col+Row*TextureGrid->ColCount]; DrawBitmap(bip); // dy = TextureGrid->DefaultRowHeight; // dx = TextureGrid->DefaultColWidth; TextureGrid->Canvas->Draw(dRect.Left, dRect.Top, Bitmap); LineDraw(Col, Row, dRect, bip); TitleText(Col, Row, dRect, bip); } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::DerivDraw(Byte pts, int Col, int Row, TRect dRect) { short dx, dy; TDeriv *dt; TTexBitData *bip; dt = (TDeriv *) Texture->d[pts]->Items[Index]; if (Col+Row*TextureGrid->ColCount<=dt->data->Count-1) { bip = (TTexBitData *) dt->data->Items[Col+Row*TextureGrid->ColCount]; DrawBitmap(bip); // dy = TextureGrid->DefaultRowHeight; // dx = TextureGrid->DefaultColWidth; // TextureGrid->Canvas->Draw(Col*(dx+2), Row*(dy+2) , Bitmap); TextureGrid->Canvas->Draw(dRect.Left, dRect.Top, Bitmap); LineDraw(Col, Row, dRect, bip); TitleText(Col, Row, dRect, bip); } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::SpecialDraw(int Col, int Row, TRect dRect) { short dx, dy; TSpecial *sp; TTexBitData *bip; sp = (TSpecial *) Texture->s->Items[Index]; if (Col+Row*TextureGrid->ColCount<=sp->data->Count-1) { bip = (TTexBitData *) sp->data->Items[Col+Row*TextureGrid->ColCount]; DrawBitmap(bip); // dy = TextureGrid->DefaultRowHeight; // dx = TextureGrid->DefaultColWidth; TextureGrid->Canvas->Draw(dRect.Left, dRect.Top, Bitmap); LineDraw(Col, Row, dRect, bip); TitleText(Col, Row, dRect, bip); } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::DrawBitmap(TTexBitData *bip) { short x, y, j, w, r, rw, zr, tot, spt, zh, zw; Byte zoom, z; PChar sl, stp, temp, pcx, pcy; zoom = StrToInt(ZoEdit->Text); stp = bip->pBitmap; pcy = stp; temp = stp; zw = bip->Width*zoom; zh = bip->Height*zoom; w = Bitmap->Width/zw; rw = Bitmap->Width%zw; if (w==0) w = 1; for (y=Bitmap->Height-1; y>=0; y--) { sl =(char*) Bitmap->ScanLine[y]; spt = Bitmap->Height-1-y; if ((spt%zoom)pBitmap; for (j=0; jWidth; r++) { zr = r*zoom; for (z=0; z=Bitmap->Width) break; sl[tot] = Byte(*pcx); } pcx = pcx+1; pcy = pcx; } } if ((Bitmap->Width>zw) && (rw!=0)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; zWidth-rw)+(r*zoom)+z; if (tot>=Bitmap->Width) break; sl[tot] = Byte(*pcx); } pcx = pcx+1; } } } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::LineDraw(int col, int row, TRect dRect, TTexBitData *bip) { short dx, dy, sx, sy, w, h, i, j, vj; Byte zoom; zoom = StrToInt(ZoEdit->Text); if (zoom<4) return; dy = TextureGrid->DefaultRowHeight; dx = TextureGrid->DefaultColWidth; sx = col*(dx+2); sy = row*(dy+2)+Bitmap->Height; w = bip->Width*zoom; h = bip->Height*zoom; if (zoom>6) { for (i=0; iWidth; i++) { if ((i%zoom)==0) { TextureGrid->Canvas->Pen->Color = clBlue; if ((i%w)==0) TextureGrid->Canvas->Pen->Color = clRed; TextureGrid->Canvas->MoveTo(sx+i, sy); TextureGrid->Canvas->LineTo(sx+i, sy-Bitmap->Height); } } for (j=Bitmap->Height-1; j>=0; j--) { vj = Bitmap->Height-1-j; if ((vj%zoom)==0) { TextureGrid->Canvas->Pen->Color = clBlue; if ((vj%h)==0) TextureGrid->Canvas->Pen->Color = clRed; TextureGrid->Canvas->MoveTo(sx, sy-vj); TextureGrid->Canvas->LineTo(sx+Bitmap->Width, sy-vj); } } } else if (zoom>3) { for (i=0; iWidth; i++) { if ((i%w)==0) { TextureGrid->Canvas->Pen->Color = clRed; TextureGrid->Canvas->MoveTo(sx+i, sy); TextureGrid->Canvas->LineTo(sx+i, sy-Bitmap->Height); } } for (j=Bitmap->Height-1; j>=0; j--) { vj = Bitmap->Height-1-j; if ((vj%h)==0) { TextureGrid->Canvas->Pen->Color = clRed; TextureGrid->Canvas->MoveTo(sx, sy-vj); TextureGrid->Canvas->LineTo(sx+Bitmap->Width, sy-vj); } } } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::TitleText(int Col, int Row, TRect dRect, TTexBitData *bip) { int tab; AnsiString Name; TRect StrRect; Name = Format("<< %s >> %d x %d", OPENARRAY(TVarRec, (bip->Name, bip->Width, bip->Height))); // Name = Format("<< %d >> %d x %d", OPENARRAY(TVarRec, (Col+1+Row*TextureGrid->ColCount, // bip->Width, bip->Height))); tab = (TextureGrid->DefaultColWidth-TextureGrid->Canvas->TextWidth(Name))/2; if (tab<0) tab = 0; StrRect = Rect(dRect.Left, dRect.Bottom-18, dRect.Left+TextureGrid->DefaultColWidth, dRect.Bottom-2); TextureGrid->Canvas->TextRect(StrRect, dRect.Left+tab, StrRect.Top+2, Name); } //--------------------------------------------------------------------------- //// Public Method //////////////////////////////////////////////////////// //--------------------------------------------------------------------------- // Texture file method // void __fastcall TTextureForm::NewDirectory(int wid) { TFound *fd, *cfd; TDeriv *dt, *cdt; TSpecial *sp, *csp; AnsiString Name, size; int cnt, i; if (Item == 0) { for (i=0; if[ptsItem]->Count; i++) { cfd = (TFound *)Texture->f[ptsItem]->Items[i]; if (cfd->size == wid) { Name = AnsiString(wid)+"X"+AnsiString(wid); MessageDlg(Name+" "+AnsiString(IDS_MESSAGE_DIREXIST), mtWarning, TMsgDlgButtons()<size = wid; fd->data = new TList; Texture->f[ptsItem]->Add(fd); cnt = Texture->f[ptsItem]->Count; size = Format(" %d x %d", OPENARRAY(TVarRec, (wid, wid))); if (ptsItem == 0) PlainListBox->Items->Add(size); else if (ptsItem == 1) TwillListBox->Items->Add(size); else SatinListBox->Items->Add(size); Texture->NewDirectory(Item, ptsItem, cnt, DirectoryTexture, Name); } else if (Item == 1) { Name = ""; if (InputQuery(IDS_COMMON_NEWDIR, IDS_COMMON_INPUTNAME, Name)) { for(i=0; id[ptsItem]->Count;i++) { cdt = (TDeriv *)Texture->d[ptsItem]->Items[i]; if (strcmp(cdt->name, Name.c_str()) == 0) { MessageDlg(Name+" "+AnsiString(IDS_MESSAGE_DIREXIST), mtWarning, TMsgDlgButtons()<name, Name.c_str()); dt->data = new TList; Texture->d[ptsItem]->Add(dt); cnt = Texture->d[ptsItem]->Count; if (ptsItem == 0) PlainListBox->Items->Add(Name); else if (ptsItem == 1) TwillListBox->Items->Add(Name); else SatinListBox->Items->Add(Name); Texture->NewDirectory(Item, ptsItem, cnt, DirectoryTexture, Name); } } else { Name = ""; if (InputQuery(IDS_COMMON_NEWDIR, IDS_COMMON_INPUTNAME, Name)) { for (i=0; is->Count; i++) { csp = (TSpecial *)Texture->s->Items[i]; if (strcmp(csp->name, Name.c_str()) == 0) { MessageDlg(Name+" "+AnsiString(IDS_MESSAGE_DIREXIST), mtWarning, TMsgDlgButtons()<name, Name.c_str()); sp->data = new TList; Texture->s->Add(sp); cnt = Texture->s->Count; PlainListBox->Items->Add(Name); Texture->NewDirectory(Item, ptsItem, cnt, DirectoryTexture, Name); } } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::ExtractData(TTexBitData **bip) { TFound *fd; TDeriv *dt; TSpecial *sp; int n = TextureGrid->Row*TextureGrid->ColCount+TextureGrid->Col; if (Item == 0) { fd = (TFound *) Texture->f[ptsItem]->Items[Index]; *bip = (TTexBitData *) fd->data->Items[n]; } else if (Item == 1) { dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; *bip = (TTexBitData *) dt->data->Items[n]; } else if (Item == 2) { sp = (TSpecial *) Texture->s->Items[Index]; *bip = (TTexBitData *) sp->data->Items[n]; } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::OverWriteTexture() { int ext; if (Item == 0) { TFound *fd = (TFound *) Texture->f[ptsItem]->Items[Index]; ext = fd->size; } else { ext = Index+1; } Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, true); TextureGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::InsertTexture(TTexBitData *bip) { int ext; TFound *fd; TDeriv *dt; TSpecial *sp; if (Item == 0) { fd = (TFound *) Texture->f[ptsItem]->Items[Index]; fd->data->Add(bip); ext = fd->size; } else if (Item == 1) { dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; dt->data->Add(bip); ext = Index+1; } else if (Item == 2) { sp = (TSpecial *) Texture->s->Items[Index]; sp->data->Add(bip); ext = Index+1; } Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, true); TextureGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::DeleteTexture() { int ext, n; TFound *fd; TDeriv *dt; TSpecial *sp; TTexBitData *bip; AnsiString str; n = TextureGrid->Row*TextureGrid->ColCount+TextureGrid->Col; if (Item == 0) { fd = (TFound *) Texture->f[ptsItem]->Items[Index]; bip = (TTexBitData *) fd->data->Items[n]; str = Format("<< %s >> %d x %d", OPENARRAY(TVarRec, (bip->Name, bip->Width, bip->Height))); if (MessageDlg(IDS_MESSAGE_DELETETEXTURE + str, mtWarning, TMsgDlgButtons()<size; fd->data->Remove(bip); delete bip; Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, true); } } else if (Item == 1) { dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; bip = (TTexBitData *) dt->data->Items[n]; str = Format("<< %s >> %d x %d", OPENARRAY(TVarRec, (bip->Name, bip->Width, bip->Height))); if (MessageDlg(IDS_MESSAGE_DELETETEXTURE + str, mtWarning, TMsgDlgButtons()<data->Remove(bip); delete bip; Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, true); } } else if (Item == 2) { sp = (TSpecial *) Texture->s->Items[Index]; bip = (TTexBitData *) sp->data->Items[n]; str = Format("<< %s >> %d x %d", OPENARRAY(TVarRec, (bip->Name, bip->Width, bip->Height))); if (MessageDlg(IDS_MESSAGE_DELETETEXTURE + str, mtWarning, TMsgDlgButtons()<data->Remove(bip); delete bip; Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, true); } } TextureGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::DeleteTextureGroup() { int ext; TFound *fd; TDeriv *dt; TSpecial *sp; TTexBitData *bip; AnsiString str; if (Item == 0) { fd = (TFound *) Texture->f[ptsItem]->Items[Index]; str = Format(" \"%d x %d\"", OPENARRAY(TVarRec, (fd->size, fd->size))); if (MessageDlg(IDS_MESSAGE_DELETEFILE + str, mtWarning, TMsgDlgButtons()<size; Texture->f[ptsItem]->Remove(fd); while(fd->data->Count > 0) { bip = (TTexBitData *) fd->data->Last(); fd->data->Remove(bip); delete bip; } delete fd->data; delete fd; Texture->DeleteTextureGroup(Item, ptsItem, ext, Index, DirectoryTexture); if (ptsItem == 0) PlainListBox->Items->Delete(Index); else if (ptsItem == 1) TwillListBox->Items->Delete(Index); else SatinListBox->Items->Delete(Index); Index = 0; } } else if (Item == 1) { dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; str = Format(" \"%s\"", OPENARRAY(TVarRec, (dt->name))); if (MessageDlg(IDS_MESSAGE_DELETEFILE + str, mtWarning, TMsgDlgButtons()<d[ptsItem]->Remove(dt); while(dt->data->Count > 0) { bip = (TTexBitData *) dt->data->Last(); dt->data->Remove(bip); delete bip; } delete dt->data; delete dt; ext = Index+1; Texture->DeleteTextureGroup(Item, ptsItem, ext, Index, DirectoryTexture); if (ptsItem == 0) PlainListBox->Items->Delete(Index); else if (ptsItem == 1) TwillListBox->Items->Delete(Index); else SatinListBox->Items->Delete(Index); Index = 0; } } else if (Item == 2) { sp = (TSpecial *) Texture->s->Items[Index]; str = Format(" \"%s\"", OPENARRAY(TVarRec, (sp->name))); if (MessageDlg(IDS_MESSAGE_DELETEFILE + str, mtWarning, TMsgDlgButtons()<s->Remove(sp); while(sp->data->Count > 0) { bip = (TTexBitData *) sp->data->Last(); sp->data->Remove(bip); delete bip; } delete sp->data; delete sp; ext = Index+1; Texture->DeleteTextureGroup(Item, ptsItem, ext, Index, DirectoryTexture); if (ptsItem == 0) PlainListBox->Items->Delete(Index); else if (ptsItem == 1) TwillListBox->Items->Delete(Index); else SatinListBox->Items->Delete(Index); Index = 0; } } TextureGrid->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TTextureForm::RenameTexture() { TFound *fd; TDeriv *dt; TSpecial *sp; TTexBitData *bip; int ext, n, i; AnsiString Name = ""; if (InputQuery(IDS_COMMON_RENAME, IDS_COMMON_INPUTNAME, Name)) { if (Name != "") { n = TextureGrid->Row*TextureGrid->ColCount+TextureGrid->Col; if (Item == 0) { fd = (TFound *) Texture->f[ptsItem]->Items[Index]; for (i=0; idata->Count; i++) { // Find same filename! bip = (TTexBitData *)fd->data->Items[i]; if (strcmp(bip->Name, Name.c_str()) == 0) { MessageDlg(IDS_MESSAGE_FILEEXIST, mtWarning, TMsgDlgButtons()<data->Items[n]; strcpy(bip->Name, Name.c_str()); ext = fd->size; } else if (Item == 1) { dt = (TDeriv *) Texture->d[ptsItem]->Items[Index]; for (i=0; idata->Count; i++) { // Find same filename! bip = (TTexBitData *)dt->data->Items[i]; if (strcmp(bip->Name, Name.c_str()) == 0) { MessageDlg(IDS_MESSAGE_FILEEXIST, mtWarning, TMsgDlgButtons()<data->Items[n]; strcpy(bip->Name, Name.c_str()); ext = Index+1; } else if (Item == 2) { sp = (TSpecial *) Texture->s->Items[Index]; for (i=0; idata->Count; i++) { // Find same filename! bip = (TTexBitData *)sp->data->Items[i]; if (strcmp(bip->Name, Name.c_str()) == 0) { MessageDlg(IDS_MESSAGE_FILEEXIST, mtWarning, TMsgDlgButtons()<data->Items[n]; strcpy(bip->Name, Name.c_str()); ext = Index+1; } Texture->SaveTexture(Item, ptsItem, ext, Index, DirectoryTexture, false); TextureGrid->Repaint(); } } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::RenameTextureGroup() { TDeriv *dt; TSpecial *sp; int i; AnsiString Name = ""; if (InputQuery(IDS_COMMON_RENAME, IDS_COMMON_INPUTNAME, Name)) { if (Name != "") { if (Item == 1) { for(i=0; id[ptsItem]->Count;i++) { // Find same directory! dt = (TDeriv *)Texture->d[ptsItem]->Items[i]; if (strcmp(dt->name, Name.c_str()) == 0) { MessageDlg(Name+" "+AnsiString(IDS_MESSAGE_DIREXIST), mtWarning, TMsgDlgButtons()<d[ptsItem]->Items[Index]; strcpy(dt->name, Name.c_str()); if (ptsItem == 0) PlainListBox->Items->Strings[Index] = Name; else if (ptsItem == 1) TwillListBox->Items->Strings[Index] = Name; else SatinListBox->Items->Strings[Index] = Name; } else if (Item == 2) { // Find same directory! for (i=0; is->Count; i++) { sp = (TSpecial *)Texture->s->Items[i]; if (strcmp(sp->name, Name.c_str()) == 0) { MessageDlg(Name+" "+AnsiString(IDS_MESSAGE_DIREXIST), mtWarning, TMsgDlgButtons()<s->Items[Index]; strcpy(sp->name, Name.c_str()); PlainListBox->Items->Strings[Index] = Name; } Texture->RenameTextureGroup(Item, ptsItem, Index, Name.c_str(), DirectoryTexture); } } } //--------------------------------------------------------------------------- void __fastcall TTextureForm::FormClose(TObject *Sender, TCloseAction &Action) { if (FOnCloseForm) FOnCloseForm(); } //---------------------------------------------------------------------------