Rev 224 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once#include <spk.h>#define VERSION 1.30#undef GetTempPathnamespace XspConvert {using namespace System;using namespace System::ComponentModel;using namespace System::Collections;using namespace System::Windows::Forms;using namespace System::Data;using namespace System::Drawing;/// <summary>/// Summary for Form1////// WARNING: If you change the name of this class, you will need to change the/// 'Resource File Name' property for the managed resource compiler tool/// associated with all .resx files this class depends on. Otherwise,/// the designers will not be able to interact properly with localized/// resources associated with this form./// </summary>public ref class Form1 : public System::Windows::Forms::Form{public:Form1(System::String ^open){InitializeComponent();this->UpdateTitle();m_bLoading = false;m_bDontChange = false;m_bDontUpdate = false;m_bChanged = false;m_bReadText = false;m_pLoadedShip = NULL;m_pDirList = new Utils::WStringList;m_pTextList = new CLinkList<Utils::WStringList>;m_pLaserList = new CLinkList<Utils::WStringList>;m_pMissileList = new CLinkList<Utils::WStringList>;m_pCockpit = NULL;this->PanelMain->Hide();this->PanelNotLoaded->Show();m_iOldGame = -1;this->Setup();if ( open )m_sOpenFile = open;}protected:/// <summary>/// Clean up any resources being used./// </summary>~Form1(){if ( m_pLoadedShip )delete m_pLoadedShip;if ( m_pDirList )delete m_pDirList;if ( m_pTextList )delete m_pTextList;if ( m_pLaserList )delete m_pLaserList;if ( m_pMissileList )delete m_pMissileList;if (components){delete components;}}private: System::Windows::Forms::MenuStrip^ menuStrip1;protected:private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;private: System::Windows::Forms::ToolStripMenuItem^ openToolStripMenuItem;private: System::Windows::Forms::Panel^ panel1;private: System::Windows::Forms::Button^ ButExit;private: System::Windows::Forms::Panel^ PanelMain;private:bool m_bLoading;bool m_bDontUpdate;bool m_bChanged;bool m_bReadText;bool m_bDontChange;Utils::WStringList *m_pDirList;CLinkList<Utils::WStringList> *m_pTextList;CLinkList<Utils::WStringList> *m_pLaserList;CLinkList<Utils::WStringList> *m_pMissileList;CXspFile *m_pLoadedShip;int m_iOldGame;array<System::Windows::Forms::ToolStripMenuItem^> ^m_aTools;System::String ^m_sOpenFile;SCockpit *m_pCockpit;int m_iLoadedLaserMask;int m_iLoadedMissileMask;int m_iLaserMask;int m_iMissileMask;private: System::Windows::Forms::Panel^ PanelNotLoaded;private: System::Windows::Forms::Label^ LabelNotLoaded;private: System::Windows::Forms::ComboBox^ ComboGame;private: System::Windows::Forms::Panel^ panel2;private: System::Windows::Forms::Label^ label1;private: System::Windows::Forms::ToolStripMenuItem^ saveToolStripMenuItem;private: System::Windows::Forms::CheckedListBox^ WeaponList;private: System::Windows::Forms::ToolStripMenuItem^ settingsToolStripMenuItem;private: System::Windows::Forms::ToolStripMenuItem^ gamesToolStripMenuItem;private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;private: System::Windows::Forms::ToolStripMenuItem^ updateGameDataToolStripMenuItem;private: System::Windows::Forms::TabControl^ tabControl1;private: System::Windows::Forms::TabPage^ tabPage1;private: System::Windows::Forms::TabPage^ tabPage2;private: System::Windows::Forms::CheckedListBox^ MissileList;private: System::Windows::Forms::ToolStripMenuItem^ loadGameTextToolStripMenuItem;private: System::Windows::Forms::ToolStripMenuItem^ saveAsToolStripMenuItem;private: System::Windows::Forms::TabPage^ tabPage3;private: System::Windows::Forms::CheckedListBox^ CockpitWeapons;private: System::Windows::Forms::ComboBox^ ComboCockpits;/// <summary>/// Required designer variable./// </summary>System::ComponentModel::Container ^components;#pragma region Windows Form Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>void Setup(){this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);this->CockpitWeapons->ItemCheck += gcnew ItemCheckEventHandler(this, &Form1::Event_Changed);// read data fileSystem::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );CFileIO Config;if ( Config.open(_WS(mydoc) + L"/Egosoft/xspconvert.dat") ){std::vector<Utils::WString> lines;if(Config.readLines(lines)){for (size_t i = 0; i < lines.size(); i++ ){Utils::WString line(lines.at(i));Utils::WString start = line.token(L":", 1).toLower();Utils::WString rest = line.tokens(L":", 2).removeFirstSpace();if ( start.Compare(L"Dir") ){Utils::WString game = rest.token(L" ", 1);Utils::WString dir = rest.tokens(L" ", 2);Utils::WString find = m_pDirList->findData(game);if (!find.empty())m_pDirList->remove(find);m_pDirList->pushBack(dir, game);}else if ( line.Compare(L"ReadText") )m_bReadText = true;}}}this->UpdateGames();this->loadGameTextToolStripMenuItem->Checked = m_bReadText;}void UpdateGames(){this->gamesToolStripMenuItem->DropDownItems->Clear();this->ComboGame->Items->Clear();CPackages p;p.startup(L".", L".", L".");// start at 1 to skip X2for ( int i = 1; i < p.GetGameExe()->numGames(); i++ ){bool added = false;Utils::WString find = m_pDirList->findData(Utils::WString::Number(i));if (!find.empty()){if(find != L"-1")added = true;}SGameExe *exe = p.GetGameExe()->game(i);this->ComboGame->Items->Add(_US(exe->sName));System::Windows::Forms::ToolStripMenuItem ^newMenu = gcnew System::Windows::Forms::ToolStripMenuItem;newMenu->Text = _US(exe->sName);this->gamesToolStripMenuItem->DropDownItems->Add(newMenu);System::Windows::Forms::ToolStripMenuItem ^newMenuDir = gcnew System::Windows::Forms::ToolStripMenuItem;if ( added )newMenuDir->Text = _US(m_pDirList->findData(Utils::WString::Number(i)));elsenewMenuDir->Text = "No Directory";newMenuDir->Enabled = false;newMenu->DropDownItems->Add(newMenuDir);newMenu->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator);System::Windows::Forms::ToolStripMenuItem ^newMenuChange = gcnew System::Windows::Forms::ToolStripMenuItem;newMenuChange->Text = "Set Directory";newMenuChange->Tag = _US(Utils::WString::Number(i)) + " " + _US(exe->sName);newMenuChange->Click += gcnew System::EventHandler(this, &Form1::Event_ChangeDirectory);newMenu->DropDownItems->Add(newMenuChange);if ( added ){System::Windows::Forms::ToolStripMenuItem ^newMenuRemove = gcnew System::Windows::Forms::ToolStripMenuItem;newMenu->DropDownItems->Add(newMenuRemove);newMenuRemove->Text = "Remove Directory";newMenuRemove->Tag = _US(Utils::WString::Number(i)) + " " + _US(exe->sName);newMenuRemove->Click += gcnew System::EventHandler(this, &Form1::Event_RemoveDirectory);}}}void UpdateTitle(){System::String ^title = "XSP Convertor V" + _US(Utils::WString::FromFloat((float)VERSION, 2));if ( m_pLoadedShip ){if ( m_bChanged || m_pLoadedShip->hasChanged() )this->Text = title + " [*" + _US(m_pLoadedShip->filename()) + "]";elsethis->Text = title + " [" + _US(m_pLoadedShip->filename()) + "]";}elsethis->Text = title;}void SaveShip(){if ( !m_pLoadedShip )MessageBox::Show(this, "There is currently no ship loaded to convert", "Ship Save", MessageBoxButtons::OK, MessageBoxIcon::Warning);else{this->SaveMasks();if ( m_pLoadedShip->writeFile(m_pLoadedShip->filename().toString()) ){MessageBox::Show(this, "Ship File: " + _US(m_pLoadedShip->filename()) + "\n\nHas been written", "Ship Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);m_bChanged = false;}}this->UpdateTitle();}void SaveShipAs(){if ( !m_pLoadedShip )MessageBox::Show(this, "There is currently no ship loaded to convert", "Ship Save", MessageBoxButtons::OK, MessageBoxIcon::Warning);else{SaveFileDialog ^ofd = gcnew SaveFileDialog();ofd->Filter = "Ship Files (*.xsp)|*.xsp";ofd->FilterIndex = 1;ofd->RestoreDirectory = true;if ( ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK ){this->SaveMasks();if ( m_pLoadedShip->writeFile(_WS(ofd->FileName)) ){MessageBox::Show(this, "Ship File: " + ofd->FileName + "\n\nHas been written", "Ship Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);m_bChanged = false;}}}this->UpdateTitle();}Utils::WString GetObjectString(int desc, const Utils::WString &idText){if ( m_bReadText ){if ( this->ComboGame->SelectedIndex < m_pMissileList->size() ){Utils::WStringList *textList = m_pTextList->Get(this->ComboGame->SelectedIndex);if ( textList ){Utils::WString str = textList->findData(Utils::WString::Number(desc));if (str){// perform recursive lookupwhile (str.contains(L"{17,") && str.contains(L"}")){int pos = str.findPos(L"{17,");pos += 4;Utils::WString check = str.right(-pos);check = check.token(L"}", 1);int num = check.toInt();Utils::WString newDesc = this->GetObjectString(num, L"#" + check + L"#");str = str.findReplace(L"{17," + check + L"}", newDesc);}// remove anything in bracketswhile(str.contains(L"(") && str.contains(L")")){int pos = str.findPos(L"(");str.erase(pos, (str.findPos(L")", pos) + 1) - pos);}return str;}}}}return idText;}void UpdateNames(){this->WeaponList->Items->Clear();this->MissileList->Items->Clear();this->CockpitWeapons->Items->Clear();bool addedLaser = false;bool addedMissile = false;Utils::WStringList missiles;if ( this->ComboGame->SelectedIndex < m_pMissileList->size() ){Utils::WStringList *missileList = m_pMissileList->Get(this->ComboGame->SelectedIndex);if ( missileList ){for(auto itr = missileList->begin(); itr != missileList->end(); itr++){Utils::WString id = (*itr)->str.token(L";", 6);Utils::WStringNode* found = missiles[id];Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 37));if ( found ){found->data += L", ";found->data += str;}elsemissiles.pushBack(id, str);}}}Utils::WStringList lasers;if ( this->ComboGame->SelectedIndex < m_pLaserList->size() ){Utils::WStringList *laserList = m_pLaserList->Get(this->ComboGame->SelectedIndex);if ( laserList ){for (auto itr = laserList->begin(); itr != laserList->end(); itr++){Utils::WString id = (*itr)->str.token(L";", 6);Utils::WStringNode* found = lasers[id];Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 23));if ( found ){found->data += L", ";found->data += str;}elselasers.pushBack(id, str);}}}for (size_t i = 0; i < 32; i++ ){if ( lasers.size() > i ){this->WeaponList->Items->Add(_US(lasers[i]->data));this->CockpitWeapons->Items->Add(_US(lasers[i]->data));addedLaser = true;}if ( missiles.size() > i ){this->MissileList->Items->Add(_US(missiles[i]->data));addedMissile = true;}if ( !addedLaser ){this->WeaponList->Items->Add(_US(Utils::WString::Number(i + 1)));this->CockpitWeapons->Items->Add(_US(Utils::WString::Number(i + 1)));}if ( !addedMissile )this->MissileList->Items->Add(_US(Utils::WString::Number(i + 1)));}}void OpenFile(System::String ^open){CXspFile *shipFile = new CXspFile;int check = CSpkFile::CheckFile(_WS(open));bool loaded = false;m_bChanged = false;if ( check == SPKFILE_SINGLESHIP )loaded = shipFile->readFile(_WS(open));else if ( check == SPKFILE_INVALID ){loaded = shipFile->convertOld(_WS(open));if ( loaded )m_bChanged = true;}this->ComboCockpits->Items->Clear();m_pCockpit = NULL;if ( loaded ){m_bLoading = true;if ( m_pLoadedShip )delete m_pLoadedShip;m_pLoadedShip = shipFile;m_pLoadedShip->setFilename(_WS(open));this->PanelMain->Show();this->PanelNotLoaded->Hide();m_iOldGame = -1;if ( m_pLoadedShip->AnyCockpits() ){for ( SCockpit *c = m_pLoadedShip->GetCockpits()->First(); c; c = m_pLoadedShip->GetCockpits()->Next() )this->ComboCockpits->Items->Add(_US(c->sCockpit.token(L";", 19)));this->CockpitWeapons->Show();this->ComboCockpits->Enabled = true;//m_pCockpit = m_pLoadedShip->GetCockpits()->First();}else{this->CockpitWeapons->Hide();this->ComboCockpits->Enabled = false;}this->ComboGame->SelectedIndex = 0;if ( this->ComboCockpits->Items->Count )this->ComboCockpits->SelectedIndex = 0;m_bChanged = false;this->UpdateTitle();MessageBox::Show(this, "Ship File: " + open + "\nHas been loaded", "Ship Loaded", MessageBoxButtons::OK, MessageBoxIcon::Information);}else{delete shipFile;if ( m_pLoadedShip ){this->PanelMain->Hide();this->PanelNotLoaded->Show();}else{this->PanelMain->Show();this->PanelNotLoaded->Hide();}MessageBox::Show(this, "Ship File: " + open + "\nHas failed to load", "Ship Failed", MessageBoxButtons::OK, MessageBoxIcon::Information);}m_bLoading = false;}void CheckSave(){if ( (m_pLoadedShip && m_pLoadedShip->hasChanged()) || m_bChanged ){if ( MessageBox::Show(this, "The current ship has been modified, do you wish to save it?", "Save Ship", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )this->SaveShip();}}void OpenFile(){// check if we need to savethis->CheckSave();OpenFileDialog ^ofd = gcnew OpenFileDialog();ofd->Filter = "Ship Files (*.xsp)|*.xsp";ofd->FilterIndex = 1;ofd->RestoreDirectory = true;if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )this->OpenFile(ofd->FileName);this->UpdateTitle();}void LoadGameData(){m_pLaserList->MemoryClear();m_pMissileList->MemoryClear();m_pTextList->MemoryClear();System::String ^tempDir = System::IO::Path::GetTempPath();Utils::WString sTempDir = _WS(tempDir);CPackages p;bool tcText = false;for(auto itr = m_pDirList->begin(); itr != m_pDirList->end(); itr++){Utils::WStringList *laserList = new Utils::WStringList;m_pLaserList->push_back(laserList);Utils::WStringList *missileList = new Utils::WStringList;m_pMissileList->push_back(missileList);Utils::WStringList *textList = new Utils::WStringList;m_pTextList->push_back(textList);if ( p.extractGameFile(L"types/TLaser.pck", sTempDir + L"/TLaser.txt", (*itr)->str) ){CFileIO Open(sTempDir + L"/TLaser.txt");std::vector<Utils::WString> lines;if(Open.readLines(lines)){bool first = false;for ( int j = 0; j < (int)lines.size(); j++ ){Utils::WString line(lines.at(j));if ( line[0] == '/' )continue;line.removeChar('\r');line = line.removeFirstSpace();line = line.removeEndSpace();if ( line.empty() )continue;if ( !first ){first = true;continue;}laserList->pushBack(line);}}Open.remove();}if ( p.extractGameFile(L"types/TMissiles.pck", sTempDir + L"/TMissiles.txt", (*itr)->str) ){CFileIO Open(sTempDir + L"/TMissiles.txt");std::vector<Utils::WString> lines;if(Open.readLines(lines)){bool first = false;for ( int j = 0; j < (int)lines.size(); j++ ){Utils::WString line(lines.at(j));if ( line[0] == '/' )continue;line.removeChar('\r');line = line.removeFirstSpace();line = line.removeEndSpace();if ( line.empty() )continue;if ( !first ){first = true;continue;}missileList->pushBack(line);}}Open.remove();}if ( !m_bReadText )continue;// load the text fileUtils::WString textFormat;if ( tcText )textFormat = L"0001-L044";elsetextFormat = L"440001";if ( p.extractGameFile(L"t/" + textFormat + L".pck", sTempDir + L"/" + textFormat + L".xml", (*itr)->str) ){CFileIO Open(sTempDir + textFormat + L".xml");if ( Open.startRead() ){int donePage = (tcText) ? 3 : 2;int inPage = 0;while ( !Open.atEnd() ){Utils::WString line = Open.readEndOfLine();if ( line.empty() )continue;line = line.removeFirstSpace();line = line.remove('\t');if ( !inPage ){if ( line.left(5).Compare(L"<page") ){int pos = line.findPos(L" id=\"");if ( pos != -1 ){int endpos = line.findPos(L"\"", pos + 5);if ( endpos != -1 ){Utils::WString check = line.mid(pos + 6, endpos - pos - 5);int iPage = check.toInt();if ( iPage == 17 || iPage == 300017 || iPage == 350017 || iPage == 380017 || iPage == 390017)inPage = iPage;}}}}else{if ( line.left(6).Compare(L"</page") ){inPage = 0;--donePage;if ( donePage <= 0 )break;}else{int pos = line.findPos(L"t id=\"");if ( pos != -1 ){int endpos = line.findPos(L"\"", pos + 6);if ( endpos != -1 ){Utils::WString check = line.mid(pos + 7, endpos - pos - 6);Utils::WString data;int pos = line.findPos(L">", endpos);if ( pos != -1 ){endpos = line.findPos(L"</", pos);if ( endpos != -1 )data = line.mid(pos + 2, endpos - pos - 1);}Utils::WString find = textList->findData(check);if (find)textList->remove(find);elsetextList->pushBack(data, check);}}}}}Open.close();}}tcText = true;}}void LoadGameDirectory(){CPackages p;p.startup(L".", L".", L".");for ( int i = 1; i < p.GetGameExe()->numGames(); i++ ){SGameExe *exe = p.GetGameExe()->game(i);if ( !m_pDirList->containsData(Utils::WString::Number(i)) ){if ( MessageBox::Show(this, "You have no directories set for " + _US(exe->sName) + "\n\nWould you like to set it now?", "Game Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes ){FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;fbd->Description = "Select the path for " + _US(exe->sName);if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK ){CDirIO Dir(_WS(fbd->SelectedPath));if ( !Dir.exists(exe->sExe) )MessageBox::Show(this, "Unable to find " + _US(exe->sExe) + " in " + fbd->SelectedPath, "Game Directory", MessageBoxButtons::OK, MessageBoxIcon::Warning);elsem_pDirList->pushBack(_WS(fbd->SelectedPath), Utils::WString::Number(i));}}elsem_pDirList->pushBack(L"-1", Utils::WString::Number(i));}}if ( !m_pDirList->empty() ){if ( MessageBox::Show(this, "Would you like to load the game data?", "Load Game Data", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )this->LoadGameData();}this->UpdateGames();}void CloseDialog(){System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );CFileIO Config(_WS(mydoc) + L"/Egosoft/xspconvert.dat");std::vector<Utils::WString> lines;for(auto itr = m_pDirList->begin(); itr != m_pDirList->end(); itr++)lines.push_back(L"Dir:" + (*itr)->data + L" " + (*itr)->str);if ( m_bReadText )lines.push_back(L"ReadText");Config.writeFile(lines);}void CheckListChanged(){if ( m_bDontUpdate )return;if ( m_bDontChange )return;if ( m_pLoadedShip )m_bChanged = true;this->UpdateTitle();}int GetMask(CheckedListBox ^list){int oldMask = 0;// First show the index and check state of all selected items.IEnumerator^ myEnum1 = list->CheckedIndices->GetEnumerator();while ( myEnum1->MoveNext() ){int indexChecked = *safe_cast<int^>(myEnum1->Current);oldMask |= (1 << indexChecked);}return oldMask;}void SaveMasks(){if ( m_pLoadedShip ){if ( m_iOldGame != -1 ){m_pLoadedShip->SetLaserMask(m_iOldGame, m_iLaserMask);m_pLoadedShip->SetMissileMask(m_iOldGame, m_iMissileMask);}if ( m_pCockpit )m_pLoadedShip->addCockpit(m_pCockpit->sCockpit, (m_iOldGame == -1) ? (this->ComboGame->SelectedIndex + 2) : m_iOldGame, this->GetMask(this->CockpitWeapons));}}void ChangeGame(){if ( !m_pLoadedShip )return;bool oldChanged = m_pLoadedShip->hasChanged();m_bDontUpdate = true;// save old maskif ( !m_bLoading )this->SaveMasks();m_iOldGame = this->ComboGame->SelectedIndex + 2;this->UpdateNames();int mask = m_pLoadedShip->GetLaserMask(this->ComboGame->SelectedIndex + 2, true);for ( int i = 0; i < this->WeaponList->Items->Count; i++ )this->WeaponList->SetItemChecked(i, (mask & (1 << i)) ? true : false);m_iLaserMask = m_iLoadedLaserMask = mask;mask = m_pLoadedShip->GetMissileMask(this->ComboGame->SelectedIndex + 2, true);for ( int i = 0; i < this->MissileList->Items->Count; i++ )this->MissileList->SetItemChecked(i, (mask & (1 << i)) ? true : false);m_iMissileMask = m_iLoadedMissileMask = mask;if ( this->ComboCockpits->Items->Count ){if ( this->ComboCockpits->SelectedIndex < 0 )this->ComboCockpits->SelectedIndex = 0;elsethis->UpdateCockpitList();}m_pLoadedShip->adjustChanged(oldChanged);m_bDontUpdate = false;this->UpdateTitle();}void Event_RemoveDirectory(System::Object ^sender, System::EventArgs ^E){System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);if ( item ){Utils::WString game = _WS(cli::safe_cast<System::String ^>(item->Tag));game = game.token(L" ", 1);Utils::WString find = m_pDirList->findData(game);if(find){m_pDirList->remove(find);m_pDirList->pushBack(L"-1", game);this->UpdateGames();}}}void Event_ChangeDirectory(System::Object ^sender, System::EventArgs ^E){System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);if ( item ){Utils::WString tag = _WS(cli::safe_cast<System::String ^>(item->Tag));Utils::WString game = tag.token(L" ", 1);if ( m_pDirList->containsData(game) ){FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;fbd->Description = "Select the path for " + _US(tag.tokens(L" ", 2));if ( fbd->ShowDialog() == System::Windows::Forms::DialogResult::OK ){Utils::WString data = m_pDirList->findData(game);m_pDirList->remove(data);m_pDirList->pushBack(_WS(fbd->SelectedPath), game);this->UpdateGames();}}}}void UpdateCockpitList(){if ( !m_pLoadedShip )return;m_bDontChange = true;if ( !m_bDontUpdate && m_pCockpit )m_pLoadedShip->addCockpit(m_pCockpit->sCockpit, (m_iOldGame == -1) ? (this->ComboGame->SelectedIndex + 2) : m_iOldGame, this->GetMask(this->CockpitWeapons));m_pCockpit = NULL;// find the cockpit pointerm_pCockpit = m_pLoadedShip->GetCockpits()->Get(this->ComboCockpits->SelectedIndex);int mask = 0;if ( m_pCockpit ){mask = m_pCockpit->sCockpit.token(L";", 9);for ( SWeaponMask *wm = m_pCockpit->lWeaponMask.First(); wm; wm = m_pCockpit->lWeaponMask.Next() ){if ( wm->iGame == (this->ComboGame->SelectedIndex + 2) ){mask = wm->iMask;break;}}}for ( int i = 0; i < this->CockpitWeapons->Items->Count; i++ )this->CockpitWeapons->SetItemChecked(i, (mask & (1 << i)) ? true : false);m_bDontChange = false;}void InitializeComponent(void){System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->saveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->settingsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->gamesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->loadGameTextToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());this->updateGameDataToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());this->panel1 = (gcnew System::Windows::Forms::Panel());this->ButExit = (gcnew System::Windows::Forms::Button());this->PanelMain = (gcnew System::Windows::Forms::Panel());this->tabControl1 = (gcnew System::Windows::Forms::TabControl());this->tabPage1 = (gcnew System::Windows::Forms::TabPage());this->WeaponList = (gcnew System::Windows::Forms::CheckedListBox());this->tabPage2 = (gcnew System::Windows::Forms::TabPage());this->MissileList = (gcnew System::Windows::Forms::CheckedListBox());this->tabPage3 = (gcnew System::Windows::Forms::TabPage());this->CockpitWeapons = (gcnew System::Windows::Forms::CheckedListBox());this->ComboCockpits = (gcnew System::Windows::Forms::ComboBox());this->panel2 = (gcnew System::Windows::Forms::Panel());this->ComboGame = (gcnew System::Windows::Forms::ComboBox());this->label1 = (gcnew System::Windows::Forms::Label());this->PanelNotLoaded = (gcnew System::Windows::Forms::Panel());this->LabelNotLoaded = (gcnew System::Windows::Forms::Label());this->menuStrip1->SuspendLayout();this->panel1->SuspendLayout();this->PanelMain->SuspendLayout();this->tabControl1->SuspendLayout();this->tabPage1->SuspendLayout();this->tabPage2->SuspendLayout();this->tabPage3->SuspendLayout();this->panel2->SuspendLayout();this->PanelNotLoaded->SuspendLayout();this->SuspendLayout();//// menuStrip1//this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->fileToolStripMenuItem,this->settingsToolStripMenuItem});this->menuStrip1->Location = System::Drawing::Point(0, 0);this->menuStrip1->Name = L"menuStrip1";this->menuStrip1->Size = System::Drawing::Size(416, 24);this->menuStrip1->TabIndex = 0;this->menuStrip1->Text = L"menuStrip1";//// fileToolStripMenuItem//this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->openToolStripMenuItem,this->saveToolStripMenuItem, this->saveAsToolStripMenuItem});this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);this->fileToolStripMenuItem->Text = L"&File";//// openToolStripMenuItem//this->openToolStripMenuItem->Name = L"openToolStripMenuItem";this->openToolStripMenuItem->Size = System::Drawing::Size(114, 22);this->openToolStripMenuItem->Text = L"&Open";this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openToolStripMenuItem_Click);//// saveToolStripMenuItem//this->saveToolStripMenuItem->Name = L"saveToolStripMenuItem";this->saveToolStripMenuItem->Size = System::Drawing::Size(114, 22);this->saveToolStripMenuItem->Text = L"&Save";this->saveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveToolStripMenuItem_Click);//// saveAsToolStripMenuItem//this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem";this->saveAsToolStripMenuItem->Size = System::Drawing::Size(114, 22);this->saveAsToolStripMenuItem->Text = L"Save &As";this->saveAsToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveAsToolStripMenuItem_Click);//// settingsToolStripMenuItem//this->settingsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->gamesToolStripMenuItem,this->loadGameTextToolStripMenuItem, this->toolStripSeparator1, this->updateGameDataToolStripMenuItem});this->settingsToolStripMenuItem->Name = L"settingsToolStripMenuItem";this->settingsToolStripMenuItem->Size = System::Drawing::Size(61, 20);this->settingsToolStripMenuItem->Text = L"Settings";//// gamesToolStripMenuItem//this->gamesToolStripMenuItem->Name = L"gamesToolStripMenuItem";this->gamesToolStripMenuItem->Size = System::Drawing::Size(173, 22);this->gamesToolStripMenuItem->Text = L"Games";//// loadGameTextToolStripMenuItem//this->loadGameTextToolStripMenuItem->Name = L"loadGameTextToolStripMenuItem";this->loadGameTextToolStripMenuItem->Size = System::Drawing::Size(173, 22);this->loadGameTextToolStripMenuItem->Text = L"Load Game Text";this->loadGameTextToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::loadGameTextToolStripMenuItem_Click);//// toolStripSeparator1//this->toolStripSeparator1->Name = L"toolStripSeparator1";this->toolStripSeparator1->Size = System::Drawing::Size(170, 6);//// updateGameDataToolStripMenuItem//this->updateGameDataToolStripMenuItem->Name = L"updateGameDataToolStripMenuItem";this->updateGameDataToolStripMenuItem->Size = System::Drawing::Size(173, 22);this->updateGameDataToolStripMenuItem->Text = L"Update Game Data";this->updateGameDataToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::updateGameDataToolStripMenuItem_Click);//// panel1//this->panel1->Controls->Add(this->ButExit);this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;this->panel1->Location = System::Drawing::Point(0, 376);this->panel1->Name = L"panel1";this->panel1->Size = System::Drawing::Size(416, 33);this->panel1->TabIndex = 1;//// ButExit//this->ButExit->DialogResult = System::Windows::Forms::DialogResult::Cancel;this->ButExit->Dock = System::Windows::Forms::DockStyle::Right;this->ButExit->Location = System::Drawing::Point(303, 0);this->ButExit->Name = L"ButExit";this->ButExit->Size = System::Drawing::Size(113, 33);this->ButExit->TabIndex = 0;this->ButExit->Text = L"Exit";this->ButExit->UseVisualStyleBackColor = true;this->ButExit->Click += gcnew System::EventHandler(this, &Form1::ButExit_Click);//// PanelMain//this->PanelMain->Controls->Add(this->tabControl1);this->PanelMain->Controls->Add(this->panel2);this->PanelMain->Dock = System::Windows::Forms::DockStyle::Fill;this->PanelMain->Location = System::Drawing::Point(0, 24);this->PanelMain->Name = L"PanelMain";this->PanelMain->Size = System::Drawing::Size(416, 352);this->PanelMain->TabIndex = 2;//// tabControl1//this->tabControl1->Controls->Add(this->tabPage1);this->tabControl1->Controls->Add(this->tabPage2);this->tabControl1->Controls->Add(this->tabPage3);this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;this->tabControl1->Location = System::Drawing::Point(0, 22);this->tabControl1->Name = L"tabControl1";this->tabControl1->SelectedIndex = 0;this->tabControl1->Size = System::Drawing::Size(416, 330);this->tabControl1->TabIndex = 2;//// tabPage1//this->tabPage1->Controls->Add(this->WeaponList);this->tabPage1->Location = System::Drawing::Point(4, 22);this->tabPage1->Name = L"tabPage1";this->tabPage1->Padding = System::Windows::Forms::Padding(3);this->tabPage1->Size = System::Drawing::Size(408, 304);this->tabPage1->TabIndex = 0;this->tabPage1->Text = L"Lasers";this->tabPage1->UseVisualStyleBackColor = true;//// WeaponList//this->WeaponList->CheckOnClick = true;this->WeaponList->Dock = System::Windows::Forms::DockStyle::Fill;this->WeaponList->FormattingEnabled = true;this->WeaponList->HorizontalScrollbar = true;this->WeaponList->Location = System::Drawing::Point(3, 3);this->WeaponList->Name = L"WeaponList";this->WeaponList->Size = System::Drawing::Size(402, 289);this->WeaponList->TabIndex = 3;this->WeaponList->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &Form1::WeaponListEvent_Changed);//// tabPage2//this->tabPage2->Controls->Add(this->MissileList);this->tabPage2->Location = System::Drawing::Point(4, 22);this->tabPage2->Name = L"tabPage2";this->tabPage2->Padding = System::Windows::Forms::Padding(3);this->tabPage2->Size = System::Drawing::Size(408, 304);this->tabPage2->TabIndex = 1;this->tabPage2->Text = L"Missiles";this->tabPage2->UseVisualStyleBackColor = true;//// MissileList//this->MissileList->Dock = System::Windows::Forms::DockStyle::Fill;this->MissileList->FormattingEnabled = true;this->MissileList->HorizontalScrollbar = true;this->MissileList->Location = System::Drawing::Point(3, 3);this->MissileList->Name = L"MissileList";this->MissileList->Size = System::Drawing::Size(402, 289);this->MissileList->TabIndex = 4;this->MissileList->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &Form1::MissileListEvent_Changed);//// tabPage3//this->tabPage3->Controls->Add(this->CockpitWeapons);this->tabPage3->Controls->Add(this->ComboCockpits);this->tabPage3->Location = System::Drawing::Point(4, 22);this->tabPage3->Name = L"tabPage3";this->tabPage3->Padding = System::Windows::Forms::Padding(3);this->tabPage3->Size = System::Drawing::Size(408, 304);this->tabPage3->TabIndex = 2;this->tabPage3->Text = L"Cockpits";this->tabPage3->UseVisualStyleBackColor = true;//// CockpitWeapons//this->CockpitWeapons->CheckOnClick = true;this->CockpitWeapons->Dock = System::Windows::Forms::DockStyle::Fill;this->CockpitWeapons->FormattingEnabled = true;this->CockpitWeapons->HorizontalScrollbar = true;this->CockpitWeapons->Location = System::Drawing::Point(3, 24);this->CockpitWeapons->Name = L"CockpitWeapons";this->CockpitWeapons->Size = System::Drawing::Size(402, 274);this->CockpitWeapons->TabIndex = 4;//// ComboCockpits//this->ComboCockpits->Dock = System::Windows::Forms::DockStyle::Top;this->ComboCockpits->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;this->ComboCockpits->FormattingEnabled = true;this->ComboCockpits->Location = System::Drawing::Point(3, 3);this->ComboCockpits->Name = L"ComboCockpits";this->ComboCockpits->Size = System::Drawing::Size(402, 21);this->ComboCockpits->TabIndex = 5;this->ComboCockpits->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::ComboCockpits_SelectedIndexChanged);//// panel2//this->panel2->Controls->Add(this->ComboGame);this->panel2->Controls->Add(this->label1);this->panel2->Dock = System::Windows::Forms::DockStyle::Top;this->panel2->Location = System::Drawing::Point(0, 0);this->panel2->Name = L"panel2";this->panel2->Size = System::Drawing::Size(416, 22);this->panel2->TabIndex = 2;//// ComboGame//this->ComboGame->Dock = System::Windows::Forms::DockStyle::Fill;this->ComboGame->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;this->ComboGame->FormattingEnabled = true;this->ComboGame->Location = System::Drawing::Point(188, 0);this->ComboGame->Name = L"ComboGame";this->ComboGame->Size = System::Drawing::Size(228, 21);this->ComboGame->TabIndex = 0;this->ComboGame->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::ComboGame_SelectedIndexChanged);//// label1//this->label1->Dock = System::Windows::Forms::DockStyle::Left;this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,static_cast<System::Byte>(0)));this->label1->Location = System::Drawing::Point(0, 0);this->label1->Name = L"label1";this->label1->Size = System::Drawing::Size(188, 22);this->label1->TabIndex = 1;this->label1->Text = L"X-Universe Game:";this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;//// PanelNotLoaded//this->PanelNotLoaded->Controls->Add(this->LabelNotLoaded);this->PanelNotLoaded->Dock = System::Windows::Forms::DockStyle::Fill;this->PanelNotLoaded->Location = System::Drawing::Point(0, 24);this->PanelNotLoaded->Name = L"PanelNotLoaded";this->PanelNotLoaded->Size = System::Drawing::Size(416, 352);this->PanelNotLoaded->TabIndex = 3;//// LabelNotLoaded//this->LabelNotLoaded->Dock = System::Windows::Forms::DockStyle::Fill;this->LabelNotLoaded->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,static_cast<System::Byte>(0)));this->LabelNotLoaded->Location = System::Drawing::Point(0, 0);this->LabelNotLoaded->Name = L"LabelNotLoaded";this->LabelNotLoaded->Size = System::Drawing::Size(416, 352);this->LabelNotLoaded->TabIndex = 0;this->LabelNotLoaded->Text = L"No ship file is currently loaded";this->LabelNotLoaded->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;//// Form1//this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;this->CancelButton = this->ButExit;this->ClientSize = System::Drawing::Size(416, 409);this->Controls->Add(this->PanelMain);this->Controls->Add(this->PanelNotLoaded);this->Controls->Add(this->panel1);this->Controls->Add(this->menuStrip1);this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));this->MainMenuStrip = this->menuStrip1;this->Name = L"Form1";this->Text = L"XSP Ship Convertor";this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);this->menuStrip1->ResumeLayout(false);this->menuStrip1->PerformLayout();this->panel1->ResumeLayout(false);this->PanelMain->ResumeLayout(false);this->tabControl1->ResumeLayout(false);this->tabPage1->ResumeLayout(false);this->tabPage2->ResumeLayout(false);this->tabPage3->ResumeLayout(false);this->panel2->ResumeLayout(false);this->PanelNotLoaded->ResumeLayout(false);this->ResumeLayout(false);this->PerformLayout();}#pragma endregionprivate: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {this->OpenFile();}private: System::Void ButExit_Click(System::Object^ sender, System::EventArgs^ e) {this->Close();}private: System::Void saveToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {this->SaveShip();}private: System::Void ComboGame_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {this->ChangeGame();}private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {this->LoadGameDirectory();if ( m_sOpenFile )this->OpenFile(m_sOpenFile);}private: void CloseEvent(System::Object ^Sender, System::EventArgs ^E) {this->CheckSave();this->CloseDialog();}private: System::Void updateGameDataToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {this->LoadGameData();}private: System::Void loadGameTextToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {m_bReadText = !m_bReadText;this->loadGameTextToolStripMenuItem->Checked = m_bReadText;}private: System::Void WeaponListEvent_Changed(System::Object^ sender, ItemCheckEventArgs^ e) {if ( !m_bLoading ){int index = (1 << e->Index);if ( e->NewValue == CheckState::Checked )m_iLaserMask |= index;else if ( e->NewValue == CheckState::Unchecked )m_iLaserMask &= ~(index);this->CheckListChanged();}}private: System::Void MissileListEvent_Changed(System::Object^ sender, ItemCheckEventArgs^ e) {if ( !m_bLoading ){int index = (1 << e->Index);if ( e->NewValue == CheckState::Checked )m_iMissileMask |= index;else if ( e->NewValue == CheckState::Unchecked )m_iMissileMask &= ~(index);this->CheckListChanged();}}private: System::Void Event_Changed(System::Object^ sender, ItemCheckEventArgs^ e) {if ( !m_bLoading ){this->CheckListChanged();}}private: System::Void saveAsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {this->SaveShipAs();}private: System::Void ComboCockpits_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {this->UpdateCockpitList();}};}