QtStereoEditorDialogue::QtStereoEditorDialogue(QWidget * parent, const char * name, bool modal, Qt::WFlags f) 
:Q3TabDialog(parent, name, modal,f)
{
	setCaption("Stereo Editor");
	//setIcon( QPixmap( "icons/config.png" ));
	
	build_layout();
}
QtMeasuringEditorDialogue::QtMeasuringEditorDialogue(QWidget * parent, const char * name, bool modal, Qt::WFlags f, QString appPath) 
:Q3TabDialog(parent, name, modal,f)
{
	apppath = appPath;
	QSizePolicy sizepolicy;
	sizepolicy.setHeightForWidth(TRUE);
	setSizePolicy(sizepolicy);
 
	setCaption("Measuring Editor");
	//setIcon( QPixmap( "Icons/ruler.png" ));

	build_layout();
}
int main(int argc, char **argv)
{
	int argi;
	int ret;
	u32 pos, pos2;

	char *bottomtex_filename = NULL, *toptex_filename = NULL;

	char tmpstr0[0x40];
	char tmpstr1[0x40];
	char tmpstr2[0x40];

	memset(texture_coords, 0, sizeof(texture_coords));

	if(argc==1)
	{
		printf("%s by yellows8\n", argv[0]);
		printf("Tool for building the data used with 3DS ExeFS:/logo.\n");
		printf("Usage:\n");
		printf("%s <options>\n", argv[0]);
		printf("Options:\n");
		printf("--dirpath=<path> Required, this is the path where the darc directory stucture is located.\n");
		printf("--bottomtex=<path> Required, filename for the bottom-screen texture, under the timg directory.\n");
		printf("--toptex=<path> Required, filename for the top-screen texture, under the timg directory. These two image filenames are *only* used for writing into the .bclyt, this tool will not verify that the specified file actually exists.\n");
		printf("--bottomtexcoords={coords} Required, coordinates for the bottom-screen texture.\n");
		printf("--toptexcoords={coords} Required, coordinates for the top-screen texture. {coords} are floats: {<width>,<height>,<x>,<y>,<z>}.\n");
		return 0;
	}

	for(argi=1; argi<argc; argi++)
	{
		if(strncmp(argv[argi], "--dirpath=", 10)==0)darc_dirpath = &argv[argi][10];
		if(strncmp(argv[argi], "--bottomtex=", 12)==0)bottomtex_filename = &argv[argi][12];
		if(strncmp(argv[argi], "--toptex=", 9)==0)toptex_filename = &argv[argi][9];

		if(strncmp(argv[argi], "--bottomtexcoords=", 18)==0)
		{
			ret = parse_texcoords_input(&argv[argi][18], 0);
			if(ret)return ret;
		}

		if(strncmp(argv[argi], "--toptexcoords=", 15)==0)
		{
			ret = parse_texcoords_input(&argv[argi][15], 1);
			if(ret)return ret;
		}
	}

	if(darc_dirpath==NULL)
	{
		printf("Specify the dirpath.\n");
		return 1;
	}

	if(bottomtex_filename == NULL || toptex_filename == NULL)
	{
		printf("Specify --bottomtex and --toptex.\n");
		return 1;
	}

	if(texture_coords_set != 0x3)
	{
		printf("Specify the bottom/top texture coords.\n");
		return 1;
	}

	filebuf = malloc(0x4000);
	if(filebuf==NULL)
	{
		printf("Failed to allocate memory for the filebuf.\n");
		free(filebuf);
		return 3;
	}

	printf("Building the layouts...\n");

	ret = build_layout("NintendoLogo_D_00.bclyt", bottomtex_filename, 0);
	if(ret)
	{
		free(filebuf);
		return ret;
	}

	ret = build_layout("NintendoLogo_U_00.bclyt", toptex_filename, 1);
	if(ret)
	{
		free(filebuf);
		return ret;
	}

	printf("Building the animation files...\n");

	for(pos=0; pos<2; pos++)
	{
		for(pos2=0; pos2<3; pos2++)
		{
			memset(tmpstr0, 0, sizeof(tmpstr0));
			memset(tmpstr1, 0, sizeof(tmpstr1));
			memset(tmpstr2, 0, sizeof(tmpstr2));

			snprintf(tmpstr2, sizeof(tmpstr2)-1, "G_%c_00", 'A' + pos2);
			snprintf(tmpstr1, sizeof(tmpstr1)-1, "SceneOut%c", 'A' + pos2);
			snprintf(tmpstr0, sizeof(tmpstr0)-1, "NintendoLogo_%c_00_%s.bclan", pos==0?'D':'U', tmpstr1);

			ret = build_anim(tmpstr0, tmpstr1, tmpstr2);
			if(ret)break;
		}
	}

	free(filebuf);

	printf("Done.\n");

	return ret;
}