SBSPSS/Utils/Libs/TexGrab/AllFiles.cpp

154 lines
3.5 KiB
C++
Raw Normal View History

2000-12-02 19:55:49 +01:00
/*=========================================================================
AllFiles.CPP
Author: Gary
Created: 011200
Project: SpongeBob
Purpose: File cycler stuff
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include <vector>
#include <gtypes.h>
#include <gstring.hpp>
#include <misc.hpp>
#include <gfname.hpp>
#include <pcre.h>
#include "sprset.h"
#include "AllFiles.h"
/*----------------------------------------------------------------------
Function: void AllFiles::AddFile(const char * Name)
Purpose: Add a file to the list, it takes all the current
properties that the AllFiles object has.
Params: Name of file to add
---------------------------------------------------------------------- */
2001-02-02 20:18:13 +01:00
int AllFiles::AddFile(const char * Name)
2000-12-02 19:55:49 +01:00
{
2001-02-02 20:18:13 +01:00
int ListSize=AllFileInfos.size();
2000-12-02 19:55:49 +01:00
DoCycle(Name,RecurseFiles);
2001-02-02 20:18:13 +01:00
return(ListSize);
2000-12-02 19:55:49 +01:00
}
/*----------------------------------------------------------------------
Function: void AllFiles::FileCallback(char const * FName,int FileNum)
---------------------------------------------------------------------- */
2001-02-08 17:27:48 +01:00
//#include <gintex.h>
2000-12-02 19:55:49 +01:00
#include <algorithm>
void AllFiles::FileCallback(char const * FName,int FileNum)
{
FileInfo MyInfo;
bool ThisZeroColZero;
GFName FileName(FName);
GString Ext(FileName.Ext());
Ext.Lower();
2001-02-08 17:30:06 +01:00
GFName Name(FName);
2000-12-02 19:55:49 +01:00
2001-02-08 17:30:06 +01:00
if (Name.File()[0]=='+')
ThisZeroColZero=true;
2000-12-02 19:55:49 +01:00
else
2001-02-08 17:30:06 +01:00
ThisZeroColZero=ZeroColZero;
2000-12-02 19:55:49 +01:00
2001-02-08 17:30:06 +01:00
if (Name.File()[0]=='!')
m_allocateAs16bit=true;
else
m_allocateAs16bit=false;
2000-12-02 19:55:49 +01:00
2001-02-08 17:30:06 +01:00
if (Name.File()[0] == '@')
{
ThisZeroColZero = true;
m_allocateAs16bit = true;
}
2000-12-02 19:55:49 +01:00
2001-02-08 17:30:06 +01:00
GString TheFile(FName);
TheFile.Lower();
MyInfo.SetInfo(TheFile,CrossHair,ThisZeroColZero,MoveUVs,AllowRotate,ShrinkToFit,m_allocateAs16bit);
if (DebugFlag) cout<<"Add image file "<<TheFile<<endl;
2000-12-02 19:55:49 +01:00
2001-02-08 17:30:06 +01:00
if (ForceOffsets)
MyInfo.SetForceOffsets(XOff,YOff);
AllFileInfos.resize(AllFileInfos.size()+1);
AllFileInfos[AllFileInfos.size()-1]=MyInfo;
2000-12-02 19:55:49 +01:00
}
2001-02-02 20:18:13 +01:00
int AllFiles::AddMemFrame(char const * FName,Frame &Frame)
2000-12-02 19:55:49 +01:00
{
FileInfo MyInfo;
bool ThisZeroColZero;
GFName Name(FName);
if (Name.File()[0]=='+')
ThisZeroColZero=true;
else
ThisZeroColZero=ZeroColZero;
if (Name.File()[0]=='!')
m_allocateAs16bit=true;
else
m_allocateAs16bit=false;
if (Name.File()[0] == '@')
{
ThisZeroColZero = true;
m_allocateAs16bit = true;
}
GString TheFile(FName);
TheFile.Lower();
MyInfo.SetInfo(TheFile,CrossHair,ThisZeroColZero,MoveUVs,AllowRotate,ShrinkToFit,m_allocateAs16bit,&Frame);
2000-12-14 17:38:34 +01:00
if (DebugFlag) cout<<"Add MemFrame "<<TheFile<<endl;
2000-12-02 19:55:49 +01:00
if (ForceOffsets)
MyInfo.SetForceOffsets(XOff,YOff);
2001-02-02 20:18:13 +01:00
int ListSize=AllFileInfos.size();
AllFileInfos.resize(ListSize+1);
AllFileInfos[ListSize]=MyInfo;
return(ListSize);
2000-12-02 19:55:49 +01:00
}
/*----------------------------------------------------------------------
Function: void AllFiles::FileCallback(char const * FName,int FileNum)
---------------------------------------------------------------------- */
void AllFiles::SortOrder()
{
if (!m_noSort)
{
int i,j;
FileInfo MyInfo;
int count = AllFileInfos.size();
for (i=0; i<count; i++)
{
for (j=0; j<count; j++)
{
if (strcmp(AllFileInfos[i].GetFileName(), AllFileInfos[j].GetFileName())<0)
{
MyInfo = AllFileInfos[i];
AllFileInfos[i] = AllFileInfos[j];
AllFileInfos[j] = MyInfo;
}
}
}
}
}
/*===========================================================================
end */