1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

New tool for extracting imgs from def (written in C++/CLI).

This commit is contained in:
Michał W. Urbańczyk 2008-01-12 18:03:21 +00:00
parent 7968aebe1a
commit 2d8a513fc2
6 changed files with 595 additions and 0 deletions

38
Defopruj/AssemblyInfo.cpp Normal file
View File

@ -0,0 +1,38 @@
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("wyprujdef")];
[assembly:AssemblyDescriptionAttribute("Cudowne narzêdzie pozwalaj¹ce w szybkimczasie wypruæ defy.")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("VCMI Team")];
[assembly:AssemblyProductAttribute("wyprujdef")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

BIN
Defopruj/CDefHandler.cpp Normal file

Binary file not shown.

BIN
Defopruj/CDefHandler.h Normal file

Binary file not shown.

62
Defopruj/Oknopruj.cpp Normal file
View File

@ -0,0 +1,62 @@
#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.

235
Defopruj/Oknopruj.h Normal file
View File

@ -0,0 +1,235 @@
#pragma once
#include <string>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace wyprujdef {
/// <summary>
/// Summary for Oknopruj
///
/// 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 Oknopruj : public System::Windows::Forms::Form
{
public:
static std::string ToString(System::String^ src);
void runSearch();
void wyprujDefyZPlikow(array<String^> ^pliki);
Oknopruj(void)
{
InitializeComponent();
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Oknopruj()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::MenuStrip^ menuStrip1;
protected:
private: System::Windows::Forms::ToolStripMenuItem^ rUNToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ getProgramDirToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ browseToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ vCMIHomepageToolStripMenuItem;
private: System::Windows::Forms::ProgressBar^ progressBar1;
private: System::Windows::Forms::TextBox^ pathBox;
private: System::Windows::Forms::Label^ label1;
private: System::DirectoryServices::DirectorySearcher^ directorySearcher1;
private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1;
private: System::Windows::Forms::RadioButton^ rfirst;
private: System::Windows::Forms::RadioButton^ rall;
private:
/// <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 InitializeComponent(void)
{
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->rUNToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->getProgramDirToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->browseToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->vCMIHomepageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
this->pathBox = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->directorySearcher1 = (gcnew System::DirectoryServices::DirectorySearcher());
this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog());
this->rfirst = (gcnew System::Windows::Forms::RadioButton());
this->rall = (gcnew System::Windows::Forms::RadioButton());
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->rUNToolStripMenuItem,
this->getProgramDirToolStripMenuItem, this->browseToolStripMenuItem, this->vCMIHomepageToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(308, 24);
this->menuStrip1->TabIndex = 0;
this->menuStrip1->Text = L"menuStrip1";
//
// rUNToolStripMenuItem
//
this->rUNToolStripMenuItem->Name = L"rUNToolStripMenuItem";
this->rUNToolStripMenuItem->Size = System::Drawing::Size(44, 20);
this->rUNToolStripMenuItem->Text = L"RUN!";
this->rUNToolStripMenuItem->Click += gcnew System::EventHandler(this, &Oknopruj::rUNToolStripMenuItem_Click);
//
// getProgramDirToolStripMenuItem
//
this->getProgramDirToolStripMenuItem->Name = L"getProgramDirToolStripMenuItem";
this->getProgramDirToolStripMenuItem->Size = System::Drawing::Size(94, 20);
this->getProgramDirToolStripMenuItem->Text = L"Get program dir";
this->getProgramDirToolStripMenuItem->Click += gcnew System::EventHandler(this, &Oknopruj::getProgramDirToolStripMenuItem_Click);
//
// browseToolStripMenuItem
//
this->browseToolStripMenuItem->Name = L"browseToolStripMenuItem";
this->browseToolStripMenuItem->Size = System::Drawing::Size(66, 20);
this->browseToolStripMenuItem->Text = L"Browse...";
this->browseToolStripMenuItem->Click += gcnew System::EventHandler(this, &Oknopruj::browseToolStripMenuItem_Click);
//
// vCMIHomepageToolStripMenuItem
//
this->vCMIHomepageToolStripMenuItem->Name = L"vCMIHomepageToolStripMenuItem";
this->vCMIHomepageToolStripMenuItem->Size = System::Drawing::Size(97, 20);
this->vCMIHomepageToolStripMenuItem->Text = L"VCMI homepage";
this->vCMIHomepageToolStripMenuItem->Click += gcnew System::EventHandler(this, &Oknopruj::vCMIHomepageToolStripMenuItem_Click);
//
// progressBar1
//
this->progressBar1->Location = System::Drawing::Point(12, 96);
this->progressBar1->Name = L"progressBar1";
this->progressBar1->Size = System::Drawing::Size(284, 14);
this->progressBar1->TabIndex = 1;
//
// pathBox
//
this->pathBox->Location = System::Drawing::Point(12, 50);
this->pathBox->Name = L"pathBox";
this->pathBox->Size = System::Drawing::Size(276, 20);
this->pathBox->TabIndex = 2;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(137, 34);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(32, 13);
this->label1->TabIndex = 3;
this->label1->Text = L"Path:";
//
// directorySearcher1
//
this->directorySearcher1->ClientTimeout = System::TimeSpan::Parse(L"-00:00:01");
this->directorySearcher1->ServerPageTimeLimit = System::TimeSpan::Parse(L"-00:00:01");
this->directorySearcher1->ServerTimeLimit = System::TimeSpan::Parse(L"-00:00:01");
//
// rfirst
//
this->rfirst->AutoSize = true;
this->rfirst->Checked = true;
this->rfirst->Location = System::Drawing::Point(12, 73);
this->rfirst->Name = L"rfirst";
this->rfirst->Size = System::Drawing::Size(128, 17);
this->rfirst->TabIndex = 4;
this->rfirst->TabStop = true;
this->rfirst->Text = L"Extract only first frame";
this->rfirst->UseVisualStyleBackColor = true;
//
// rall
//
this->rall->AutoSize = true;
this->rall->Location = System::Drawing::Point(183, 73);
this->rall->Name = L"rall";
this->rall->Size = System::Drawing::Size(105, 17);
this->rall->TabIndex = 4;
this->rall->Text = L"Extract all frames";
this->rall->UseVisualStyleBackColor = true;
//
// Oknopruj
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(308, 120);
this->Controls->Add(this->rall);
this->Controls->Add(this->rfirst);
this->Controls->Add(this->label1);
this->Controls->Add(this->pathBox);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->MaximizeBox = false;
this->Name = L"Oknopruj";
this->ShowIcon = false;
this->Text = L"Defopruj 1.0";
this->Load += gcnew System::EventHandler(this, &Oknopruj::Oknopruj_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void rUNToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
runSearch();
}
private: System::Void Oknopruj_Load(System::Object^ sender, System::EventArgs^ e)
{
pathBox->Text = IO::Directory::GetCurrentDirectory();
}
private: System::Void getProgramDirToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
pathBox->Text = IO::Directory::GetCurrentDirectory();
}
private: System::Void browseToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
if (folderBrowserDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)
{
pathBox->Text = folderBrowserDialog1->SelectedPath;
}
}
private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
}
private: System::Void vCMIHomepageToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Diagnostics::Process::Start(gcnew String("http://antypika.aplus.pl/vcmi"));
}
};
}

