| 1 |
cycrow |
1 |
#include "../StdAfx.h"
|
|
|
2 |
#include "ImportShip.h"
|
|
|
3 |
|
| 36 |
cycrow |
4 |
namespace Creator {
|
|
|
5 |
ImportShip::ImportShip(String ^id, CVirtualFileSystem *pVfs)
|
|
|
6 |
{
|
|
|
7 |
InitializeComponent();
|
|
|
8 |
|
|
|
9 |
this->Text = this->Text + " (" + id + ")";
|
|
|
10 |
|
|
|
11 |
this->button1->Visible = false;
|
|
|
12 |
this->pictureBox1->Visible = false;
|
|
|
13 |
this->pictureBox2->Visible = false;
|
|
|
14 |
this->pictureBox3->Visible = false;
|
|
|
15 |
this->pictureBox4->Visible = false;
|
|
|
16 |
this->pictureBox5->Visible = false;
|
|
|
17 |
this->pictureBox6->Visible = false;
|
|
|
18 |
this->pictureBox7->Visible = false;
|
|
|
19 |
this->pictureBox8->Visible = false;
|
|
|
20 |
this->pictureBox9->Visible = false;
|
|
|
21 |
this->pictureBox10->Visible = false;
|
|
|
22 |
|
|
|
23 |
m_pVfs = pVfs;
|
|
|
24 |
m_bError = false;
|
|
|
25 |
m_sID = id;
|
|
|
26 |
m_pShip = NULL;
|
|
|
27 |
|
|
|
28 |
m_pInfo = new CProgressInfoDone;
|
|
|
29 |
m_pInfo->UpdateStatus(IMPORTSHIP_NONE);
|
|
|
30 |
m_lModels = NULL;
|
|
|
31 |
m_iStatus = IMPORTSHIP_SCENE;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
void ImportShip::StartImport()
|
|
|
35 |
{
|
|
|
36 |
m_pShip = new CXspFile();
|
|
|
37 |
m_bError = false;
|
|
|
38 |
m_iStatus = IMPORTSHIP_SCENE;
|
|
|
39 |
this->backgroundWorker1->RunWorkerAsync();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
void ImportShip::Import()
|
|
|
43 |
{
|
|
|
44 |
m_bError = false;
|
|
|
45 |
if ( m_iStatus <= IMPORTSHIP_SCENE )
|
|
|
46 |
{
|
|
|
47 |
// make sure the id is correct
|
|
|
48 |
Utils::String data = CyStringFromSystemString(m_sID).ToString();
|
|
|
49 |
data.removeChar('\r');
|
|
|
50 |
while(data.right(1) == ";")
|
|
|
51 |
data.truncate(-1);
|
|
|
52 |
|
|
|
53 |
m_bError = !m_pShip->startExtractShip(m_pVfs, data, m_pInfo);
|
|
|
54 |
if ( m_bError ) m_sError = "Unable to extract scene file";
|
|
|
55 |
|
|
|
56 |
m_iStatus = IMPORTSHIP_EXTRACTSCENE;
|
|
|
57 |
}
|
|
|
58 |
else if ( m_iStatus == IMPORTSHIP_EXTRACTSCENE )
|
|
|
59 |
{
|
|
|
60 |
m_lModels = m_pShip->ReadSceneModels();
|
|
|
61 |
if ( !m_lModels ) {
|
|
|
62 |
m_bError = true;
|
|
|
63 |
m_sError = "Unable to read the scene file to extract model data";
|
|
|
64 |
}
|
|
|
65 |
++m_iStatus;
|
|
|
66 |
}
|
|
|
67 |
else if ( m_iStatus == IMPORTSHIP_PACK )
|
|
|
68 |
{
|
|
|
69 |
m_pShip->PackAllFiles();
|
|
|
70 |
m_iStatus = IMPORTSHIP_DONE;
|
|
|
71 |
}
|
|
|
72 |
else if ( m_iStatus > IMPORTSHIP_EXTRACTSCENE )
|
|
|
73 |
{
|
|
|
74 |
m_bError = !m_pShip->processSceneFileSection(m_iStatus, m_pVfs, m_lModels, m_pInfo);
|
|
|
75 |
if ( m_bError ) m_sError = "Unable to process scene file (Status=" + (long)m_iStatus;
|
|
|
76 |
++m_iStatus;
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
void ImportShip::_runNext()
|
|
|
81 |
{
|
|
|
82 |
if ( m_bError )
|
|
|
83 |
{
|
|
|
84 |
this->Close();
|
|
|
85 |
return;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
if ( m_iStatus > IMPORTSHIP_SCENE )
|
|
|
89 |
this->pictureBox2->Visible = true;
|
|
|
90 |
if ( m_iStatus > IMPORTSHIP_EXTRACTSCENE )
|
|
|
91 |
this->pictureBox1->Visible = true;
|
|
|
92 |
if ( m_iStatus > IMPORTSHIP_DUMMIES )
|
|
|
93 |
this->pictureBox3->Visible = true;
|
|
|
94 |
if ( m_iStatus > IMPORTSHIP_COMPONANT )
|
|
|
95 |
this->pictureBox4->Visible = true;
|
|
|
96 |
if ( m_iStatus > IMPORTSHIP_MODELS )
|
|
|
97 |
this->pictureBox5->Visible = true;
|
|
|
98 |
if ( m_iStatus > IMPORTSHIP_TEXTURES )
|
|
|
99 |
this->pictureBox6->Visible = true;
|
|
|
100 |
if ( m_iStatus > IMPORTSHIP_TEXTS )
|
|
|
101 |
this->pictureBox7->Visible = true;
|
|
|
102 |
if ( m_iStatus > IMPORTSHIP_BODIES )
|
|
|
103 |
this->pictureBox8->Visible = true;
|
|
|
104 |
if ( m_iStatus > IMPORTSHIP_COCKPITS )
|
|
|
105 |
this->pictureBox9->Visible = true;
|
|
|
106 |
if ( m_iStatus > IMPORTSHIP_PACK )
|
|
|
107 |
this->pictureBox10->Visible = true;
|
|
|
108 |
|
|
|
109 |
if ( m_iStatus < IMPORTSHIP_DONE )
|
|
|
110 |
this->backgroundWorker1->RunWorkerAsync();
|
|
|
111 |
else
|
|
|
112 |
this->button1->Visible = true;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
void ImportShip::_cleanUp()
|
|
|
116 |
{
|
|
|
117 |
delete m_pInfo;
|
|
|
118 |
if ( m_lModels )
|
|
|
119 |
delete m_lModels;
|
|
|
120 |
}
|
|
|
121 |
}
|