Line 78... |
Line 78... |
78 |
TreeNode ^newNode = gcnew TreeNode(SystemStringFromCyString(str->str));
|
78 |
TreeNode ^newNode = gcnew TreeNode(SystemStringFromCyString(str->str));
|
79 |
|
79 |
|
80 |
int status = str->data.ToInt();
|
80 |
int status = str->data.ToInt();
|
81 |
if ( status == -1 ) // in both
|
81 |
if ( status == -1 ) // in both
|
82 |
{
|
82 |
{
|
83 |
if ( m_pPackages->CanWeMerge(str->str) )
|
83 |
if ( m_pPackages->CanWeMerge(str->str.ToString()) )
|
84 |
merged->Nodes->Add(newNode);
|
84 |
merged->Nodes->Add(newNode);
|
85 |
else if ( m_pPackages->NeedToMerge(str->str) )
|
85 |
else if ( m_pPackages->NeedToMerge(str->str) )
|
86 |
conflict->Nodes->Add(newNode);
|
86 |
conflict->Nodes->Add(newNode);
|
87 |
else
|
87 |
else
|
88 |
both->Nodes->Add(newNode);
|
88 |
both->Nodes->Add(newNode);
|
Line 138... |
Line 138... |
138 |
ofd->Filter = "X-Universe Mod File (*.cat)|*.cat";
|
138 |
ofd->Filter = "X-Universe Mod File (*.cat)|*.cat";
|
139 |
ofd->Title = "Select the mod file you wish to merge files into";
|
139 |
ofd->Title = "Select the mod file you wish to merge files into";
|
140 |
ofd->FilterIndex = 1;
|
140 |
ofd->FilterIndex = 1;
|
141 |
ofd->RestoreDirectory = true;
|
141 |
ofd->RestoreDirectory = true;
|
142 |
ofd->AddExtension = true;
|
142 |
ofd->AddExtension = true;
|
143 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
143 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK ) {
|
- |
|
144 |
if ( ofd->FileName == this->textBox1->Text || ofd->FileName == this->textBox2->Text )
|
- |
|
145 |
MessageBox::Show(this, "Error: Unable to save to file: " + ofd->FileName + "\nYou must not select the same file name as the primary or secondary mod", "Invalid Save File", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
- |
|
146 |
else
|
144 |
Merge(ofd->FileName);
|
147 |
Merge(ofd->FileName);
|
- |
|
148 |
}
|
145 |
}
|
149 |
}
|
146 |
|
150 |
|
147 |
void Merge(String ^file)
|
151 |
void Merge(String ^file)
|
148 |
{
|
152 |
{
|
149 |
// create the mod file by copying the primary mod
|
153 |
// create the mod file by copying the primary mod
|
Line 154... |
Line 158... |
154 |
CyString file1 = CFileIO(CyStringFromSystemString(this->textBox1->Text)).ChangeFileExtension("dat");
|
158 |
CyString file1 = CFileIO(CyStringFromSystemString(this->textBox1->Text)).ChangeFileExtension("dat");
|
155 |
CyString file2 = CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat");
|
159 |
CyString file2 = CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat");
|
156 |
if ( IO::File::Exists(SystemStringFromCyString(file2)) )
|
160 |
if ( IO::File::Exists(SystemStringFromCyString(file2)) )
|
157 |
IO::File::Delete(SystemStringFromCyString(file2));
|
161 |
IO::File::Delete(SystemStringFromCyString(file2));
|
158 |
IO::File::Copy(SystemStringFromCyString(file1), SystemStringFromCyString(file2));
|
162 |
IO::File::Copy(SystemStringFromCyString(file1), SystemStringFromCyString(file2));
|
159 |
|
163 |
|
160 |
CCatFile CatFile;
|
164 |
CCatFile CatFile;
|
161 |
if ( !CCatFile::Opened(CatFile.Open(CyStringFromSystemString(file), "", CATREAD_CATDECRYPT, false), false) )
|
165 |
if ( !CCatFile::Opened(CatFile.Open(CyStringFromSystemString(file), "", CATREAD_CATDECRYPT, false), false) )
|
162 |
{
|
166 |
{
|
163 |
MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
167 |
MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
164 |
return;
|
168 |
return;
|
Line 166... |
Line 170... |
166 |
|
170 |
|
167 |
// now we need to move non merge files from the 2nd mod to the new one
|
171 |
// now we need to move non merge files from the 2nd mod to the new one
|
168 |
CyStringList *list = m_pPackages->GetMergedFiles(m_pFile1, m_pFile2);
|
172 |
CyStringList *list = m_pPackages->GetMergedFiles(m_pFile1, m_pFile2);
|
169 |
if ( list )
|
173 |
if ( list )
|
170 |
{
|
174 |
{
|
171 |
for ( SStringList *str = list->Head(); str; str = str->next )
|
- |
|
172 |
{
|
- |
|
173 |
int status = str->data.ToInt();
|
- |
|
174 |
if ( status == 2 ) // in 2nd mod
|
- |
|
175 |
CatFile.AppendFile(_S(this->textBox2->Text) + "::" + str->str.ToString(), str->str.ToString());
|
175 |
CModDiff Diff(_S(this->textBox3->Text).token(" (", 1), "addon", Convert::ToInt32(this->numericUpDown1->Value));
|
176 |
// finally, we need to diff the remaining files
|
176 |
if ( Diff.startDiff(_S(this->textBox2->Text)) ) {
|
177 |
else if ( status == -1 ) // in both
|
177 |
for ( SStringList *str = list->Head(); str; str = str->next )
|
178 |
{
|
178 |
{
|
- |
|
179 |
int status = str->data.ToInt();
|
179 |
// only diffable files, we ignore the rest
|
180 |
if ( status == 2 ) { // in 2nd mod
|
- |
|
181 |
if ( CatFile.AppendFile(_S(this->textBox2->Text) + "::" + str->str.ToString(), str->str.ToString()) )
|
180 |
if ( CModDiff::CanBeDiffed(str->str) )
|
182 |
CatFile.WriteCatFile();
|
181 |
{
|
183 |
}
|
182 |
CModDiff Diff(CyStringFromSystemString(this->textBox3->Text), Convert::ToInt32(this->numericUpDown1->Value));
|
184 |
// finally, we need to diff the remaining files
|
183 |
if ( !Diff.CreateDiff(CyStringFromSystemString(this->textBox2->Text)) )
|
185 |
else if ( status == -1 ) { // in both
|
184 |
continue;
|
186 |
// only diffable files, we ignore the rest
|
185 |
Diff.ApplyDiff(CyStringFromSystemString(file));
|
187 |
if ( CModDiff::CanBeDiffed(str->str.ToString()) ) Diff.doDiff(str->str.ToString());
|
186 |
}
|
188 |
}
|
187 |
}
|
189 |
}
|
188 |
}
|
- |
|
189 |
|
190 |
|
- |
|
191 |
Diff.ApplyDiff(_S(file));
|
- |
|
192 |
}
|
190 |
delete list;
|
193 |
delete list;
|
191 |
}
|
194 |
}
|
192 |
|
195 |
|
193 |
MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
196 |
MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
194 |
}
|
197 |
}
|