Subversion Repositories spk

Rev

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

Rev 191 Rev 197
Line 43... Line 43...
43
 
43
 
44
			this->toolTip1->SetToolTip(this->button1, "Add new game directory");
44
			this->toolTip1->SetToolTip(this->button1, "Add new game directory");
45
			this->toolTip1->SetToolTip(this->ButDel, "Remove selected game directory");
45
			this->toolTip1->SetToolTip(this->ButDel, "Remove selected game directory");
46
			this->toolTip1->SetToolTip(this->ButClear, "Clear all game directories");
46
			this->toolTip1->SetToolTip(this->ButClear, "Clear all game directories");
47
 
47
 
48
			m_sDirs = new CyStringList;
48
			m_sDirs = new Utils::WStringList;
49
			this->GetAllDirs();
49
			this->GetAllDirs();
50
 
50
 
51
			this->checkBox1->Checked = set->bGenerateUpdate;
51
			this->checkBox1->Checked = set->bGenerateUpdate;
52
		}
52
		}
53
 
53
 
Line 56... Line 56...
56
 
56
 
57
		void GetAllDirs()
57
		void GetAllDirs()
58
		{
58
		{
59
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
59
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
60
			CFileIO Config;
60
			CFileIO Config;
61
			if ( Config.open(_S(mydoc) + "/Egosoft/pluginmanager.dat") )
61
			if ( Config.open(_WS(mydoc) + L"/Egosoft/pluginmanager.dat") )
62
			{
62
			{
63
				std::vector<Utils::String> *lines = Config.readLines();
63
				std::vector<Utils::String> *lines = Config.readLines();
64
				if ( lines )
64
				if ( lines )
65
				{
65
				{
66
					for ( int i = 0; i < (int)lines->size(); i++ )
66
					for ( int i = 0; i < (int)lines->size(); i++ )
67
					{
67
					{
68
						Utils::String line(lines->at(i));
68
						Utils::WString line(lines->at(i));
69
						Utils::String start = line.token(":", 1).toLower();
69
						Utils::WString start = line.token(L":", 1).toLower();
70
						Utils::String rest = line.tokens(":", 2).removeFirstSpace();
70
						Utils::WString rest = line.tokens(L":", 2).removeFirstSpace();
71
						if ( start.Compare("DirExe") )
71
						if ( start.Compare(L"DirExe") )
72
						{
72
						{
73
							if ( rest.countToken("|" ) > 2 )
73
							if ( rest.countToken(L"|" ) > 2 )
74
								m_sDirs->PushBack(CyString(rest.token("|", 3)), CyString(rest.token("|", 2)));
74
								m_sDirs->pushBack(rest.token(L"|", 3), rest.token(L"|", 2));
75
							else
75
							else
76
								m_sDirs->PushBack(CyString(rest.token("|", 2)), CyString(rest.token("|", 1)));
76
								m_sDirs->pushBack(rest.token(L"|", 2), rest.token(L"|", 1));
77
						}
77
						}
78
					}
78
					}
79
 
79
 
80
					delete lines;
80
					delete lines;
81
				}
81
				}
Line 83... Line 83...
83
		}
83
		}
84
 
84
 
85
		void UpdateGameDirs()
85
		void UpdateGameDirs()
86
		{
86
		{
87
			this->ListGameDir->Items->Clear();
87
			this->ListGameDir->Items->Clear();
88
			for ( Utils::String dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
88
			for ( Utils::WString dir = _pGameDir->first(); !dir.empty(); dir = _pGameDir->next() ) {
89
				ListViewItem ^item = gcnew ListViewItem(_US(dir));
89
				ListViewItem ^item = gcnew ListViewItem(_US(dir));
90
				item->ImageIndex = _pGameDir->currentGame();
90
				item->ImageIndex = _pGameDir->currentGame();
91
				item->SubItems->Add(_US(_pGameDir->currentName()));
91
				item->SubItems->Add(_US(_pGameDir->currentName()));
92
				if ( _pGameDir->currentLoad() )
92
				if ( _pGameDir->currentLoad() )
93
					item->SubItems->Add("Yes");
93
					item->SubItems->Add("Yes");
Line 104... Line 104...
104
			this->ButDel->Enabled = (this->ListGameDir->SelectedItems->Count) ? true : false;
104
			this->ButDel->Enabled = (this->ListGameDir->SelectedItems->Count) ? true : false;
105
		}
105
		}
106
 
106
 
107
		void AddDir(String ^sDir, bool ask, bool load)
107
		void AddDir(String ^sDir, bool ask, bool load)
108
		{
108
		{
109
			Utils::String dir = _S(sDir);
109
			Utils::WString dir = _WS(sDir);
110
 
110
 
111
			Utils::String game = m_pP->getGameName(dir);
111
			Utils::WString game = m_pP->getGameName(dir);
112
			int iGame = m_pP->GetGameExe()->GetGameType(dir);
112
			int iGame = m_pP->GetGameExe()->getGameType(dir);
113
 
113
 
114
			dir = m_pP->GetGameExe()->GetProperDir(dir);
114
			dir = m_pP->GetGameExe()->properDir(dir);
115
 
115
 
116
			dir = dir.findReplace("\\", "/");
116
			dir = dir.findReplace(L"\\", L"/");
117
			dir = dir.findReplace("//", "/");
117
			dir = dir.findReplace(L"//", L"/");
118
 
118
 
119
			SGameExe *exe = m_pP->GetGameExe()->GetGame(iGame);
119
			SGameExe *exe = m_pP->GetGameExe()->game(iGame);
120
 
120
 
121
			if ( !_pGameDir->isDir(dir) && ask ) {
121
			if ( !_pGameDir->isDir(dir) && ask ) {
122
				if ( MessageBox::Show(this, "Do you want to load text from this directory\n" + _US(dir), "Load Game Text", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
122
				if ( MessageBox::Show(this, "Do you want to load text from this directory\n" + _US(dir), "Load Game Text", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
123
				{
123
				{
124
					load = true;
124
					load = true;
Line 134... Line 134...
134
		void AddNewDir()
134
		void AddNewDir()
135
		{
135
		{
136
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
136
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
137
			ofd->Filter = "X-Universe Executable|";
137
			ofd->Filter = "X-Universe Executable|";
138
			String ^games = "";
138
			String ^games = "";
139
			for ( int i = 0; i < m_pP->GetGameExe()->GetNumGames(); i++ )
139
			for ( int i = 0; i < m_pP->GetGameExe()->numGames(); i++ )
140
			{
140
			{
141
				SGameExe *exe = m_pP->GetGameExe()->GetGame(i);
141
				SGameExe *exe = m_pP->GetGameExe()->game(i);
142
				if ( i ) ofd->Filter += ";";
142
				if ( i ) ofd->Filter += ";";
143
				ofd->Filter += _US(exe->sExe);
143
				ofd->Filter += _US(exe->sExe);
144
				games += "|" + _US(exe->sName) + "|" + _US(exe->sExe);
144
				games += "|" + _US(exe->sName) + "|" + _US(exe->sExe);
145
			}
145
			}
146
			ofd->Filter += games;
146
			ofd->Filter += games;
147
			ofd->FilterIndex = 1;
147
			ofd->FilterIndex = 1;
148
			ofd->RestoreDirectory = true;
148
			ofd->RestoreDirectory = true;
149
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
149
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
150
			{
150
			{
151
				// check for a valid game
151
				// check for a valid game
152
				if ( m_pP->getGameName(_S(ofd->FileName)).empty() )
152
				if ( m_pP->getGameName(_WS(ofd->FileName)).empty() )
153
					MessageBox::Show(this, "The path selected doesn't contain a valid game version\n" + IO::FileInfo(ofd->FileName).DirectoryName, "Invalid Directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
153
					MessageBox::Show(this, "The path selected doesn't contain a valid game version\n" + IO::FileInfo(ofd->FileName).DirectoryName, "Invalid Directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
154
				else
154
				else
155
					this->AddDir(ofd->FileName, true, false);
155
					this->AddDir(ofd->FileName, true, false);
156
			}
156
			}
157
		}
157
		}
Line 202... Line 202...
202
		/// Required designer variable.
202
		/// Required designer variable.
203
		/// </summary>
203
		/// </summary>
204
		ImageList ^m_pGameImages;
204
		ImageList ^m_pGameImages;
205
		CGameDirectories *_pGameDir;
205
		CGameDirectories *_pGameDir;
206
		ListViewItem ^m_pSelectedItem;
206
		ListViewItem ^m_pSelectedItem;
207
		CyStringList *m_sDirs;
207
		Utils::WStringList *m_sDirs;
208
 
208
 
209
	private: System::Windows::Forms::ToolTip^  toolTip1;
209
	private: System::Windows::Forms::ToolTip^  toolTip1;
210
	private: System::Windows::Forms::ContextMenuStrip^  contextMenuStrip1;
210
	private: System::Windows::Forms::ContextMenuStrip^  contextMenuStrip1;
211
	private: System::Windows::Forms::ToolStripMenuItem^  addDirectoryToolStripMenuItem;
211
	private: System::Windows::Forms::ToolStripMenuItem^  addDirectoryToolStripMenuItem;
212
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
212
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
Line 664... Line 664...
664
			 for ( int i = (this->addDirectoryToolStripMenuItem->DropDownItems->Count - 1); i >= 2; --i )
664
			 for ( int i = (this->addDirectoryToolStripMenuItem->DropDownItems->Count - 1); i >= 2; --i )
665
				 this->addDirectoryToolStripMenuItem->DropDownItems->RemoveAt(i);
665
				 this->addDirectoryToolStripMenuItem->DropDownItems->RemoveAt(i);
666
 
666
 
667
			 // add any unadded directories
667
			 // add any unadded directories
668
			 System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Options::typeid));
668
			 System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Options::typeid));
669
			 for ( SStringList *str = m_sDirs->Head(); str; str = str->next )
669
			 for ( Utils::WStringNode *str = m_sDirs->first(); str; str = m_sDirs->next())
670
			 {
670
			 {
671
				 if ( !_pGameDir->isDir(str->str.ToString()) ) {
671
				 if ( !_pGameDir->isDir(str->str) ) {
672
					 ToolStripMenuItem ^newItem = gcnew ToolStripMenuItem();
672
					 ToolStripMenuItem ^newItem = gcnew ToolStripMenuItem();
673
					 newItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"testDirToolStripMenuItem.Image")));
673
					 newItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"testDirToolStripMenuItem.Image")));
674
					 newItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
674
					 newItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
675
					 newItem->Text = _US(str->str.ToString()) + " (" + _US(str->data.ToString()) + ")";
675
					 newItem->Text = _US(str->str) + " (" + _US(str->data) + ")";
676
					 newItem->Tag = _US(str->str.ToString());
676
					 newItem->Tag = _US(str->str);
677
					 newItem->Click += gcnew System::EventHandler(this, &Options::testDirToolStripMenuItem_Click);
677
					 newItem->Click += gcnew System::EventHandler(this, &Options::testDirToolStripMenuItem_Click);
678
					 this->addDirectoryToolStripMenuItem->DropDownItems->Add(newItem);
678
					 this->addDirectoryToolStripMenuItem->DropDownItems->Add(newItem);
679
				 }
679
				 }
680
			 }
680
			 }
681
 
681
 
Line 731... Line 731...
731
			 for ( int i = (this->contextMenuStrip2->Items->Count - 1); i >= 2; --i )
731
			 for ( int i = (this->contextMenuStrip2->Items->Count - 1); i >= 2; --i )
732
				 this->contextMenuStrip2->Items->RemoveAt(i);
732
				 this->contextMenuStrip2->Items->RemoveAt(i);
733
 
733
 
734
			 // add any unadded directories
734
			 // add any unadded directories
735
			 System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Options::typeid));
735
			 System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Options::typeid));
736
			 for ( SStringList *str = m_sDirs->Head(); str; str = str->next )
736
			 for ( Utils::WStringNode *str = m_sDirs->first(); str; str = m_sDirs->next() )
737
			 {
737
			 {
738
				 if ( !_pGameDir->isDir(m_pP->GetGameExe()->GetProperDir(str->str.ToString())) ) {
738
				 if ( !_pGameDir->isDir(m_pP->GetGameExe()->properDir(str->str)) ) {
739
					 ToolStripMenuItem ^newItem = gcnew ToolStripMenuItem();
739
					 ToolStripMenuItem ^newItem = gcnew ToolStripMenuItem();
740
					 newItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"testDirToolStripMenuItem.Image")));
740
					 newItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"testDirToolStripMenuItem.Image")));
