diff --git a/Utils/MapEdit/MapEdit.clw b/Utils/MapEdit/MapEdit.clw index 2e070b2da..2da4b05d1 100644 --- a/Utils/MapEdit/MapEdit.clw +++ b/Utils/MapEdit/MapEdit.clw @@ -33,26 +33,26 @@ Class21=CMapEditDoc Class22=CMapEditView ResourceCount=20 -Resource1=IDD_ADDLAYER -Resource2=IDD_LAYER_PLATFORM -Resource3=IDR_TOOLBAR (English (U.S.)) +Resource1=IDD_LAYER_PLATFORM +Resource2=IDD_ADDLAYER +Resource3=IDD_TOOLBAR Resource4=IDR_MAPEDITYPE (English (U.S.)) -Resource5=IDD_NEWMAP -Resource6=IDD_TOOLBAR -Resource7=IDD_LAYER_LIST -Resource8=IDD_LAYER_ACTOR -Resource9=IDD_ELEMLIST -Resource10=IDD_RESIZE -Resource11=IDD_TILEBANK -Resource12=IDD_LAYER_THING_POS -Resource13=IDD_LAYER_TRIGGER -Resource14=IDD_LAYER_SHADE -Resource15=IDD_LAYER_COLLISION -Resource16=IDD_ABOUTBOX (English (U.S.)) -Resource17=IDD_MULTIBAR (English (U.S.)) -Resource18=IDR_MAINFRAME (English (U.S.)) +Resource5=IDD_LAYER_THING_POS +Resource6=IDR_TOOLBAR (English (U.S.)) +Resource7=IDD_LAYER_ACTOR +Resource8=IDD_LAYER_LIST +Resource9=IDD_MULTIBAR (English (U.S.)) +Resource10=IDD_LAYER_THING +Resource11=IDD_LAYER_TRIGGER +Resource12=IDD_NEWMAP +Resource13=IDD_TILEBANK +Resource14=IDR_MAINFRAME (English (U.S.)) +Resource15=IDD_ABOUTBOX (English (U.S.)) +Resource16=IDD_LAYER_COLLISION +Resource17=IDD_ELEMLIST +Resource18=IDD_LAYER_SHADE Class23=CGUILayerTrigger -Resource19=IDD_LAYER_THING +Resource19=IDD_RESIZE Class24=CGUILayerFX Resource20=IDD_LAYER_FX diff --git a/Utils/MkActor/MkActor.cpp b/Utils/MkActor/MkActor.cpp index e891fd8a2..b13f7082d 100644 --- a/Utils/MkActor/MkActor.cpp +++ b/Utils/MkActor/MkActor.cpp @@ -15,9 +15,10 @@ #include using namespace std; -//#define CheckDups 1 //#define OutputTGA +// This has got really messy :o( + //*************************************************************************** vector ActorList; int TPBase=-1,TPWidth=-1,TPHeight=-1; @@ -28,24 +29,6 @@ GString SpritePath; GString OutPath; GString IncludePath; -//*************************************************************************** -void RepAlign(FILE *File,char *Txt=0) -{ -/* -int Align=ftell(File)&3; - - if (Align) - { - if (Txt) - printf("%s MisAlign %i\n",Txt,Align); - else - printf("%s MisAlign %i\n","File",Align); - - } -*/ - PadFile(File); -} - //*************************************************************************** char * CycleCommands(char *String,int Num) { @@ -165,6 +148,8 @@ CMkActor::CMkActor(GString &ActorName,GString &ActorPath,GString &SpritePath) TexGrab.AllowRotate(false); DupCount=0; + MaxW=0; + MaxH=0; } //*************************************************************************** @@ -263,8 +248,11 @@ GString Filename; _finddata_t Find; long FileHandle; int Error=0; +GString BaseName=Name+"_"+ThisAnim.Name; +int BaseLen=strlen(BaseName); + + Filename=SpriteDir+BaseName+"*.bmp"; - Filename=SpriteDir+Name+"_"+ThisAnim.Name+"*.bmp"; if( (FileHandle= _findfirst( Filename, &Find)) == -1L ) { GObject::Error(ERR_WARNING,"Cant find Anim %s.\n",ThisAnim.Name); @@ -275,7 +263,11 @@ int Error=0; { sFrame NewFrame; NewFrame.Filename=Find.name; - ThisAnim.Frames.push_back(NewFrame); + char c=NewFrame.Filename[BaseLen]; + if (c>='0' && c<='9') + { + ThisAnim.Frames.push_back(NewFrame); + } Error=_findnext( FileHandle, &Find); } @@ -310,19 +302,8 @@ void CMkActor::LoadFrame(sFrame &ThisFrame,bool VRamFlag) void CMkActor::MakePsxGfx(sBmp &Bmp) { // Copied from SprSet -// apparantly only works on 16 colors, so I gotta watch it!! -int AlignPixels=4; int nfW,nfH,nfLineWidthBytes,nfAreaBytes; -Frame &Frm=Bmp.Bmp; -Rect OriginalRect; - - OriginalRect=Frm; - - OriginalRect.X=0; - OriginalRect.Y=0; - OriginalRect.W=GU_AlignVal(OriginalRect.W,AlignPixels); - - Frm.Crop(OriginalRect); +Frame Frm=Bmp.Bmp; nfW=Frm.GetWidth(); nfH=Frm.GetHeight(); @@ -330,6 +311,8 @@ Rect OriginalRect; nfAreaBytes=nfLineWidthBytes*nfH; Bmp.PsxSize=nfAreaBytes; + if (nfW>MaxW) MaxW=nfW; + if (nfH>MaxH) MaxH=nfH; Bmp.Psx=(u8*)malloc(nfAreaBytes+16); ASSERT(Bmp.Psx); @@ -360,103 +343,58 @@ Rect OriginalRect; } //*************************************************************************** -int CMkActor::LoadBmp(GString &Name,bool VRamFlag) +int CMkActor::FindDup(sBmp &Bmp) { -GString Filename=SpriteDir+Name; - -int BmpListSize=BmpList.size(); -sBmp NewBmp; -SprFrame &NewFrame=NewBmp.Bmp; -FileInfo ThisInfo; - -// ThisInfo.SetInfo(name, CrossHair, ThisZeroColZero, MoveUVs, AllowRotate, ShrinkToFit, m_allocateAs16bit); - ThisInfo.SetInfo(Filename, false, true, false, false, true, false); - - NewBmp.RGB=0; - NewBmp.Pak=0; - NewBmp.Psx=0; - NewBmp.VRamFlag=VRamFlag; - - NewFrame.LoadBMP(Filename); -int ColorCount=NewFrame.GetNumOfCols(); - if (ColorCount>16) - { - GObject::Error(ERR_WARNING,"%s has %i colors.\n",Name,ColorCount); - } - - -#ifdef CheckDups -int Size=NewFrame.GetWidth()*NewFrame.GetHeight(); - NewBmp.RGB=(u8*)malloc(Size*3); - ASSERT(NewBmp.RGB); - NewFrame.MakeRGB(NewBmp.RGB); +int i,BmpListSize=BmpList.size(); +int Size=Bmp.Bmp.GetWidth()*Bmp.Bmp.GetHeight(); + Bmp.RGB=(u8*)malloc(Size*3); + ASSERT(Bmp.RGB); + Bmp.Bmp.MakeRGB(Bmp.RGB); // Check for dups (Broken at the mo, ah well) // Gen Chksum -u8 *RGB=NewBmp.RGB; - NewBmp.ChkR=NewBmp.ChkG=NewBmp.ChkB=0; + +u8 *RGB=Bmp.RGB; + Bmp.ChkR=Bmp.ChkG=Bmp.ChkB=0; for (i=0; i16) + { + GObject::Error(ERR_FATAL,"%s has %i colors.\n",Name,ColorCount); + } + +// ThisInfo.SetInfo(name, CrossHair, ThisZeroColZero, MoveUVs, AllowRotate, ShrinkToFit, m_allocateAs16bit); + ThisInfo.SetInfo(Filename, false, true, false, false, true, false); + +// Copy Frame + Dst.SetFrameAndInfo(Src,ThisInfo,0); +// Align Frame + + OriginalRect=Src; + OriginalRect.X=0; + OriginalRect.Y=0; + OriginalRect.W=GU_AlignVal(OriginalRect.W,4); + + Dst.Crop(OriginalRect); + +} + +//*************************************************************************** +int CMkActor::LoadBmp(GString &Name,bool VRamFlag) +{ +GString Filename=SpriteDir+Name; +int BmpListSize=BmpList.size(); +sBmp NewBmp; +Frame NewFrame; + +// Init Frame + NewBmp.RGB=0; + NewBmp.Pak=0; + NewBmp.Psx=0; + NewBmp.VRamFlag=VRamFlag; + +// Load frame + NewFrame.LoadBMP(Filename); + SetAndShrinkFrame(Filename,NewFrame,NewBmp.Bmp); + +// Check Dups +int Idx=FindDup(NewBmp); + + if (Idx!=-1) + { + DupCount++; + return(Idx); + } +// Its unique, add to list + BmpList.push_back(NewBmp); + + MakePsxGfx(BmpList[BmpListSize]); + +#if _DEBUG && defined(OutputTGA) +void WriteTGA(GString Name,Frame Frm); + WriteTGA(Name,NewBmp.Bmp); +#endif + + return(BmpListSize); +} + +//*************************************************************************** +void WriteTGA(GString Name,Frame Frm) +{ +u8 *TGA=(u8*)malloc(Frm.GetWidth()*Frm.GetHeight()*3); + ASSERT(TGA); + Frm.FlipY(); + Frm.MakeRGB(TGA); + + char OutName[256]; + sprintf(OutName,"\\x\\%s.tga",Name); + SaveTGA(OutName,Frm.GetWidth(),Frm.GetHeight(),TGA,true); + free(TGA); +} + //*************************************************************************** //*************************************************************************** //*************************************************************************** @@ -513,16 +534,16 @@ GString OutName=OutFile+".SBK"; // Write Dummy Hdr fwrite(&FileHdr,1,sizeof(sSpriteAnimBank),File); - RepAlign(File,"MainHeader"); + PadFile(File); // Write Palette FileHdr.Palette=(u8*)WritePalette(); - RepAlign(File,"PaletteHdr"); + PadFile(File); // Write AnimList FileHdr.AnimList=(sSpriteAnim*)WriteAnimList(); - RepAlign(File,"AnimListHdr"); + PadFile(File); // Write FrameList FileHdr.FrameList=(sSpriteFrame*)WriteFrameList(); -// RepAlign(File,"FrameHdr"); +// PadFile(File); // Rewrite Header fseek(File, 0, SEEK_SET); @@ -575,7 +596,7 @@ vector Hdrs; { fwrite(&Hdrs[i],1,sizeof(sSpriteAnim),File); } - RepAlign(File,"AnimListHdr"); + PadFile(File); // Write Frame Lists for (i=0; i Hdrs; u16 FrameNo=ThisFrame.FrameIdx; fwrite(&FrameNo,1,sizeof(u16),File); } - RepAlign(File,"AnimIdx"); + PadFile(File); } @@ -616,13 +637,15 @@ int i,FrameCount=BmpList.size(); vector Hdrs; // Write Dummy Hdrs + FileHdr.MaxW=MaxW; + FileHdr.MaxH=MaxH; FileHdr.FrameCount=FrameCount; Hdrs.resize(FrameCount); for (i=0; i &List); void BuildFrameList(); void FindFrames(sAnim &ThisAnim); + int FindDup(sBmp &Frm); void LoadFrameList(); void LoadFrame(sFrame &ThisFrame,bool VRamFlag); int LoadBmp(GString &Name,bool VRamFlag); + void SetAndShrinkFrame(GString &Filename,Frame &Src,SprFrame &Dst); bool IsImageSame(sBmp &Bmp0,sBmp &Bmp1); void MakePsxGfx(sBmp &Bmp); void ProcessFrames(); @@ -74,6 +76,7 @@ private: vector BmpList; CTexGrab TexGrab; int DupCount; + int MaxW,MaxH; }; //***************************************************************************