Subversion Repositories spk

Rev

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

Rev 223 Rev 224
Line 152... Line 152...
152
			// create the mod file by copying the primary mod
152
			// create the mod file by copying the primary mod
153
			if ( IO::File::Exists(file) )
153
			if ( IO::File::Exists(file) )
154
				IO::File::Delete(file);
154
				IO::File::Delete(file);
155
			IO::File::Copy(this->textBox1->Text, file);
155
			IO::File::Copy(this->textBox1->Text, file);
156
			// and the dat file
156
			// and the dat file
157
			Utils::WString file1 = CFileIO(_S(this->textBox1->Text)).changeFileExtension(L"dat");
157
			Utils::WString file1 = CFileIO(_WS(this->textBox1->Text)).changeFileExtension(L"dat");
158
			Utils::WString file2 = CFileIO(_S(file)).changeFileExtension(L"dat");
158
			Utils::WString file2 = CFileIO(_WS(file)).changeFileExtension(L"dat");
159
			if ( IO::File::Exists(_US(file2)) )
159
			if ( IO::File::Exists(_US(file2)) )
160
				IO::File::Delete(_US(file2));
160
				IO::File::Delete(_US(file2));
161
			IO::File::Copy(_US(file1), _US(file2));
161
			IO::File::Copy(_US(file1), _US(file2));
162
 
162
 
163
			CCatFile CatFile;
163
			CCatFile CatFile;
164
			if ( !CCatFile::Opened(CatFile.open(_S(file), "", CATREAD_CATDECRYPT, false), false) )
164
			if ( !CCatFile::Opened(CatFile.open(_WS(file), L"", CATREAD_CATDECRYPT, false), false) )
165
			{
165
			{
166
				MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
166
				MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
167
				return;
167
				return;
168
			}
168
			}
169
 
169
 
170
			// now we need to move non merge files from the 2nd mod to the new one
170
			// now we need to move non merge files from the 2nd mod to the new one
171
			Utils::WStringList list;
171
			Utils::WStringList list;
172
			m_pPackages->getMergedFiles(list, m_pFile1, m_pFile2);
172
			m_pPackages->getMergedFiles(list, m_pFile1, m_pFile2);
173
			if (!list.empty())
173
			if (!list.empty())
174
			{
174
			{
175
				CModDiff Diff(_S(this->textBox3->Text).token(" (", 1), "addon", Convert::ToInt32(this->numericUpDown1->Value));
175
				CModDiff Diff(_WS(this->textBox3->Text).token(L" (", 1), L"addon", Convert::ToInt32(this->numericUpDown1->Value));
176
				if ( Diff.startDiff(_S(this->textBox2->Text)) ) {
176
				if ( Diff.startDiff(_WS(this->textBox2->Text)) ) {
177
					for(auto itr = list.begin(); itr != list.end(); itr++)
177
					for(auto itr = list.begin(); itr != list.end(); itr++)
178
					{
178
					{
179
						int status = (*itr)->data.toInt();
179
						int status = (*itr)->data.toInt();
180
						if ( status == 2 ) { // in 2nd mod
180
						if ( status == 2 ) { // in 2nd mod
181
							if ( CatFile.appendFile(_WS(this->textBox2->Text) + L"::" + (*itr)->str, (*itr)->str) )
181
							if ( CatFile.appendFile(_WS(this->textBox2->Text) + L"::" + (*itr)->str, (*itr)->str) )
Line 186... Line 186...
186
							// only diffable files, we ignore the rest
186
							// only diffable files, we ignore the rest
187
							if ( CModDiff::CanBeDiffed((*itr)->str) ) Diff.doDiff((*itr)->str);
187
							if ( CModDiff::CanBeDiffed((*itr)->str) ) Diff.doDiff((*itr)->str);
188
						}
188
						}
189
					}
189
					}
190
 
190
 
191
					Diff.ApplyDiff(_S(file));
191
					Diff.ApplyDiff(_WS(file));
192
				}
192
				}
193
			}
193
			}
194
 
194
 
195
			MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
195
			MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
196
		}
196
		}
Line 271... Line 271...
271
		}
271
		}
272
 
272
 
273
 
273
 
274
		bool SetGameDir(int patch, String ^gameDir)
274
		bool SetGameDir(int patch, String ^gameDir)
275
		{
275
		{
276
			Utils::String dir = _S(gameDir);
276
			Utils::WString dir = _WS(gameDir);
277
			if ( !dir.empty() )
277
			if ( !dir.empty() )
278
			{
278
			{
279
				Utils::WString gameName = m_pPackages->getGameName(dir);
279
				Utils::WString gameName = m_pPackages->getGameName(dir);
280
				if ( !gameName.empty() )
280
				if ( !gameName.empty() )
281
				{
281
				{
Line 646... Line 646...
646
#pragma endregion
646
#pragma endregion
647
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
647
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
648
			String ^openfile = this->OpenFile("Select the mod file to use as the primary mod");
648
			String ^openfile = this->OpenFile("Select the mod file to use as the primary mod");
649
			if ( openfile )
649
			if ( openfile )
650
			{
650
			{
651
				if ( m_pFile1->open(_S(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
651
				if ( m_pFile1->open(_WS(openfile), L"", CATREAD_CATDECRYPT, false) == CATERR_NONE )
652
				{
652
				{
653
					this->textBox1->Text = openfile;
653
					this->textBox1->Text = openfile;
654
					this->panel2->Enabled = true;
654
					this->panel2->Enabled = true;
655
				}
655
				}
656
				else
656
				else
Line 659... Line 659...
659
		}
659
		}
660
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
660
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
661
			String ^openfile = this->OpenFile("Select the mod file to use as the secondary mod");
661
			String ^openfile = this->OpenFile("Select the mod file to use as the secondary mod");
662
			if ( openfile )
662
			if ( openfile )
663
			{
663
			{
664
				if ( m_pFile2->open(_S(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
664
				if ( m_pFile2->open(_WS(openfile), L"", CATREAD_CATDECRYPT, false) == CATERR_NONE )
665
				{
665
				{
666
					this->textBox2->Text = openfile;
666
					this->textBox2->Text = openfile;
667
					this->UpdateFileList();
667
					this->UpdateFileList();
668
				}
668
				}
669
				else
669
				else