741
					 newItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
741
					 newItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
742
					 newItem->Text = _US(str->str.ToString()) + " (" + _US(str->data.ToString()) + ")";
742
					 newItem->Text = _US(str->str) + " (" + _US(str->data) + ")";
743
					 newItem->Tag = _US(str->str.ToString());
743
					 newItem->Tag = _US(str->str);
744
					 newItem->Click += gcnew System::EventHandler(this, &Options::testDirToolStripMenuItem_Click);
744
					 newItem->Click += gcnew System::EventHandler(this, &Options::testDirToolStripMenuItem_Click);
745
					 this->contextMenuStrip2->Items->Add(newItem);
745
					 this->contextMenuStrip2->Items->Add(newItem);
746
				 }
746
				 }
747
			 }
747
			 }
748
 
748
 
Line 768... Line 768...
768
		 }
768
		 }
769
private: System::Void AllDirToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
769
private: System::Void AllDirToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
770
			 bool load = false;
770
			 bool load = false;
771
			 if ( MessageBox::Show(this, "Do you want to load text for all the directories", "Load Game Text", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
771
			 if ( MessageBox::Show(this, "Do you want to load text for all the directories", "Load Game Text", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
772
				load = true;
772
				load = true;
773
			 for ( SStringList *str = m_sDirs->Head(); str; str = str->next )
773
			 for ( Utils::WStringNode *str = m_sDirs->first(); str; str = m_sDirs->next() )
774
				 this->AddDir(_US(str->str.ToString()), false, load);
774
				 this->AddDir(_US(str->str), false, load);
775
		 }
775
		 }
776
};
776
};
777
}
777
}