Subversion Repositories spk

Rev

Rev 31 | Rev 116 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31 Rev 36
Line 19... Line 19...
19
	///          the designers will not be able to interact properly with localized
19
	///          the designers will not be able to interact properly with localized
20
	///          resources associated with this form.
20
	///          resources associated with this form.
21
	/// </summary>
21
	/// </summary>
22
	public ref class ImportShip : public System::Windows::Forms::Form
22
	public ref class ImportShip : public System::Windows::Forms::Form
23
	{
23
	{
-
 
24
	private:
-
 
25
		int				 m_iStatus;
-
 
26
		bool			 m_bError;
-
 
27
		CyStringList	*m_lModels;
-
 
28
		CProgressInfo	*m_pInfo;
-
 
29
		String			^m_sID;
-
 
30
		CXspFile		*m_pShip;
-
 
31
		String			^m_sError;
-
 
32
		CVirtualFileSystem *m_pVfs;
-
 
33
 
24
	public:
34
	public:
25
		ImportShip(CPackages *p, String ^cat, String ^id, String ^secondCat)
35
		ImportShip(String ^id, CVirtualFileSystem *vfs);
26
		{
-
 
27
			InitializeComponent();
-
 
28
 
-
 
29
			this->Text = this->Text + " (" + id + ")";
-
 
30
 
-
 
31
			this->button1->Visible = false;
-
 
32
			this->pictureBox1->Visible = false;
-
 
33
			this->pictureBox2->Visible = false;
-
 
34
			this->pictureBox3->Visible = false;
-
 
35
			this->pictureBox4->Visible = false;
-
 
36
			this->pictureBox5->Visible = false;
-
 
37
			this->pictureBox6->Visible = false;
-
 
38
			this->pictureBox7->Visible = false;
-
 
39
			this->pictureBox8->Visible = false;
-
 
40
			this->pictureBox9->Visible = false;
-
 
41
			this->pictureBox10->Visible = false;
-
 
42
 
-
 
43
			m_bError = false;
-
 
44
			m_pPackages = p;
-
 
45
			m_sCatFile = cat;
-
 
46
			m_sSecondCat = secondCat;
-
 
47
			m_sID = id;
-
 
48
			m_pShip = NULL;
-
 
49
 
-
 
50
			m_pInfo = new CProgressInfoDone;
-
 
51
			m_pInfo->UpdateStatus(IMPORTSHIP_NONE);
-
 
52
			m_lModels = NULL;
-
 
53
			m_iStatus = IMPORTSHIP_SCENE;
-
 
54
		}
-
 
55
 
36
 
56
		String ^getErrorString() { return m_sError; }
37
		String ^getErrorString() { return m_sError; }
57
		CXspFile *GetShip() { return m_pShip; }
38
		CXspFile *GetShip() { return m_pShip; }
58
 
39
 
59
		void StartImport()
40
		void StartImport();
60
		{
-
 
61
			m_pShip = new CXspFile;
-
 
62
			m_pCatFile = new CCatFile;
-
 
63
			if ( m_sSecondCat ) {
-
 
64
				m_pSecondCatFile = new CCatFile;
-
 
65
			}
-
 
66
			else {
-
 
67
				m_pSecondCatFile = NULL;
-
 
68
			}
-
 
69
 
-
 
70
			if ( m_pCatFile->Open(CyStringFromSystemString(m_sCatFile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE ) {
-
 
71
				if ( m_pSecondCatFile && m_pSecondCatFile->Open(CyStringFromSystemString(m_sSecondCat), "", CATREAD_CATDECRYPT, false) != CATERR_NONE ) {
-
 
72
					delete m_pSecondCatFile;
-
 
73
					m_pSecondCatFile = NULL;
-
 
74
				}
-
 
75
				m_bError = false;
-
 
76
			}
-
 
77
			else
-
 
78
			{
-
 
79
				delete m_pShip;
-
 
80
				m_bError = true;
-
 
81
				m_sError = "Unable to open the cat file: " + m_sCatFile;
-
 
82
				this->Close();
-
 
83
			}
-
 
84
 
-
 
85
			m_iStatus = IMPORTSHIP_SCENE;
-
 
86
			this->backgroundWorker1->RunWorkerAsync();
-
 
87
		}
-
 
88
 
-
 
89
		bool Error() { return m_bError; }
41
		bool Error() { return m_bError; }
90
		//CyString ErrorString() { return m_sError; }
-
 
91
 
-
 
92
		void Import()
42
		void Import();
93
		{
-
 
94
			m_bError = false;
-
 
95
			if ( m_iStatus <= IMPORTSHIP_SCENE )
-
 
96
			{
-
 
97
				// make sure the id is correct
-
 
98
				CyString data = CyStringFromSystemString(m_sID);
-
 
99
				data.RemoveChar('\r');
-
 
100
				while(data.Right(1) == ";")
-
 
101
					data.Truncate((int)data.Length() - 1);
-
 
102
 
-
 
103
				m_bError = !m_pShip->StartExtractShip(m_pCatFile, m_pSecondCatFile, data, m_pInfo);
-
 
104
				if ( m_bError ) m_sError = "Unable to extract scene file";
-
 
105
 
-
 
106
				m_iStatus = IMPORTSHIP_EXTRACTSCENE;
-
 
107
			}
-
 
108
			else if ( m_iStatus == IMPORTSHIP_EXTRACTSCENE )
-
 
109
			{
-
 
110
				m_lModels = m_pShip->ReadSceneModels();
-
 
111
				if ( !m_lModels ) {
-
 
112
					m_bError = true;
-
 
113
					m_sError = "Unable to read the scene file to extract model data";
-
 
114
				}
-
 
115
				++m_iStatus;
-
 
116
			}
-
 
117
			else if ( m_iStatus == IMPORTSHIP_PACK )
-
 
118
			{
-
 
119
				m_pShip->PackAllFiles();
-
 
120
				m_iStatus = IMPORTSHIP_DONE;
-
 
121
			}
-
 
122
			else if ( m_iStatus > IMPORTSHIP_EXTRACTSCENE )
-
 
123
			{
-
 
124
				m_bError = !m_pShip->ProcessSceneFileSection(m_iStatus, m_pCatFile, m_pSecondCatFile, m_lModels, m_pInfo);
-
 
125
				if ( m_bError ) m_sError = "Unable to process scene file (Status=" + (long)m_iStatus;
-
 
126
				++m_iStatus;
-
 
127
			}
-
 
128
		}
-
 
129
 
43
 
130
	protected:
44
	protected:
-
 
45
		void _runNext();
-
 
46
		void _cleanUp();
-
 
47
 
131
		/// <summary>
48
		/// <summary>
132
		/// Clean up any resources being used.
49
		/// Clean up any resources being used.
133
		/// </summary>
50
		/// </summary>
134
		~ImportShip()
51
		~ImportShip()
135
		{
52
		{
136
			if (components)
53
			if (components)
137
			{
54
			{
138
				delete components;
55
				delete components;
139
			}
56
			}
140
			delete m_pInfo;
-
 
141
			if ( m_lModels )
57
			this->_cleanUp();
142
				delete m_lModels;
-
 
143
			delete m_pCatFile;
-
 
144
		}
58
		}
145
 
-
 
-
 
59
////////////////////////////////////////////////////////////////////////////////////////////
146
	private:
60
	private:
147
	private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
61
	private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
148
	private: System::Windows::Forms::Label^  label1;
62
	private: System::Windows::Forms::Label^  label1;
149
	private: System::Windows::Forms::Panel^  panel1;
63
	private: System::Windows::Forms::Panel^  panel1;
150
	private: System::Windows::Forms::PictureBox^  pictureBox1;
64
	private: System::Windows::Forms::PictureBox^  pictureBox1;
151
	private: System::Windows::Forms::Panel^  panel2;
65
	private: System::Windows::Forms::Panel^  panel2;
152
	private: System::Windows::Forms::PictureBox^  pictureBox2;
66
	private: System::Windows::Forms::PictureBox^  pictureBox2;
153
	private: System::Windows::Forms::Panel^  panel3;
67
	private: System::Windows::Forms::Panel^  panel3;
154
	private: System::Windows::Forms::Label^  label11;
68
	private: System::Windows::Forms::Label^  label11;
155
private: System::Windows::Forms::PictureBox^  pictureBox4;
69
	private: System::Windows::Forms::PictureBox^  pictureBox4;
156
 
-
 
157
	private: System::Windows::Forms::Panel^  panel4;
70
	private: System::Windows::Forms::Panel^  panel4;
158
	private: System::Windows::Forms::Label^  label2;
71
	private: System::Windows::Forms::Label^  label2;
159
private: System::Windows::Forms::PictureBox^  pictureBox5;
72
	private: System::Windows::Forms::PictureBox^  pictureBox5;
160
 
-
 
161
	private: System::Windows::Forms::Panel^  panel5;
73
	private: System::Windows::Forms::Panel^  panel5;
162
	private: System::Windows::Forms::Label^  label3;
74
	private: System::Windows::Forms::Label^  label3;
163
private: System::Windows::Forms::PictureBox^  pictureBox3;
75
	private: System::Windows::Forms::PictureBox^  pictureBox3;
164
 
-
 
165
 
-
 
166
	private: System::Windows::Forms::Panel^  panel6;
76
	private: System::Windows::Forms::Panel^  panel6;
167
	private: System::Windows::Forms::Label^  label12;
77
	private: System::Windows::Forms::Label^  label12;
168
	private: System::Windows::Forms::PictureBox^  pictureBox6;
78
	private: System::Windows::Forms::PictureBox^  pictureBox6;
169
	private: System::Windows::Forms::Panel^  panel7;
79
	private: System::Windows::Forms::Panel^  panel7;
170
	private: System::Windows::Forms::Label^  label13;
80
	private: System::Windows::Forms::Label^  label13;
171
	private: System::Windows::Forms::PictureBox^  pictureBox7;
81
	private: System::Windows::Forms::PictureBox^  pictureBox7;
172
	private: System::Windows::Forms::Panel^  panel8;
82
	private: System::Windows::Forms::Panel^  panel8;
173
	private: System::Windows::Forms::Label^  label14;
83
	private: System::Windows::Forms::Label^  label14;
174
	private: System::Windows::Forms::PictureBox^  pictureBox8;
84
	private: System::Windows::Forms::PictureBox^  pictureBox8;
175
private: System::Windows::Forms::Label^  label10;
85
	private: System::Windows::Forms::Label^  label10;
176
private: System::Windows::Forms::Panel^  panel9;
86
	private: System::Windows::Forms::Panel^  panel9;
177
private: System::Windows::Forms::Label^  label15;
87
	private: System::Windows::Forms::Label^  label15;
178
private: System::Windows::Forms::PictureBox^  pictureBox9;
88
	private: System::Windows::Forms::PictureBox^  pictureBox9;
179
private: System::Windows::Forms::Panel^  panel10;
89
	private: System::Windows::Forms::Panel^  panel10;
180
private: System::Windows::Forms::Label^  label4;
90
	private: System::Windows::Forms::Label^  label4;
181
private: System::Windows::Forms::PictureBox^  pictureBox10;
91
	private: System::Windows::Forms::PictureBox^  pictureBox10;
182
private: System::Windows::Forms::Button^  button1;
92
	private: System::Windows::Forms::Button^  button1;
183
private: System::Windows::Forms::Panel^  panel11;
93
	private: System::Windows::Forms::Panel^  panel11;
184
	private: System::ComponentModel::IContainer^  components;
94
	private: System::ComponentModel::IContainer^  components;
185
			 /// <summary>
95
		/// <summary>
186
		/// Required designer variable.
96
		/// Required designer variable.
187
		/// </summary>
97
		/// </summary>
188
		int				 m_iStatus;
-
 
189
		bool			 m_bError;
-
 
190
		CyStringList	*m_lModels;
-
 
191
		CProgressInfo	*m_pInfo;
-
 
192
		CPackages		*m_pPackages;
-
 
193
		String			^m_sCatFile;
-
 
194
		String			^m_sID;
-
 
195
		CXspFile		*m_pShip;
-
 
196
		CCatFile		*m_pCatFile;
-
 
197
		CCatFile		*m_pSecondCatFile;
-
 
198
		String			^m_sError;
-
 
199
		String			^m_sSecondCat;
-
 
200
 
98
 
201
#pragma region Windows Form Designer generated code
99
#pragma region Windows Form Designer generated code
202
		/// <summary>
100
		/// <summary>
203
		/// Required method for Designer support - do not modify
101
		/// Required method for Designer support - do not modify
204
		/// the contents of this method with the code editor.
102
		/// the contents of this method with the code editor.
Line 546... Line 444...
546
			this->panel9->Dock = System::Windows::Forms::DockStyle::Top;
444
			this->panel9->Dock = System::Windows::Forms::DockStyle::Top;
547
			this->panel9->Location = System::Drawing::Point(25, 273);
445
			this->panel9->Location = System::Drawing::Point(25, 273);
548
			this->panel9->Name = L"panel9";
446
			this->panel9->Name = L"panel9";
549
			this->panel9->Size = System::Drawing::Size(397, 31);
447
			this->panel9->Size = System::Drawing::Size(397, 31);
550
			this->panel9->TabIndex = 17;
448
			this->panel9->TabIndex = 17;
551
			// 
449
			// 
552
			// label15
450
			// label15
553
			// 
451
			// 
554
			this->label15->Dock = System::Windows::Forms::DockStyle::Fill;
452
			this->label15->Dock = System::Windows::Forms::DockStyle::Fill;
555
			this->label15->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
453
			this->label15->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
556
				static_cast<System::Byte>(0)));
454
				static_cast<System::Byte>(0)));
