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

Annotation of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations) (download)
Sat Jul 31 01:44:00 2010 UTC (9 years, 7 months ago) by william
File MIME type: text/plain
File size: 10287 byte(s)
commit - header redesign -- actually compiles now.

** Have some issues with loading for granny files, will fix in subsequent commits...

1 william 5 #pragma once
2 william 7 //#include "gr2lib_core.h"
3     //#include "gr2lib_core_imports.h"
4     #ifndef GR2LIB_RIGEDITOR_FRM_H
5     #define GR2LIB_RIGEDITOR_FRM_H
6     #include "grannyfile.h"
7     #include <stdio.h>
8     #include <iostream>
9     #include <stdlib.h>
10     #include <assert.h>
11     #include <string>
12     #include <sstream>
13     using namespace std;
14 william 5
15 william 7 using namespace gr2lib::core;
16     using namespace gr2lib::core::coretypes::implementation;
17    
18 william 5 using namespace System;
19     using namespace System::ComponentModel;
20     using namespace System::Collections;
21     using namespace System::Collections::Generic;
22     using namespace System::Windows::Forms;
23     using namespace System::Data;
24     using namespace System::Drawing;
25 william 6 using namespace System::Runtime::InteropServices;
26     //
27     //namespace gr2lib
28     //{
29     // namespace core
30     // {
31     // namespace rigeditor
32     // {
33 william 5 /// <summary>
34     /// Summary for gr2lib_rigeditor_frm
35     ///
36     /// WARNING: If you change the name of this class, you will need to change the
37     /// 'Resource File Name' property for the managed resource compiler tool
38     /// associated with all .resx files this class depends on. Otherwise,
39     /// the designers will not be able to interact properly with localized
40     /// resources associated with this form.
41     /// </summary>
42     public ref class gr2lib_rigeditor_frm : public System::Windows::Forms::Form
43     {
44 william 7 private:
45 william 6 grannyfile* _grn_file;
46 william 5 public:
47     gr2lib_rigeditor_frm(void)
48     {
49     InitializeComponent();
50     //
51     //TODO: Add the constructor code here
52     //
53     }
54     gr2lib_rigeditor_frm(grannyfile* grn_file)
55     {
56     InitializeComponent();
57     // parse art tool info
58 william 6 _grn_file = grn_file;
59     propgrid->SelectedObjects = ConvertToManaged();
60    
61 william 5 }
62    
63     protected:
64     /// <summary>
65     /// Clean up any resources being used.
66     /// </summary>
67     ~gr2lib_rigeditor_frm()
68     {
69     if (components)
70     {
71     delete components;
72     }
73     }
74     private: System::Windows::Forms::PropertyGrid^ propgrid;
75     protected:
76 william 6 private: System::Windows::Forms::MenuStrip^ mainmenu;
77     private: System::Windows::Forms::ToolStripMenuItem^ mnuFile;
78     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemExit;
79     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemOpen;
80     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSave;
81     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSaveAs;
82 william 5
83 william 6 protected:
84    
85 william 5 private:
86     /// <summary>
87     /// Required designer variable.
88     /// </summary>
89     System::ComponentModel::Container ^components;
90    
91     #pragma region Windows Form Designer generated code
92     /// <summary>
93     /// Required method for Designer support - do not modify
94     /// the contents of this method with the code editor.
95     /// </summary>
96     void InitializeComponent(void)
97     {
98     this->propgrid = (gcnew System::Windows::Forms::PropertyGrid());
99 william 6 this->mainmenu = (gcnew System::Windows::Forms::MenuStrip());
100     this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
101     this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
102     this->mnuItemOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
103     this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
104     this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
105     this->mainmenu->SuspendLayout();
106 william 5 this->SuspendLayout();
107     //
108     // propgrid
109     //
110     this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
111 william 6 this->propgrid->Location = System::Drawing::Point(0, 24);
112 william 5 this->propgrid->Name = L"propgrid";
113 william 6 this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
114     this->propgrid->Size = System::Drawing::Size(558, 456);
115     this->propgrid->TabIndex = 4;
116     this->propgrid->ToolbarVisible = false;
117 william 5 //
118 william 6 // mainmenu
119     //
120     this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuFile});
121     this->mainmenu->Location = System::Drawing::Point(0, 0);
122     this->mainmenu->Name = L"mainmenu";
123     this->mainmenu->Size = System::Drawing::Size(558, 24);
124     this->mainmenu->TabIndex = 3;
125     this->mainmenu->Text = L"menuStrip1";
126     //
127     // mnuFile
128     //
129     this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->mnuItemOpen,
130     this->mnuItemSave, this->mnuItemSaveAs, this->mnuItemExit});
131     this->mnuFile->Name = L"mnuFile";
132     this->mnuFile->Size = System::Drawing::Size(37, 20);
133     this->mnuFile->Text = L"&File";
134     //
135     // mnuItemExit
136     //
137     this->mnuItemExit->Name = L"mnuItemExit";
138     this->mnuItemExit->Size = System::Drawing::Size(152, 22);
139     this->mnuItemExit->Text = L"&Exit";
140     this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
141     //
142     // mnuItemOpen
143     //
144     this->mnuItemOpen->Name = L"mnuItemOpen";
145     this->mnuItemOpen->Size = System::Drawing::Size(152, 22);
146     this->mnuItemOpen->Text = L"&Open";
147     this->mnuItemOpen->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemOpen_Click);
148     //
149     // mnuItemSave
150     //
151     this->mnuItemSave->Name = L"mnuItemSave";
152     this->mnuItemSave->Size = System::Drawing::Size(152, 22);
153     this->mnuItemSave->Text = L"&Save";
154     //
155     // mnuItemSaveAs
156     //
157     this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
158     this->mnuItemSaveAs->Size = System::Drawing::Size(152, 22);
159     this->mnuItemSaveAs->Text = L"Save &As";
160     //
161 william 5 // gr2lib_rigeditor_frm
162     //
163     this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
164     this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
165 william 6 this->ClientSize = System::Drawing::Size(558, 480);
166 william 5 this->Controls->Add(this->propgrid);
167 william 6 this->Controls->Add(this->mainmenu);
168 william 5 this->Name = L"gr2lib_rigeditor_frm";
169     this->Text = L"gr2lib_rigeditor_frm";
170 william 6 this->mainmenu->ResumeLayout(false);
171     this->mainmenu->PerformLayout();
172 william 5 this->ResumeLayout(false);
173 william 6 this->PerformLayout();
174 william 5
175     }
176     #pragma endregion
177 william 6 #pragma region MarshalToMananaged
178     ArtToolInfo^ _ArtToolInfo;
179    
180     #pragma region ManagedNativeParsing
181     array<Object^>^ ConvertToManaged()
182     {
183     List<Object^> ret = gcnew List<Object^>();
184    
185     // Art Tool info
186     ret.Add(ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo));
187    
188     return ret.ToArray();
189     }
190     void ConvertToNative()
191     {
192     // Art Tool info
193     ArtToolInfo_ToNative();
194     }
195     #pragma endregion
196    
197     #pragma region ArtToolInfo
198     ArtToolInfo^ ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
199     {
200     _ArtToolInfo = gcnew ArtToolInfo();
201     // Tool Name
202     _ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
203    
204     // Tool Vector
205     Vector3* Origin = new Vector3(
206     toolinfo->Origin[0],
207     toolinfo->Origin[1],
208     toolinfo->Origin[2]);
209     Vector3* Right = new Vector3(
210     toolinfo->RightVector[0],
211     toolinfo->RightVector[1],
212     toolinfo->RightVector[2]);
213     Vector3* Up = new Vector3(
214     toolinfo->UpVector[0],
215     toolinfo->UpVector[1],
216     toolinfo->UpVector[2]);
217     Vector3* Back = new Vector3(
218     toolinfo->BackVector[0],
219     toolinfo->BackVector[1],
220     toolinfo->BackVector[2]);
221     _ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
222    
223     // Tool Version
224     _ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
225     // Tool Units Per Meter
226     _ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
227     return _ArtToolInfo;
228     }
229     #pragma endregion
230    
231     #pragma region MarshalToNative
232    
233     #pragma region ArtToolInfo
234     void ArtToolInfo_ToNative()
235     {
236    
237     _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(_ArtToolInfo->FromArtToolName).ToPointer();
238     _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = _ArtToolInfo->ToolVersion->Major;
239     _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision = _ArtToolInfo->ToolVersion->Minor;
240     _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter = _ArtToolInfo->UnitsPerMeter;
241    
242    
243     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0] = _ArtToolInfo->Vector->Origin.x;
244     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1] = _ArtToolInfo->Vector->Origin.y;
245     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2] = _ArtToolInfo->Vector->Origin.z;
246    
247     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0] = _ArtToolInfo->Vector->Right.x;
248     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1] = _ArtToolInfo->Vector->Right.y;
249     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2] = _ArtToolInfo->Vector->Right.z;
250    
251     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0] = _ArtToolInfo->Vector->Up.x;
252     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1] = _ArtToolInfo->Vector->Up.y;
253     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2] = _ArtToolInfo->Vector->Up.z;
254    
255     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0] = _ArtToolInfo->Vector->Back.x;
256     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = _ArtToolInfo->Vector->Back.y;
257     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = _ArtToolInfo->Vector->Back.z;
258    
259     }
260     #pragma endregion
261    
262     #pragma endregion
263    
264     #pragma endregion
265     private: System::Void mnuItemExit_Click(System::Object^ sender, System::EventArgs^ e)
266     {
267     ConvertToNative();
268     this->Close();
269     }
270     private: System::Void mnuItemOpen_Click(System::Object^ sender, System::EventArgs^ e)
271     {
272     _grn_file = new grannyfile("C:\\Program Files\\Granny Viewer\\Gryphon.gr2");
273     propgrid->SelectedObjects = ConvertToManaged();
274     }
275     };
276     // }
277     // }
278 william 7 //}
279     #endif /* GR2LIB_RIGEDITOR_FRM_H */

  ViewVC Help
Powered by ViewVC 1.1.22