From 34f791a0bfc512e482c76d93896b41de305366c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 19 Jan 2008 20:24:01 +0000 Subject: [PATCH] * moved tools to the tools Folder * added Wpasujbud tool. --- {Defopruj => tools/Defopruj}/AssemblyInfo.cpp | 0 {Defopruj => tools/Defopruj}/CDefHandler.cpp | Bin {Defopruj => tools/Defopruj}/CDefHandler.h | Bin {Defopruj => tools/Defopruj}/Oknopruj.cpp | 0 {Defopruj => tools/Defopruj}/Oknopruj.h | 0 {Defopruj => tools/Defopruj}/wyprujdef.vcproj | 0 .../Defsorter}/Form1.Designer.cs | 0 {defSorter => tools/Defsorter}/Form1.cs | 0 .../Defsorter}/Form2.Designer.cs | 0 {defSorter => tools/Defsorter}/Form2.cs | 0 .../Defsorter}/Form3.Designer.cs | 0 {defSorter => tools/Defsorter}/Form3.cs | 0 {defSorter => tools/Defsorter}/Program.cs | 0 tools/Wpasujbud/AssemblyInfo.cpp | 38 + tools/Wpasujbud/Wpasujbud.cpp | 361 ++++++++++ tools/Wpasujbud/Wpasujbud.h | 649 ++++++++++++++++++ tools/Wpasujbud/data.h | 12 + tools/Wpasujbud/dataEditor.cpp | 2 + tools/Wpasujbud/dataEditor.h | 209 ++++++ tools/Wpasujbud/obrazek.cpp | 2 + tools/Wpasujbud/obrazek.h | 121 ++++ 21 files changed, 1394 insertions(+) rename {Defopruj => tools/Defopruj}/AssemblyInfo.cpp (100%) rename {Defopruj => tools/Defopruj}/CDefHandler.cpp (100%) rename {Defopruj => tools/Defopruj}/CDefHandler.h (100%) rename {Defopruj => tools/Defopruj}/Oknopruj.cpp (100%) rename {Defopruj => tools/Defopruj}/Oknopruj.h (100%) rename {Defopruj => tools/Defopruj}/wyprujdef.vcproj (100%) rename {defSorter => tools/Defsorter}/Form1.Designer.cs (100%) rename {defSorter => tools/Defsorter}/Form1.cs (100%) rename {defSorter => tools/Defsorter}/Form2.Designer.cs (100%) rename {defSorter => tools/Defsorter}/Form2.cs (100%) rename {defSorter => tools/Defsorter}/Form3.Designer.cs (100%) rename {defSorter => tools/Defsorter}/Form3.cs (100%) rename {defSorter => tools/Defsorter}/Program.cs (100%) create mode 100644 tools/Wpasujbud/AssemblyInfo.cpp create mode 100644 tools/Wpasujbud/Wpasujbud.cpp create mode 100644 tools/Wpasujbud/Wpasujbud.h create mode 100644 tools/Wpasujbud/data.h create mode 100644 tools/Wpasujbud/dataEditor.cpp create mode 100644 tools/Wpasujbud/dataEditor.h create mode 100644 tools/Wpasujbud/obrazek.cpp create mode 100644 tools/Wpasujbud/obrazek.h diff --git a/Defopruj/AssemblyInfo.cpp b/tools/Defopruj/AssemblyInfo.cpp similarity index 100% rename from Defopruj/AssemblyInfo.cpp rename to tools/Defopruj/AssemblyInfo.cpp diff --git a/Defopruj/CDefHandler.cpp b/tools/Defopruj/CDefHandler.cpp similarity index 100% rename from Defopruj/CDefHandler.cpp rename to tools/Defopruj/CDefHandler.cpp diff --git a/Defopruj/CDefHandler.h b/tools/Defopruj/CDefHandler.h similarity index 100% rename from Defopruj/CDefHandler.h rename to tools/Defopruj/CDefHandler.h diff --git a/Defopruj/Oknopruj.cpp b/tools/Defopruj/Oknopruj.cpp similarity index 100% rename from Defopruj/Oknopruj.cpp rename to tools/Defopruj/Oknopruj.cpp diff --git a/Defopruj/Oknopruj.h b/tools/Defopruj/Oknopruj.h similarity index 100% rename from Defopruj/Oknopruj.h rename to tools/Defopruj/Oknopruj.h diff --git a/Defopruj/wyprujdef.vcproj b/tools/Defopruj/wyprujdef.vcproj similarity index 100% rename from Defopruj/wyprujdef.vcproj rename to tools/Defopruj/wyprujdef.vcproj diff --git a/defSorter/Form1.Designer.cs b/tools/Defsorter/Form1.Designer.cs similarity index 100% rename from defSorter/Form1.Designer.cs rename to tools/Defsorter/Form1.Designer.cs diff --git a/defSorter/Form1.cs b/tools/Defsorter/Form1.cs similarity index 100% rename from defSorter/Form1.cs rename to tools/Defsorter/Form1.cs diff --git a/defSorter/Form2.Designer.cs b/tools/Defsorter/Form2.Designer.cs similarity index 100% rename from defSorter/Form2.Designer.cs rename to tools/Defsorter/Form2.Designer.cs diff --git a/defSorter/Form2.cs b/tools/Defsorter/Form2.cs similarity index 100% rename from defSorter/Form2.cs rename to tools/Defsorter/Form2.cs diff --git a/defSorter/Form3.Designer.cs b/tools/Defsorter/Form3.Designer.cs similarity index 100% rename from defSorter/Form3.Designer.cs rename to tools/Defsorter/Form3.Designer.cs diff --git a/defSorter/Form3.cs b/tools/Defsorter/Form3.cs similarity index 100% rename from defSorter/Form3.cs rename to tools/Defsorter/Form3.cs diff --git a/defSorter/Program.cs b/tools/Defsorter/Program.cs similarity index 100% rename from defSorter/Program.cs rename to tools/Defsorter/Program.cs diff --git a/tools/Wpasujbud/AssemblyInfo.cpp b/tools/Wpasujbud/AssemblyInfo.cpp new file mode 100644 index 000000000..a64855d4a --- /dev/null +++ b/tools/Wpasujbud/AssemblyInfo.cpp @@ -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("Wpasujbud 1.0")]; +[assembly:AssemblyDescriptionAttribute("Cudowne narzedzie, ktore wpasuje budynki za mnie")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("VCMI Team")]; +[assembly:AssemblyProductAttribute("ret")]; +[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)]; diff --git a/tools/Wpasujbud/Wpasujbud.cpp b/tools/Wpasujbud/Wpasujbud.cpp new file mode 100644 index 000000000..7fa0e50a9 --- /dev/null +++ b/tools/Wpasujbud/Wpasujbud.cpp @@ -0,0 +1,361 @@ +// Wpasujbud.cpp : main project file. +//#include +#include "SDL.h" +#include "Wpasujbud.h" +#include "tchar.h" +#include "obrazek.h" +#include "dataEditor.h" +using namespace Wpasuj; + +int Inaccuracy=5; +int zgodnosc(Bitmap^ bg, Bitmap^ st, int x, int y); +int zgodnosc(SDL_Surface * bg, SDL_Surface * st, int x, int y); + +std::string Wpasujbud::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; +} + +[STAThreadAttribute] +int __stdcall WinMain() +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + Application::Run(gcnew Wpasujbud()); + exit(0); + return 0; +} + +Wpasujbud::Wpasujbud(void) +{ + InitializeComponent(); + openFileDialog1->InitialDirectory = IO::Directory::GetCurrentDirectory(); + IO::StreamReader ^sr = gcnew IO::StreamReader(L"config/TOWNTYPE.TXT"); + Int32 i=0; + while(!sr->EndOfStream) + { + String ^ n = sr->ReadLine(); + n = (i.ToString()) + L". " + n; + townID->Items->Add(n); + i++; + } + townID->SelectedIndex=0; + sr->Close(); + i++; + + + sr = gcnew IO::StreamReader(L"config/BNAMES.TXT"); + i=0; + while(!sr->EndOfStream) + { + String ^ n = sr->ReadLine(); + //n = (i.ToString()) + L". " + n; + buildingType->Items->Add(n); + i++; + } + buildingType->SelectedIndex=0; + sr->Close(); + i++; + + bitmapsFolder->Text = openFileDialog1->InitialDirectory; + +} + +System::Void Wpasujbud::searchBitmaps_Click(System::Object^ sender, System::EventArgs^ e) +{ + bitmapList->Items->Clear(); + array^ pliki = IO::Directory::GetFiles(bitmapsFolder->Text,bmpPattern->Text); + for each(String ^ plik in pliki) + { + //if(plik->EndsWith(L".bmp") || plik->EndsWith(L".BMP")) + bitmapList->Items->Add(plik->Substring(plik->LastIndexOf('\\')+1)); + } + if(bitmapList->Items->Count>0) + bitmapList->SelectedIndex=0; +} +System::Void Wpasujbud::startLocating_Click(System::Object^ sender, System::EventArgs^ e) +{ + searchPicturePos(); +} +System::Void Wpasujbud::setBackground_Click(System::Object^ sender, System::EventArgs^ e) +{ + if(townBgPath->Text->Length==0) + return; + Bitmap ^ bg = gcnew Bitmap(townBgPath->Text); + townBg->Image = dynamic_cast(bg); + sbg = SDL_LoadBMP(ToString(townBgPath->Text).c_str()); +} +System::Void Wpasujbud::openFileDialog1_FileOk(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) +{ + townBgPath->Text = (dynamic_cast(sender))->FileName; +} +System::Void Wpasujbud::browseForBg_Click(System::Object^ sender, System::EventArgs^ e) +{ + openFileDialog1->ShowDialog(); +} +System::Void Wpasujbud::browseForbmpfol_Click(System::Object^ sender, System::EventArgs^ e) +{ + folderBrowserDialog1->ShowDialog(); + bitmapsFolder->Text = folderBrowserDialog1->SelectedPath; +} +System::Void Wpasujbud::bitmapList_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) +{ + int nsel = bitmapList->SelectedIndex; + if (nsel<0) + return; + String ^ bmpname = bitmapsFolder->Text + "\\" + dynamic_cast(bitmapList->SelectedItem); + Bitmap ^building = gcnew Bitmap(bmpname); + buildingImg->Image = dynamic_cast(building); +} +System::Void Wpasujbud::townBg_Click(System::Object^ sender, System::EventArgs^ e) +{ + //Int32 tx, ty, ux, uy; + //tx = townBg->Location.X; + //ty = townBg->Location.Y; + //ux = Location.X; + //uy = Location.Y; + mx = MousePosition.X - townBg->Location.X - Location.X - 4; + my = MousePosition.Y - townBg->Location.Y - Location.Y - 30; + koordy->Text = mx.ToString() + L", " + my.ToString(); +} +System::Void Wpasujbud::button1_Click(System::Object^ sender, System::EventArgs^ e) //skip +{ + nextPicture(); +} + +Uint32 SDL_GetPixel(SDL_Surface *surface, int x, int y) +{ + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * surface->format->BytesPerPixel; + + switch(surface->format->BytesPerPixel) + { + case 1: + { + SDL_Color * color = surface->format->palette->colors+(*p); + return color->r<<16 | color->g<<8 | color->b; + } + case 3: + return p[0] | p[1] << 8 | p[2] << 16; + } +} +int zgodnosc(SDL_Surface * bg, SDL_Surface * st, int x, int y) +{ + int ret=0; + for(int i=0;iw;i+=Inaccuracy) + { + for(int j=0;jh;j+=Inaccuracy) + { + int c1 = SDL_GetPixel(bg,i+x,j+y); + int c2 = SDL_GetPixel(st,i,j); + if((i+x)>=bg->w) + break; + if((j+y)>=bg->h) + break; + if(SDL_GetPixel(bg,i+x,j+y) == SDL_GetPixel(st,i,j)) + { + ret++; + } + } + } + return ret*(Inaccuracy*Inaccuracy); +} +int zgodnosc(Bitmap^ bg, Bitmap^ st, int x, int y) +{ + int ret=0; + for(int i=0;iWidth;i++) + { + for(int j=0;jHeight;j++) + { + //Color c1 = bg->GetPixel(i+x,j+y); + //Color c2 = st->GetPixel(i,j); + if((i+x)>=bg->Width) + break; + if((j+y)>=bg->Height) + break; + if(bg->GetPixel(i+x,j+y) == st->GetPixel(i,j)) + { + ret++; + } + } + } + return ret; +} +void Wpasujbud::searchPicturePos() +{ + //Bitmap^ b = gcnew Bitmap((townBg->Image)->Width,(townBg->Image)->Height,Imaging::PixelFormat::Format24bppRgb); + //Bitmap^ s = dynamic_cast(buildingImg->Image); + //Graphics ^ g = Graphics::FromImage(b); + //g->DrawImage(townBg->Image,0,0); + //townBg->Image = b; + String^ sss = bitmapsFolder->Text; + if(!(sss->EndsWith(L"/")||sss->EndsWith(L"\\"))) + sss+=L"\\"; + sss+=dynamic_cast(bitmapList->SelectedItem); + SDL_Surface *str = SDL_LoadBMP(ToString(sss).c_str()); + Int32 colorPxs = 0; + + int aq = 0x00ffff; + for (int x=0;xw;x++) + { + for(int y=0;yh;y++) + { + if(SDL_GetPixel(str,x,y) != aq) + colorPxs++; + } + } + int zgoda=0, retx, rety; + int px=mx, py=my, maxr = Convert::ToInt32(radious->Text); + if (radioButton2->Checked) + { + px-=str->w/2; + py-=str->h/2; + } + else if (radioButton3->Checked) + { + px-=str->w; + py-=str->h; + } + px-=maxr/2; + py-=maxr/2; + for(int i=0;izgoda) + { + zgoda = pom; + retx = px+i; + rety = py+j; + } + } + } + //for(int r=0;rzgoda) + // { + // zgoda = pom; + // retx = px+i; + // rety = py; + // } + // pom = zgodnosc(sbg,str,px+i,py+r); + // if (pom>zgoda) + // { + // zgoda = pom; + // retx = px+i; + // rety = py+r; + // } + // pom = zgodnosc(sbg,str,px,py+i); + // if (pom>zgoda) + // { + // zgoda = pom; + // retx = px; + // rety = py+i; + // } + // pom = zgodnosc(sbg,str,px+r,py+i); + // if (pom>zgoda) + // { + // zgoda = pom; + // retx = px+r; + // rety = py+i; + // } + // float per = zgoda/colorPxs; + // + // } + // px--; + // py--; + //} + accordanceBox->Text = zgoda.ToString() + L"/" + colorPxs.ToString(); + curx = retx; + cury = rety; + foundedCoords->Text = retx.ToString() + L", " + rety.ToString(); + //townBg->Refresh(); +} + +System::Void Wpasujbud::inaccuracy_TextChanged(System::Object^ sender, System::EventArgs^ e) +{ + int ni = Convert::ToUInt32(inaccuracy->Text); + if(ni==0) + { + inaccuracy->Text == L"1"; + Inaccuracy = 1; + } + else + { + Inaccuracy = ni; + } +} + +void Wpasujbud::nextPicture() +{ + if(bitmapList->SelectedIndex<(bitmapList->Items->Count-1)) + bitmapList->SelectedIndex++; +} +void Wpasujbud::previousPicture() +{ + if(bitmapList->SelectedIndex>0) + bitmapList->SelectedIndex--; +} + +System::Void Wpasujbud::confirm_Click(System::Object^ sender, System::EventArgs^ e) +{ + CBuildingData ^cbd = gcnew CBuildingData(); + //cbd->defname = bitmapsFolder->Text; + //if(!(cbd->defname->EndsWith(L"/")||cbd->defname->EndsWith(L"\\"))) + // cbd->defname+=L"\\"; + cbd->defname+=dynamic_cast(bitmapList->SelectedItem); + cbd->defname = (cbd->defname)->Substring(0,cbd->defname->Length-7)+".def"; + cbd->ID = buildingType->SelectedIndex; + cbd->townID = townID->SelectedIndex; + cbd->x = curx; + cbd->y = cury; + + //int curind = bitmapList->SelectedIndex; + bitmapList->Items->RemoveAt(bitmapList->SelectedIndex); + + nextPicture(); + nextPicture(); + data.push_back(cbd); + +} + //System::String^ defname; + //System::Int32 ID, x, y; + //System::Int32 townID; +System::Void Wpasujbud::save_Click(System::Object^ sender, System::EventArgs^ e) +{ + String ^n = DateTime::Now.ToString()+".txt"; + n = n->Replace(L" ",L"___")->Replace(':','_'); + IO::StreamWriter sr(IO::Directory::GetCurrentDirectory() + L"\\" + n); + for each (CBuildingData ^Data in data) + { + String ^temp = Data->ToString(); + sr.Write(temp); + } + sr.Close(); +} + +System::Void Wpasujbud::buildingImg_Click(System::Object^ sender, System::EventArgs^ e) +{ + if (!buildingImg->Image) + return; + obrazek ^ob = gcnew obrazek(buildingImg->Image); + ob->Show(); +} +System::Void Wpasujbud::dataview_Click(System::Object^ sender, System::EventArgs^ e) +{ + if (data.size()<=0) + return; + dataEditor ^ de = gcnew dataEditor(%data); + de->Show(); +} \ No newline at end of file diff --git a/tools/Wpasujbud/Wpasujbud.h b/tools/Wpasujbud/Wpasujbud.h new file mode 100644 index 000000000..0ab671c47 --- /dev/null +++ b/tools/Wpasujbud/Wpasujbud.h @@ -0,0 +1,649 @@ +#pragma once +#include +#include "data.h" +#include "obrazek.h" +#include "dataEditor.h" +#include +namespace Wpasuj { + + 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 for Wpasujbud + /// + /// 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. + /// + public ref class Wpasujbud : public System::Windows::Forms::Form + { + public: + cliext::vector data; + + Int32 mx, my, curx, cury; + SDL_Surface * sbg; + private: System::Windows::Forms::TextBox^ foundedCoords; + public: + + public: + + public: + + public: + private: System::Windows::Forms::Label^ label11; + private: System::Windows::Forms::Button^ confirm; + + private: System::Windows::Forms::Label^ label12; + private: System::Windows::Forms::Button^ button3; + private: System::Windows::Forms::TextBox^ accordanceBox; + private: System::Windows::Forms::Button^ button4; + private: System::Windows::Forms::TextBox^ inaccuracy; + private: System::Windows::Forms::Label^ label13; + private: System::Windows::Forms::Button^ save; + + private: System::Windows::Forms::RadioButton^ radioButton3; + private: System::Windows::Forms::Button^ dataview; + private: System::Windows::Forms::Label^ label9; + private: System::Windows::Forms::Label^ label14; + + private: System::Windows::Forms::Button^ button1; + public: + + void searchPicturePos(); + void nextPicture(); + void previousPicture(); + std::string ToString(System::String^ src); + + + obrazek ^curob; + dataEditor ^cured; + + Wpasujbud(void); + + protected: + /// + /// Clean up any resources being used. + /// + ~Wpasujbud() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::PictureBox^ townBg; + private: System::Windows::Forms::PictureBox^ buildingImg; + + private: System::Windows::Forms::Label^ label1; + private: System::Windows::Forms::RadioButton^ radioButton1; + private: System::Windows::Forms::RadioButton^ radioButton2; + private: System::Windows::Forms::TextBox^ koordy; + private: System::Windows::Forms::Label^ label2; + private: System::Windows::Forms::ComboBox^ buildingType; + + private: System::Windows::Forms::Label^ label3; + private: System::Windows::Forms::Label^ label4; + private: System::Windows::Forms::ComboBox^ townID; + private: System::Windows::Forms::TextBox^ bmpPattern; + private: System::Windows::Forms::Label^ label5; + private: System::Windows::Forms::ListBox^ bitmapList; + private: System::Windows::Forms::Label^ label6; + private: System::Windows::Forms::Button^ searchBitmaps; + private: System::Windows::Forms::Button^ startLocating; + + private: System::Windows::Forms::TextBox^ townBgPath; + private: System::Windows::Forms::Label^ label7; + private: System::Windows::Forms::Button^ setBackground; + + private: System::Windows::Forms::TextBox^ radious; + private: System::Windows::Forms::Label^ label8; + + + private: System::Windows::Forms::OpenFileDialog^ openFileDialog1; + private: System::Windows::Forms::Button^ browseForBg; + private: System::Windows::Forms::TextBox^ bitmapsFolder; + private: System::Windows::Forms::Label^ label10; + private: System::Windows::Forms::Button^ browseForbmpfol; + + private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1; + + + protected: + + protected: + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->townBg = (gcnew System::Windows::Forms::PictureBox()); + this->buildingImg = (gcnew System::Windows::Forms::PictureBox()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->radioButton1 = (gcnew System::Windows::Forms::RadioButton()); + this->radioButton2 = (gcnew System::Windows::Forms::RadioButton()); + this->koordy = (gcnew System::Windows::Forms::TextBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->buildingType = (gcnew System::Windows::Forms::ComboBox()); + this->label3 = (gcnew System::Windows::Forms::Label()); + this->label4 = (gcnew System::Windows::Forms::Label()); + this->townID = (gcnew System::Windows::Forms::ComboBox()); + this->bmpPattern = (gcnew System::Windows::Forms::TextBox()); + this->label5 = (gcnew System::Windows::Forms::Label()); + this->bitmapList = (gcnew System::Windows::Forms::ListBox()); + this->label6 = (gcnew System::Windows::Forms::Label()); + this->searchBitmaps = (gcnew System::Windows::Forms::Button()); + this->startLocating = (gcnew System::Windows::Forms::Button()); + this->townBgPath = (gcnew System::Windows::Forms::TextBox()); + this->label7 = (gcnew System::Windows::Forms::Label()); + this->setBackground = (gcnew System::Windows::Forms::Button()); + this->radious = (gcnew System::Windows::Forms::TextBox()); + this->label8 = (gcnew System::Windows::Forms::Label()); + this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog()); + this->browseForBg = (gcnew System::Windows::Forms::Button()); + this->bitmapsFolder = (gcnew System::Windows::Forms::TextBox()); + this->label10 = (gcnew System::Windows::Forms::Label()); + this->browseForbmpfol = (gcnew System::Windows::Forms::Button()); + this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog()); + this->button1 = (gcnew System::Windows::Forms::Button()); + this->foundedCoords = (gcnew System::Windows::Forms::TextBox()); + this->label11 = (gcnew System::Windows::Forms::Label()); + this->confirm = (gcnew System::Windows::Forms::Button()); + this->label12 = (gcnew System::Windows::Forms::Label()); + this->button3 = (gcnew System::Windows::Forms::Button()); + this->accordanceBox = (gcnew System::Windows::Forms::TextBox()); + this->button4 = (gcnew System::Windows::Forms::Button()); + this->inaccuracy = (gcnew System::Windows::Forms::TextBox()); + this->label13 = (gcnew System::Windows::Forms::Label()); + this->save = (gcnew System::Windows::Forms::Button()); + this->radioButton3 = (gcnew System::Windows::Forms::RadioButton()); + this->dataview = (gcnew System::Windows::Forms::Button()); + this->label9 = (gcnew System::Windows::Forms::Label()); + this->label14 = (gcnew System::Windows::Forms::Label()); + (cli::safe_cast(this->townBg))->BeginInit(); + (cli::safe_cast(this->buildingImg))->BeginInit(); + this->SuspendLayout(); + // + // townBg + // + this->townBg->Location = System::Drawing::Point(12, 6); + this->townBg->Name = L"townBg"; + this->townBg->Size = System::Drawing::Size(800, 374); + this->townBg->TabIndex = 0; + this->townBg->TabStop = false; + this->townBg->Click += gcnew System::EventHandler(this, &Wpasujbud::townBg_Click); + // + // buildingImg + // + this->buildingImg->Location = System::Drawing::Point(12, 401); + this->buildingImg->Name = L"buildingImg"; + this->buildingImg->Size = System::Drawing::Size(163, 137); + this->buildingImg->TabIndex = 1; + this->buildingImg->TabStop = false; + this->buildingImg->Click += gcnew System::EventHandler(this, &Wpasujbud::buildingImg_Click); + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(12, 385); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(166, 13); + this->label1->TabIndex = 2; + this->label1->Text = L"Current building (click for full size):"; + // + // radioButton1 + // + this->radioButton1->AutoSize = true; + this->radioButton1->Checked = true; + this->radioButton1->Location = System::Drawing::Point(185, 491); + this->radioButton1->Name = L"radioButton1"; + this->radioButton1->Size = System::Drawing::Size(94, 17); + this->radioButton1->TabIndex = 3; + this->radioButton1->TabStop = true; + this->radioButton1->Text = L"Top left corner"; + this->radioButton1->UseVisualStyleBackColor = true; + // + // radioButton2 + // + this->radioButton2->AutoSize = true; + this->radioButton2->Location = System::Drawing::Point(185, 512); + this->radioButton2->Name = L"radioButton2"; + this->radioButton2->Size = System::Drawing::Size(85, 17); + this->radioButton2->TabIndex = 3; + this->radioButton2->Text = L"Middle of pic"; + this->radioButton2->UseVisualStyleBackColor = true; + // + // koordy + // + this->koordy->Location = System::Drawing::Point(185, 470); + this->koordy->Name = L"koordy"; + this->koordy->Size = System::Drawing::Size(121, 20); + this->koordy->TabIndex = 4; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(214, 456); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(67, 13); + this->label2->TabIndex = 5; + this->label2->Text = L"Your coords:"; + // + // buildingType + // + this->buildingType->FormattingEnabled = true; + this->buildingType->Location = System::Drawing::Point(185, 400); + this->buildingType->Name = L"buildingType"; + this->buildingType->Size = System::Drawing::Size(121, 21); + this->buildingType->TabIndex = 6; + // + // label3 + // + this->label3->AutoSize = true; + this->label3->Location = System::Drawing::Point(214, 385); + this->label3->Name = L"label3"; + this->label3->Size = System::Drawing::Size(67, 13); + this->label3->TabIndex = 7; + this->label3->Text = L"Building type"; + // + // label4 + // + this->label4->AutoSize = true; + this->label4->Location = System::Drawing::Point(224, 422); + this->label4->Name = L"label4"; + this->label4->Size = System::Drawing::Size(48, 13); + this->label4->TabIndex = 7; + this->label4->Text = L"Town ID"; + // + // townID + // + this->townID->FormattingEnabled = true; + this->townID->Location = System::Drawing::Point(185, 435); + this->townID->Name = L"townID"; + this->townID->Size = System::Drawing::Size(121, 21); + this->townID->TabIndex = 6; + // + // bmpPattern + // + this->bmpPattern->Location = System::Drawing::Point(317, 467); + this->bmpPattern->Name = L"bmpPattern"; + this->bmpPattern->Size = System::Drawing::Size(121, 20); + this->bmpPattern->TabIndex = 4; + this->bmpPattern->Text = L"*.bmp"; + // + // label5 + // + this->label5->AutoSize = true; + this->label5->Location = System::Drawing::Point(332, 452); + this->label5->Name = L"label5"; + this->label5->Size = System::Drawing::Size(103, 13); + this->label5->TabIndex = 5; + this->label5->Text = L"Search bmp pattern:"; + // + // bitmapList + // + this->bitmapList->Enabled = false; + this->bitmapList->FormattingEnabled = true; + this->bitmapList->Location = System::Drawing::Point(449, 400); + this->bitmapList->Name = L"bitmapList"; + this->bitmapList->Size = System::Drawing::Size(133, 95); + this->bitmapList->TabIndex = 8; + this->bitmapList->SelectedIndexChanged += gcnew System::EventHandler(this, &Wpasujbud::bitmapList_SelectedIndexChanged); + // + // label6 + // + this->label6->AutoSize = true; + this->label6->Location = System::Drawing::Point(485, 384); + this->label6->Name = L"label6"; + this->label6->Size = System::Drawing::Size(57, 13); + this->label6->TabIndex = 9; + this->label6->Text = L"Bitmap list:"; + // + // searchBitmaps + // + this->searchBitmaps->Location = System::Drawing::Point(449, 501); + this->searchBitmaps->Name = L"searchBitmaps"; + this->searchBitmaps->Size = System::Drawing::Size(133, 23); + this->searchBitmaps->TabIndex = 10; + this->searchBitmaps->Text = L"Search bitmaps"; + this->searchBitmaps->UseVisualStyleBackColor = true; + this->searchBitmaps->Click += gcnew System::EventHandler(this, &Wpasujbud::searchBitmaps_Click); + // + // startLocating + // + this->startLocating->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(238))); + this->startLocating->Location = System::Drawing::Point(696, 464); + this->startLocating->Name = L"startLocating"; + this->startLocating->Size = System::Drawing::Size(120, 29); + this->startLocating->TabIndex = 11; + this->startLocating->Text = L"Search pos!"; + this->startLocating->UseVisualStyleBackColor = true; + this->startLocating->Click += gcnew System::EventHandler(this, &Wpasujbud::startLocating_Click); + // + // townBgPath + // + this->townBgPath->Location = System::Drawing::Point(317, 403); + this->townBgPath->Name = L"townBgPath"; + this->townBgPath->Size = System::Drawing::Size(121, 20); + this->townBgPath->TabIndex = 4; + // + // label7 + // + this->label7->AutoSize = true; + this->label7->Location = System::Drawing::Point(332, 386); + this->label7->Name = L"label7"; + this->label7->Size = System::Drawing::Size(94, 13); + this->label7->TabIndex = 5; + this->label7->Text = L"Town background"; + // + // setBackground + // + this->setBackground->Location = System::Drawing::Point(317, 427); + this->setBackground->Name = L"setBackground"; + this->setBackground->Size = System::Drawing::Size(52, 23); + this->setBackground->TabIndex = 12; + this->setBackground->Text = L"Set bg"; + this->setBackground->UseVisualStyleBackColor = true; + this->setBackground->Click += gcnew System::EventHandler(this, &Wpasujbud::setBackground_Click); + // + // radious + // + this->radious->Location = System::Drawing::Point(591, 441); + this->radious->Name = L"radious"; + this->radious->Size = System::Drawing::Size(98, 20); + this->radious->TabIndex = 13; + this->radious->Text = L"100"; + // + // label8 + // + this->label8->AutoSize = true; + this->label8->Location = System::Drawing::Point(597, 426); + this->label8->Name = L"label8"; + this->label8->Size = System::Drawing::Size(62, 13); + this->label8->TabIndex = 5; + this->label8->Text = L"Search rad:"; + // + // openFileDialog1 + // + this->openFileDialog1->FileName = L"openFileDialog1"; + this->openFileDialog1->Filter = L"BMP Files (*.bmp)|*.bmp|All files (*.*)|*.*"; + this->openFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Wpasujbud::openFileDialog1_FileOk); + // + // browseForBg + // + this->browseForBg->Location = System::Drawing::Point(373, 427); + this->browseForBg->Name = L"browseForBg"; + this->browseForBg->Size = System::Drawing::Size(65, 23); + this->browseForBg->TabIndex = 14; + this->browseForBg->Text = L"Browse"; + this->browseForBg->UseVisualStyleBackColor = true; + this->browseForBg->Click += gcnew System::EventHandler(this, &Wpasujbud::browseForBg_Click); + // + // bitmapsFolder + // + this->bitmapsFolder->Location = System::Drawing::Point(317, 505); + this->bitmapsFolder->Name = L"bitmapsFolder"; + this->bitmapsFolder->Size = System::Drawing::Size(121, 20); + this->bitmapsFolder->TabIndex = 4; + // + // label10 + // + this->label10->AutoSize = true; + this->label10->Location = System::Drawing::Point(334, 490); + this->label10->Name = L"label10"; + this->label10->Size = System::Drawing::Size(97, 13); + this->label10->TabIndex = 5; + this->label10->Text = L"Folder with bitmaps"; + // + // browseForbmpfol + // + this->browseForbmpfol->Location = System::Drawing::Point(321, 528); + this->browseForbmpfol->Name = L"browseForbmpfol"; + this->browseForbmpfol->Size = System::Drawing::Size(111, 19); + this->browseForbmpfol->TabIndex = 15; + this->browseForbmpfol->Text = L"Browse"; + this->browseForbmpfol->UseVisualStyleBackColor = true; + this->browseForbmpfol->Click += gcnew System::EventHandler(this, &Wpasujbud::browseForbmpfol_Click); + // + // button1 + // + this->button1->Location = System::Drawing::Point(592, 466); + this->button1->Name = L"button1"; + this->button1->Size = System::Drawing::Size(97, 23); + this->button1->TabIndex = 16; + this->button1->Text = L"Next pic"; + this->button1->UseVisualStyleBackColor = true; + this->button1->Click += gcnew System::EventHandler(this, &Wpasujbud::button1_Click); + // + // foundedCoords + // + this->foundedCoords->Location = System::Drawing::Point(696, 441); + this->foundedCoords->Name = L"foundedCoords"; + this->foundedCoords->Size = System::Drawing::Size(120, 20); + this->foundedCoords->TabIndex = 17; + this->foundedCoords->Text = L"0, 0"; + // + // label11 + // + this->label11->AutoSize = true; + this->label11->Location = System::Drawing::Point(722, 425); + this->label11->Name = L"label11"; + this->label11->Size = System::Drawing::Size(87, 13); + this->label11->TabIndex = 18; + this->label11->Text = L"Founded coords:"; + // + // confirm + // + this->confirm->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(238))); + this->confirm->Location = System::Drawing::Point(590, 525); + this->confirm->Name = L"confirm"; + this->confirm->Size = System::Drawing::Size(120, 23); + this->confirm->TabIndex = 19; + this->confirm->Text = L"Confirm"; + this->confirm->UseVisualStyleBackColor = true; + this->confirm->Click += gcnew System::EventHandler(this, &Wpasujbud::confirm_Click); + // + // label12 + // + this->label12->AutoSize = true; + this->label12->Location = System::Drawing::Point(722, 385); + this->label12->Name = L"label12"; + this->label12->Size = System::Drawing::Size(68, 13); + this->label12->TabIndex = 21; + this->label12->Text = L"Accordance:"; + // + // button3 + // + this->button3->Location = System::Drawing::Point(736, 496); + this->button3->Name = L"button3"; + this->button3->Size = System::Drawing::Size(83, 23); + this->button3->TabIndex = 22; + this->button3->Text = L"Check pos"; + this->button3->UseVisualStyleBackColor = true; + // + // accordanceBox + // + this->accordanceBox->Enabled = false; + this->accordanceBox->Location = System::Drawing::Point(696, 401); + this->accordanceBox->Name = L"accordanceBox"; + this->accordanceBox->Size = System::Drawing::Size(115, 20); + this->accordanceBox->TabIndex = 20; + this->accordanceBox->Text = L"0/0"; + // + // button4 + // + this->button4->Location = System::Drawing::Point(592, 496); + this->button4->Name = L"button4"; + this->button4->Size = System::Drawing::Size(83, 23); + this->button4->TabIndex = 23; + this->button4->Text = L"Previous pic"; + this->button4->UseVisualStyleBackColor = true; + this->button4->Click += gcnew System::EventHandler(this, &Wpasujbud::button4_Click); + // + // inaccuracy + // + this->inaccuracy->Location = System::Drawing::Point(592, 401); + this->inaccuracy->Name = L"inaccuracy"; + this->inaccuracy->Size = System::Drawing::Size(98, 20); + this->inaccuracy->TabIndex = 20; + this->inaccuracy->Text = L"5"; + this->inaccuracy->TextChanged += gcnew System::EventHandler(this, &Wpasujbud::inaccuracy_TextChanged); + // + // label13 + // + this->label13->AutoSize = true; + this->label13->Location = System::Drawing::Point(587, 385); + this->label13->Name = L"label13"; + this->label13->Size = System::Drawing::Size(88, 13); + this->label13->TabIndex = 21; + this->label13->Text = L"Inaccuracy level:"; + // + // save + // + this->save->Location = System::Drawing::Point(681, 497); + this->save->Name = L"save"; + this->save->Size = System::Drawing::Size(48, 23); + this->save->TabIndex = 24; + this->save->Text = L"Save"; + this->save->UseVisualStyleBackColor = true; + this->save->Click += gcnew System::EventHandler(this, &Wpasujbud::save_Click); + // + // radioButton3 + // + this->radioButton3->AutoSize = true; + this->radioButton3->Location = System::Drawing::Point(185, 531); + this->radioButton3->Name = L"radioButton3"; + this->radioButton3->Size = System::Drawing::Size(114, 17); + this->radioButton3->TabIndex = 3; + this->radioButton3->Text = L"Bottom right corner"; + this->radioButton3->UseVisualStyleBackColor = true; + // + // dataview + // + this->dataview->Location = System::Drawing::Point(449, 528); + this->dataview->Name = L"dataview"; + this->dataview->Size = System::Drawing::Size(135, 21); + this->dataview->TabIndex = 25; + this->dataview->Text = L"Data view/edition"; + this->dataview->UseVisualStyleBackColor = true; + this->dataview->Click += gcnew System::EventHandler(this, &Wpasujbud::dataview_Click); + // + // label9 + // + this->label9->AutoSize = true; + this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(238))); + this->label9->Location = System::Drawing::Point(722, 523); + this->label9->Name = L"label9"; + this->label9->Size = System::Drawing::Size(99, 15); + this->label9->TabIndex = 26; + this->label9->Text = L"By VCMI Team"; + // + // label14 + // + this->label14->AutoSize = true; + this->label14->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(238))); + this->label14->Location = System::Drawing::Point(742, 538); + this->label14->Name = L"label14"; + this->label14->Size = System::Drawing::Size(53, 15); + this->label14->TabIndex = 27; + this->label14->Text = L"© 2008"; + // + // Wpasujbud + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(823, 554); + this->Controls->Add(this->label14); + this->Controls->Add(this->label9); + this->Controls->Add(this->dataview); + this->Controls->Add(this->save); + this->Controls->Add(this->button4); + this->Controls->Add(this->button3); + this->Controls->Add(this->label13); + this->Controls->Add(this->label12); + this->Controls->Add(this->inaccuracy); + this->Controls->Add(this->accordanceBox); + this->Controls->Add(this->confirm); + this->Controls->Add(this->label11); + this->Controls->Add(this->foundedCoords); + this->Controls->Add(this->button1); + this->Controls->Add(this->browseForbmpfol); + this->Controls->Add(this->browseForBg); + this->Controls->Add(this->radious); + this->Controls->Add(this->setBackground); + this->Controls->Add(this->startLocating); + this->Controls->Add(this->searchBitmaps); + this->Controls->Add(this->label6); + this->Controls->Add(this->bitmapList); + this->Controls->Add(this->label4); + this->Controls->Add(this->label3); + this->Controls->Add(this->townID); + this->Controls->Add(this->buildingType); + this->Controls->Add(this->label8); + this->Controls->Add(this->label7); + this->Controls->Add(this->label10); + this->Controls->Add(this->label5); + this->Controls->Add(this->label2); + this->Controls->Add(this->bitmapsFolder); + this->Controls->Add(this->townBgPath); + this->Controls->Add(this->bmpPattern); + this->Controls->Add(this->koordy); + this->Controls->Add(this->radioButton3); + this->Controls->Add(this->radioButton2); + this->Controls->Add(this->radioButton1); + this->Controls->Add(this->label1); + this->Controls->Add(this->buildingImg); + this->Controls->Add(this->townBg); + this->MaximizeBox = false; + this->Name = L"Wpasujbud"; + this->Text = L"Cudowny wpasowywacz 1.00"; + (cli::safe_cast(this->townBg))->EndInit(); + (cli::safe_cast(this->buildingImg))->EndInit(); + this->ResumeLayout(false); + this->PerformLayout(); + + } +#pragma endregion + private: + System::Void searchBitmaps_Click(System::Object^ sender, System::EventArgs^ e); + System::Void startLocating_Click(System::Object^ sender, System::EventArgs^ e); + System::Void setBackground_Click(System::Object^ sender, System::EventArgs^ e); + System::Void openFileDialog1_FileOk(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) ; + System::Void browseForBg_Click(System::Object^ sender, System::EventArgs^ e); + System::Void browseForbmpfol_Click(System::Object^ sender, System::EventArgs^ e); + System::Void bitmapList_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e); + System::Void townBg_Click(System::Object^ sender, System::EventArgs^ e); + System::Void button1_Click(System::Object^ sender, System::EventArgs^ e); + System::Void inaccuracy_TextChanged(System::Object^ sender, System::EventArgs^ e); + System::Void confirm_Click(System::Object^ sender, System::EventArgs^ e); + System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { + previousPicture(); + } + System::Void save_Click(System::Object^ sender, System::EventArgs^ e); + System::Void buildingImg_Click(System::Object^ sender, System::EventArgs^ e); + System::Void dataview_Click(System::Object^ sender, System::EventArgs^ e); + +}; + +} + diff --git a/tools/Wpasujbud/data.h b/tools/Wpasujbud/data.h new file mode 100644 index 000000000..6ec54ad59 --- /dev/null +++ b/tools/Wpasujbud/data.h @@ -0,0 +1,12 @@ +#pragma once +public ref class CBuildingData +{ +public: + System::String^ defname; + System::Int32 ID, x, y; + System::Int32 townID; + virtual System::String^ ToString()override + { + return townID.ToString() + L" " + ID.ToString() + L" " + defname + L" " + x.ToString() + L" " + y.ToString() + L"\n"; + } +}; \ No newline at end of file diff --git a/tools/Wpasujbud/dataEditor.cpp b/tools/Wpasujbud/dataEditor.cpp new file mode 100644 index 000000000..5bd79ee72 --- /dev/null +++ b/tools/Wpasujbud/dataEditor.cpp @@ -0,0 +1,2 @@ +#include "dataEditor.h" + diff --git a/tools/Wpasujbud/dataEditor.h b/tools/Wpasujbud/dataEditor.h new file mode 100644 index 000000000..1ff83d23c --- /dev/null +++ b/tools/Wpasujbud/dataEditor.h @@ -0,0 +1,209 @@ +#pragma once +#include "data.h" +#include +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 Wpasuj { + + /// + /// Summary for dataEditor + /// + /// 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. + /// + public ref class dataEditor : public System::Windows::Forms::Form + { + public: + dataEditor(cliext::vector ^Data) + { + data = Data; + InitializeComponent(); + dataGridView1->Rows->Add(data->size()); + for (int i=0;isize();i++) + { + dataGridView1->Rows[i]->Cells[0]->Value = data->at(i)->townID; + dataGridView1->Rows[i]->Cells[1]->Value = data->at(i)->ID; + dataGridView1->Rows[i]->Cells[2]->Value = data->at(i)->defname; + dataGridView1->Rows[i]->Cells[3]->Value = data->at(i)->x; + dataGridView1->Rows[i]->Cells[4]->Value = data->at(i)->y; + } + } + private: System::Windows::Forms::DataGridViewTextBoxColumn^ townid; + public: + private: System::Windows::Forms::DataGridViewTextBoxColumn^ buildingID; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ defname; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ x; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ y; + private: System::Windows::Forms::Button^ save; + private: System::Windows::Forms::Button^ clear; + private: System::Windows::Forms::Button^ close; + private: + + cliext::vector ^data; + protected: + /// + /// Clean up any resources being used. + /// + ~dataEditor() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::DataGridView^ dataGridView1; + + + + + + protected: + + protected: + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView()); + this->townid = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->buildingID = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->defname = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->x = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->y = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->save = (gcnew System::Windows::Forms::Button()); + this->clear = (gcnew System::Windows::Forms::Button()); + this->close = (gcnew System::Windows::Forms::Button()); + (cli::safe_cast(this->dataGridView1))->BeginInit(); + this->SuspendLayout(); + // + // dataGridView1 + // + this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; + this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5) {this->townid, + this->buildingID, this->defname, this->x, this->y}); + this->dataGridView1->Location = System::Drawing::Point(12, 12); + this->dataGridView1->Name = L"dataGridView1"; + this->dataGridView1->Size = System::Drawing::Size(334, 276); + this->dataGridView1->TabIndex = 0; + // + // townid + // + this->townid->HeaderText = L"Town ID"; + this->townid->Name = L"townid"; + this->townid->Width = 50; + // + // buildingID + // + this->buildingID->HeaderText = L"Building ID"; + this->buildingID->Name = L"buildingID"; + this->buildingID->Width = 60; + // + // defname + // + this->defname->HeaderText = L"Def name"; + this->defname->Name = L"defname"; + this->defname->Width = 120; + // + // x + // + this->x->HeaderText = L"X"; + this->x->Name = L"x"; + this->x->Width = 30; + // + // y + // + this->y->HeaderText = L"Y"; + this->y->Name = L"y"; + this->y->Width = 30; + // + // save + // + this->save->Location = System::Drawing::Point(12, 294); + this->save->Name = L"save"; + this->save->Size = System::Drawing::Size(105, 23); + this->save->TabIndex = 1; + this->save->Text = L"Save changes"; + this->save->UseVisualStyleBackColor = true; + this->save->Click += gcnew System::EventHandler(this, &dataEditor::save_Click); + // + // clear + // + this->clear->Location = System::Drawing::Point(248, 294); + this->clear->Name = L"clear"; + this->clear->Size = System::Drawing::Size(96, 23); + this->clear->TabIndex = 2; + this->clear->Text = L"Clear changes"; + this->clear->UseVisualStyleBackColor = true; + this->clear->Click += gcnew System::EventHandler(this, &dataEditor::clear_Click); + // + // close + // + this->close->Location = System::Drawing::Point(123, 294); + this->close->Name = L"close"; + this->close->Size = System::Drawing::Size(119, 23); + this->close->TabIndex = 3; + this->close->Text = L"Close"; + this->close->UseVisualStyleBackColor = true; + this->close->Click += gcnew System::EventHandler(this, &dataEditor::close_Click); + // + // dataEditor + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(356, 328); + this->Controls->Add(this->close); + this->Controls->Add(this->clear); + this->Controls->Add(this->save); + this->Controls->Add(this->dataGridView1); + this->Name = L"dataEditor"; + this->Text = L"dataEditor"; + (cli::safe_cast(this->dataGridView1))->EndInit(); + this->ResumeLayout(false); + + } +#pragma endregion + + private: System::Void clear_Click(System::Object^ sender, System::EventArgs^ e) { + for (int i=0;isize();i++) + { + dataGridView1->Rows[i]->Cells[0]->Value = data->at(i)->townID; + dataGridView1->Rows[i]->Cells[1]->Value = data->at(i)->ID; + dataGridView1->Rows[i]->Cells[2]->Value = data->at(i)->defname; + dataGridView1->Rows[i]->Cells[3]->Value = data->at(i)->x; + dataGridView1->Rows[i]->Cells[4]->Value = data->at(i)->y; + } + } +private: System::Void close_Click(System::Object^ sender, System::EventArgs^ e) { + Close(); + } +private: System::Void save_Click(System::Object^ sender, System::EventArgs^ e) { + for (int i=0;isize();i++) + { + data->at(i)->townID = Convert::ToInt32( static_cast(dataGridView1->Rows[i]->Cells[0]->Value)); + data->at(i)->ID = Convert::ToInt32( static_cast(dataGridView1->Rows[i]->Cells[1]->Value)); + data->at(i)->defname = static_cast(dataGridView1->Rows[i]->Cells[2]->Value); + data->at(i)->x = Convert::ToInt32( static_cast(dataGridView1->Rows[i]->Cells[3]->Value)); + data->at(i)->y = Convert::ToInt32( static_cast(dataGridView1->Rows[i]->Cells[4]->Value)); + } + } +}; +} diff --git a/tools/Wpasujbud/obrazek.cpp b/tools/Wpasujbud/obrazek.cpp new file mode 100644 index 000000000..f4a63a41b --- /dev/null +++ b/tools/Wpasujbud/obrazek.cpp @@ -0,0 +1,2 @@ +#include "obrazek.h" + diff --git a/tools/Wpasujbud/obrazek.h b/tools/Wpasujbud/obrazek.h new file mode 100644 index 000000000..c5b7c50d9 --- /dev/null +++ b/tools/Wpasujbud/obrazek.h @@ -0,0 +1,121 @@ +#pragma once + +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 Wpasuj { + + /// + /// Summary for obrazek + /// + /// 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. + /// + public ref class obrazek : public System::Windows::Forms::Form + { + public: + obrazek(System::Drawing::Image^ img) + { + InitializeComponent(img); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~obrazek() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::PictureBox^ pictureBox1; + private: System::Windows::Forms::TrackBar^ trackBar1; + private: System::Windows::Forms::Label^ Transparency; + protected: + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(System::Drawing::Image^ img) + { + this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox()); + (cli::safe_cast(this->pictureBox1))->BeginInit(); + this->SuspendLayout(); + // + // pictureBox1 + // + this->pictureBox1->Location = System::Drawing::Point(12, 12); + this->pictureBox1->Name = L"pictureBox1"; + this->pictureBox1->Size = System::Drawing::Size(img->Width,img->Height);//(268, 242); + this->pictureBox1->TabIndex = 0; + this->pictureBox1->TabStop = false; + this->pictureBox1->Image = img; + this->pictureBox1->Click += gcnew System::EventHandler(this,&obrazek::obrazek_Click); + + + + this->Transparency = (gcnew System::Windows::Forms::Label()); + this->Transparency->AutoSize = true; + this->Transparency->Location = System::Drawing::Point(12, img->Height+70); + this->Transparency->Name = L"label13"; + this->Transparency->Size = System::Drawing::Size(110, 13); + this->Transparency->TabIndex = 21; + this->Transparency->Text = L"Window transparency"; + + + this->trackBar1 = (gcnew System::Windows::Forms::TrackBar()); + this->trackBar1->Location = System::Drawing::Point(12, img->Height+24); + this->trackBar1->Name = L"trackBar1"; + this->trackBar1->Size = System::Drawing::Size(img->Width, 45); + this->trackBar1->TabIndex = 26; + this->trackBar1->Minimum = 0; + this->trackBar1->Maximum = 255; + this->trackBar1->Value = 255; + this->trackBar1->TickFrequency=1; + this->trackBar1->ValueChanged += gcnew System::EventHandler(this,&obrazek::suwakiemRuszono); + + // + // obrazek + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(img->Width+24,img->Height+94);//(292, 266); + this->Controls->Add(this->pictureBox1); + this->Controls->Add(this->trackBar1); + this->Controls->Add(this->Transparency); + this->Click += gcnew System::EventHandler(this,&obrazek::obrazek_Click); + this->Name = L"obrazek"; + this->Text = L"Picture window"; + (cli::safe_cast(this->pictureBox1))->EndInit(); + this->ResumeLayout(false); + + + } +#pragma endregion + + private: System::Void obrazek_Click(System::Object^ sender, System::EventArgs^ e) { + Close(); + } + private: System::Void suwakiemRuszono(System::Object^ sender, System::EventArgs^ e) { + Opacity = trackBar1->Value/((double)255); + } + }; +}