260
Defopruj/wyprujdef.vcproj Normal file
View File

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="wyprujdef"
ProjectGUID="{D247EBCC-E8B2-4DE9-8B72-DFF180DB6241}"
RootNamespace="wyprujdef"
Keyword="ManagedCProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="G:\tp\SDL\include"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib $(NOINHERIT)"
LinkIncremental="2"
AdditionalLibraryDirectories="G:\tp\SDL\lib"
GenerateDebugInformation="true"
AssemblyDebug="1"
SubSystem="0"
EntryPointSymbol=""
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
InlineFunctionExpansion="0"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
AdditionalIncludeDirectories="G:\tp\SDL\include"
PreprocessorDefinitions="WIN32;NDEBUG"
StringPooling="true"
MinimalRebuild="false"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib $(NOINHERIT)"
LinkIncremental="1"
AdditionalLibraryDirectories="G:\tp\SDL\lib"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Drawing.dll"
AssemblyName="System.Drawing, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Windows.Forms.dll"
AssemblyName="System.Windows.Forms, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.DirectoryServices.dll"
AssemblyName="System.DirectoryServices, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\CDefHandler.cpp"
>
</File>
<File
RelativePath=".\Oknopruj.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\CDefHandler.h"
>
</File>
<File
RelativePath=".\Oknopruj.h"
FileType="3"
>
<File
RelativePath=".\Oknopruj.resx"
SubType="Designer"
>
</File>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>