| 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 |
CyString file1 = CFileIO(CyStringFromSystemString(this->textBox1->Text)).ChangeFileExtension("dat");
|
157 |
Utils::String file1 = CFileIO(_S(this->textBox1->Text)).changeFileExtension("dat");
|
| 158 |
CyString file2 = CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat");
|
158 |
Utils::String file2 = CFileIO(_S(file)).changeFileExtension("dat");
|
| 159 |
if ( IO::File::Exists(SystemStringFromCyString(file2)) )
|
159 |
if ( IO::File::Exists(_US(file2)) )
|
| 160 |
IO::File::Delete(SystemStringFromCyString(file2));
|
160 |
IO::File::Delete(_US(file2));
|
| 161 |
IO::File::Copy(SystemStringFromCyString(file1), SystemStringFromCyString(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(_S(file), "", 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);
|
| Line 199... |
Line 199... |
| 199 |
{
|
199 |
{
|
| 200 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
200 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
| 201 |
CFileIO Config;
|
201 |
CFileIO Config;
|
| 202 |
if ( Config.open(_S(mydoc) + "/Egosoft/modmerge.dat") )
|
202 |
if ( Config.open(_S(mydoc) + "/Egosoft/modmerge.dat") )
|
| 203 |
{
|
203 |
{
|
| 204 |
std::vector<CyString> *lines = Config.ReadLines();
|
204 |
std::vector<Utils::String> *lines = Config.readLines();
|
| 205 |
if ( lines )
|
205 |
if ( lines )
|
| 206 |
{
|
206 |
{
|
| 207 |
for ( int i = 0; i < (int)lines->size(); i++ )
|
207 |
for ( int i = 0; i < (int)lines->size(); i++ )
|
| 208 |
{
|
208 |
{
|
| 209 |
CyString line(lines->at(i));
|
209 |
Utils::String line(lines->at(i));
|
| 210 |
CyString start = line.GetToken(":", 1, 1).lower();
|
210 |
Utils::String start = line.token(":", 1).lower();
|
| 211 |
CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
|
211 |
Utils::String rest = line.tokens(":", 2).removeFirstSpace();
|
| 212 |
if ( start.Compare("ModMergeSize") )
|
212 |
if ( start.Compare("ModMergeSize") )
|
| 213 |
this->Size = System::Drawing::Size(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
|
213 |
this->Size = System::Drawing::Size(rest.token(" ", 1).toInt(), rest.token(" ", 2).toInt());
|
| 214 |
else if ( start.Compare("ModMergePos") )
|
214 |
else if ( start.Compare("ModMergePos") )
|
| 215 |
{
|
215 |
{
|
| 216 |
m_iLocX = rest.GetToken(" ", 1, 1).ToInt();
|
216 |
m_iLocX = rest.token(" ", 1).toInt();
|
| 217 |
m_iLocY = rest.GetToken(" ", 2, 2).ToInt();
|
217 |
m_iLocY = rest.token(" ", 2).toInt();
|
| 218 |
if ( !this->TopMost )
|
218 |
if ( !this->TopMost )
|
| 219 |
this->Location = System::Drawing::Point(m_iLocX, m_iLocY);
|
219 |
this->Location = System::Drawing::Point(m_iLocX, m_iLocY);
|
| 220 |
}
|
220 |
}
|
| 221 |
else if ( start.Compare("ModMergeMax") )
|
221 |
else if ( start.Compare("ModMergeMax") )
|
| 222 |
{
|
222 |
{
|
| 223 |
if ( !this->TopMost )
|
223 |
if ( !this->TopMost )
|
| 224 |
this->WindowState = FormWindowState::Maximized;
|
224 |
this->WindowState = FormWindowState::Maximized;
|
| 225 |
}
|
225 |
}
|
| 226 |
else if ( start.Compare("GameDir") )
|
226 |
else if ( start.Compare("GameDir") )
|
| 227 |
SetGameDir(rest.GetToken(";", 1, 1).ToInt(), SystemStringFromCyString(rest.GetToken(";", 2)));
|
227 |
SetGameDir(rest.token(";", 1).toInt(), SystemStringFromCyString(rest.tokens(";", 2)));
|
| 228 |
}
|
228 |
}
|
| 229 |
|
229 |
|
| 230 |
delete lines;
|
230 |
delete lines;
|
| 231 |
}
|
231 |
}
|
| 232 |
}
|
232 |
}
|
| Line 236... |
Line 236... |
| 236 |
}
|
236 |
}
|
| 237 |
|
237 |
|
| 238 |
void SaveData()
|
238 |
void SaveData()
|
| 239 |
{
|
239 |
{
|
| 240 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
240 |
System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
|
| 241 |
CFileIO Config(CyStringFromSystemString(mydoc) + "/Egosoft/modmerge.dat");
|
241 |
CFileIO Config(_S(mydoc) + "/Egosoft/modmerge.dat");
|
| 242 |
CyStringList lines;
|
242 |
Utils::CStringList lines;
|
| 243 |
|
243 |
|
| 244 |
if ( this->WindowState == FormWindowState::Normal )
|
244 |
if ( this->WindowState == FormWindowState::Normal )
|
| 245 |
{
|
245 |
{
|
| 246 |
lines.PushBack(CyString("ModMergeSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
|
246 |
lines.pushBack(Utils::String("ModMergeSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
|
| 247 |
if ( this->TopMost )
|
247 |
if ( this->TopMost )
|
| 248 |
{
|
248 |
{
|
| 249 |
if ( m_iLocX != -1 && m_iLocY != -1 )
|
249 |
if ( m_iLocX != -1 && m_iLocY != -1 )
|
| 250 |
lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
|
250 |
lines.pushBack(Utils::String("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
|
| 251 |
}
|
251 |
}
|
| 252 |
else
|
252 |
else
|
| 253 |
lines.PushBack(CyString("ModMergePos:") + (long)this->Location.X + " " + (long)this->Location.Y);
|
253 |
lines.pushBack(Utils::String("ModMergePos:") + (long)this->Location.X + " " + (long)this->Location.Y);
|
| 254 |
}
|
254 |
}
|
| 255 |
else
|
255 |
else
|
| 256 |
{
|
256 |
{
|
| 257 |
lines.PushBack(CyString("ModMergeSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
|
257 |
lines.pushBack(Utils::String("ModMergeSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
|
| 258 |
if ( this->TopMost )
|
258 |
if ( this->TopMost )
|
| 259 |
{
|
259 |
{
|
| 260 |
if ( m_iLocX != -1 && m_iLocY != -1 )
|
260 |
if ( m_iLocX != -1 && m_iLocY != -1 )
|
| 261 |
lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
|
261 |
lines.pushBack(Utils::String("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
|
| 262 |
}
|
262 |
}
|
| 263 |
else
|
263 |
else
|
| 264 |
lines.PushBack(CyString("ModMergePos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
|
264 |
lines.pushBack(Utils::String("ModMergePos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
|
| 265 |
}
|
265 |
}
|
| 266 |
|
266 |
|
| 267 |
if ( this->WindowState == FormWindowState::Maximized )
|
267 |
if ( this->WindowState == FormWindowState::Maximized )
|
| 268 |
lines.PushBack("ModMergeMax:");
|
268 |
lines.pushBack("ModMergeMax:");
|
| 269 |
|
269 |
|
| 270 |
if ( this->textBox3->Text->Length )
|
270 |
if ( this->textBox3->Text->Length )
|
| 271 |
lines.PushBack(CyString("GameDir:") + (long)Convert::ToInt32(this->numericUpDown1->Value) + ";" + m_pPackages->getCurrentDirectory());
|
271 |
lines.pushBack(Utils::String("GameDir:") + (long)Convert::ToInt32(this->numericUpDown1->Value) + ";" + m_pPackages->getCurrentDirectory());
|
| 272 |
Config.WriteFile(&lines);
|
272 |
Config.writeFile(&lines);
|
| 273 |
}
|
273 |
}
|
| 274 |
|
274 |
|
| 275 |
|
275 |
|
| 276 |
bool SetGameDir(int patch, String ^gameDir)
|
276 |
bool SetGameDir(int patch, String ^gameDir)
|
| 277 |
{
|
277 |
{
|