//===========================================================================//
// File:	vectlist.cpp                                                        //
// Project: MUNGA           Brick: Gauge Renderer         	                 //
// Contents: 																					  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 05/19/95  CPB  Initial coding.                                            //
// 06/01/95  CPB  Resourcified.                                              //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved //
//                      PROPRIETARY and CONFIDENTIAL                         //
//===========================================================================//

#include <mungal4.hpp>

#if !defined(L4GAUIMA_HPP)
#	include <l4gauima.hpp>
#endif

#if !defined(GAUGALRM_HPP)
#	include <gaugalrm.hpp>
#endif

#if !defined(L4TOOL_HPP)
#	include <l4tool.hpp>
#endif

ResourceDescription::ResourceID
	L4Tool::CreateModelGaugeImageStreamResource(
		ResourceFile *resource_file,
		const char *model_name,
		NotationFile *model_file,
		const ResourceDirectories *directories
	)
{
	return
		L4GaugeImage::CreateL4GaugeImageStream(
			resource_file,
			model_name,
			model_file,
			directories
		);
}

ResourceDescription::ResourceID
	L4Tool::CreateModelGaugeMissionReviewStreamResource(
		ResourceFile *resource_file,
		const char *model_name,
		NotationFile *model_file,
		const ResourceDirectories */*directories*/
	)
{
	Check(resource_file);
	Check_Pointer(model_name);
	Check(model_file);
	//Check_Pointer(directories);

	ResourceDescription::ResourceID
		res_id = ResourceDescription::NullResourceID;

	//----------------------------------------------------------------------
	// Check to see if the model has a mission review page
	//----------------------------------------------------------------------
	const char
		*pixelmap_name;

	if (
			model_file->GetEntry(
				"gaugeMissionReview",
				"pixelmap",
				&pixelmap_name
			)
		)
	{
		//-------------------------------------------------------------
		// Create a dynamic memory stream, write out the data
		//-------------------------------------------------------------
		DynamicMemoryStream
			*stream = new DynamicMemoryStream();

		Check(stream);
		Register_Object(stream);

		int
			length = strlen(pixelmap_name);
		MemoryStream_Write(stream, &length);

		for( ; length>0; --length, ++pixelmap_name)
		{
			MemoryStream_Write(stream, (char *) pixelmap_name);
		}
		//-------------------------------------------------------------
		// Create the resource description, assign an ID
		//-------------------------------------------------------------
		ResourceDescription
			*res_desc_stream =
					resource_file->ResourceFile::AddResourceMemoryStream(
						model_name,
						ResourceDescription::GaugeMissionReviewStreamResourceType,
						1,
						ResourceDescription::Preload,
						stream
					);

		Check(res_desc_stream);
		res_id = res_desc_stream->resourceID;

		Check(stream);
		Unregister_Object(stream);
		delete stream;

		cout << "GaugeMissionReview res_id = " << res_id << "\n";
	}
	//-------------------------------------------------------------
	// Return the new ResourceID
	//-------------------------------------------------------------
	Check_Fpu();
	return res_id;
}


