1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/tools/Defopruj/Oknopruj.cpp
Michał W. Urbańczyk 34f791a0bf * moved tools to the tools Folder
* added Wpasujbud tool.
2008-01-19 20:24:01 +00:00

63 lines
1.5 KiB
C++

#include "Oknopruj.h"
#include "tchar.h"
#include "CDefHandler.h"
#include "Oknopruj.h"
#include <string>
#include <sstream>
using namespace System;
using namespace wyprujdef;
std::string Oknopruj::ToString(System::String^ src)
{
std::string dest;
using namespace System::Runtime::InteropServices;
const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(src)).ToPointer();
dest = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
return dest;
}
void Oknopruj::wyprujDefyZPlikow(array<String^> ^pliki)
{
progressBar1->Maximum = pliki->Length;
progressBar1->Value = 0;
CDefHandler * defik;
for each(String ^ plik in pliki)
{
progressBar1->Value++;
if(!((plik->EndsWith(".def")||(plik->EndsWith(".DEF")))))
continue;
defik = new CDefHandler();
defik->openDef(ToString(plik));
int to=1;
std::string bmpname;
if (rall->Checked)
{
to = defik->ourImages.size();
}
for (int i=0;i<to;i++)
{
std::ostringstream oss;
oss << ToString(plik->Substring(0,plik->Length-4)) << '_' << i << "_.bmp";
SDL_SaveBMP(defik->ourImages[i].bitmap,oss.str().c_str());
}
delete defik;
}
}
[STAThreadAttribute]
int WinMain()
{
String^ folder = (System::IO::Directory::GetCurrentDirectory());
array<String^>^ pliki = IO::Directory::GetFiles(folder);
Oknopruj ^ okno = gcnew Oknopruj();
Application::Run(okno);
exit(0);
}
void Oknopruj::runSearch()
{
wyprujDefyZPlikow(IO::Directory::GetFiles(pathBox->Text));
}// wyprujdef.cpp : main project file.