/[Sims3RigEditor]/trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h
ViewVC logotype

Diff of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/01 02:44:09	15
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/08/01 04:22:12	19
@@ -1,3 +1,4 @@
+#define SHOW_DEBUG_MENU // if defined, will show the debug menu -> else it will not be shown
 #pragma once
 //#include "gr2lib_core.h"
 //#include "gr2lib_core_imports.h"
@@ -5,6 +6,8 @@
 #define GR2LIB_RIGEDITOR_FRM_H
 #include "grannyfile.h"
 //#include "guicon.h"
+#include "VSDebugOutput.h"
+#include "GrannyFileWriter.h"
 #include <stdio.h>
 #include <iostream>
 #include <stdlib.h>
@@ -113,6 +116,16 @@
 private: System::Windows::Forms::ToolStripMenuItem^  mnuItemOpen;
 private: System::Windows::Forms::ToolStripMenuItem^  mnuItemSave;
 private: System::Windows::Forms::ToolStripMenuItem^  mnuItemSaveAs;
+private: System::Windows::Forms::ToolStripMenuItem^  mnuDebug;
+private: System::Windows::Forms::ToolStripMenuItem^  mnuDebug_UnitTests;
+private: System::Windows::Forms::ToolStripMenuItem^  mnuTestArtToolInfoReturnValues;
+
+private: System::Windows::Forms::OpenFileDialog^  RigLoader;
+private: System::Windows::Forms::ToolStripMenuItem^  mnuTestExporterInfoReturnValues;
+private: System::Windows::Forms::SaveFileDialog^  RigSaver;
+
+
+
 
 protected: 
 
@@ -136,6 +149,12 @@
 		this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
 		this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
 		this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
+		this->mnuDebug = (gcnew System::Windows::Forms::ToolStripMenuItem());
+		this->mnuDebug_UnitTests = (gcnew System::Windows::Forms::ToolStripMenuItem());
+		this->mnuTestArtToolInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
+		this->mnuTestExporterInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
+		this->RigLoader = (gcnew System::Windows::Forms::OpenFileDialog());
+		this->RigSaver = (gcnew System::Windows::Forms::SaveFileDialog());
 		this->mainmenu->SuspendLayout();
 		this->SuspendLayout();
 		// 
@@ -151,7 +170,7 @@
 		// 
 		// mainmenu
 		// 
-		this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->mnuFile});
+		this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->mnuFile, this->mnuDebug});
 		this->mainmenu->Location = System::Drawing::Point(0, 0);
 		this->mainmenu->Name = L"mainmenu";
 		this->mainmenu->Size = System::Drawing::Size(558, 24);
@@ -178,12 +197,14 @@
 		this->mnuItemSave->Name = L"mnuItemSave";
 		this->mnuItemSave->Size = System::Drawing::Size(114, 22);
 		this->mnuItemSave->Text = L"&Save";
+		this->mnuItemSave->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSave_Click);
 		// 
 		// mnuItemSaveAs
 		// 
 		this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
 		this->mnuItemSaveAs->Size = System::Drawing::Size(114, 22);
 		this->mnuItemSaveAs->Text = L"Save &As";
+		this->mnuItemSaveAs->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSaveAs_Click);
 		// 
 		// mnuItemExit
 		// 
@@ -192,6 +213,49 @@
 		this->mnuItemExit->Text = L"&Exit";
 		this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
 		// 
+		// mnuDebug
+		// 
+		this->mnuDebug->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->mnuDebug_UnitTests});
+		this->mnuDebug->Name = L"mnuDebug";
+		this->mnuDebug->Size = System::Drawing::Size(56, 20);
+		this->mnuDebug->Text = L"&DEBUG";
+		// 
+		// mnuDebug_UnitTests
+		// 
+		this->mnuDebug_UnitTests->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->mnuTestArtToolInfoReturnValues, 
+			this->mnuTestExporterInfoReturnValues});
+		this->mnuDebug_UnitTests->Name = L"mnuDebug_UnitTests";
+		this->mnuDebug_UnitTests->Size = System::Drawing::Size(135, 22);
+		this->mnuDebug_UnitTests->Text = L"&Unit Tests...";
+		// 
+		// mnuTestArtToolInfoReturnValues
+		// 
+		this->mnuTestArtToolInfoReturnValues->Name = L"mnuTestArtToolInfoReturnValues";
+		this->mnuTestArtToolInfoReturnValues->Size = System::Drawing::Size(238, 22);
+		this->mnuTestArtToolInfoReturnValues->Text = L"Test ArtoolInfo Rerturn values";
+		this->mnuTestArtToolInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestArtToolInfoReturnValues_Click);
+		// 
+		// mnuTestExporterInfoReturnValues
+		// 
+		this->mnuTestExporterInfoReturnValues->Name = L"mnuTestExporterInfoReturnValues";
+		this->mnuTestExporterInfoReturnValues->Size = System::Drawing::Size(238, 22);
+		this->mnuTestExporterInfoReturnValues->Text = L"Test ExporterInfo Return Values";
+		this->mnuTestExporterInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestExporterInfoReturnValues_Click);
+		// 
+		// RigLoader
+		// 
+		this->RigLoader->DefaultExt = L"gr2";
+		this->RigLoader->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
+		this->RigLoader->SupportMultiDottedExtensions = true;
+		this->RigLoader->Title = L"Please choose the Granny2 Rig file to load";
+		// 
+		// RigSaver
+		// 
+		this->RigSaver->DefaultExt = L"gr2";
+		this->RigSaver->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
+		this->RigSaver->SupportMultiDottedExtensions = true;
+		this->RigSaver->Title = L"Please select the Granny2 Rig to write to or create";
+		// 
 		// gr2lib_rigeditor_frm
 		// 
 		this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
