Subversion Repositories spk

Rev

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

Rev 77 Rev 94
Line 15... Line 15...
15
	this->multiPackageToolStripMenuItem->Image = this->imageList1->Images[this->imageList1->Images->IndexOfKey("multi")];
15
	this->multiPackageToolStripMenuItem->Image = this->imageList1->Images[this->imageList1->Images->IndexOfKey("multi")];
16
	this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
16
	this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
17
 
17
 
18
	this->Text = "Package Creator " + GetVersionString();
18
	this->Text = "Package Creator " + GetVersionString();
19
	m_pLoadedList = new CyStringList;
19
	m_pLoadedList = new CyStringList;
20
	m_pGameDir = new CLinkList<SGameDir>;
20
	_pGameDir = new CGameDirectories();
-
 
21
	_pGameDir->setLanguage(44);
21
 
22
 
22
	// default settings
23
	// default settings
23
	m_settings = new SSettings;
24
	m_settings = new SSettings;
24
	m_settings->bGenerateUpdate = false;
25
	m_settings->bGenerateUpdate = false;
25
 
-
 
26
	m_pComponents = NULL;
-
 
27
	m_pDummies = NULL;
-
 
28
	m_pBodies = NULL;
-
 
29
	m_pShields = NULL;
-
 
30
	m_pCockpits = new CLinkList<CyStringList>;
-
 
31
	m_pLasers = new CLinkList<CyStringList>;
-
 
32
	m_pMissiles = new CLinkList<CyStringList>;
-
 
33
 
26
 
34
	m_iLocX = m_iLocY = -1;
27
	m_iLocX = m_iLocY = -1;
35
 
28
 
36
	this->toolTip1->SetToolTip(this->button1, "Closes all open windows, will ask about saving any that have been modified when they close");
29
	this->toolTip1->SetToolTip(this->button1, "Closes all open windows, will ask about saving any that have been modified when they close");
37
 
30
 
Line 94... Line 87...
94
		}
87
		}
95
 
88
 
96
		if ( list->Count ) {
89
		if ( list->Count ) {
97
			this->OpenFiles(list, true, true);
90
			this->OpenFiles(list, true, true);
98
			m_bAutoClose = false;
91
			m_bAutoClose = false;
99
		}
92
		}
100
	}
93
	}
101
}
94
}
102
 
95
 
103
 
96
 
104
String ^Form1::getShipSelection(CVirtualFileSystem *pVfs)
97
String ^Form1::getShipSelection(CVirtualFileSystem *pVfs)
105
{
98
{
106
	CyStringList list;
99
	CyStringList list;
107
	if ( pVfs->loadShipData(&list) ) {
100
	if ( pVfs->loadShipData(&list) ) {
-
 
101
 
-
 
102
		this->LoadText();
-
 
103
 
108
		LoadShip ^ls = gcnew LoadShip();
104
		LoadShip ^ls = gcnew LoadShip();
109
		for ( SStringList *str = list.Head(); str; str = str->next )
105
		for ( SStringList *str = list.Head(); str; str = str->next )
110
		{
106
		{
111
			int tId = str->data.GetToken(";", 7, 7).ToInt();
107
			int tId = str->data.GetToken(";", 7, 7).ToInt();
112
			String ^name;
-
 
113
			if ( pVfs->textExists(44, 17, tId) )
108
			String ^name = _US(pVfs->findText(0, 17, tId));
114
				name = SystemStringFromCyString(pVfs-&gt;findText(44, 17, tId));
109
			String ^race = _US(pVfs->findText(0, 1266, str-&gt;data.GetToken(";", 46, 46).ToInt()));
115
			else
-
 
116
				name = this-&gt;FindText(-1, 17, tId);
110
			String ^text = race + " &quot; + name;
117
			String ^text = this->FindText(-1, 1266, str->data.GetToken(";", 46, 46).ToInt()) + " " + name;
-
 
118
			int variation = str->data.GetToken(";", 51, 51).ToInt();
111
			int variation = str->data.GetToken(";", 51, 51).ToInt();
119
			if ( variation )
112
			if ( variation )
120
				text = text + " " + this->FindText(-1, 17, 10000 + variation);
113
				text = text + " " + _US(pVfs->findText(0, 17, 10000 + variation));
121
			ls->AddShip(SystemStringFromCyString(str->str), text);
114
			ls->AddShip(SystemStringFromCyString(str->str), text);
122
		}
115
		}
123
 
116
 
124
		if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )	{
117
		if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )	{
125
			SStringList *str = list.FindString(CyStringFromSystemString(ls->GetData()));
118
			SStringList *str = list.FindString(CyStringFromSystemString(ls->GetData()));
126
			if ( str )	{
119
			if ( str )	{
127
				return ls->GetData();
120
				return ls->GetData();
128
			}
121
			}
129
		}
122
		}
130
		else return "";
123
		else return "";
131
	}
124
	}