Line 682... Line 580...
682
	private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
580
	private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
683
				 System::Threading::Thread::Sleep(100);
581
				 System::Threading::Thread::Sleep(100);
684
				 this->Import();
582
				 this->Import();
685
			 }
583
			 }
686
	private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
584
	private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
687
				 if ( m_bError )
-
 
688
				 {
-
 
689
					 this->Close();
585
				 this->_runNext();
690
					 return;
-
 
691
				 }
-
 
692
 
-
 
693
				 if ( m_iStatus > IMPORTSHIP_SCENE )
-
 
694
					 this->pictureBox2->Visible = true;
-
 
695
				 if ( m_iStatus > IMPORTSHIP_EXTRACTSCENE )
-
 
696
					 this->pictureBox1->Visible = true;
-
 
697
				 if ( m_iStatus > IMPORTSHIP_DUMMIES )
-
 
698
					 this->pictureBox3->Visible = true;
-
 
699
				 if ( m_iStatus > IMPORTSHIP_COMPONANT )
-
 
700
					 this->pictureBox4->Visible = true;
-
 
701
				 if ( m_iStatus > IMPORTSHIP_MODELS )
-
 
702
					 this->pictureBox5->Visible = true;
-
 
703
				 if ( m_iStatus > IMPORTSHIP_TEXTURES )
-
 
704
					 this->pictureBox6->Visible = true;
-
 
705
				 if ( m_iStatus > IMPORTSHIP_TEXTS )
-
 
706
					 this->pictureBox7->Visible = true;
-
 
707
				 if ( m_iStatus > IMPORTSHIP_BODIES )
-
 
708
					 this->pictureBox8->Visible = true;
-
 
709
				 if ( m_iStatus > IMPORTSHIP_COCKPITS )
-
 
710
					 this->pictureBox9->Visible = true;
-
 
711
				 if ( m_iStatus > IMPORTSHIP_PACK )
-
 
712
					 this->pictureBox10->Visible = true;
-
 
713
 
-
 
714
				 if ( m_iStatus < IMPORTSHIP_DONE )
-
 
715
					 this->backgroundWorker1->RunWorkerAsync();
-
 
716
				 else
-
 
717
					 this->button1->Visible = true;
-
 
718
			 }
586
			 }
719
};
587
};
720
}
588
}