@@ -201,6 +265,7 @@
 		this->Controls->Add(this->mainmenu);
 		this->Name = L"gr2lib_rigeditor_frm";
 		this->Text = L"gr2lib_rigeditor_frm";
+		this->Load += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_Load);
 		this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_FormClosed);
 		this->mainmenu->ResumeLayout(false);
 		this->mainmenu->PerformLayout();
@@ -235,45 +300,49 @@
 	void ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
 	{
 		//GR2LibPropertyWrapper->ArtToolInfo = gcnew ArtToolInfo();
-		// Tool Name
-		GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
+		if (toolinfo != NULL)
+		{
+			GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
 
-		// Tool Vector
-		Vector3* Origin = new Vector3(
-			toolinfo->Origin[0],
-			toolinfo->Origin[1],
-			toolinfo->Origin[2]);
-		Vector3* Right = new Vector3(
-			toolinfo->RightVector[0],
-			toolinfo->RightVector[1],
-			toolinfo->RightVector[2]);
-		Vector3* Up = new Vector3(
-			toolinfo->UpVector[0],
-			toolinfo->UpVector[1],
-			toolinfo->UpVector[2]);
-		Vector3* Back = new Vector3(
-			toolinfo->BackVector[0],
-			toolinfo->BackVector[1],
-			toolinfo->BackVector[2]);
-		GR2LibPropertyWrapper->ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
-
-		// Tool Version
-		GR2LibPropertyWrapper->ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
-		// Tool Units Per Meter
-		GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
+			// Tool Vector
+			Vector3* Origin = new Vector3(
+				toolinfo->Origin[0],
+				toolinfo->Origin[1],
+				toolinfo->Origin[2]);
+			Vector3* Right = new Vector3(
+				toolinfo->RightVector[0],
+				toolinfo->RightVector[1],
+				toolinfo->RightVector[2]);
+			Vector3* Up = new Vector3(
+				toolinfo->UpVector[0],
+				toolinfo->UpVector[1],
+				toolinfo->UpVector[2]);
+			Vector3* Back = new Vector3(
+				toolinfo->BackVector[0],
+				toolinfo->BackVector[1],
+				toolinfo->BackVector[2]);
+			GR2LibPropertyWrapper->ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
+
+			// Tool Version
+			GR2LibPropertyWrapper->ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
+			// Tool Units Per Meter
+			GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
+		}
 	}
 #pragma endregion
 #pragma region ExporterInfo_ToManaged
 	void ExporterInfo_ToManaged(granny_exporter_info* toolinfo)
 	{		
 		//GR2LibPropertyWrapper->ExporterInfo = gcnew ExporterInfo();
-		// Tool Name
-		GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
-		GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
-			toolinfo->ExporterMajorRevision,
-			toolinfo->ExporterMinorRevision,
-			toolinfo->ExporterCustomization,
-			toolinfo->ExporterBuildNumber);
+		if (toolinfo != NULL)
+		{
+			GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
+			GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
+				toolinfo->ExporterMajorRevision,
+				toolinfo->ExporterMinorRevision,
+				toolinfo->ExporterCustomization,
+				toolinfo->ExporterBuildNumber);
+		}
 		//_ExporterInfo->ExtendedData = new IntPtr(toolinfo->ExtendedData.Object);
 	}
 #pragma endregion
@@ -283,6 +352,10 @@
 #pragma region ArtToolInfo_ToNative
 	void ArtToolInfo_ToNative()
 	{
+		if (_grn_file->GrannyFileInfo->ArtToolInfo == NULL)
+		{
+			_grn_file->GrannyFileInfo->ArtToolInfo = new granny_art_tool_info();
+		}
 
 		_grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName).ToPointer();
 		_grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = GR2LibPropertyWrapper->ArtToolInfo->ToolVersion->Major;
