Subversion Repositories spk

Rev

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

Rev 197 Rev 222
Line 40... Line 40...
40
			this->DoToolTips();
40
			this->DoToolTips();
41
 
41
 
42
			this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
42
			this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
43
 
43
 
44
			this->Text = "SPK Explorer " + GetProgramVersionString((float)VERSION, (int)BETA);
44
			this->Text = "SPK Explorer " + GetProgramVersionString((float)VERSION, (int)BETA);
45
			m_pLoadedList = new CyStringList;
45
			m_pLoadedList = new Utils::WStringList;
46
 
46
 
47
			m_pPackages = new CPackages;
47
			m_pPackages = new CPackages;
48
			m_pPackages->startup(".", _S(IO::Path::GetTempPath()), _S(Environment::GetFolderPath(Environment::SpecialFolder::Personal)));
48
			m_pPackages->startup(".", _S(IO::Path::GetTempPath()), _S(Environment::GetFolderPath(Environment::SpecialFolder::Personal)));
49
 
49
 
50
			this->UpdateDisplay();
50
			this->UpdateDisplay();
Line 148... Line 148...
148
 
148
 
149
		void LoadData()
149
		void LoadData()
150
		{
150
		{
151
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
151
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
152
			CFileIO Config;
152
			CFileIO Config;
153
			if ( Config.open(_S(mydoc) + "/Egosoft/spkexplorer.dat") )
153
			if ( Config.open(_WS(mydoc) + L"/Egosoft/spkexplorer.dat") )
154
			{
154
			{
155
				std::vector<Utils::String> *lines = Config.readLines();
155
				std::vector<Utils::WString> lines;
156
				if ( lines )
156
				if(Config.readLines(lines))
157
				{
157
				{
158
					for ( int i = 0; i < (int)lines->size(); i++ )
158
					for (size_t i = 0; i < lines.size(); i++ )
159
					{
159
					{
160
						Utils::String line(lines->at(i));
160
						Utils::WString line(lines.at(i));
161
						Utils::String start = line.token(":", 1).lower();
161
						Utils::WString start = line.token(L":", 1).lower();
162
						Utils::String rest = line.tokens(":", 2).removeFirstSpace();
162
						Utils::WString rest = line.tokens(L":", 2).removeFirstSpace();
163
						if ( start.Compare("ExplorerSize") )
163
						if ( start.Compare(L"ExplorerSize") )
164
							this->Size = System::Drawing::Size(rest.token(" ", 1).toInt(), rest.token(" ", 2).toInt());
164
							this->Size = System::Drawing::Size(rest.token(L" ", 1).toInt(), rest.token(L" ", 2).toInt());
165
						else if ( start.Compare("ExplorerPos") )
165
						else if ( start.Compare(L"ExplorerPos") )
166
						{
166
						{
167
							m_iLocX = rest.token(" ", 1).toInt();
167
							m_iLocX = rest.token(L" ", 1).toInt();
168
							m_iLocY = rest.token(" ", 2).toInt();
168
							m_iLocY = rest.token(L" ", 2).toInt();
169
						}
169
						}
170
						else if ( start.Compare("Loaded") )
170
						else if ( start.Compare(L"Loaded") )
171
							m_pLoadedList->PushBack(CyString(rest));
171
							m_pLoadedList->pushBack(rest);
172
						else if ( start.Compare("ExplorerMax") )
172
						else if ( start.Compare(L"ExplorerMax") )
173
							this->WindowState = FormWindowState::Maximized;
173
							this->WindowState = FormWindowState::Maximized;
174
					}
174
					}
175
 
-
 
176
					delete lines;
-
 
177
				}
175
				}
178
			}
176
			}
179
		}
177
		}
180
 
178
 
181
 
179
 
Line 276... Line 274...
276
			this->toolStripSplitButton1->DropDownItems->Add(newItem);
274
			this->toolStripSplitButton1->DropDownItems->Add(newItem);
277
 
275
 
278
			this->toolStripSplitButton1->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator());
276
			this->toolStripSplitButton1->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator());
279
 
277
 
280
			// add all none open items
278
			// add all none open items
281
			for ( SStringList *str = m_pLoadedList->Head(); str; str = str->next )
279
			for (auto itr = m_pLoadedList->begin(); itr != m_pLoadedList->end(); itr++)
282
			{
280
			{
283
				// check if we have it open
281
				// check if we have it open
284
				System::String ^sFile = _US(str-&gt;str.findreplace(&quot;/", &quot;\\").ToString());
282
				System::String ^sFile = _US((*itr)-&gt;str.findReplace(L&quot;/", L&quot;\\"));
285
				if ( this->IsOpen(sFile) )
283
				if ( this->IsOpen(sFile) )
286
					continue;
284
					continue;
287
				if ( this->IsOpen(_US(str-&gt;str.findreplace(&quot;\\", &quot;/").ToString())) )
285
				if ( this->IsOpen(_US((*itr)-&gt;str.findReplace(L&quot;\\", L&quot;/"))) )
288
					continue;
286
					continue;
289
 
287
 
290
				// otherwise add it to the list
288
				// otherwise add it to the list
291
				System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
289
				System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
292
				newItem->Text = sFile;
290
				newItem->Text = sFile;
Line 297... Line 295...
297
		}
295
		}
298
 
296
 
299
		void SaveData()
297
		void SaveData()