132
 
125
 
133
	return nullptr;
126
	return nullptr;
Line 146... Line 139...
146
 
139
 
147
	if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
140
	if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
148
	{
141
	{
149
		if ( !vfs->loadMod(CyStringFromSystemString(ofd->FileName).ToString()) ) {
142
		if ( !vfs->loadMod(CyStringFromSystemString(ofd->FileName).ToString()) ) {
150
			MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + "\n\nError: Unable to open mod file", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
143
			MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + "\n\nError: Unable to open mod file", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
151
			return;
144
			return;
152
		}
145
		}
153
		this->UseWaitCursor = true;
146
		this->UseWaitCursor = true;
154
 
147
 
155
		vfs->updateModTexts(17);
148
		vfs->updateModTexts(17);
156
 
149
 
Line 200... Line 193...
200
 
193
 
201
 
194
 
202
void Form1::ImportShipFromVFS()
195
void Form1::ImportShipFromVFS()
203
{
196
{
204
	// some way to select the VFS to use
197
	// some way to select the VFS to use
205
	SelectFilesystem ^Filesystem = gcnew SelectFilesystem(m_pGameDir, this->GetHighestGame());
198
	SelectFilesystem ^Filesystem = gcnew SelectFilesystem(_pGameDir);
206
	if ( Filesystem->ShowDialog(this) != System::Windows::Forms::DialogResult::OK ) {
199
	if ( Filesystem->ShowDialog(this) != System::Windows::Forms::DialogResult::OK ) {
207
		return;
200
		return;
208
	}
201
	}
209
 
202
 
210
	SGameDir *pDir = Filesystem->gameDir();
203
	Utils::String dir = Filesystem->gameDir();
211
	CyString mod;
204
	CyString mod;
212
	if ( Filesystem->gameMod() ) {
205
	if ( Filesystem->gameMod() ) {
213
		mod = CyString(pDir->dir) + "/mods/" + CyStringFromSystemString(Filesystem->gameMod()) + ".cat";
206
		mod = CyString(dir) + "/mods/" + CyStringFromSystemString(Filesystem->gameMod()) + ".cat";
-
 
207
	}
-
 
208
 
-
 
209
	CVirtualFileSystem *vfs = _pGameDir->selectedVFS();
-
 
210
 
-
 
211
	if ( !vfs ) {
-
 
212
		MessageBox::Show(this, "Error: Couldn't open Virtual File System", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
-
 
213
		return;
214
	}
214
	}
215
 
215
 
216
	// load a mod on top of the VFS
216
	// load a mod on top of the VFS
217
	if ( !mod.Empty() ) {
217
	if ( !mod.Empty() ) {
218
		if ( !pDir->pVfs->loadMod(mod.ToString()) ) {
218
		if ( !vfs->loadMod(mod.ToString()) ) {
219
			MessageBox::Show(this, "There was a problem trying to open the mod file\n" + Filesystem->gameMod(), "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
219
			MessageBox::Show(this, "There was a problem trying to open the mod file\n" + Filesystem->gameMod(), "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
220
			return;
220
			return;
221
		}
221
		}
222
		pDir->pVfs->updateModTexts(17);
222
		vfs->updateModTexts(17);
223
	}
223
	}
224
 
224
 
225
	// get the ship id to load
225
	// get the ship id to load
226
	String ^shipID = getShipSelection(pDir->pVfs);
226
	String ^shipID = getShipSelection(vfs);
227
	if ( !shipID ) {
227
	if ( !shipID ) {
228
		MessageBox::Show(this, "There was a problem trying to load ship data from VFS\n", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
228
		MessageBox::Show(this, "There was a problem trying to load ship data from VFS\n", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
229
	}
229
	}
230
	else if ( shipID->Length ) {
230
	else if ( shipID->Length ) {
231
		// import the ship
231
		// import the ship
232
		Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, pDir->pVfs);
232
		Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, vfs);
233
		import->ShowDialog(this);
233
		import->ShowDialog(this);
234
 
234
 
235
		// create the new form with ship data
235
		// create the new form with ship data
236
		if ( !import->Error() ) {
236
		if ( !import->Error() ) {
237
			PackageForm ^childForm = this->OpenPackage(true, import->GetShip(), "", "Imported Ship");
237
			PackageForm ^childForm = this->OpenPackage(true, import->GetShip(), "", "Imported Ship");
Line 240... Line 240...
240
			childForm->UpdateChanged();
240
			childForm->UpdateChanged();
241
		}
241
		}
242
	}
242
	}
243
 
243
 
244
	// remove any mods that we have loaded
244
	// remove any mods that we have loaded
245
	pDir->pVfs->clearMods();
245
	vfs->clearMods();
246
}
246
}
247
 
247
 
248
} //NAMESPACE
248
} //NAMESPACE