@@ -311,6 +384,10 @@
 #pragma region ExporterInfo_ToNative
 	void ExporterInfo_ToNative()
 	{
+		if (_grn_file->GrannyFileInfo->ExporterInfo == NULL)
+		{
+			_grn_file->GrannyFileInfo->ExporterInfo = new granny_exporter_info();
+		}
 		_grn_file->GrannyFileInfo->ExporterInfo->ExporterName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ExporterInfo->ExporterName).ToPointer();
 		_grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->major;
 		_grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->minor;
@@ -329,7 +406,12 @@
 		 }
 private: System::Void mnuItemOpen_Click(System::Object^  sender, System::EventArgs^  e) 
 		 {
-			 const char* fn = "C:\\Program Files\\Granny Viewer\\Gryphon.gr2";
+			 
+
+			 System::Windows::Forms::DialogResult result = RigLoader->ShowDialog();
+			 if (result != System::Windows::Forms::DialogResult::OK) return;
+			 const char* fn = (char*)Marshal::StringToHGlobalAnsi(RigLoader->FileName).ToPointer();
+
 			 _grn_file = new grannyfile();
 			 const char* loading_msg = "Loading File: ";
 			 int msg_malloc = (strlen(loading_msg) + strlen(fn));
@@ -350,6 +432,90 @@
 		 {
 			 //TerminateConsoleIO();
 		 }
+private: System::Void gr2lib_rigeditor_frm_Load(System::Object^  sender, System::EventArgs^  e) 
+		 {
+#if defined SHOW_DEBUG_MENU
+			 mnuDebug->Visible = true;
+#else
+			 mnuDebug->Visible = false;
+#endif
+		 }
+private: System::Void mnuTestArtToolInfoReturnValues_Click(System::Object^  sender, System::EventArgs^  e) 
+		 {
+			 // Convert ArtToolInfo To Native, and ouput the values -> to check that they were updated correctly
+			 ArtToolInfo_ToNative();
+			 VSDebugWriterW VSDebugWriter;
+			 VSDebugWriter 
+				 << "\n\n\tArtToolInfo ->"
+				 << "\n\t\tTool Name: " 
+					<< _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName
+				 << "\n\t\tTool Version: " 
+					<<  _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision 
+					<< "." << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision
+				<< "\n\t\tUnits Per Meter: " 
+					<<  _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter
+				<< "\n\t\tOrigin: " 
+					<< "\n\t\t\tX: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0]
+					<< "\n\t\t\tY: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1]
+					<< "\n\t\t\tZ: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]
+				<< "\n\t\tRight: " 
+					<< "\n\t\t\tX: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0]
+					<< "\n\t\t\tY: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1]
+					<< "\n\t\t\tZ: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]
+				<< "\n\t\tUp: " 
+					<< "\n\t\t\tX: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0]
+					<< "\n\t\t\tY: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1]
+					<< "\n\t\t\tZ: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]
+				<< "\n\t\tBack: " 
+					<< "\n\t\t\tX: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0]
+					<< "\n\t\t\tY: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1]
+					<< "\n\t\t\tZ: " 
+						<< _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]
+			 ;
+		 }
+private: System::Void mnuTestExporterInfoReturnValues_Click(System::Object^  sender, System::EventArgs^  e) 
+		 {
+			  // Convert ExporterInfo To Native, and ouput the values -> to check that they were updated correctly
+			ExporterInfo_ToNative();
+			 VSDebugWriterW VSDebugWriter;
+			 VSDebugWriter 
+				 << "\n\n\tExporterInfo ->"
+				 << "\n\t\tExporter Name: " 
+					<<  _grn_file->GrannyFileInfo->ExporterInfo->ExporterName
+				 << "\n\t\tExporter Version: " 
+					<< _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision 
+					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision
+					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization
+					<< "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber
+					;
+		 }
+private: System::Void mnuItemSave_Click(System::Object^  sender, System::EventArgs^  e) 
+		 {
+			 // convert Data to Native
+			 ConvertToNative();
+			 const char* filename = _grn_file->_GrannyFilename;
+			 GrannyFileWriter::WriteGrannyFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
+		 }
+private: System::Void mnuItemSaveAs_Click(System::Object^  sender, System::EventArgs^  e)
+		 {
+			  // convert Data to Native
+			 ConvertToNative();
+			 System::Windows::Forms::DialogResult result = RigSaver->ShowDialog();
+			 if (result != System::Windows::Forms::DialogResult::OK) return;
+			 const char* filename = (char*)Marshal::StringToHGlobalAnsi(RigSaver->FileName).ToPointer();
+			 GrannyFileWriter::WriteGrannyFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);			  
+		 }
 };
 //		}
 //	}

 

  ViewVC Help
Powered by ViewVC 1.1.22