300
		{
298
		{
301
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
299
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
302
			CFileIO Config(_S(mydoc) + "/Egosoft/spkexplorer.dat");
300
			CFileIO Config(_WS(mydoc) + L"/Egosoft/spkexplorer.dat");
303
			Utils::CStringList lines;
301
			Utils::WStringList lines;
304
 
302
 
305
			if ( this->WindowState == FormWindowState::Normal )
303
			if ( this->WindowState == FormWindowState::Normal )
306
			{
304
			{
307
				lines.pushBack(Utils::String("ExplorerSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
305
				lines.pushBack(Utils::WString(L"ExplorerSize:") + (long)this->Size.Width + L" " + (long)this->Size.Height);
308
				lines.pushBack(Utils::String("ExplorerPos:") + (long)this->Location.X + " " + (long)this->Location.Y);
306
				lines.pushBack(Utils::WString(L"ExplorerPos:") + (long)this->Location.X + L" " + (long)this->Location.Y);
309
			}
307
			}
310
			else
308
			else
311
			{
309
			{
312
				lines.pushBack(Utils::String("ExplorerPos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
310
				lines.pushBack(Utils::WString(L"ExplorerPos:") + (long)this->RestoreBounds.Location.X + L" " + (long)this->RestoreBounds.Location.Y);
313
				lines.pushBack(Utils::String("ExplorerSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
311
				lines.pushBack(Utils::WString(L"ExplorerSize:") + (long)this->RestoreBounds.Size.Width + L" " + (long)this->RestoreBounds.Size.Height);
314
			}
312
			}
315
 
313
 
316
			if ( this->WindowState == FormWindowState::Maximized )
314
			if ( this->WindowState == FormWindowState::Maximized )
317
				lines.pushBack("ExplorerMax:");
315
				lines.pushBack(L"ExplorerMax:");
318
 
316
 
319
			for ( SStringList *str = m_pLoadedList->Head(); str; str = str->next )
317
			for (auto itr = m_pLoadedList->begin(); itr != m_pLoadedList->end(); itr++)
320
				lines.pushBack(Utils::String("Loaded:") + str-&gt;data.ToString() + " " + str->str.ToString());
318
				lines.pushBack(Utils::WString(L"Loaded:") + (*itr)-&gt;data + L" " + (*itr)->str);
321
			Config.writeFile(&lines);
319
			Config.writeFile(&lines);
322
		}
320
		}
323
		void CloseEvent(System::Object ^Sender, System::EventArgs ^E) 
321
		void CloseEvent(System::Object ^Sender, System::EventArgs ^E) 
324
		{
322
		{
325
			this->CloseAll();
323
			this->CloseAll();
Line 549... Line 547...
549
					MessageBox::Show(this, "Unable to open package file:\n" + file + "\n\nFile doesn't exist", "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
547
					MessageBox::Show(this, "Unable to open package file:\n" + file + "\n\nFile doesn't exist", "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
550
				return;
548
				return;
551
			}
549
			}
552
 
550
 
553
			float fVersion;
551
			float fVersion;
554
			Utils::String sFile = _S(file);
552
			Utils::WString sFile = _WS(file);
555
			int fileType = CSpkFile::CheckFile(sFile, &fVersion);
553
			int fileType = CSpkFile::CheckFile(sFile, &fVersion);
556
 
554
 
557
			if ( fVersion > (float)FILEVERSION )
555
			if ( fVersion > (float)FILEVERSION )
558
			{
556
			{
559
				if ( display )
557
				if ( display )
Line 655... Line 653...
655
				}
653
				}
656
				childForm->WindowState = FormWindowState::Maximized;
654
				childForm->WindowState = FormWindowState::Maximized;
657
				childForm->ChangeView(m_curView);
655
				childForm->ChangeView(m_curView);
658
 
656
 
659
				// adjust the loaded list
657
				// adjust the loaded list
660
				sFile = sFile.findReplace("/", "\\").remove(9).remove('\r').remove('\n');
658
				sFile = sFile.findReplace(L"/", L"\\").remove(9).remove('\r').remove('\n');
661
				m_pLoadedList->Remove(sFile, true);
659
				m_pLoadedList->remove(sFile);
662
				m_pLoadedList->PushFront(CyString(sFile));
660
				m_pLoadedList->pushFront(sFile);
663
 
661
 
664
				while ( m_pLoadedList->Count() > 15 )
662
				while ( m_pLoadedList->size() > 15 )
665
					m_pLoadedList->PopBack();
663
					m_pLoadedList->popBack();
666
 
664
 
667
				this->SaveData();
665
				this->SaveData();
668
 
666
 
669
				this->UpdateDropDownOpen();
667
				this->UpdateDropDownOpen();
670
			}	
668
			}	
Line 888... Line 886...
888
			if ( child )
886
			if ( child )
889
				child->RemoveSelected();
887
				child->RemoveSelected();
890
		}
888
		}
891
 
889
 
892
		System::Windows::Forms::View m_curView;
890
		System::Windows::Forms::View m_curView;
893
		CyStringList		*m_pLoadedList;
891
		Utils::WStringList		*m_pLoadedList;
894
		CLinkList<C_File>	*m_lCopiedFiles;
892
		CLinkList<C_File>	*m_lCopiedFiles;
895
		SpkForm				^m_pCutFrom;
893
		SpkForm				^m_pCutFrom;
896
		CLinkList<C_File>	*m_lDraggedFiles;
894
		CLinkList<C_File>	*m_lDraggedFiles;
897
		SpkForm				^m_pDraggedFrom;
895
		SpkForm				^m_pDraggedFrom;
898
 
896