void ResourceLoader::Init()
{


    Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));


    LoadResourcePaths(AString::char_to_str(ctrl->GetProjectName()));
    Add("Environment", new Environment(GetEnvFile()));
    Add("FilterSettings", new FilterSettings(GetFSettingsFile()));
    Add("Entities", new SceneInfo(AString::char_to_str(GetSceneFile())));
    LoadChanges();


}
Exemple #2
0
int main(int argc, char **argv)
{
	int i,StringOffset;
	char *replace;
	int		TempInt,TotalLength;
	char TempStr[512];
	char TempList[512][256];
	char FName[256];

	strcpy(FName,argv[1]);
	
	replace=strstr(FName,"adt");
	replace[0]='t';
	replace[1]='x';
	replace[2]='t';

	FILE *Output;
	Output=fopen(FName,"rt");
	printf("Loading Info From File %s\n",argv[1]);
	fscanf(Output,"MMDX %d",&diffMDXs);	
	TotalLength=0;
	MDXOffsets=new int[diffMDXs];
	for(i=0;i<diffMDXs;i++)
	{
		fgets(TempStr,512,Output);
		if(strlen(TempStr)<3)
		{
			i--;
			continue;
		}
		printf("Read %s",TempStr);
		for(int j=0;j<512;j++)
		{
			if(TempStr[j]=='\t')
			{
				TempInt=atoi(TempStr);
				TempStr[j]=0;
				StringOffset=j+1;
			}
			else if(TempStr[j]=='\n')
			{
				TempStr[j]=0;
				break;
			}
		}

		printf("Loaded %d %s\n",TempInt,TempStr+StringOffset);
		strcpy(TempList[TempInt],TempStr+StringOffset);
		TotalLength+=strlen(TempStr+StringOffset)+1;
	}

	MMDXSize=TotalLength;
	
	MDXFiles=new char[TotalLength];
	TempInt=0;
	for(i=0;i<diffMDXs;i++)
	{
		MDXOffsets[i]=TempInt;
		strcpy(MDXFiles+TempInt,TempList[i]);
		TempInt+=strlen(TempList[i])+1;
	}

	fgets(TempStr,512,Output);
	while(strlen(TempStr)<3)
	{
		fgets(TempStr,512,Output);
		if(feof(Output))
		{
			printf("Error!\n");
			return 0;
		}
	}

	sscanf(TempStr,"MWMO %d",&diffWMOs);	
	printf("Read %d\n",diffWMOs);
	TotalLength=0;
	WMOOffsets=new int[diffWMOs];
	for(i=0;i<diffWMOs;i++)
	{
		fgets(TempStr,512,Output);
		if(strlen(TempStr)<3)
		{
			i--;
			continue;
		}
		printf("Read %s",TempStr);
		for(int j=0;j<512;j++)
		{
			if(TempStr[j]=='\t')
			{
				TempInt=atoi(TempStr);
				TempStr[j]=0;
				StringOffset=j+1;
			}
			else if(TempStr[j]=='\n')
			{
				TempStr[j]=0;
				break;
			}
		}

		printf("Loaded %d %s\n",TempInt,TempStr+StringOffset);
		strcpy(TempList[TempInt],TempStr+StringOffset);
		TotalLength+=strlen(TempStr+StringOffset)+1;
	}

	
	MWMOSize=TotalLength;
	WMOFiles=new char[TotalLength];
	TempInt=0;
	for(i=0;i<diffWMOs;i++)
	{
		WMOOffsets[i]=TempInt;
		strcpy(WMOFiles+TempInt,TempList[i]);
		TempInt+=strlen(TempList[i])+1;
	}

	fgets(TempStr,512,Output);
	while(strlen(TempStr)<3)
	{
		fgets(TempStr,512,Output);
		if(feof(Output))
		{
			printf("Error!\n");
			return 0;
		}
	}

	sscanf(TempStr,"MDDF %d",&NumDDFs);
	printf("There is %d doodads\n",NumDDFs);
	DDFs=new DDF[NumDDFs];
	for(i=0;i<NumDDFs;i++)
		fscanf(Output,"%d %d %f %f %f %f %f %f %d",&DDFs[i].ID,&DDFs[i].UniqueID,&DDFs[i].Pos[0],&DDFs[i].Pos[1],&DDFs[i].Pos[2],&DDFs[i].Rot[0],&DDFs[i].Rot[1],&DDFs[i].Rot[2],&DDFs[i].Scale);

	fgets(TempStr,512,Output);
	while(strlen(TempStr)<3)
	{
		fgets(TempStr,512,Output);
		if(feof(Output))
		{
			printf("Error!\n");
			return 0;
		}
	}
	sscanf(TempStr,"MODF %d",&NumWMOs);
	printf("There is %d WMOs\n",NumWMOs);
	WMOs=new WMO[NumWMOs];
	for(i=0;i<NumWMOs;i++)
	{
		fscanf(Output,"%d %d %f %f %f %f %f %f %f %f %f %f %f %f %d",&(WMOs[i].ID),&(WMOs[i].UniqueID),&(WMOs[i].Pos[0]),&(WMOs[i].Pos[1]),&(WMOs[i].Pos[2]),&WMOs[i].Rot[0],&WMOs[i].Rot[1],&WMOs[i].Rot[2],&WMOs[i].Pos2[0],&WMOs[i].Pos2[1],&WMOs[i].Pos2[2],&WMOs[i].Pos3[0],&WMOs[i].Pos3[1],&WMOs[i].Pos3[2],&WMOs[i].DoodadIndex);
		WMOs[i].Unknown1=0;
		WMOs[i].Unknown2=0;
	}
	fclose(Output);

	replace[0]='a';
	replace[1]='d';
	replace[2]='t';

	printf("Loading Info Into File %s\n",FName);
	Input=fopen(FName,"rb");
	fseek(Input,0,SEEK_END);
	FileSize=ftell(Input);

	File=new unsigned char[FileSize];
	fseek(Input,0,SEEK_SET);
	fread(File,1,FileSize,Input);
	fclose(Input);
	NewFileSize=FileSize;
	NewFile=new unsigned char[2*FileSize];
	Change=0;

	FindOffsets();
	LoadChanges();

	Output=fopen(FName,"wb");
	fwrite(NewFile,1,FileSize+Change,Output);
	fclose(Output);

	delete NewFile;
	delete File;
}