Subversion Repositories spk

Rev

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

Rev 115 Rev 116
Line 117... Line 117...
117
		}
117
		}
118
	}
118
	}
119
}
119
}
120
 
120
 
121
 
121
 
122
String ^Form1::getShipSelection(CVirtualFileSystem *pVfs)
122
String ^Form1::getShipSelection(CVirtualFileSystem *pVfs, System::String ^*shipName)
123
{
123
{
124
	Utils::CStringList *ships = pVfs->getTShipsEntries();
124
	Utils::CStringList *ships = pVfs->getTShipsEntries();
125
	if ( ships ) {
125
	if ( ships ) {
126
		this->LoadText(pVfs);
126
		this->LoadText(pVfs);
127
 
127
 
Line 139... Line 139...
139
 
139
 
140
		if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )	{
140
		if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )	{
141
			Utils::String line = pVfs->getTShipsEntry(_S(ls->GetData()));
141
			Utils::String line = pVfs->getTShipsEntry(_S(ls->GetData()));
142
	
142
	
143
			if ( !line.empty() ) {
143
			if ( !line.empty() ) {
-
 
144
				if ( shipName ) {
-
 
145
					(*shipName) = ls->GetShipName();
-
 
146
				}
144
				return ls->GetData();
147
				return ls->GetData();
145
			}
148
			}
146
		}
149
		}
147
		else return "";
150
		else return "";
148
	}
151
	}
Line 169... Line 172...
169
		}
172
		}
170
		this->UseWaitCursor = true;
173
		this->UseWaitCursor = true;
171
 
174
 
172
		vfs->updateModTexts(17);
175
		vfs->updateModTexts(17);
173
 
176
 
-
 
177
		String ^shipName = "";
174
		String ^shipID = getShipSelection(vfs);
178
		String ^shipID = getShipSelection(vfs, &shipName);
175
		if ( !shipID ) {
179
		if ( !shipID ) {
176
			MessageBox::Show(this, "There was a problem trying to load the mod file\n" + ofd->FileName + "\n\nNo TShips file found", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
180
			MessageBox::Show(this, "There was a problem trying to load the mod file\n" + ofd->FileName + "\n\nNo TShips file found", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
177
		}
181
		}
178
		else if ( shipID->Length ) {
182
		else if ( shipID->Length ) {
179
			String ^loadMod = ofd->FileName;
183
			String ^loadMod = ofd->FileName;
180
			CXspFile *newShip = NULL;
184
			CXspFile *newShip = NULL;
181
 
185
 
182
			while ( true ) {
186
			while ( true ) {
183
				Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, vfs);
187
				Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, shipName, vfs);
184
				import->ShowDialog(this);
188
				import->ShowDialog(this);
185
				newShip = (import->Error()) ? NULL : import->GetShip();
189
				newShip = (import->Error()) ? NULL : import->GetShip();
186
				if ( !newShip ) {
190
				if ( !newShip ) {
187
					if ( MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + " (" + shipID + ")\n\nError: " + import->getErrorString() + "\n\nWould you like to read files from another mod as well?", "Error Importing Ship", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes ) {
191
					if ( MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + " (" + shipID + ")\n\nError: " + import->getErrorString() + "\n\nWould you like to read files from another mod as well?", "Error Importing Ship", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes ) {
188
						// load in another file
192
						// load in another file
Line 246... Line 250...
246
		}
250
		}
247
		vfs->updateModTexts(17);
251
		vfs->updateModTexts(17);
248
	}
252
	}
249
 
253
 
250
	// get the ship id to load
254
	// get the ship id to load
-
 
255
	String ^shipName = "";
251
	String ^shipID = getShipSelection(vfs);
256
	String ^shipID = getShipSelection(vfs, &shipName);
252
	if ( !shipID ) {
257
	if ( !shipID ) {
253
		MessageBox::Show(this, "There was a problem trying to load ship data from VFS\n", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
258
		MessageBox::Show(this, "There was a problem trying to load ship data from VFS\n", "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
254
	}
259
	}
255
	else if ( shipID->Length ) {
260
	else if ( shipID->Length ) {
256
		// import the ship
261
		// import the ship
257
		Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, vfs);
262
		Creator::ImportShip ^import = gcnew Creator::ImportShip(shipID, shipName, vfs);
258
		import->ShowDialog(this);
263
		import->ShowDialog(this);
259
 
264
 
260
		// create the new form with ship data
265
		// create the new form with ship data
261
		if ( !import->Error() ) {
266
		if ( !import->Error() ) {
262
			PackageForm ^childForm = this->OpenPackage(true, import->GetShip(), "", "Imported Ship");
267
			PackageForm ^childForm = this->OpenPackage(true, import->GetShip(), "", "Imported Ship");