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

Contents of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (show annotations) (download)
Sun Aug 1 06:33:06 2010 UTC (9 years, 6 months ago) by william
File MIME type: text/plain
File size: 26114 byte(s)
Add Support to Convert Texture List to Managed...
Still need to implement support to convert managed texture list to native

1 #define SHOW_DEBUG_MENU // if defined, will show the debug menu -> else it will not be shown
2 #pragma once
3 //#include "gr2lib_core.h"
4 //#include "gr2lib_core_imports.h"
5 #ifndef GR2LIB_RIGEDITOR_FRM_H
6 #define GR2LIB_RIGEDITOR_FRM_H
7 #include "grannyfile.h"
8 //#include "guicon.h"
9 #include "VSDebugOutput.h"
10 #include "GrannyFileWriter.h"
11 #include <stdio.h>
12 #include <iostream>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <string>
16 #include <sstream>
17 #include <vcclr.h>
18 using namespace std;
19
20 using namespace gr2lib::core;
21 using namespace gr2lib::core::coretypes::implementation;
22 using namespace gr2lib::core::apiversion;
23 using namespace gr2lib::core::ui::helpers;
24 using namespace gr2lib::core::helpers;
25 using namespace System;
26 using namespace System::ComponentModel;
27 using namespace System::Collections;
28 using namespace System::Collections::Generic;
29 using namespace System::Windows::Forms;
30 using namespace System::Data;
31 using namespace System::Drawing;
32 using namespace System::Runtime::InteropServices;
33 //
34 //namespace gr2lib
35 //{
36 // namespace core
37 // {
38 // namespace rigeditor
39 // {
40 /// <summary>
41 /// Summary for gr2lib_rigeditor_frm
42 ///
43 /// WARNING: If you change the name of this class, you will need to change the
44 /// 'Resource File Name' property for the managed resource compiler tool
45 /// associated with all .resx files this class depends on. Otherwise,
46 /// the designers will not be able to interact properly with localized
47 /// resources associated with this form.
48 /// </summary>
49 public ref class gr2lib_rigeditor_frm : public System::Windows::Forms::Form
50 {
51 private:
52 grannyfile* _grn_file;
53 void LogApplicationStartup()
54 {
55 const char* ApplicationName = "GR2Lib Rig Editor: ";
56
57 const char* product_version = (char*)(void*)Marshal::StringToHGlobalAnsi(Application::ProductVersion);
58 const char* version_prefix = "v";
59 const char* startup_string = " {Starting up...}";
60
61
62 int msg_malloc = (strlen(ApplicationName) + strlen(product_version) + strlen(version_prefix) + strlen(startup_string)) + 3;
63
64 char* msg = (char*)malloc(msg_malloc);
65 for (int i=0; i<msg_malloc; i++) {
66 msg[i] = 0; // Initialize all elements to zero.
67 }
68
69 strcat(msg,ApplicationName);
70 strcat(msg,version_prefix);
71 strcat(msg,product_version);
72 strcat(msg,startup_string);
73 strcat(msg,"\n");
74 _grn_file->_logger->LogMessage(msg);
75 }
76 public:
77 gr2lib_rigeditor_frm(void)
78 {
79 InitializeComponent();
80 _grn_file = new grannyfile();
81 //
82 //TODO: Add the constructor code here
83 //
84 // Log Application Startup
85 LogApplicationStartup();
86 }
87 gr2lib_rigeditor_frm(grannyfile* grn_file)
88 {
89 InitializeComponent();
90 // parse art tool info
91 _grn_file = grn_file;
92
93 // Log Application Startup
94 LogApplicationStartup();
95
96 this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
97 ConvertToManaged();
98 propgrid->SelectedObject = this->GR2LibPropertyWrapper;
99
100 }
101
102 protected:
103 /// <summary>
104 /// Clean up any resources being used.
105 /// </summary>
106 ~gr2lib_rigeditor_frm()
107 {
108 if (components)
109 {
110 delete components;
111 }
112 }
113 private: System::Windows::Forms::PropertyGrid^ propgrid;
114 protected:
115 private: System::Windows::Forms::MenuStrip^ mainmenu;
116 private: System::Windows::Forms::ToolStripMenuItem^ mnuFile;
117 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemExit;
118 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemOpen;
119 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSave;
120 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSaveAs;
121 private: System::Windows::Forms::ToolStripMenuItem^ mnuDebug;
122 private: System::Windows::Forms::ToolStripMenuItem^ mnuDebug_UnitTests;
123 private: System::Windows::Forms::ToolStripMenuItem^ mnuTestArtToolInfoReturnValues;
124
125 private: System::Windows::Forms::OpenFileDialog^ RigLoader;
126 private: System::Windows::Forms::ToolStripMenuItem^ mnuTestExporterInfoReturnValues;
127 private: System::Windows::Forms::SaveFileDialog^ RigSaver;
128
129
130
131
132 protected:
133
134 private:
135 /// <summary>
136 /// Required designer variable.
137 /// </summary>
138 System::ComponentModel::Container ^components;
139
140 #pragma region Windows Form Designer generated code
141 /// <summary>
142 /// Required method for Designer support - do not modify
143 /// the contents of this method with the code editor.
144 /// </summary>
145 void InitializeComponent(void)
146 {
147 this->propgrid = (gcnew System::Windows::Forms::PropertyGrid());
148 this->mainmenu = (gcnew System::Windows::Forms::MenuStrip());
149 this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
150 this->mnuItemOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
151 this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
152 this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
153 this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
154 this->mnuDebug = (gcnew System::Windows::Forms::ToolStripMenuItem());
155 this->mnuDebug_UnitTests = (gcnew System::Windows::Forms::ToolStripMenuItem());
156 this->mnuTestArtToolInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
157 this->mnuTestExporterInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
158 this->RigLoader = (gcnew System::Windows::Forms::OpenFileDialog());
159 this->RigSaver = (gcnew System::Windows::Forms::SaveFileDialog());
160 this->mainmenu->SuspendLayout();
161 this->SuspendLayout();
162 //
163 // propgrid
164 //
165 this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
166 this->propgrid->Location = System::Drawing::Point(0, 24);
167 this->propgrid->Name = L"propgrid";
168 this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
169 this->propgrid->Size = System::Drawing::Size(558, 456);
170 this->propgrid->TabIndex = 4;
171 this->propgrid->ToolbarVisible = false;
172 //
173 // mainmenu
174 //
175 this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuFile, this->mnuDebug});
176 this->mainmenu->Location = System::Drawing::Point(0, 0);
177 this->mainmenu->Name = L"mainmenu";
178 this->mainmenu->Size = System::Drawing::Size(558, 24);
179 this->mainmenu->TabIndex = 3;
180 this->mainmenu->Text = L"menuStrip1";
181 //
182 // mnuFile
183 //
184 this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->mnuItemOpen,
185 this->mnuItemSave, this->mnuItemSaveAs, this->mnuItemExit});
186 this->mnuFile->Name = L"mnuFile";
187 this->mnuFile->Size = System::Drawing::Size(37, 20);
188 this->mnuFile->Text = L"&File";
189 //
190 // mnuItemOpen
191 //
192 this->mnuItemOpen->Name = L"mnuItemOpen";
193 this->mnuItemOpen->Size = System::Drawing::Size(114, 22);
194 this->mnuItemOpen->Text = L"&Open";
195 this->mnuItemOpen->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemOpen_Click);
196 //
197 // mnuItemSave
198 //
199 this->mnuItemSave->Name = L"mnuItemSave";
200 this->mnuItemSave->Size = System::Drawing::Size(114, 22);
201 this->mnuItemSave->Text = L"&Save";
202 this->mnuItemSave->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSave_Click);
203 //
204 // mnuItemSaveAs
205 //
206 this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
207 this->mnuItemSaveAs->Size = System::Drawing::Size(114, 22);
208 this->mnuItemSaveAs->Text = L"Save &As";
209 this->mnuItemSaveAs->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSaveAs_Click);
210 //
211 // mnuItemExit
212 //
213 this->mnuItemExit->Name = L"mnuItemExit";
214 this->mnuItemExit->Size = System::Drawing::Size(114, 22);
215 this->mnuItemExit->Text = L"&Exit";
216 this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
217 //
218 // mnuDebug
219 //
220 this->mnuDebug->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuDebug_UnitTests});
221 this->mnuDebug->Name = L"mnuDebug";
222 this->mnuDebug->Size = System::Drawing::Size(56, 20);
223 this->mnuDebug->Text = L"&DEBUG";
224 //
225 // mnuDebug_UnitTests
226 //
227 this->mnuDebug_UnitTests->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuTestArtToolInfoReturnValues,
228 this->mnuTestExporterInfoReturnValues});
229 this->mnuDebug_UnitTests->Name = L"mnuDebug_UnitTests";
230 this->mnuDebug_UnitTests->Size = System::Drawing::Size(135, 22);
231 this->mnuDebug_UnitTests->Text = L"&Unit Tests...";
232 //
233 // mnuTestArtToolInfoReturnValues
234 //
235 this->mnuTestArtToolInfoReturnValues->Name = L"mnuTestArtToolInfoReturnValues";
236 this->mnuTestArtToolInfoReturnValues->Size = System::Drawing::Size(238, 22);
237 this->mnuTestArtToolInfoReturnValues->Text = L"Test ArtoolInfo Rerturn values";
238 this->mnuTestArtToolInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestArtToolInfoReturnValues_Click);
239 //
240 // mnuTestExporterInfoReturnValues
241 //
242 this->mnuTestExporterInfoReturnValues->Name = L"mnuTestExporterInfoReturnValues";
243 this->mnuTestExporterInfoReturnValues->Size = System::Drawing::Size(238, 22);
244 this->mnuTestExporterInfoReturnValues->Text = L"Test ExporterInfo Return Values";
245 this->mnuTestExporterInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestExporterInfoReturnValues_Click);
246 //
247 // RigLoader
248 //
249 this->RigLoader->DefaultExt = L"gr2";
250 this->RigLoader->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
251 this->RigLoader->SupportMultiDottedExtensions = true;
252 this->RigLoader->Title = L"Please choose the Granny2 Rig file to load";
253 //
254 // RigSaver
255 //
256 this->RigSaver->DefaultExt = L"gr2";
257 this->RigSaver->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
258 this->RigSaver->SupportMultiDottedExtensions = true;
259 this->RigSaver->Title = L"Please select the Granny2 Rig to write to or create";
260 //
261 // gr2lib_rigeditor_frm
262 //
263 this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
264 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
265 this->ClientSize = System::Drawing::Size(558, 480);
266 this->Controls->Add(this->propgrid);
267 this->Controls->Add(this->mainmenu);
268 this->Name = L"gr2lib_rigeditor_frm";
269 this->Text = L"gr2lib_rigeditor_frm";
270 this->Load += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_Load);
271 this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_FormClosed);
272 this->mainmenu->ResumeLayout(false);
273 this->mainmenu->PerformLayout();
274 this->ResumeLayout(false);
275 this->PerformLayout();
276
277 }
278 #pragma endregion
279 #pragma region MarshalToMananaged
280 //ArtToolInfo^ _ArtToolInfo;
281 //ExporterInfo^ _ExporterInfo;
282 GR2LibWrapper^ GR2LibPropertyWrapper;
283
284 #pragma region ManagedNativeParsing
285 void ConvertToManaged()
286 {
287 // Art Tool info
288 ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo);
289 // Exporter Info
290 ExporterInfo_ToManaged(_grn_file->GrannyFileInfo->ExporterInfo);
291 // Texture List
292 Textures_ToManaged(_grn_file->GrannyFileInfo->Textures,_grn_file->GrannyFileInfo->TextureCount);
293 }
294 void ConvertToNative()
295 {
296 // Art Tool info
297 ArtToolInfo_ToNative();
298 // Exporter Info
299 ExporterInfo_ToNative();
300 }
301 #pragma endregion
302
303 #pragma region ArtToolInfo_ToManaged
304 void ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
305 {
306 //GR2LibPropertyWrapper->ArtToolInfo = gcnew ArtToolInfo();
307 if (toolinfo != NULL)
308 {
309 GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
310
311 // Tool Vector
312 Vector3* Origin = new Vector3(
313 toolinfo->Origin[0],
314 toolinfo->Origin[1],
315 toolinfo->Origin[2]);
316 Vector3* Right = new Vector3(
317 toolinfo->RightVector[0],
318 toolinfo->RightVector[1],
319 toolinfo->RightVector[2]);
320 Vector3* Up = new Vector3(
321 toolinfo->UpVector[0],
322 toolinfo->UpVector[1],
323 toolinfo->UpVector[2]);
324 Vector3* Back = new Vector3(
325 toolinfo->BackVector[0],
326 toolinfo->BackVector[1],
327 toolinfo->BackVector[2]);
328 GR2LibPropertyWrapper->ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
329
330 // Tool Version
331 GR2LibPropertyWrapper->ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
332 // Tool Units Per Meter
333 GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
334 }
335 }
336 #pragma endregion
337 #pragma region ExporterInfo_ToManaged
338 void ExporterInfo_ToManaged(granny_exporter_info* toolinfo)
339 {
340 //GR2LibPropertyWrapper->ExporterInfo = gcnew ExporterInfo();
341 if (toolinfo != NULL)
342 {
343 GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
344 GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
345 toolinfo->ExporterMajorRevision,
346 toolinfo->ExporterMinorRevision,
347 toolinfo->ExporterCustomization,
348 toolinfo->ExporterBuildNumber);
349 }
350 //_ExporterInfo->ExtendedData = new IntPtr(toolinfo->ExtendedData.Object);
351 }
352 #pragma endregion
353 #pragma region Textures_ToManaged
354 void Textures_ToManaged(granny_texture** toolinfo, granny_int32 TextureCount)
355 {
356 if (toolinfo != NULL)
357 {
358 /*GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
359 GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
360 toolinfo->ExporterMajorRevision,
361 toolinfo->ExporterMinorRevision,
362 toolinfo->ExporterCustomization,
363 toolinfo->ExporterBuildNumber);*/
364 GR2LibPropertyWrapper->Textures = gcnew List<Texture^>();
365 for(int i=0;i<TextureCount;i++)
366 {
367 Texture^ t = gcnew Texture();
368 t->FromFileName = gcnew FilePath(gcnew String(reinterpret_cast<const char*>(toolinfo[i]->FromFileName)));
369 t->TextureType = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_type>(
370 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_type>(
371 (gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType),
372 (gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType);
373 t->Width = toolinfo[i]->Width;
374 t->Height = toolinfo[i]->Height;
375 t->Encoding = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_encoding>(
376 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_encoding>(
377 (gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding),
378 (gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding);
379 t->SubFormat = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_pixel_layout>(
380 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_pixel_layout>(
381 (gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat),
382 (gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat);
383 t->Layout = gcnew gr2lib::core::coretypes::implementation::Layout();
384 t->Layout->BytesPerPixel = toolinfo[i]->Layout.BytesPerPixel;
385 for(int j=0;j<4;j++)
386 {
387 t->Layout->ShiftForComponent[j] = toolinfo[i]->Layout.ShiftForComponent[j];
388 t->Layout->BitsForComponent[j] = toolinfo[i]->Layout.BitsForComponent[j];
389 }
390
391 t->Images = gcnew List<gr2lib::core::coretypes::implementation::Image^>();
392 for(int j=0;j<toolinfo[i]->ImageCount;j++)
393 {
394 gr2lib::core::coretypes::implementation::Image^ img = gcnew gr2lib::core::coretypes::implementation::Image();
395 img->MIPLevels = gcnew List<gr2lib::core::coretypes::implementation::MIPLevel^>();
396
397 for(int k=0;k<toolinfo[i]->Images[j].MIPLevelCount;k++)
398 {
399 gr2lib::core::coretypes::implementation::MIPLevel^ mip = gcnew gr2lib::core::coretypes::implementation::MIPLevel();
400 mip->Stride = toolinfo[i]->Images[j].MIPLevels[k].Stride;
401 mip->Pixels = gcnew List<gr2lib::core::coretypes::implementation::Pixel^>();
402
403 unsigned char* bytes = (unsigned char*)malloc(toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount);
404 for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
405 {
406 bytes[l] =0;
407 }
408 bytes = (unsigned char*)toolinfo[i]->Images[j].MIPLevels[k].PixelBytes;
409
410 for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
411 {
412 gr2lib::core::coretypes::implementation::Pixel^ pix = gcnew gr2lib::core::coretypes::implementation::Pixel();
413 pix->UInt8 = bytes[l];
414 pix->ReferenceTexture =t;
415 mip->Pixels->Add(pix);
416 }
417
418 img->MIPLevels->Add(mip);
419 }
420
421 t->Images->Add(img);
422 t->NativePointer = *(new IntPtr(toolinfo[i]));
423 }
424 GR2LibPropertyWrapper->Textures->Add(t);
425 }
426 }
427 }
428 #pragma endregion
429
430 #pragma region MarshalToNative
431
432 #pragma region ArtToolInfo_ToNative
433 void ArtToolInfo_ToNative()
434 {
435 if (_grn_file->GrannyFileInfo->ArtToolInfo == NULL)
436 {
437 _grn_file->GrannyFileInfo->ArtToolInfo = new granny_art_tool_info();
438 }
439
440 _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName).ToPointer();
441 _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = GR2LibPropertyWrapper->ArtToolInfo->ToolVersion->Major;
442 _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision = GR2LibPropertyWrapper->ArtToolInfo->ToolVersion->Minor;
443 _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter = GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter;
444
445
446 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.x;
447 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.y;
448 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.z;
449
450 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.x;
451 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.y;
452 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.z;
453
454 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.x;
455 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.y;
456 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.z;
457
458 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.x;
459 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.y;
460 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.z;
461
462 }
463 #pragma endregion
464 #pragma region ExporterInfo_ToNative
465 void ExporterInfo_ToNative()
466 {
467 if (_grn_file->GrannyFileInfo->ExporterInfo == NULL)
468 {
469 _grn_file->GrannyFileInfo->ExporterInfo = new granny_exporter_info();
470 }
471 _grn_file->GrannyFileInfo->ExporterInfo->ExporterName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ExporterInfo->ExporterName).ToPointer();
472 _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->major;
473 _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->minor;
474 _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization = GR2LibPropertyWrapper->ExporterInfo->Version->customization;
475 _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber = GR2LibPropertyWrapper->ExporterInfo->Version->build;
476 //_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData
477 }
478 #pragma endregion
479 #pragma region Textures_ToNative
480 void Textures_ToNative()
481 {
482 if (_grn_file->GrannyFileInfo->Textures == NULL)
483 {
484 _grn_file->GrannyFileInfo->Textures = new granny_texture*();
485 }
486 //_grn_file->GrannyFileInfo->ExporterInfo->ExporterName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ExporterInfo->ExporterName).ToPointer();
487 //_grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->major;
488 //_grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->minor;
489 //_grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization = GR2LibPropertyWrapper->ExporterInfo->Version->customization;
490 //_grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber = GR2LibPropertyWrapper->ExporterInfo->Version->build;
491 ////_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData
492 }
493 #pragma endregion
494 #pragma endregion
495
496 #pragma endregion
497 private: System::Void mnuItemExit_Click(System::Object^ sender, System::EventArgs^ e)
498 {
499 ConvertToNative();
500 this->Close();
501 }
502 private: System::Void mnuItemOpen_Click(System::Object^ sender, System::EventArgs^ e)
503 {
504
505
506 System::Windows::Forms::DialogResult result = RigLoader->ShowDialog();
507 if (result != System::Windows::Forms::DialogResult::OK) return;
508 const char* fn = (char*)Marshal::StringToHGlobalAnsi(RigLoader->FileName).ToPointer();
509
510 _grn_file = new grannyfile();
511 const char* loading_msg = "Loading File: ";
512 int msg_malloc = (strlen(loading_msg) + strlen(fn));
513 char* msg = (char*)malloc(msg_malloc);
514 for (int i=0; i<msg_malloc; i++) { msg[i] = 0; }
515 strcat(msg,loading_msg);
516 strcat(msg,fn);
517 strcat(msg,"\n");
518 _grn_file->_logger->LogMessage(msg);
519 //_grn_file->_logger->SetLogFileName("c:\\gr2_logs",fn);
520 _grn_file = new grannyfile(fn);
521
522 this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
523 ConvertToManaged();
524 propgrid->SelectedObject = this->GR2LibPropertyWrapper;
525 }
526 private: System::Void gr2lib_rigeditor_frm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)
527 {
528 //TerminateConsoleIO();
529 }
530 private: System::Void gr2lib_rigeditor_frm_Load(System::Object^ sender, System::EventArgs^ e)
531 {
532 #if defined SHOW_DEBUG_MENU
533 mnuDebug->Visible = true;
534 #else
535 mnuDebug->Visible = false;
536 #endif
537 }
538 private: System::Void mnuTestArtToolInfoReturnValues_Click(System::Object^ sender, System::EventArgs^ e)
539 {
540 // Convert ArtToolInfo To Native, and ouput the values -> to check that they were updated correctly
541 ArtToolInfo_ToNative();
542 VSDebugWriterW VSDebugWriter;
543 VSDebugWriter
544 << "\n\n\tArtToolInfo ->"
545 << "\n\t\tTool Name: "
546 << _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName
547 << "\n\t\tTool Version: "
548 << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision
549 << "." << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision
550 << "\n\t\tUnits Per Meter: "
551 << _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter
552 << "\n\t\tOrigin: "
553 << "\n\t\t\tX: "
554 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0]
555 << "\n\t\t\tY: "
556 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1]
557 << "\n\t\t\tZ: "
558 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]
559 << "\n\t\tRight: "
560 << "\n\t\t\tX: "
561 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0]
562 << "\n\t\t\tY: "
563 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1]
564 << "\n\t\t\tZ: "
565 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]
566 << "\n\t\tUp: "
567 << "\n\t\t\tX: "
568 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0]
569 << "\n\t\t\tY: "
570 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1]
571 << "\n\t\t\tZ: "
572 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]
573 << "\n\t\tBack: "
574 << "\n\t\t\tX: "
575 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0]
576 << "\n\t\t\tY: "
577 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1]
578 << "\n\t\t\tZ: "
579 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]
580 ;
581 }
582 private: System::Void mnuTestExporterInfoReturnValues_Click(System::Object^ sender, System::EventArgs^ e)
583 {
584 // Convert ExporterInfo To Native, and ouput the values -> to check that they were updated correctly
585 ExporterInfo_ToNative();
586 VSDebugWriterW VSDebugWriter;
587 VSDebugWriter
588 << "\n\n\tExporterInfo ->"
589 << "\n\t\tExporter Name: "
590 << _grn_file->GrannyFileInfo->ExporterInfo->ExporterName
591 << "\n\t\tExporter Version: "
592 << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision
593 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision
594 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization
595 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber
596 ;
597 }
598 private: System::Void mnuItemSave_Click(System::Object^ sender, System::EventArgs^ e)
599 {
600 // convert Data to Native
601 ConvertToNative();
602 const char* filename = _grn_file->_GrannyFilename;
603 GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
604 }
605 private: System::Void mnuItemSaveAs_Click(System::Object^ sender, System::EventArgs^ e)
606 {
607 // convert Data to Native
608 ConvertToNative();
609 System::Windows::Forms::DialogResult result = RigSaver->ShowDialog();
610 if (result != System::Windows::Forms::DialogResult::OK) return;
611 const char* filename = (char*)Marshal::StringToHGlobalAnsi(RigSaver->FileName).ToPointer();
612 GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
613 }
614 };
615 // }
616 // }
617 //}
618 #endif /* GR2LIB_RIGEDITOR_FRM_H */

  ViewVC Help
Powered by ViewVC 1.1.22