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

More changes for netcode/serialization

Removed not needed stuff
This commit is contained in:
Michał W. Urbańczyk 2008-07-25 17:28:28 +00:00
parent 358ab062eb
commit 0c139e72f5
62 changed files with 1102 additions and 5137 deletions

View File

@ -4,6 +4,7 @@
#include "CPlayerInterface.h"
#include "hch/CPreGameTextHandler.h"
#include "hch/CGeneralTextHandler.h"
#include "hch/CDefHandler.h"
#include "hch/CTownHandler.h"
#include "CPathfinder.h"
#include "CGameInfo.h"

View File

@ -14,63 +14,8 @@
#include "CPlayerInterface.h"
#include "hch/CBuildingHandler.h"
#include "hch/CObjectHandler.h"
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
//LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
int CCallback::lowestSpeed(CGHeroInstance * chi)
{
int min = 150;
for ( std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin();
i!=chi->army.slots.end(); i++ )
{
if (min>(*i).second.first->speed)
min = (*i).second.first->speed;
}
return min;
}
int CCallback::valMovePoints(CGHeroInstance * chi)
{
int ret = 1270+70*lowestSpeed(chi);
if (ret>2000)
ret=2000;
//TODO: additional bonuses (but they aren't currently stored in chi)
return ret;
}
void CCallback::newTurn()
{
//std::map<int, PlayerState>::iterator i = gs->players.begin() ;
gs->day++;
for (std::set<CCPPObjectScript *>::iterator i=gs->cppscripts.begin();i!=gs->cppscripts.end();i++)
{
(*i)->newTurn();
}
for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
{
//handle heroes/////////////////////////////
for (int j=0;j<(*i).second.heroes.size();j++)
{
(*i).second.heroes[j]->movement = valMovePoints((*i).second.heroes[j]);
}
//handle towns/////////////////////////////
for(int j=0;j<i->second.towns.size();j++)
{
i->second.towns[j]->builded=0;
if(getDate(1)==1) //first day of week
{
for(int k=0;k<CREATURES_PER_TOWN;k++)
{
if(i->second.towns[j]->creatureDwelling(k))//there is dwelling
i->second.towns[j]->strInfo.creatures[k]+=i->second.towns[j]->creatureGrowth(k);
}
}
if((gs->day>1) && i->first<PLAYER_LIMIT)
i->second.resources[6]+=i->second.towns[j]->dailyIncome();
}
}
}
bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
{
CGHeroInstance * hero = NULL;
@ -93,7 +38,7 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
else //idtype==1; player<0
{
for(std::map<int, PlayerState>::iterator j=CGI->state->players.begin(); j!=CGI->state->players.end(); ++j)
for(std::map<ui8, PlayerState>::iterator j=CGI->state->players.begin(); j!=CGI->state->players.end(); ++j)
{
for (int i=0; i<(*j).second.heroes.size();i++)
{
@ -193,7 +138,7 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
//notify interfacesabout move
int nn=0; //number of interfece of currently browsed player
for(std::map<int, PlayerState>::iterator j=CGI->state->players.begin(); j!=CGI->state->players.end(); ++j)//CGI->state->players.size(); ++j) //for testing
for(std::map<ui8, PlayerState>::iterator j=CGI->state->players.begin(); j!=CGI->state->players.end(); ++j)//CGI->state->players.size(); ++j) //for testing
{
if (j->first > PLAYER_LIMIT)
break;
@ -425,30 +370,7 @@ std::vector<int> CCallback::getResourceAmount()
}
int CCallback::getDate(int mode)
{
int temp;
switch (mode)
{
case 0:
return gs->day;
break;
case 1:
temp = (gs->day)%7;
if (temp)
return temp;
else return 7;
break;
case 2:
temp = ((gs->day-1)/7)+1;
if (!(temp%4))
return 4;
else
return (temp%4);
break;
case 3:
return ((gs->day-1)/28)+1;
break;
}
return 0;
return gs->getDate(mode);
}
bool CCallback::verifyPath(CPath * path, bool blockSea)
{
@ -504,7 +426,7 @@ bool CCallback::isVisible(int3 pos, int Player)
std::vector < const CGTownInstance *> CCallback::getTownsInfo(bool onlyOur)
{
std::vector < const CGTownInstance *> ret = std::vector < const CGTownInstance *>();
for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
for ( std::map<ui8, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
{
for (int j=0;j<(*i).second.towns.size();j++)
{
@ -519,7 +441,7 @@ std::vector < const CGTownInstance *> CCallback::getTownsInfo(bool onlyOur)
std::vector < const CGHeroInstance *> CCallback::getHeroesInfo(bool onlyOur)
{
std::vector < const CGHeroInstance *> ret = std::vector < const CGHeroInstance *>();
for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
for ( std::map<ui8, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
{
for (int j=0;j<(*i).second.heroes.size();j++)
{
@ -1037,77 +959,68 @@ void CScriptCallback::startBattle(int heroID, CCreatureSet * army, int3 tile) //
}
void CLuaCallback::registerFuncs(lua_State * L)
{
lua_newtable(L);
#define REGISTER_C_FUNC(x) \
lua_pushstring(L, #x); \
lua_pushcfunction(L, x); \
lua_rawset(L, -3)
REGISTER_C_FUNC(getPos);
REGISTER_C_FUNC(changePrimSkill);
REGISTER_C_FUNC(getGnrlText);
REGISTER_C_FUNC(getSelectedHero);
/*
REGISTER_C_FUNC(changePrimSkill);
REGISTER_C_FUNC(getGnrlText);
REGISTER_C_FUNC(changePrimSkill);
REGISTER_C_FUNC(getGnrlText);
REGISTER_C_FUNC(changePrimSkill);
REGISTER_C_FUNC(getGnrlText);*/
lua_setglobal(L, "vcmi");
#undef REGISTER_C_FUNC
// lua_newtable(L);
//
//#define REGISTER_C_FUNC(x) \
// lua_pushstring(L, #x); \
// lua_pushcfunction(L, x); \
// lua_rawset(L, -3)
//
// REGISTER_C_FUNC(getPos);
// REGISTER_C_FUNC(changePrimSkill);
// REGISTER_C_FUNC(getGnrlText);
// REGISTER_C_FUNC(getSelectedHero);
//
// lua_setglobal(L, "vcmi");
// #undef REGISTER_C_FUNC
}
int CLuaCallback::getPos(lua_State * L)//(CGObjectInstance * object);
{
const int args = lua_gettop(L); // number of arguments
if ((args < 1) || !lua_isnumber(L, 1) )
luaL_error(L,
"Incorrect arguments to getPos([Object address])");
CGObjectInstance * object = (CGObjectInstance *)(lua_tointeger(L, 1));
lua_pushinteger(L,object->pos.x);
lua_pushinteger(L,object->pos.y);
lua_pushinteger(L,object->pos.z);
//const int args = lua_gettop(L); // number of arguments
//if ((args < 1) || !lua_isnumber(L, 1) )
// luaL_error(L,
// "Incorrect arguments to getPos([Object address])");
//CGObjectInstance * object = (CGObjectInstance *)(lua_tointeger(L, 1));
//lua_pushinteger(L,object->pos.x);
//lua_pushinteger(L,object->pos.y);
//lua_pushinteger(L,object->pos.z);
return 3;
}
int CLuaCallback::changePrimSkill(lua_State * L)//(int ID, int which, int val);
{
const int args = lua_gettop(L); // number of arguments
if ((args < 1) || !lua_isnumber(L, 1) ||
((args >= 2) && !lua_isnumber(L, 2)) ||
((args >= 3) && !lua_isnumber(L, 3)) )
{
luaL_error(L,
"Incorrect arguments to changePrimSkill([Hero ID], [Which Primary skill], [Change by])");
}
int ID = lua_tointeger(L, 1),
which = lua_tointeger(L, 2),
val = lua_tointeger(L, 3);
//const int args = lua_gettop(L); // number of arguments
//if ((args < 1) || !lua_isnumber(L, 1) ||
// ((args >= 2) && !lua_isnumber(L, 2)) ||
// ((args >= 3) && !lua_isnumber(L, 3)) )
//{
// luaL_error(L,
// "Incorrect arguments to changePrimSkill([Hero ID], [Which Primary skill], [Change by])");
//}
//int ID = lua_tointeger(L, 1),
// which = lua_tointeger(L, 2),
// val = lua_tointeger(L, 3);
CScriptCallback::changePrimSkill(ID,which,val);
//CScriptCallback::changePrimSkill(ID,which,val);
return 0;
}
int CLuaCallback::getGnrlText(lua_State * L) //(int which),returns string
{
const int args = lua_gettop(L); // number of arguments
if ((args < 1) || !lua_isnumber(L, 1) )
luaL_error(L,
"Incorrect arguments to getGnrlText([Text ID])");
int which = lua_tointeger(L,1);
lua_pushstring(L,CGI->generaltexth->allTexts[which].c_str());
//const int args = lua_gettop(L); // number of arguments
//if ((args < 1) || !lua_isnumber(L, 1) )
// luaL_error(L,
// "Incorrect arguments to getGnrlText([Text ID])");
//int which = lua_tointeger(L,1);
//lua_pushstring(L,CGI->generaltexth->allTexts[which].c_str());
return 1;
}
int CLuaCallback::getSelectedHero(lua_State * L) //(),returns int (ID of hero, -1 if no hero is seleceted)
{
int ret;
if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
else
ret = -1;
lua_pushinteger(L,ret);
//int ret;
//if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
// ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
//else
// ret = -1;
//lua_pushinteger(L,ret);
return 1;
}

View File

@ -85,11 +85,8 @@ struct HeroMoveDetails
class CCallback : public ICallback
{
private:
void newTurn();
CCallback(CGameState * GS, int Player):gs(GS),player(Player){};
CGameState * gs;
int lowestSpeed(CGHeroInstance * chi); //speed of the slowest stack
int valMovePoints(CGHeroInstance * chi);
bool isVisible(int3 pos, int Player);
protected:
@ -148,7 +145,7 @@ public:
//friends
friend int _tmain(int argc, _TCHAR* argv[]);
friend class CClient;
};
class CScriptCallback
{
@ -174,7 +171,8 @@ public:
void startBattle(int heroID, CCreatureSet * army, int3 tile); //for hero<=>neutral army
//friends
friend CGameState;
friend class CGameState;
friend class CClient;
};
class CLuaCallback : public CScriptCallback
{
@ -186,6 +184,7 @@ private:
static int getGnrlText(lua_State * L);//(int ID, int which, int val);
static int getSelectedHero(lua_State * L);//()
friend CGameState;
friend class CGameState;
friend class CClient;
};
#endif //CCALLBACK_H

View File

@ -7,7 +7,7 @@ class CConsoleHandler
public:
void runConsole();
friend int _tmain(int argc, _TCHAR* argv[]);
friend class CClient;
};
#endif //CCONSOLEHANDLER_H

View File

@ -249,8 +249,37 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
map->defs.insert(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]);
if(!cur->defInfo){std::cout<<"Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;return;}
}
void CGameState::init(StartInfo * si, Mapa * map, int seed)
int CGameState::getDate(int mode) const
{
int temp;
switch (mode)
{
case 0:
return day;
break;
case 1:
temp = (day)%7;
if (temp)
return temp;
else return 7;
break;
case 2:
temp = ((day-1)/7)+1;
if (!(temp%4))
return 4;
else
return (temp%4);
break;
case 3:
return ((day-1)/28)+1;
break;
}
return 0;
}
void CGameState::init(StartInfo * si, Mapa * map, int Seed)
{
seed = Seed;
ran.seed((long)seed);
scenarioOps = si;
this->map = map;
@ -313,7 +342,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int seed)
startres.push_back(k);
}
tis.close();
for (std::map<int,PlayerState>::iterator i = players.begin(); i!=players.end(); i++)
for (std::map<ui8,PlayerState>::iterator i = players.begin(); i!=players.end(); i++)
{
(*i).second.resources.resize(RESOURCE_QUANTITY);
for (int x=0;x<RESOURCE_QUANTITY;x++)
@ -391,7 +420,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int seed)
}
/*************************FOG**OF**WAR******************************************/
for(std::map<int, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
for(std::map<ui8, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
{
k->second.fogOfWarMap.resize(map->width);
for(int g=0; g<map->width; ++g)
@ -439,7 +468,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int seed)
players[vti->getOwner()].towns.push_back(vti);
}
for(std::map<int, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
for(std::map<ui8, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
{
if(k->first==-1 || k->first==255)
continue;

View File

@ -66,11 +66,12 @@ class DLL_EXPORT CGameState
{
private:
StartInfo* scenarioOps;
int currentPlayer; //ID of player currently having turn
ui32 seed;
ui8 currentPlayer; //ID of player currently having turn
BattleInfo *curB; //current battle
int day; //total number of days in game
ui32 day; //total number of days in game
Mapa * map;
std::map<int,PlayerState> players; //ID <-> playerstate
std::map<ui8,PlayerState> players; //ID <-> playerstate
std::set<CCPPObjectScript *> cppscripts; //C++ scripts
std::map<int, std::map<std::string, CObjectScript*> > objscr; //non-C++ scripts
@ -88,7 +89,7 @@ private:
return false;
}
void init(StartInfo * si, Mapa * map, int seed);
void init(StartInfo * si, Mapa * map, int Seed);
void randomizeObject(CGObjectInstance *cur);
std::pair<int,int> pickObject(CGObjectInstance *obj);
int pickHero(int owner);
@ -98,15 +99,17 @@ private:
bool battleAttackCreatureStack(int ID, int dest);
std::vector<int> battleGetRange(int ID); //called by std::vector<int> CCallback::battleGetAvailableHexes(int ID);
public:
friend CCallback;
friend CPathfinder;;
friend CLuaCallback;
friend int _tmain(int argc, _TCHAR* argv[]);
int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
friend class CCallback;
friend class CPathfinder;;
friend class CLuaCallback;
friend class CClient;
friend void initGameState(Mapa * map, CGameInfo * cgi);
friend CScriptCallback;
friend class CScriptCallback;
friend void handleCPPObjS(std::map<int,CCPPObjectScript*> * mapa, CCPPObjectScript * script);
friend class CMapHandler;
friend class CVCMIServer;
friend class CGameHandler;
};
#endif //CGAMESTATE_H

133
CLua.cpp
View File

@ -2,12 +2,12 @@
#include "CLua.h"
#include "CLuaHandler.h"
#include "hch/CHeroHandler.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lobject.h"
#include "lgc.h"
#include "lapi.h"
//#include "lua.h"
//#include "lualib.h"
//#include "lauxlib.h"
//#include "lobject.h"
//#include "lgc.h"
//#include "lapi.h"
#include "CGameInfo.h"
#include "CGameState.h"
#include <sstream>
@ -26,10 +26,11 @@
#pragma warning (disable : 4311)
bool getGlobalFunc(lua_State * L, std::string fname)
{
unsigned int hash = lua_calchash(fname.c_str(), fname.size());
lua_pushhstring(L, hash, fname.c_str(), fname.size());
lua_gettable(L, LUA_GLOBALSINDEX);
return lua_isfunction(L, -1);
//unsigned int hash = lua_calchash(fname.c_str(), fname.size());
//lua_pushhstring(L, hash, fname.c_str(), fname.size());
//lua_gettable(L, LUA_GLOBALSINDEX);
//return lua_isfunction(L, -1);
return false;
}
CObjectScript::CObjectScript()
@ -65,20 +66,20 @@ CLua::CLua()
}
void CLua::open(std::string initpath)
{
LST = lua_open();
opened = true;
LUA_OPEN_LIB(LST, luaopen_base);
LUA_OPEN_LIB(LST, luaopen_io);
if ((luaL_loadfile (LST, initpath.c_str())) == 0)
{
lua_pcall (LST, 0, LUA_MULTRET, 0);
}
else
{
std::string temp = "Cannot open script ";
temp += initpath;
throw std::exception(temp.c_str());
}
//LST = lua_open();
//opened = true;
//LUA_OPEN_LIB(LST, luaopen_base);
//LUA_OPEN_LIB(LST, luaopen_io);
//if ((luaL_loadfile (LST, initpath.c_str())) == 0)
//{
// lua_pcall (LST, 0, LUA_MULTRET, 0);
//}
//else
//{
// std::string temp = "Cannot open script ";
// temp += initpath;
// throw std::exception(temp.c_str());
//}
}
void CLua::registerCLuaCallback()
{
@ -86,31 +87,31 @@ void CLua::registerCLuaCallback()
CLua::~CLua()
{
//std::cout << "Usuwam obiekt clua "<<this<<std::endl;
if (opened)
{
std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
lua_close(LST);
}
////std::cout << "Usuwam obiekt clua "<<this<<std::endl;
//if (opened)
//{
// std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
// lua_close(LST);
//}
}
void CLua::findF(std::string fname)
{
lua_getfield(is, LUA_GLOBALSINDEX, fname.c_str()); /* function to be called */
// lua_getfield(is, LUA_GLOBALSINDEX, fname.c_str()); /* function to be called */
}
void CLua::findF2(std::string fname)
{
lua_pushstring (is, fname.c_str());
lua_gettable (is, LUA_GLOBALSINDEX);
//lua_pushstring (is, fname.c_str());
//lua_gettable (is, LUA_GLOBALSINDEX);
}
void CLua::findFS(std::string fname)
{
lua_settop(is, 0);
if (!getGlobalFunc(is,fname))
{
lua_settop(is, 0);
throw new std::exception((fname + ": function not defined").c_str()); // the call is not defined
}
//lua_settop(is, 0);
//if (!getGlobalFunc(is,fname))
//{
// lua_settop(is, 0);
// throw new std::exception((fname + ": function not defined").c_str()); // the call is not defined
//}
}
#undef LST
@ -139,40 +140,40 @@ std::string CLuaObjectScript::genFN(std::string base, int ID)
void CLuaObjectScript::newObject(CGObjectInstance *os)
{
findF(genFN("newObject",os->ID));
lua_pushinteger(is, (int)os);
if (lua_pcall (is, 1, 0, 0))
{
lua_settop(is, 0);
throw new std::exception(("Failed to call "+genFN("newObject",os->ID)+" function in lua script.").c_str());
}
lua_settop(is, 0);
//findF(genFN("newObject",os->ID));
//lua_pushinteger(is, (int)os);
//if (lua_pcall (is, 1, 0, 0))
//{
// lua_settop(is, 0);
// throw new std::exception(("Failed to call "+genFN("newObject",os->ID)+" function in lua script.").c_str());
//}
//lua_settop(is, 0);
return;
}
void CLuaObjectScript::onHeroVisit(CGObjectInstance *os, int heroID)
{
findF(genFN("heroVisit",os->ID));
lua_pushinteger(is, (int)os);
lua_pushinteger(is, heroID);
if (lua_pcall (is, 2, 0, 0))
{
lua_settop(is, 0);
throw new std::exception(("Failed to call "+genFN("heroVisit",os->ID)+" function in lua script.").c_str());
}
lua_settop(is, 0);
//findF(genFN("heroVisit",os->ID));
//lua_pushinteger(is, (int)os);
//lua_pushinteger(is, heroID);
//if (lua_pcall (is, 2, 0, 0))
//{
// lua_settop(is, 0);
// throw new std::exception(("Failed to call "+genFN("heroVisit",os->ID)+" function in lua script.").c_str());
//}
//lua_settop(is, 0);
}
std::string CLuaObjectScript::hoverText(CGObjectInstance *os)
{
findF(genFN("hoverText",os->ID));
lua_pushinteger(is, (int)os);
if (lua_pcall (is, 1, 1, 0))
{
lua_settop(is, 0);
throw new std::exception(("Failed to call "+genFN("hoverText",os->ID)+" function in lua script.").c_str());
}
std::string ret = lua_tostring(is,1);
lua_settop(is, 0);
return ret;
//findF(genFN("hoverText",os->ID));
//lua_pushinteger(is, (int)os);
//if (lua_pcall (is, 1, 1, 0))
//{
// lua_settop(is, 0);
// throw new std::exception(("Failed to call "+genFN("hoverText",os->ID)+" function in lua script.").c_str());
//}
//std::string ret = lua_tostring(is,1);
//lua_settop(is, 0);
return "";
}
std::string CCPPObjectScript::hoverText(CGObjectInstance *os)

3
CLua.h
View File

@ -1,6 +1,6 @@
#pragma once
#include "global.h"
#include "lstate.h"
//#include "lstate.h"
#include <set>
#include <map>
class CLua;
@ -13,6 +13,7 @@ class SComponent;
class CSelectableComponent;
class CGameState;
struct Mapa;
struct lua_State;
enum ESLan{UNDEF=-1,CPP,ERM,LUA};
class CObjectScript
{

View File

@ -23,45 +23,21 @@ CLuaHandler::~CLuaHandler()
}
void CLuaHandler::test()
{
int iErr = 0;
lua_State *lua = lua_open (); // Open Lua
LUA_OPEN_LIB(lua, luaopen_base);
LUA_OPEN_LIB(lua, luaopen_io);
//luabind::open(lua);
//luabind::module(lua)
//[
// luabind::class_<int3>("int3")
// //.def(luabind::constructor<>())
// //.def(luabind::constructor<const int&,const int&,const int&>())
// .def_readwrite("x", &int3::x)
// .def_readwrite("y", &int3::y)
// .def_readwrite("z", &int3::z)
//];
//luabind::module(lua)
//[
// luabind::def("powitanie",&piszpowitanie2)
//];
if ((iErr = luaL_loadfile (lua, "scripts/lua/objects/0023_marletto_tower.lua")) == 0)
{
// Call main...
if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
{
//int ret = luabind::call_function<int>(lua, "helloWorld2");
//lua_pushstring (lua, "helloWorld2");
//lua_gettable (lua, LUA_GLOBALSINDEX);
//lua_pcall (lua, 0, 0, 0);
// Push the function name onto the stack
lua_pushstring (lua, "rightText");
lua_gettable (lua, LUA_GLOBALSINDEX);
lua_pcall (lua, 0, 0, 0);
}
}
lua_close (lua);
//int iErr = 0;
//lua_State *lua = lua_open (); // Open Lua
//LUA_OPEN_LIB(lua, luaopen_base);
//LUA_OPEN_LIB(lua, luaopen_io);
//if ((iErr = luaL_loadfile (lua, "scripts/lua/objects/0023_marletto_tower.lua")) == 0)
//{
// // Call main...
// if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
// {
// lua_pushstring (lua, "rightText");
// lua_gettable (lua, LUA_GLOBALSINDEX);
// lua_pcall (lua, 0, 0, 0);
// }
//}
//lua_close (lua);
}

150
CMT.cpp
View File

@ -1,35 +1,19 @@
// CMT.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "SDL_TTF.h"
#include "hch/CVideoHandler.h"
#include "SDL_mixer.h"
#include "hch/CBuildingHandler.h"
#include "SDL_Extensions.h"
#include "SDL_framerate.h"
#include <cmath>
#include <string>
#include <vector>
#include "zlib.h"
#include <cmath>
#include "hch/CArtHandler.h"
#include "hch/CHeroHandler.h"
#include "hch/CCreatureHandler.h"
#include "hch/CAbilityHandler.h"
#include "hch/CSpellHandler.h"
#include "hch/CBuildingHandler.h"
#include "hch/CObjectHandler.h"
#include <boost/thread.hpp>
#include "SDL_TTF.h"
#include "SDL_mixer.h"
#include "SDL_Extensions.h"
#include "SDL_framerate.h"
#include "CGameInfo.h"
#include "hch/CMusicHandler.h"
#include "hch/CLodHandler.h"
#include "hch/CDefHandler.h"
#include "hch/CTownHandler.h"
#include "hch/CDefObjInfoHandler.h"
#include "hch/CAmbarCendamo.h"
#include "mapHandler.h"
#include "global.h"
#include "CPreGame.h"
#include "hch/CGeneralTextHandler.h"
#include "CConsoleHandler.h"
#include "CCursorHandler.h"
#include "CScreenHandler.h"
@ -40,10 +24,22 @@
#include "CLuaHandler.h"
#include "CLua.h"
#include "CAdvmapInterface.h"
#include "hch/CBuildingHandler.h"
#include "hch/CVideoHandler.h"
#include "hch/CAbilityHandler.h"
#include "hch/CHeroHandler.h"
#include "hch/CCreatureHandler.h"
#include "hch/CSpellHandler.h"
#include "hch/CBuildingHandler.h"
#include "hch/CMusicHandler.h"
#include "hch/CLodHandler.h"
#include "hch/CDefHandler.h"
#include "hch/CAmbarCendamo.h"
#include "hch/CGeneralTextHandler.h"
#include "client/Graphics.h"
#include <boost/thread.hpp>
#include "Client/Client.h"
#include "lib/Connection.h"
#include <boost/crc.hpp>
#include "lib/VCMI_Lib.h"
std::string NAME = NAME_VER + std::string(" (client)");
DLL_EXPORT void initDLL(CLodHandler *b);
SDL_Surface * screen, * screen2;
@ -108,6 +104,13 @@ int _tmain(int argc, _TCHAR* argv[])
cgi->bitmaph->init("Data\\H3bitmap.lod","Data");
THC std::cout<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
initDLL(cgi->bitmaph);
CGI->arth = VLC->arth;
CGI->townh = VLC->townh;
CGI->heroh = VLC->heroh;
CGI->objh = VLC->objh;
CGI->dobjinfo = VLC->dobjinfo;
THC std::cout<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
//cgi->curh->initCursor();
@ -116,18 +119,12 @@ int _tmain(int argc, _TCHAR* argv[])
cgi->screenh = new CScreenHandler;
cgi->screenh->initScreen();
THC std::cout<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
cgi->townh = new CTownHandler;
cgi->townh->loadNames();
THC std::cout<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
CAbilityHandler * abilh = new CAbilityHandler;
abilh->loadAbilities();
cgi->abilh = abilh;
THC std::cout<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
CHeroHandler * heroh = new CHeroHandler;
heroh->loadHeroes();
heroh->loadPortraits();
cgi->heroh = heroh;
THC std::cout<<"\tHero handler: "<<pomtime.getDif()<<std::endl;
THC std::cout<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
pomtime.getDif();
graphics = new Graphics();
@ -148,24 +145,12 @@ int _tmain(int argc, _TCHAR* argv[])
cpg->mush = mush;
StartInfo *options = new StartInfo(cpg->runLoop());
///////////////////////////////////////////////////////////////////////////////////////
cgi->dobjinfo = new CDefObjInfoHandler;
cgi->dobjinfo->load();
THC std::cout<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
cgi->state = new CGameState();
cgi->state->scenarioOps = options;
THC std::cout<<"\tGamestate: "<<pomtime.getDif()<<std::endl;
THC tmh.getDif();pomtime.getDif();//reset timers
CArtHandler * arth = new CArtHandler;
arth->loadArtifacts();
cgi->arth = arth;
THC std::cout<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
CCreatureHandler * creh = new CCreatureHandler();
creh->loadCreatures();
cgi->creh = creh;
THC std::cout<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
CSpellHandler * spellh = new CSpellHandler;
spellh->loadSpells();
@ -177,78 +162,21 @@ int _tmain(int argc, _TCHAR* argv[])
cgi->buildh = buildh;
THC std::cout<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
CObjectHandler * objh = new CObjectHandler;
objh->loadObjects();
cgi->objh = objh;
THC std::cout<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
cgi->pathf = new CPathfinder();
THC std::cout<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
cgi->consoleh->cb = new CCallback(cgi->state,-1);
cgi->consoleh->runConsole();
THC std::cout<<"\tCallback and console: "<<pomtime.getDif()<<std::endl;
THC std::cout<<"Handlers initialization (together): "<<tmh.getDif()<<std::endl;
//////////////////////////////////loading map and connecting
CConnection c("localhost","3030",NAME,std::cout);
std::ofstream lll("client_log.txt");
CConnection c("localhost","3030",NAME,lll);
THC std::cout<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
std::string mapname = cpg->ourScenSel->mapsel.ourMaps[cpg->ourScenSel->mapsel.selected].filename;
std::cout<<"Opening map file: "<<mapname<<"\t\t"<<std::flush;
gzFile map = gzopen(mapname.c_str(),"rb");
std::vector<unsigned char> mapstr; int pom;
while((pom=gzgetc(map))>=0)
{
mapstr.push_back(pom);
}
gzclose(map);
unsigned char *initTable = new unsigned char[mapstr.size()];
for(int ss=0; ss<mapstr.size(); ++ss)
{
initTable[ss] = mapstr[ss];
}
std::cout<<"done."<<std::endl;
////////////////////////////////////////////////////
ui8 pom8;
c << uint8_t(2) << uint8_t(1) << mapname;
c >> pom8;
if(pom8) throw "Server cannot open the map!";
c < *options;
c << ui8(options->playerInfos.size());
for(int i=0;i<options->playerInfos.size();i++)
c << ui8(options->playerInfos[i].color);
boost::crc_32_type result;
result.process_bytes(initTable,mapstr.size());
std::cout << "\tMap checksum: "<<result.checksum();
std::cout << "\t" << sizeof(result.checksum());
THC std::cout<<"\tSending info to the server: "<<tmh.getDif()<<std::endl;
Mapa * mapa = new Mapa(initTable);
CClient cl(&c,options);
THC std::cout<<"Reading and detecting map file (together): "<<tmh.getDif()<<std::endl;
cgi->state->init(options,mapa,8);
CMapHandler * mh = cgi->mh = new CMapHandler();
THC std::cout<<"Initializing GameState (together): "<<tmh.getDif()<<std::endl;
mh->map = mapa;
THC std::cout<<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
mh->loadDefs();
THC std::cout<<"Reading terrain defs: "<<tmh.getDif()<<std::endl;
mh->init();
THC std::cout<<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
for (int i=0; i<cgi->state->scenarioOps->playerInfos.size();i++) //initializing interfaces
{
if(!cgi->state->scenarioOps->playerInfos[i].human)
cgi->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->state->scenarioOps->playerInfos[i].color),"EmptyAI.dll")));
else
{
cgi->state->currentPlayer=cgi->state->scenarioOps->playerInfos[i].color;
cgi->playerint.push_back(new CPlayerInterface(cgi->state->scenarioOps->playerInfos[i].color,i));
((CPlayerInterface*)(cgi->playerint[i]))->init(new CCallback(cgi->state,cgi->state->scenarioOps->playerInfos[i].color));
}
}
///claculating FoWs for minimap
/****************************Minimaps' FoW******************************************/
//for(int g=0; g<cgi->playerint.size(); ++g)
@ -281,19 +209,7 @@ int _tmain(int argc, _TCHAR* argv[])
// }
//}
while(1) //main game loop, one execution per turn
{
cgi->consoleh->cb->newTurn();
for (int i=0;i<cgi->playerint.size();i++)
{
cgi->state->currentPlayer=cgi->playerint[i]->playerID;
try
{
cgi->playerint[i]->yourTurn();
}HANDLE_EXCEPTION
}
}
cl.run();
}
else
{

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,7 +9,7 @@
#include <boost/algorithm/string.hpp>
#include "hch/CDefHandler.h"
#include <map>
#include "client\Graphics.h"
#include "client/Graphics.h"
SDL_Surface * CSDL_Ext::newSurface(int w, int h, SDL_Surface * mod) //creates new surface, with flags/format same as in surface given
{

View File

@ -21,16 +21,16 @@ struct StartInfo
bool human;
template <typename Handler> void serialize(Handler &h, const int version)
{
h && castle;
h && hero;
h && heroPortrait;
h && heroName;
h && bonus;
h && color;
h && serial;
h && handicap;
h && name;
h && human;
h & castle;
h & hero;
h & heroPortrait;
h & heroName;
h & bonus;
h & color;
h & serial;
h & handicap;
h & name;
h & human;
}
};
si32 difficulty; //0=easy; 4=impossible
@ -44,13 +44,13 @@ struct StartInfo
return playerInfos[i];
throw new std::exception("Cannot find info about player");
}
template <typename Handler> void serialize(Handler &h, const int version)
template <typename Handler> void serialize(Handler &h, const int version)
{
h && difficulty;
h & difficulty;
h & playerInfos;
h && turnTime;
h && mapname;
h & turnTime;
h & mapname;
}
};
#endif
#endif

110
client/Client.cpp Normal file
View File

@ -0,0 +1,110 @@
#include "Client.h"
#include "../lib/Connection.h"
#include "../StartInfo.h"
#include "../map.h"
#include "../CGameState.h"
#include "../CGameInfo.h"
#include "../mapHandler.h"
#include "../CCallback.h"
#include "../CPlayerInterface.h"
#include "../CConsoleHandler.h"
CClient::CClient(void)
{
}
CClient::CClient(CConnection *con, StartInfo *si)
:serv(con)
{
timeHandler tmh, pomtime;
CConnection &c(*con);
////////////////////////////////////////////////////
ui8 pom8;
c << ui8(2) << ui8(1);
c << *si;
c >> pom8;
if(pom8) throw "Server cannot open the map!";
c << ui8(si->playerInfos.size());
for(int i=0;i<si->playerInfos.size();i++)
c << ui8(si->playerInfos[i].color);
ui32 seed, sum;
std::string mapname;
c >> mapname >> sum >> seed;
THC std::cout<<"\tSending/Getting info to/from the server: "<<tmh.getDif()<<std::endl;
Mapa * mapa = new Mapa(mapname);
THC std::cout<<"Reading and detecting map file (together): "<<tmh.getDif()<<std::endl;
std::cout << "\tServer checksum for "<<mapname <<": "<<sum << std::endl;
std::cout << "\tOur checksum for the map: "<< mapa->checksum << std::endl;
if(mapa->checksum != sum)
exit(-1);
std::cout << "\tUsing random seed: "<<seed << std::endl;
gs = CGI->state;
gs->scenarioOps = si;
gs->init(si,mapa,seed);
CGI->mh = new CMapHandler();
THC std::cout<<"Initializing GameState (together): "<<tmh.getDif()<<std::endl;
CGI->mh->map = mapa;
THC std::cout<<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
CGI->mh->init();
THC std::cout<<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
for (int i=0; i<CGI->state->scenarioOps->playerInfos.size();i++) //initializing interfaces
{
if(!CGI->state->scenarioOps->playerInfos[i].human)
CGI->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(CGI->state,CGI->state->scenarioOps->playerInfos[i].color),"EmptyAI.dll")));
else
{
CGI->state->currentPlayer=CGI->state->scenarioOps->playerInfos[i].color;
CGI->playerint.push_back(new CPlayerInterface(CGI->state->scenarioOps->playerInfos[i].color,i));
((CPlayerInterface*)(CGI->playerint[i]))->init(new CCallback(CGI->state,CGI->state->scenarioOps->playerInfos[i].color));
}
}
CGI->consoleh->cb = new CCallback(CGI->state,-1);
}
CClient::~CClient(void)
{
}
void CClient::process(int what)
{
switch (what)
{
case 100: //one of our interaces has turn
ui8 player;
*serv >> player;//who?
CGI->playerint[gs->players[player].serial]->yourTurn();
*serv << ui16(100); //report that we ended turn
break;
default:
throw std::exception("Not supported server message!");
break;
}
}
void CClient::run()
{
try
{
ui16 typ;
while(1)
{
*serv >> typ;
process(typ);
}
} HANDLE_EXCEPTION
//while(1) //main game loop, one execution per turn
//{
// CGI->consoleh->cb->newTurn();
// for (int i=0;i<CGI->playerint.size();i++)
// {
// CGI->state->currentPlayer=CGI->playerint[i]->playerID;
// try
// {
// CGI->playerint[i]->yourTurn();
// }HANDLE_EXCEPTION
// }
//}
}

19
client/Client.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#include "../global.h"
struct StartInfo;
class CGameState;
class CGameInterface;
class CConnection;
class CClient
{
CGameState *gs;
std::map<int,CGameInterface *> playerint;
CConnection *serv;
public:
CClient(void);
CClient(CConnection *con, StartInfo *si);
~CClient(void);
void process(int what);
void run();
};

View File

@ -124,8 +124,9 @@
BasicRuntimeChecks="0"
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
EnableEnhancedInstructionSet="0"
WarningLevel="3"
DebugInformationFormat="3"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -140,7 +141,8 @@
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib zdll.lib SDL_image.lib SDL_ttf.lib SDL_mixer.lib lua5.1.lib VCMI_lib.lib"
AdditionalLibraryDirectories="G:\vcmt\repa\libs"
GenerateDebugInformation="true"
GenerateDebugInformation="false"
Driver="0"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="0"
@ -313,6 +315,10 @@
RelativePath="..\CHeroWindow.cpp"
>
</File>
<File
RelativePath=".\Client.cpp"
>
</File>
<File
RelativePath="..\CLua.cpp"
>
@ -381,138 +387,6 @@
RelativePath="..\SDL_framerate.cpp"
>
</File>
<Filter
Name="lua"
>
<File
RelativePath="..\..\..\trunk\lua\src\lapi.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lauxlib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lbaselib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lcode.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ldblib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ldebug.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ldo.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ldump.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lfunc.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lgc.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\linit.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\liolib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\llex.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lmathlib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lmem.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\loadlib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lobject.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lopcodes.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\loslib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lparser.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lstate.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lstring.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lstrlib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ltable.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ltablib.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\ltm.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lua.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\luac.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lundump.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lvm.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\lzio.cpp"
>
</File>
<File
RelativePath="..\..\..\trunk\lua\src\print.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
@ -603,6 +477,10 @@
RelativePath="..\CHeroWindow.h"
>
</File>
<File
RelativePath=".\Client.h"
>
</File>
<File
RelativePath="..\CLuaHandler.h"
>
@ -692,12 +570,6 @@
>
</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>
</Files>
<Globals>
</Globals>

2
int3.h
View File

@ -76,7 +76,7 @@ inline std::istream & operator>>(std::istream & str, int3 & dest)
str>>dest.x>>dest.y>>dest.z;
return str;
}
inline std::ostream & operator<<(std::ostream & str, int3 & sth)
inline std::ostream & operator<<(std::ostream & str, const int3 & sth)
{
return str<<sth.x<<' '<<sth.y<<' '<<sth.z;
}

View File

@ -18,6 +18,38 @@ using namespace boost::asio::ip;
#define LIL_ENDIAN
#endif
//CConnection & operator<<(CConnection &c, const std::string &data)
//{
// boost::uint32_t length = data.size();
// c << length;
// c.write(data.c_str(),length);
// return c;
//}
//CConnection & operator>>(CConnection &c, std::string &data)
//{
// boost::uint32_t length;
// c >> length;
// data.resize(length);
// c.read((void*)data.c_str(),length);
// return c;
//}
//CConnection & operator<<(CConnection &c, const char * &data)
//{
// boost::uint32_t length = strlen(data);
// c << length;
// c.write(data,length);
// return c;
//}
//CConnection & operator>>(CConnection &c, char * &data)
//{
// boost::uint32_t length;
// c >> length;
// std::cout <<"Alokujemy " <<length << " bajtow."<<std::endl;
// data = new char[length];
// c.read(data,length);
// return c;
//}
void CConnection::init()
{
#ifdef LIL_ENDIAN
@ -34,7 +66,7 @@ void CConnection::init()
}
CConnection::CConnection(std::string host, std::string port, std::string Name, std::ostream & Out)
:io_service(new asio::io_service), name(Name), out(Out), send(this), rec(this)
:io_service(new asio::io_service), name(Name), out(Out)//, send(this), rec(this)
{
system::error_code error = asio::error::host_not_found;
socket = new tcp::socket(*io_service);
@ -48,12 +80,12 @@ CConnection::CConnection(
boost::asio::basic_stream_socket<boost::asio::ip::tcp , boost::asio::stream_socket_service<boost::asio::ip::tcp> > * Socket,
std::string Name,
std::ostream & Out )
:socket(Socket),io_service(Socket->io_service()), out(Out), name(Name), send(this), rec(this)
:socket(Socket),io_service(&Socket->io_service()), out(Out), name(Name)//, send(this), rec(this)
{
init();
}
CConnection::CConnection(boost::asio::basic_socket_acceptor<boost::asio::ip::tcp, boost::asio::socket_acceptor_service<boost::asio::ip::tcp> > * acceptor, boost::asio::io_service *Io_service, std::string Name, std::ostream & Out)
: out(Out), name(Name), send(this), rec(this)
: out(Out), name(Name)//, send(this), rec(this)
{
system::error_code error = asio::error::host_not_found;
socket = new tcp::socket(*io_service);
@ -70,13 +102,14 @@ int CConnection::write(const void * data, unsigned size)
}
int CConnection::read(void * data, unsigned size)
{
LOG("odbieram dane o rozmiarze " << size << std::endl);
int ret = asio::read(*socket,asio::mutable_buffers_1(asio::mutable_buffer(data,size)));
return ret;
}
CConnection::~CConnection(void)
{
delete io_service;
if(socket)
socket->close();
delete socket;
delete io_service;
}

View File

@ -3,9 +3,32 @@
#include <string>
#include <vector>
#include <set>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_all_extents.hpp>
#include <boost/serialization/is_abstract.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/greater_equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/not.hpp>
const int version = 63;
class CConnection;
namespace mpl = boost::mpl;
namespace boost
{
namespace asio
@ -24,48 +47,248 @@ namespace boost
template <typename Protocol,typename SocketAcceptorService>
class basic_socket_acceptor;
}
class mutex;
};
class CSender
enum SerializationLvl
{
Wrong=0,
Primitive,
Serializable
};
template<typename T>
struct SerializationLevel
{
typedef mpl::integral_c_tag tag;
typedef
typename mpl::eval_if<
boost::is_fundamental<T>,
mpl::int_<Primitive>,
//else
typename mpl::eval_if<
boost::is_class<T>,
mpl::int_<Serializable>,
//else
typename mpl::eval_if<
boost::is_array<T>,
mpl::int_<Wrong>,
//else
typename mpl::eval_if<
boost::is_enum<T>,
mpl::int_<Primitive>,
//else
mpl::int_<Wrong>
>
>
>
>::type type;
static const int value = SerializationLevel::type::value;
};
template <typename Serializer> class DLL_EXPORT COSer
{
public:
CConnection* c;
CSender(CConnection* C):c(C){};
template <typename T> CSender & operator&&(T &data) //send built-in type
COSer(){};
Serializer * This()
{
*c << data;
return *this;
return static_cast<Serializer*>(this);
}
template <typename T> CSender & operator&(T &data) //send serializable type
template<class T>
Serializer & operator<<(const T &t)
{
*c < data;
return *this;
this->This()->save(t);
return * this->This();
}
template<class T>
Serializer & operator&(T & t){
return * this->This() << t;
}
};
class CReceiver
template <typename Serializer> class DLL_EXPORT CISer
{
public:
CConnection *c;
CReceiver(CConnection* C):c(C){};
template <typename T> CReceiver & operator&&(T &data) //get built-in type
CISer(){};
Serializer * This()
{
*c >> data;
return *this;
return static_cast<Serializer*>(this);
}
template <typename T> CReceiver & operator&(T &data) //get serializable type
template<class T>
Serializer & operator>>(T &t)
{
*c > data;
return *this;
this->This()->load(t);
return * this->This();
}
template<class T>
Serializer & operator&(T & t){
return * this->This() >> t;
}
};
template<typename Ser,typename T>
struct SavePrimitive
{
static void invoke(Ser &s, const T &data)
{
s.savePrimitive(data);
}
};
template<typename Ser,typename T>
struct SaveSerializable
{
static void invoke(Ser &s, const T &data)
{
s.saveSerializable(data);
}
};
template<typename Ser,typename T>
struct LoadPrimitive
{
static void invoke(Ser &s, T &data)
{
s.loadPrimitive(data);
}
};
template<typename Ser,typename T>
struct LoadSerializable
{
static void invoke(Ser &s, T &data)
{
s.loadSerializable(data);
}
};
template<typename Ser,typename T>
struct SaveWrong
{
static void invoke(Ser &s, const T &data)
{
throw std::exception("Wrong save serialization call!");
}
};
template<typename Ser,typename T>
struct LoadWrong
{
static void invoke(Ser &s, const T &data)
{
throw std::exception("Wrong load serialization call!");
}
};
class DLL_EXPORT CConnection
:public CISer<CConnection>, public COSer<CConnection>
{
std::ostream &out;
CConnection(void);
void init();
boost::mutex *mx;
public:
CSender send;
CReceiver rec;
template <typename T>
void savePrimitive(const T &data)
{
write(&data,sizeof(data));
}
template <typename T>
void loadPrimitive(T &data)
{
read(&data,sizeof(data));
}
template <typename T>
void saveSerializable(const T &data)
{
const_cast<T&>(data).serialize(*static_cast<COSer*>(this),version);
}
template <typename T>
void loadSerializable(T &data)
{
data.serialize(*static_cast<CISer*>(this),version);
}
template <>
void saveSerializable<std::string>(const std::string &data)
{
*this << ui32(data.size());
write(data.c_str(),data.size());
}
template <>
void loadSerializable<std::string>(std::string &data)
{
ui32 l;
*this >> l;
data.resize(l);
read((void*)data.c_str(),l);
}
template <typename T>
void saveSerializable(const std::vector<T> &data)
{
boost::uint32_t length = data.size();
*this << length;
for(ui32 i=0;i<length;i++)
*this << data[i];
}
template <typename T>
void loadSerializable(std::vector<T> &data)
{
boost::uint32_t length;
*this >> length;
data.resize(length);
for(ui32 i=0;i<length;i++)
*this >> data[i];
}
//template <typename T>
//void saveSerializable(T &data)
//{
// data.serialize(*static_cast<COSer*>(this),version);
//}
//template <typename T>
//void loadSerializable(T &data)
//{
// data.serialize(*static_cast<CISer*>(this),version);
//}
template <typename T>
void save(const T &data)
{
typedef
//if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
mpl::identity<SavePrimitive<CConnection,T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
mpl::identity<SaveSerializable<CConnection,T> >,
//else
mpl::identity<SaveWrong<CConnection,T> >
>
>::type typex;
typex::invoke(*this, data);
}
template <typename T>
void load(T &data)
{
typedef
//if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
mpl::identity<LoadPrimitive<CConnection,T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
mpl::identity<LoadSerializable<CConnection,T> >,
//else
mpl::identity<LoadWrong<CConnection,T> >
>
>::type typex;
typex::invoke(*this, data);
}
//CSender send;
//CReceiver rec;
boost::asio::basic_stream_socket < boost::asio::ip::tcp , boost::asio::stream_socket_service<boost::asio::ip::tcp> > * socket;
bool logging;
bool connected;
@ -88,56 +311,28 @@ public:
};
template <typename T> CConnection & operator<<(CConnection &c, const T &data);
template <typename T> CConnection & operator>>(CConnection &c, T &data);
CConnection & operator<<(CConnection &c, const std::string &data)
{
boost::uint32_t length = data.size();
c << length;
c.write(data.c_str(),length);
return c;
}
CConnection & operator>>(CConnection &c, std::string &data)
{
boost::uint32_t length;
c >> length;
data.resize(length);
c.read((void*)data.c_str(),length);
return c;
}
CConnection & operator<<(CConnection &c, const char * &data)
{
boost::uint32_t length = strlen(data);
c << length;
c.write(data,length);
return c;
}
CConnection & operator>>(CConnection &c, char * &data)
{
boost::uint32_t length;
c >> length;
std::cout <<"Alokujemy " <<length << " bajtow."<<std::endl;
data = new char[length];
c.read(data,length);
return c;
}
template <typename T> CConnection & operator<<(CConnection &c, std::vector<T> &data)
{
boost::uint32_t length = data.size();
c << length;
for(ui32 i=0;i<length;i++)
c << data[i];
return c;
}
template <typename T> CConnection & operator>>(CConnection &c, std::vector<T> &data)
{
boost::uint32_t length;
c >> length;
data.resize(length);
for(ui32 i=0;i<length;i++)
c >> data[i];
return c;
}
//DLL_EXPORT CConnection & operator<<(CConnection &c, const std::string &data);
//DLL_EXPORT CConnection & operator>>(CConnection &c, std::string &data);
//DLL_EXPORT CConnection & operator<<(CConnection &c, const char * &data);
//DLL_EXPORT CConnection & operator>>(CConnection &c, char * &data);
//
//template <typename T> CConnection & operator<<(CConnection &c, std::vector<T> &data)
//{
// boost::uint32_t length = data.size();
// c << length;
// for(ui32 i=0;i<length;i++)
// c << data[i];
// return c;
//}
//template <typename T> CConnection & operator>>(CConnection &c, std::vector<T> &data)
//{
// boost::uint32_t length;
// c >> length;
// data.resize(length);
// for(ui32 i=0;i<length;i++)
// c >> data[i];
// return c;
//}
//template <typename T> CConnection & operator<<(CConnection &c, std::set<T> &data)
//{
// boost::uint32_t length = data.size();
@ -159,40 +354,61 @@ template <typename T> CConnection & operator>>(CConnection &c, std::vector<T> &
// }
// return c;
//}
template <typename T> CConnection & operator<<(CConnection &c, const T &data)
{
c.write(&data,sizeof(data));
return c;
}
template <typename T> CConnection & operator>>(CConnection &c, T &data)
{
c.read(&data,sizeof(data));
return c;
}
template <typename T> CConnection & operator<(CConnection &c, std::vector<T> &data)
{
boost::uint32_t length = data.size();
c << length;
for(ui32 i=0;i<length;i++)
data[i].serialize(c.send,version);
return c;
}
template <typename T> CConnection & operator>(CConnection &c, std::vector<T> &data)
{
boost::uint32_t length;
c >> length;
data.resize(length);
for(ui32 i=0;i<length;i++)
data[i].serialize(c.rec,version);
return c;
}
template <typename T> CConnection & operator<(CConnection &c, T &data)
{
data.serialize(c.send,version);
return c;
}
template <typename T> CConnection & operator>(CConnection &c, T &data)
{
data.serialize(c.rec,version);
return c;
}
//template <typename T> CConnection & operator<<(CConnection &c, const T &data)
//{
// c.write(&data,sizeof(data));
// return c;
//}
//template <typename T> CConnection & operator>>(CConnection &c, T &data)
//{
// c.read(&data,sizeof(data));
// return c;
//}
//template <typename T> CConnection & operator<(CConnection &c, std::vector<T> &data)
//{
// boost::uint32_t length = data.size();
// c << length;
// for(ui32 i=0;i<length;i++)
// data[i].serialize(c.send,version);
// return c;
//}
//template <typename T> CConnection & operator>(CConnection &c, std::vector<T> &data)
//{
// boost::uint32_t length;
// c >> length;
// data.resize(length);
// for(ui32 i=0;i<length;i++)
// data[i].serialize(c.rec,version);
// return c;
//}
//template <typename T> CConnection & operator<(CConnection &c, std::set<T> &data)
//{
// boost::uint32_t length = data.size();
// c << length;
// for(std::set<T>::iterator i=data.begin();i!=data.end();i++)
// i->serialize(c.send,version);
// return c;
//}
//template <typename T> CConnection & operator>(CConnection &c, std::set<T> &data)
//{
// boost::uint32_t length;
// c >> length;
// data.resize(length);
// T pom;
// for(int i=0;i<length;i++)
// {
// pom.serialize(c.rec,version);
// data.insert(pom);
// }
// return c;
//}
//template <typename T> CConnection & operator<(CConnection &c, T &data)
//{
// data.serialize(c.send,version);
// return c;
//}
//template <typename T> CConnection & operator>(CConnection &c, T &data)
//{
// data.serialize(c.rec,version);
// return c;
//}

View File

@ -1,14 +1,50 @@
#define VCMI_DLL
#include "../global.h"
#include "VCMI_Lib.h"
#include "../hch/CArtHandler.h"
#include "../hch/CCreatureHandler.h"
#include "../hch/CDefObjInfoHandler.h"
#include "../hch/CHeroHandler.h"
#include "../hch/CObjectHandler.h"
#include "../hch/CTownHandler.h"
class CLodHandler;
LibClasses * VLC = NULL;
CLodHandler * bitmaph=NULL;
DLL_EXPORT void initDLL(CLodHandler *b)
{
timeHandler pomtime;
bitmaph=b;
VLC = new LibClasses;
CHeroHandler * heroh = new CHeroHandler;
heroh->loadHeroes();
heroh->loadPortraits();
VLC->heroh = heroh;
THC std::cout<<"\tHero handler: "<<pomtime.getDif()<<std::endl;
CArtHandler * arth = new CArtHandler;
arth->loadArtifacts();
VLC->arth = arth;
THC std::cout<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
CCreatureHandler * creh = new CCreatureHandler();
creh->loadCreatures();
VLC->creh = creh;
THC std::cout<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
VLC->townh = new CTownHandler;
VLC->townh->loadNames();
THC std::cout<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
CObjectHandler * objh = new CObjectHandler;
objh->loadObjects();
VLC->objh = objh;
THC std::cout<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
VLC->dobjinfo = new CDefObjInfoHandler;
VLC->dobjinfo->load();
THC std::cout<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
}
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)

View File

@ -1,6 +1,6 @@
#include "../global.h"
class CLodHandler;
//class CMapHandler;
class CArtHandler;
class CHeroHandler;
@ -55,4 +55,7 @@ public:
//StartInfo scenarioOps;
};
extern LibClasses * VLC;
extern DLL_EXPORT LibClasses * VLC;
DLL_EXPORT void initDLL(CLodHandler *b);

View File

@ -124,7 +124,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
WarningLevel="3"
DebugInformationFormat="3"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -140,7 +140,7 @@
AdditionalDependencies="zdll.lib"
Version=""
AdditionalLibraryDirectories="G:\vcmt\repa\libs"
GenerateDebugInformation="true"
GenerateDebugInformation="false"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="0"
@ -437,6 +437,10 @@
RelativePath="..\map.h"
>
</File>
<File
RelativePath=".\NetPacks.h"
>
</File>
<File
RelativePath=".\VCMI_Lib.h"
>

27
map.cpp
View File

@ -4,6 +4,8 @@
#include "hch/CObjectHandler.h"
#include "hch/CDefObjInfoHandler.h"
#include "lib/VCMI_Lib.h"
#include <zlib.h>
#include <boost/crc.hpp>
std::set<int> convertBuildings(const std::set<int> h3m, int castleID)
{
std::map<int,int> mapa;
@ -440,7 +442,7 @@ CMapHeader::CMapHeader(unsigned char *map)
}
}
}
Mapa::Mapa(unsigned char * bufor)
void Mapa::initFromBytes(unsigned char * bufor)
{
THC timeHandler th;
th.getDif();
@ -2288,6 +2290,29 @@ borderguardend:
//map readed, bufor no longer needed
delete[] bufor; bufor=NULL;
}
Mapa::Mapa(std::string filename)
{
std::cout<<"Opening map file: "<<filename<<"\t "<<std::flush;
gzFile map = gzopen(filename.c_str(),"rb");
std::vector<unsigned char> mapstr; int pom;
while((pom=gzgetc(map))>=0)
{
mapstr.push_back(pom);
}
gzclose(map);
unsigned char *initTable = new unsigned char[mapstr.size()];
for(int ss=0; ss<mapstr.size(); ++ss)
{
initTable[ss] = mapstr[ss];
}
std::cout<<"done."<<std::endl;
boost::crc_32_type result;
result.process_bytes(initTable,mapstr.size());
std::cout << "\tOur map checksum: "<<result.checksum() << std::endl;
initFromBytes(initTable);
}
CGHeroInstance * Mapa::getHero(int ID, int mode)
{
if (mode != 0)

4
map.h
View File

@ -448,6 +448,7 @@ public:
struct DLL_EXPORT Mapa
{
Eformat version; // version of map Eformat
ui32 checksum;
int twoLevel; // if map has underground level
int difficulty; // 0 easy - 4 impossible
int levelLimit;
@ -478,7 +479,8 @@ struct DLL_EXPORT Mapa
std::vector<CGHeroInstance*> heroes;
std::vector<CGTownInstance*> towns;
Mapa(unsigned char * bufor); //creates map from decompressed .h3m data
void initFromBytes(unsigned char * bufor); //creates map from decompressed .h3m data
Mapa(std::string filename); //creates map structure from .h3m file
CGHeroInstance * getHero(int ID, int mode=0);
};
#endif //MAPD_H

View File

@ -10,11 +10,12 @@
#include "CLua.h"
#include "hch/CHeroHandler.h"
#include "hch/CTownHandler.h"
#include "client\Graphics.h"
#include "client/Graphics.h"
#include <iomanip>
#include <sstream>
#include "hch/CObjectHandler.h"
#include "map.h"
#include "hch/CDefHandler.h"
extern SDL_Surface * screen;
std::string nameFromType (EterrainType typ)
{
@ -567,6 +568,8 @@ void CMapHandler::init()
{
timeHandler th;
th.getDif();
loadDefs();
THC std::cout<<"Reading terrain defs: "<<th.getDif()<<std::endl;
std::for_each(map->defy.begin(),map->defy.end(),processDef); //load h3m defs
std::for_each(map->defs.begin(),map->defs.end(),processDef); //and non-h3m defs
THC std::cout<<"\tUnpacking and handling defs: "<<th.getDif()<<std::endl;
@ -876,17 +879,6 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
//borders printed
return su;
}
SDL_Surface * CMapHandler::terrBitmap(int x, int y)
{
return ttiles[x+Woff][y+Hoff][0].terbitmap[0];
}
SDL_Surface * CMapHandler::undTerrBitmap(int x, int y)
{
return ttiles[x+Woff][y+Hoff][0].terbitmap[1];
}
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl)
{
int size = visibilityMap.size()-1; //is tile visible. arrangement: (like num keyboard)
@ -1325,12 +1317,6 @@ bool CMapHandler::hideObject(CGObjectInstance *obj)
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
return true;
}
std::string CMapHandler::getRandomizedDefName(CGDefInfo *di, CGObjectInstance * obj)
{
return std::string();
}
bool CMapHandler::removeObject(CGObjectInstance *obj)
{
hideObject(obj);

View File

@ -2,8 +2,6 @@
#define MAPHANDLER_H
#include "global.h"
#include <SDL.h>
#include "hch/CDefHandler.h"
#include <boost/logic/tribool.hpp>
#include <list>
#include <set>
const int Woff = 12; //width of map's frame
@ -13,7 +11,8 @@ class CGObjectInstance;
class CGHeroInstance;
struct Mapa;
class CGDefInfo;
class CGObjectInstance;
class CDefHandler;
struct TerrainTile2
{
int3 pos; //this tile's position
@ -81,8 +80,6 @@ public:
CDefHandler * fullHide;
CDefHandler * partialHide;
std::vector< std::vector< std::vector<unsigned char> > > visibility; //true means that pointed place is visible //not used now
//std::vector< std::vector<char> > undVisibility; //true means that pointed place is visible
std::vector<CDefHandler *> roadDefs;
std::vector<CDefHandler *> staticRiverDefs;
std::vector<CDefHandler*> defs;
@ -92,8 +89,6 @@ public:
std::vector<std::vector<std::vector<unsigned char> > > hideBitmap; //specifies number of graphic that should be used to fully hide a tile
void loadDefs();
char & visAccess(int x, int y);
char & undVisAccess(int x, int y);
SDL_Surface * getVisBitmap(int x, int y, std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl);
int getCost(int3 & a, int3 & b, const CGHeroInstance * hero);
@ -107,20 +102,13 @@ public:
bool recalculateHideVisPos(int3& pos); //recalculates position for hidden / visitable positions
bool recalculateHideVisPosUnderObj(CGObjectInstance * obj, bool withBorder = false); //recalculates position for hidden / visitable positions under given object
void init();
int pickHero(int owner);
std::pair<int,int> pickObject(CGObjectInstance *obj);
void randomizeObject(CGObjectInstance *cur);
void calculateBlockedPos();
void initObjectRects();
void borderAndTerrainBitmapInit();
void roadsRiverTerrainInit();
void prepareFOWDefs();
void randomizeObjects();
SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap = NULL, bool otherHeroAnim = false, unsigned char heroAnim = 0, SDL_Surface * extSurf = NULL, SDL_Rect * extRect = NULL); //if extSurf is specified, blit to it
SDL_Surface * terrBitmap(int x, int y);
SDL_Surface * undTerrBitmap(int x, int y);
std::string getRandomizedDefName(CGDefInfo* di, CGObjectInstance * obj = NULL); //objinstance needed only for heroes and towns
unsigned char getHeroFrameNum(const unsigned char & dir, const bool & isMoving) const; //terrainRect helper function
void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper
static unsigned char getDir(const int3 & a, const int3 & b); //returns direction number in range 0 - 7 (0 is left top, clockwise) [direction: form a to b]

View File

@ -1,9 +1,154 @@
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/bind.hpp>
#include "CGameHandler.h"
#include "../CGameState.h"
#include "../StartInfo.h"
#include "../map.h"
#include "../lib/NetPacks.h"
#include "../lib/Connection.h"
#include "../CLua.h"
#include "../hch/CObjectHandler.h"
#include "../hch/CTownHandler.h"
#include "../hch/CHeroHandler.h"
bool makingTurn;
boost::condition_variable cTurn;
boost::mutex mTurn;
boost::shared_mutex gsm;
void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
{
ui16 pom;
while(1)
{
c >> pom;
switch(pom)
{
case 100: //my interface end its turn
mTurn.lock();
makingTurn = false;
mTurn.unlock();
cTurn.notify_all();
break;
default:
throw std::exception("Not supported client message!");
break;
}
}
}
CGameHandler::CGameHandler(void)
{
gs = NULL;
}
CGameHandler::~CGameHandler(void)
{
delete gs;
}
void CGameHandler::init(StartInfo *si, int Seed)
{
Mapa *map = new Mapa(si->mapname);
gs = new CGameState();
gs->init(si,map,Seed);
}
int lowestSpeed(CGHeroInstance * chi)
{
std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin();
int ret = (*i++).second.first->speed;
for (;i!=chi->army.slots.end();i++)
{
ret = min(ret,(*i).second.first->speed);
}
return ret;
}
int valMovePoints(CGHeroInstance * chi)
{
int ret = 1270+70*lowestSpeed(chi);
if (ret>2000)
ret=2000;
//TODO: additional bonuses (but they aren't currently stored in chi)
return ret;
}
void CGameHandler::newTurn()
{
//std::map<int, PlayerState>::iterator i = gs->players.begin() ;
gs->day++;
for ( std::map<ui8, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
{
//handle heroes/////////////////////////////
for (unsigned j=0;j<(*i).second.heroes.size();j++)
{
(*i).second.heroes[j]->movement = valMovePoints((*i).second.heroes[j]);
}
//handle towns/////////////////////////////
for(unsigned j=0;j<i->second.towns.size();j++)
{
i->second.towns[j]->builded=0;
if(gs->getDate(1)==1) //first day of week
{
for(int k=0;k<CREATURES_PER_TOWN;k++) //creature growths
{
if(i->second.towns[j]->creatureDwelling(k))//there is dwelling (k-level)
i->second.towns[j]->strInfo.creatures[k]+=i->second.towns[j]->creatureGrowth(k);
}
}
if((gs->day>1) && i->first<PLAYER_LIMIT)
i->second.resources[6]+=i->second.towns[j]->dailyIncome();
}
}
for (std::set<CCPPObjectScript *>::iterator i=gs->cppscripts.begin();i!=gs->cppscripts.end();i++)
{
(*i)->newTurn();
}
}
void CGameHandler::run()
{
BOOST_FOREACH(CConnection *cc, conns)
{//init conn.
ui8 quantity, pom;
//ui32 seed;
(*cc) << gs->scenarioOps->mapname;// << gs->map->checksum << seed;
(*cc) >> quantity;
for(int i=0;i<quantity;i++)
{
(*cc) >> pom;
gsm.lock();
connections[pom] = cc;
gsm.unlock();
}
}
for(std::set<CConnection*>::iterator i = conns.begin(); i!=conns.end();i++)
{
std::set<int> pom;
for(std::map<int,CConnection*>::iterator j = connections.begin(); j!=connections.end();j++)
if(j->second == *i)
pom.insert(j->first);
boost::thread(boost::bind(&CGameHandler::handleConnection,this,pom,boost::ref(**i)));
}
while (1)
{
for(std::map<ui8,PlayerState>::iterator i = gs->players.begin(); i != gs->players.end(); i++)
{
if((i->second.towns.size()==0 && i->second.heroes.size()==0) || i->second.color<0) continue; //players has not towns/castle - loser
makingTurn = true;
*connections[i->first] << ui16(100) << i->first;
//wait till turn is done
boost::unique_lock<boost::mutex> lock(mTurn);
while(makingTurn)
{
cTurn.wait(lock);
}
}
}
}

View File

@ -1,8 +1,23 @@
#pragma once
#include "../global.h"
#include <set>
class CVCMIServer;
class CGameState;
class CConnection;
struct StartInfo;
class CGameHandler
{
CGameState *gs;
CVCMIServer *s;
std::map<int,CConnection*> connections;
std::set<CConnection*> conns;
public:
CGameHandler(void);
~CGameHandler(void);
void init(StartInfo *si, int Seed);
void handleConnection(std::set<int> players, CConnection &c);
void run();
void newTurn();
friend class CVCMIServer;
};

View File

@ -112,10 +112,15 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableFunctionLevelLinking="false"
WarningLevel="3"
DebugInformationFormat="3"
DebugInformationFormat="0"
DisableSpecificWarnings="4251"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -130,7 +135,7 @@
Name="VCLinkerTool"
AdditionalDependencies="VCMI_lib.lib zdll.lib"
AdditionalLibraryDirectories="G:\vcmt\repa\libs"
GenerateDebugInformation="true"
GenerateDebugInformation="false"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
@ -184,6 +189,10 @@
RelativePath=".\CGameHandler.h"
>
</File>
<File
RelativePath=".\CVCMIServer.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View File

@ -1,148 +1,143 @@
#include <iostream>
#include <string>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include "../global.h"
#include "../lib/Connection.h"
#include "../CGameState.h"
#include "zlib.h"
#include <boost/thread.hpp>
#include <tchar.h>
#include "CVCMIServer.h"
#include <boost/crc.hpp>
#include <boost/serialization/split_member.hpp>
#include "../StartInfo.h"
#include "../map.h"
#include "../hch/CLodHandler.h"
#include "../lib/VCMI_Lib.h"
#include "CGameHandler.h"
std::string NAME = NAME_VER + std::string(" (server)");
using boost::asio::ip::tcp;
using namespace boost;
using namespace boost::asio;
using namespace boost::asio::ip;
mutex smx1;
class CVCMIServer
CVCMIServer::CVCMIServer()
: io(new io_service()), acceptor(new tcp::acceptor(*io, tcp::endpoint(tcp::v4(), 3030)))
{
CGameState *gs;
tcp::acceptor acceptor;
std::map<int,CConnection*> connections;
std::set<CConnection*> conns;
ui32 seed;
public:
CVCMIServer(io_service& io_service)
: acceptor(io_service, tcp::endpoint(tcp::v4(), 3030))
}
CVCMIServer::~CVCMIServer()
{
delete io;
delete acceptor;
}
void CVCMIServer::newGame(CConnection &c)
{
CGameHandler gh;
boost::system::error_code error;
StartInfo *si = new StartInfo;
ui8 clients;
c >> clients; //how many clients should be connected - TODO: support more than one
c >> *si; //get start options
int problem;
#ifdef _MSC_VER
FILE *f;
problem = fopen_s(&f,si->mapname.c_str(),"r");
#else
FILE * f = fopen(si->mapname.c_str(),"r");
problem = !f;
#endif
if(problem)
{
start();
c << ui8(problem); //WRONG!
return;
}
void setUpConnection(CConnection *c, std::string mapname, si32 checksum)
else
{
ui8 quantity, pom;
(*c) << mapname << checksum << seed;
(*c) >> quantity;
for(int i=0;i<quantity;i++)
{
(*c) >> pom;
smx1.lock();
connections[pom] = c;
conns.insert(c);
smx1.unlock();
}
fclose(f);
c << ui8(0); //OK!
}
void newGame(CConnection &c)
gh.init(si,rand());
CConnection* cc; //tcp::socket * ss;
for(int i=0; i<clients; i++)
{
boost::system::error_code error;
StartInfo *si = new StartInfo;
ui8 clients;
std::string mapname;
c >> clients;
c >> mapname;
//getting map
gzFile map = gzopen(mapname.c_str(),"rb");
if(!map){ c << int8_t(1); return; }
std::vector<unsigned char> mapstr; int pom;
while((pom=gzgetc(map))>=0)
if(!i)
{
mapstr.push_back(pom);
cc=&c;
}
gzclose(map);
//map is decompressed
c << int8_t(0); //OK!
gs = new CGameState();
gs->scenarioOps = si;
c > *si; //get start options
boost::crc_32_type result;
result.process_bytes(&(*mapstr.begin()),mapstr.size());
int checksum = result.checksum();
std::cout << "Checksum:" << checksum << std::endl;
CConnection* cc; tcp::socket * ss;
for(int i=0; i<clients; i++)
else
{
if(!i)
tcp::socket * s = new tcp::socket(acceptor->io_service());
acceptor->accept(*s,error);
if(error) //retry
{
cc=&c;
std::cout<<"Cannot establish connection - retrying..." << std::endl;
i--;
continue;
}
else
{
tcp::socket * s = new tcp::socket(acceptor.io_service());
acceptor.accept(*s,error);
if(error) //retry
{
std::cout<<"Cannot establish connection - retrying..." << std::endl;
i--;
continue;
}
cc = new CConnection(s,NAME,std::cout);
}
setUpConnection(cc,mapname,checksum);
}
//TODO: wait for other connections
cc = new CConnection(s,NAME,std::cout);
}
gh.conns.insert(cc);
}
void start()
gh.run();
}
void CVCMIServer::start()
{
boost::system::error_code error;
std::cout<<"Listening for connections at port " << acceptor->local_endpoint().port() << std::endl;
tcp::socket * s = new tcp::socket(acceptor->io_service());
acceptor->accept(*s,error);
if (error)
{
srand ( time(NULL) );
seed = rand();
boost::system::error_code error;
std::cout<<"Listening for connections at port " << acceptor.local_endpoint().port() << std::endl;
tcp::socket * s = new tcp::socket(acceptor.io_service());
acceptor.accept(*s,error);
if (error)
std::cout<<"Got connection but there is an error " << std::endl;
return;
}
CConnection connection(s,NAME,std::cout);
std::cout<<"Got connection!" << std::endl;
while(1)
{
uint8_t mode;
connection >> mode;
switch (mode)
{
std::cout<<"Got connection but there is an error " << std::endl;
case 0:
connection.socket->close();
exit(0);
break;
case 1:
connection.socket->close();
return;
}
CConnection connection(s,NAME,std::cout);
std::cout<<"Got connection!" << std::endl;
while(1)
{
uint8_t mode;
connection >> mode;
switch (mode)
{
case 0:
connection.socket->close();
exit(0);
break;
case 1:
connection.socket->close();
return;
break;
case 2:
newGame(connection);
break;
}
break;
case 2:
newGame(connection);
break;
}
}
};
}
int _tmain(int argc, _TCHAR* argv[])
{
try
{
io_service io_service;
CVCMIServer server(io_service);
while(1)
server.start();
io_service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
CLodHandler h3bmp;
h3bmp.init("Data\\H3bitmap.lod","Data");
initDLL(&h3bmp);
srand ( (unsigned int)time(NULL) );
try
{
io_service io_service;
CVCMIServer server;
while(1)
server.start();
io_service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
catch(...)
{
;
}
return 0;
}

View File

@ -1,38 +0,0 @@
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)];

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -1,235 +0,0 @@
#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"));
}
};
}

View File

@ -1,260 +0,0 @@
<?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>

View File

@ -1,99 +0,0 @@
namespace DefSorter
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.SuspendLayout();
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.button1.Location = new System.Drawing.Point(41, 35);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(138, 27);
this.button1.TabIndex = 0;
this.button1.Text = "Posortuj defy!";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(114, 18);
this.label1.TabIndex = 1;
this.label1.Text = "Defów wykryto: ";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label2.Location = new System.Drawing.Point(146, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 18);
this.label2.TabIndex = 2;
this.label2.Text = "XXXX";
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(4, 73);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(202, 19);
this.progressBar1.TabIndex = 3;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(210, 97);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Def sorter by Tow";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ProgressBar progressBar1;
}
}

View File

@ -1,242 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace DefSorter
{
public partial class Form1 : Form
{
int bledy;
public Form1()
{
InitializeComponent();
int ile = 0;
bledy = 0;
string[] pliczki = Directory.GetFiles(Directory.GetCurrentDirectory());
foreach (string ss in pliczki)
{
if ((!(ss.EndsWith(".DEF")))&&(!(ss.EndsWith(".def"))))
continue;
else ile++;
}
label2.Text = ile.ToString();
progressBar1.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
int s12 = 0, s13 = 0, s14 = 0, s15 = 0, s16 = 0, s17 = 0, s18 = 0,
s19 = 0, s20 = 0, s21 = 0;
Form2 pozegnanie = new Form2();
ArrayList defy = new ArrayList();
string[] pliczki = Directory.GetFiles(Directory.GetCurrentDirectory(),"*.DEF");
progressBar1.Visible = true;
progressBar1.Minimum = progressBar1.Value = 0;
progressBar1.Maximum = Convert.ToInt32(label2.Text);
foreach (string ss in pliczki)
{
if ((!(ss.EndsWith(".DEF"))) && (!(ss.EndsWith(".def"))))
continue;
FileStream czytacz = File.OpenRead(ss);
int coTo = czytacz.ReadByte();
czytacz.Close();
int poczP = ss.LastIndexOf('\\');
string nazwa = ss.Substring(poczP + 1, ss.Length - poczP - 1);
try
{
switch (coTo)
{
case 64:
if (!Directory.Exists("40Spell"))
Directory.CreateDirectory("40Spell");
File.Copy(ss, "40Spell\\" + nazwa);
s12++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "40Spell\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "40Spell\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 65:
if (!Directory.Exists("41SpriteDef"))
Directory.CreateDirectory("41SpriteDef");
File.Copy(ss, "41SpriteDef\\" + nazwa);
s13++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "41SpriteDef\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "41SpriteDef\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 66:
if (!Directory.Exists("42Creature"))
Directory.CreateDirectory("42Creature");
File.Copy(ss, "42Creature\\" + nazwa);
s14++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "42Creature\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "42Creature\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 67:
if (!Directory.Exists("43AdvObject"))
Directory.CreateDirectory("43AdvObject");
File.Copy(ss, "43AdvObject\\" + nazwa);
s15++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "43AdvObject\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "43AdvObject\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 68:
if (!Directory.Exists("44Hero"))
Directory.CreateDirectory("44Hero");
File.Copy(ss, "44Hero\\" + nazwa);
s16++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "44Hero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "44Hero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 69:
if (!Directory.Exists("45Terrain"))
Directory.CreateDirectory("45Terrain");
File.Copy(ss, "45Terrain\\" + nazwa);
s17++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4)+".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4)+".MSK","45Terrain\\"+nazwa.Substring(0, nazwa.Length - 4)+".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4)+".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4)+".MSG","45Terrain\\"+nazwa.Substring(0, nazwa.Length - 4)+".MSG");
}
break;
case 70:
if (!Directory.Exists("46Cursor"))
Directory.CreateDirectory("46Cursor");
File.Copy(ss, "46Cursor\\" + nazwa);
s18++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "46Cursor\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "46Cursor\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 71:
if (!Directory.Exists("47Interface"))
Directory.CreateDirectory("47Interface");
File.Copy(ss, "47Interface\\" + nazwa);
s19++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "47Interface\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "47Interface\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 72:
if (!Directory.Exists("48Spriteframe"))
Directory.CreateDirectory("48Spriteframe");
File.Copy(ss, "48Spriteframe\\" + nazwa);
s20++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "48Spriteframe\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "48Spriteframe\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
case 73:
if (!Directory.Exists("49CombatHero"))
Directory.CreateDirectory("49CombatHero");
File.Copy(ss, "49CombatHero\\" + nazwa);
s21++;
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "49CombatHero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
}
if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
{
File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "49CombatHero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
}
break;
}
}
catch (Exception ee)
{
bledy++;
Form3 niedobrze = new Form3();
niedobrze.textBox1.Text += ee.Message;
DialogResult res = niedobrze.ShowDialog();
switch (res)
{
case DialogResult.Ignore:
break;
case DialogResult.Cancel:
try { Directory.Delete("40Spell"); }catch(Exception){};
try { Directory.Delete("41SpriteDef"); }catch(Exception){};
try { Directory.Delete("42Creature"); }catch(Exception){};
try { Directory.Delete("43AdvObject"); }catch(Exception){};
try { Directory.Delete("45Terrain"); }catch(Exception){};
try { Directory.Delete("46Cursor"); }catch(Exception){};
try { Directory.Delete("47Interface"); }catch(Exception){};
try { Directory.Delete("48Spriteframe"); }catch(Exception){};
try { Directory.Delete("49CombatHero"); }catch(Exception){};
Application.Exit();
break;
}
}
progressBar1.Value++;
if (progressBar1.Value % 100 == 5)
this.Update();
}
progressBar1.Visible = false;
pozegnanie.label12.Text = s12.ToString();
pozegnanie.label13.Text = s13.ToString();
pozegnanie.label14.Text = s14.ToString();
pozegnanie.label15.Text = s15.ToString();
pozegnanie.label16.Text = s16.ToString();
pozegnanie.label17.Text = s17.ToString();
pozegnanie.label18.Text = s18.ToString();
pozegnanie.label19.Text = s19.ToString();
pozegnanie.label20.Text = s20.ToString();
pozegnanie.label21.Text = s21.ToString();
pozegnanie.label34.Text = bledy.ToString();
if (bledy == 0)
pozegnanie.label35.Text = ":)";
pozegnanie.Show();
pozegnanie.Activate();
}
}
}

View File

@ -1,517 +0,0 @@
namespace DefSorter
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.label23 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.label26 = new System.Windows.Forms.Label();
this.label27 = new System.Windows.Forms.Label();
this.label28 = new System.Windows.Forms.Label();
this.label29 = new System.Windows.Forms.Label();
this.label30 = new System.Windows.Forms.Label();
this.label31 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label33 = new System.Windows.Forms.Label();
this.label34 = new System.Windows.Forms.Label();
this.label35 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(255, 17);
this.label1.TabIndex = 0;
this.label1.Text = "Szczęśliwie posortowano. Wg kategorii:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label2.Location = new System.Drawing.Point(12, 26);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 17);
this.label2.TabIndex = 1;
this.label2.Text = "40Spell:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label3.Location = new System.Drawing.Point(12, 43);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(87, 17);
this.label3.TabIndex = 1;
this.label3.Text = "41SpriteDef:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label4.Location = new System.Drawing.Point(12, 60);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(83, 17);
this.label4.TabIndex = 1;
this.label4.Text = "42Creature:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label5.Location = new System.Drawing.Point(12, 77);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(93, 17);
this.label5.TabIndex = 1;
this.label5.Text = "43AdvObject:";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label6.Location = new System.Drawing.Point(12, 94);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 17);
this.label6.TabIndex = 1;
this.label6.Text = "44Hero:";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label7.Location = new System.Drawing.Point(12, 111);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(74, 17);
this.label7.TabIndex = 1;
this.label7.Text = "45Terrain:";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label8.Location = new System.Drawing.Point(12, 128);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(70, 17);
this.label8.TabIndex = 1;
this.label8.Text = "46Cursor:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label9.Location = new System.Drawing.Point(12, 145);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(83, 17);
this.label9.TabIndex = 1;
this.label9.Text = "47Interface:";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label10.Location = new System.Drawing.Point(12, 162);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(101, 17);
this.label10.TabIndex = 1;
this.label10.Text = "48Spriteframe:";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label11.Location = new System.Drawing.Point(12, 179);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(107, 17);
this.label11.TabIndex = 1;
this.label11.Text = "49CombatHero:";
this.label11.Click += new System.EventHandler(this.label11_Click);
//
// label12
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label12.Location = new System.Drawing.Point(125, 26);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(48, 17);
this.label12.TabIndex = 2;
this.label12.Text = "XXXX";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label13.Location = new System.Drawing.Point(125, 43);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(48, 17);
this.label13.TabIndex = 2;
this.label13.Text = "XXXX";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label14.Location = new System.Drawing.Point(125, 60);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(48, 17);
this.label14.TabIndex = 2;
this.label14.Text = "XXXX";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label15.Location = new System.Drawing.Point(125, 77);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(48, 17);
this.label15.TabIndex = 2;
this.label15.Text = "XXXX";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label16.Location = new System.Drawing.Point(125, 94);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(48, 17);
this.label16.TabIndex = 2;
this.label16.Text = "XXXX";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label17.Location = new System.Drawing.Point(125, 111);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(48, 17);
this.label17.TabIndex = 2;
this.label17.Text = "XXXX";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label18.Location = new System.Drawing.Point(125, 128);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(48, 17);
this.label18.TabIndex = 2;
this.label18.Text = "XXXX";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label19.Location = new System.Drawing.Point(125, 145);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(48, 17);
this.label19.TabIndex = 2;
this.label19.Text = "XXXX";
//
// label20
//
this.label20.AutoSize = true;
this.label20.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label20.Location = new System.Drawing.Point(125, 162);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(48, 17);
this.label20.TabIndex = 2;
this.label20.Text = "XXXX";
//
// label21
//
this.label21.AutoSize = true;
this.label21.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label21.Location = new System.Drawing.Point(125, 179);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(48, 17);
this.label21.TabIndex = 2;
this.label21.Text = "XXXX";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label22.Location = new System.Drawing.Point(179, 26);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(49, 17);
this.label22.TabIndex = 3;
this.label22.Text = "defów.";
//
// label23
//
this.label23.AutoSize = true;
this.label23.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label23.Location = new System.Drawing.Point(179, 43);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(49, 17);
this.label23.TabIndex = 3;
this.label23.Text = "defów.";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label24.Location = new System.Drawing.Point(179, 60);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(49, 17);
this.label24.TabIndex = 3;
this.label24.Text = "defów.";
//
// label25
//
this.label25.AutoSize = true;
this.label25.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label25.Location = new System.Drawing.Point(179, 77);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(49, 17);
this.label25.TabIndex = 3;
this.label25.Text = "defów.";
//
// label26
//
this.label26.AutoSize = true;
this.label26.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label26.Location = new System.Drawing.Point(179, 94);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(49, 17);
this.label26.TabIndex = 3;
this.label26.Text = "defów.";
//
// label27
//
this.label27.AutoSize = true;
this.label27.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label27.Location = new System.Drawing.Point(179, 111);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(49, 17);
this.label27.TabIndex = 3;
this.label27.Text = "defów.";
//
// label28
//
this.label28.AutoSize = true;
this.label28.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label28.Location = new System.Drawing.Point(179, 128);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(49, 17);
this.label28.TabIndex = 3;
this.label28.Text = "defów.";
//
// label29
//
this.label29.AutoSize = true;
this.label29.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label29.Location = new System.Drawing.Point(179, 145);
this.label29.Name = "label29";
this.label29.Size = new System.Drawing.Size(49, 17);
this.label29.TabIndex = 3;
this.label29.Text = "defów.";
//
// label30
//
this.label30.AutoSize = true;
this.label30.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label30.Location = new System.Drawing.Point(179, 162);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(49, 17);
this.label30.TabIndex = 3;
this.label30.Text = "defów.";
//
// label31
//
this.label31.AutoSize = true;
this.label31.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label31.Location = new System.Drawing.Point(179, 179);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(49, 17);
this.label31.TabIndex = 3;
this.label31.Text = "defów.";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(12, 221);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(258, 13);
this.label32.TabIndex = 4;
this.label32.Text = "Defy zostaly umieszczone w odpowiednich folderach.";
//
// button1
//
this.button1.Location = new System.Drawing.Point(98, 237);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 5;
this.button1.Text = "Koniec!";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label33
//
this.label33.AutoSize = true;
this.label33.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label33.Location = new System.Drawing.Point(12, 196);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(57, 17);
this.label33.TabIndex = 1;
this.label33.Text = "Błędów:";
this.label33.Click += new System.EventHandler(this.label11_Click);
//
// label34
//
this.label34.AutoSize = true;
this.label34.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label34.Location = new System.Drawing.Point(125, 196);
this.label34.Name = "label34";
this.label34.Size = new System.Drawing.Size(48, 17);
this.label34.TabIndex = 2;
this.label34.Text = "XXXX";
//
// label35
//
this.label35.AutoSize = true;
this.label35.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.label35.Location = new System.Drawing.Point(179, 196);
this.label35.Name = "label35";
this.label35.Size = new System.Drawing.Size(17, 17);
this.label35.TabIndex = 3;
this.label35.Text = ":(";
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(276, 272);
this.Controls.Add(this.button1);
this.Controls.Add(this.label32);
this.Controls.Add(this.label35);
this.Controls.Add(this.label31);
this.Controls.Add(this.label29);
this.Controls.Add(this.label30);
this.Controls.Add(this.label27);
this.Controls.Add(this.label28);
this.Controls.Add(this.label26);
this.Controls.Add(this.label25);
this.Controls.Add(this.label24);
this.Controls.Add(this.label23);
this.Controls.Add(this.label22);
this.Controls.Add(this.label34);
this.Controls.Add(this.label21);
this.Controls.Add(this.label20);
this.Controls.Add(this.label19);
this.Controls.Add(this.label18);
this.Controls.Add(this.label17);
this.Controls.Add(this.label16);
this.Controls.Add(this.label15);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.label12);
this.Controls.Add(this.label33);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form2";
this.Text = "Udało się! :)";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label25;
private System.Windows.Forms.Label label26;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.Label label28;
private System.Windows.Forms.Label label29;
private System.Windows.Forms.Label label30;
private System.Windows.Forms.Label label31;
private System.Windows.Forms.Label label32;
private System.Windows.Forms.Button button1;
public System.Windows.Forms.Label label12;
public System.Windows.Forms.Label label13;
public System.Windows.Forms.Label label14;
public System.Windows.Forms.Label label15;
public System.Windows.Forms.Label label16;
public System.Windows.Forms.Label label17;
public System.Windows.Forms.Label label18;
public System.Windows.Forms.Label label19;
public System.Windows.Forms.Label label20;
public System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label33;
public System.Windows.Forms.Label label34;
public System.Windows.Forms.Label label35;
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DefSorter
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void label11_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -1,101 +0,0 @@
namespace DefSorter
{
partial class Form3
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(268, 209);
this.textBox1.TabIndex = 0;
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Ignore;
this.button1.Location = new System.Drawing.Point(12, 231);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Pomiń";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Location = new System.Drawing.Point(205, 231);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Harakiri";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button3.Location = new System.Drawing.Point(93, 231);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(106, 23);
this.button3.TabIndex = 1;
this.button3.Text = "Anuluj wszystko";
this.button3.UseVisualStyleBackColor = true;
//
// Form3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "Form3";
this.Text = "Nastapil blad :(";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public System.Windows.Forms.TextBox textBox1;
public System.Windows.Forms.Button button1;
public System.Windows.Forms.Button button2;
public System.Windows.Forms.Button button3;
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DefSorter
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DefSorter
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -1,44 +0,0 @@
0 Mage guild 1
1 Mage guild 2
2 Mage guild 3
3 Mage guild 4
4 Mage guild 5
5 tavern
6 shipyard when it's present:))
7 fort
8 citadel
9 castle
10 village hall
11 town hall
12 city hall
13 capitol
14 marketplace
15 resource silo
16 blacksmith
17 lighthouse(0) mystic pond(1) artifact merchants(2,5,8) veil of darkness(4) escape tunnel(6) cage of warlords(7)
18 horde buildings for non-upgraded creatures: Griffins, dwarves, stone gargoyles, imps, skeletons, troglodytes, goblins, gnolls, pixies.
19 horde buildings for upgraded creatures Royal griffins, battle dwarves, obsidian gargoyles, familiars, skeleton warriors, infernal troglodytes, hobgoblins, gnoll marauders, sprites
20 Ship at the Shipyard
21 stables(0) fountain of fortune(1) lookout tower(2) brimstone clouds(3) necromancy amplifier(4) mana vortex(5) freelancer's guild(6) glyphs of fear(7) magic university(8)
22 brotherhood of sword(0) dwarven treasury(1) library(2) castle gates(3) skeleton transformer(4) portal of summoning(5) ballista yard(6) blood obelisk(7)
23 wall of Knowledge.(2) order of fire(3) academy of battle scholars(5) hall of valhalla(6)
24 horde buildings for non-upgraded creatures: dendroid guards, hell hounds
25 horde buildings for upgraded creatures: Dendroid soldiers, Cerberi
26 Grail
27 Houses near city hall
28 Houses near municipal
29 Houses near Capitol
30 dwelling 1
31 dwelling 2
32 dwelling 3
33 dwelling 4
34 dwelling 5
35 dwelling 6
36 dwelling 7
37 upgraded dwelling 1
38 upgraded dwelling 2
39 upgraded dwelling 3
40 upgraded dwelling 4
41 upgraded dwelling 5
42 upgraded dwelling 6
43 upgraded dwelling 7

View File

@ -1,791 +0,0 @@
#pragma once
#include <string>
#include <fstream>
namespace Obwodziciel {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
std::string 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;
}
/// <summary>
/// Summary for Form1
///
/// 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 Form1 : public System::Windows::Forms::Form
{
public:
value struct BuildingEntry
{
int townID, ID;
String^ defname;
};
Form1(void)
{
InitializeComponent();
source1->Text = IO::Directory::GetCurrentDirectory();
source2->Text = IO::Directory::GetCurrentDirectory();
IO::StreamReader ^sr = gcnew IO::StreamReader(IO::Directory::GetCurrentDirectory()+L"\\BNAMES.TXT");
int i=0;
while(!sr->EndOfStream)
{
String ^ n = sr->ReadLine();
//n = (i.ToString()) + L". " + n;
buildingTypes->Items->Add(n);
i++;
}
buildingTypes->SelectedIndex=0;
sr->Close();
delete sr;
sr = gcnew IO::StreamReader(IO::Directory::GetCurrentDirectory()+L"\\TOWNTYPE.TXT");
while(!sr->EndOfStream)
{
String ^ n = sr->ReadLine();
castleType->Items->Add(n);
}
castleType->SelectedIndex = 0;
std::ifstream bb("buildings.txt");
std::string pom;
while(!bb.eof())
{
BuildingEntry be;
bb >> be.townID >> be.ID >> pom >> i >> i;
be.defname = gcnew String(pom.c_str());
lista.Add(be);
}
bb.close();
bb.clear();
out = gcnew IO::StreamWriter("wynik.txt");
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
out->Close();
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::PictureBox^ pictureBox2;
private: System::Windows::Forms::ListBox^ listBox1;
private: System::Windows::Forms::ListBox^ listBox2;
private: System::Windows::Forms::TextBox^ searchpat1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::TextBox^ searchpat2;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ search1;
private: System::Windows::Forms::Button^ search2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ prev1;
private: System::Windows::Forms::Button^ next1;
private: System::Windows::Forms::Button^ prev2;
private: System::Windows::Forms::Button^ next2;
private: System::Windows::Forms::Button^ assign1;
private: System::Windows::Forms::Button^ assign2;
private: System::Windows::Forms::ListBox^ possibilites1;
private: System::Windows::Forms::ListBox^ possibilites2;
private: System::Windows::Forms::Button^ confirm1;
private: System::Windows::Forms::Button^ confirm2;
private: System::Windows::Forms::TextBox^ source1;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::TextBox^ source2;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Button^ browse1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ browse2;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
int b1, b2;
IO::StreamWriter ^out;
System::Collections::Generic::List<BuildingEntry> lista;
private: System::Windows::Forms::ComboBox^ buildingTypes;
private: System::Windows::Forms::ComboBox^ castleType;
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->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
this->listBox1 = (gcnew System::Windows::Forms::ListBox());
this->listBox2 = (gcnew System::Windows::Forms::ListBox());
this->searchpat1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->searchpat2 = (gcnew System::Windows::Forms::TextBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->search1 = (gcnew System::Windows::Forms::Button());
this->search2 = (gcnew System::Windows::Forms::Button());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->prev1 = (gcnew System::Windows::Forms::Button());
this->next1 = (gcnew System::Windows::Forms::Button());
this->prev2 = (gcnew System::Windows::Forms::Button());
this->next2 = (gcnew System::Windows::Forms::Button());
this->assign1 = (gcnew System::Windows::Forms::Button());
this->assign2 = (gcnew System::Windows::Forms::Button());
this->possibilites1 = (gcnew System::Windows::Forms::ListBox());
this->possibilites2 = (gcnew System::Windows::Forms::ListBox());
this->confirm1 = (gcnew System::Windows::Forms::Button());
this->confirm2 = (gcnew System::Windows::Forms::Button());
this->source1 = (gcnew System::Windows::Forms::TextBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->source2 = (gcnew System::Windows::Forms::TextBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->browse1 = (gcnew System::Windows::Forms::Button());
this->button1 = (gcnew System::Windows::Forms::Button());
this->browse2 = (gcnew System::Windows::Forms::Button());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label10 = (gcnew System::Windows::Forms::Label());
this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog());
this->buildingTypes = (gcnew System::Windows::Forms::ComboBox());
this->castleType = (gcnew System::Windows::Forms::ComboBox());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Location = System::Drawing::Point(12, 38);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(450, 298);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// pictureBox2
//
this->pictureBox2->Location = System::Drawing::Point(522, 38);
this->pictureBox2->Name = L"pictureBox2";
this->pictureBox2->Size = System::Drawing::Size(450, 298);
this->pictureBox2->TabIndex = 0;
this->pictureBox2->TabStop = false;
//
// listBox1
//
this->listBox1->FormattingEnabled = true;
this->listBox1->HorizontalScrollbar = true;
this->listBox1->Location = System::Drawing::Point(12, 342);
this->listBox1->Name = L"listBox1";
this->listBox1->Size = System::Drawing::Size(167, 186);
this->listBox1->TabIndex = 1;
this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listBox1_SelectedIndexChanged);
//
// listBox2
//
this->listBox2->FormattingEnabled = true;
this->listBox2->HorizontalScrollbar = true;
this->listBox2->Location = System::Drawing::Point(805, 342);
this->listBox2->Name = L"listBox2";
this->listBox2->Size = System::Drawing::Size(167, 186);
this->listBox2->TabIndex = 1;
this->listBox2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listBox2_SelectedIndexChanged);
//
// searchpat1
//
this->searchpat1->Location = System::Drawing::Point(185, 363);
this->searchpat1->Name = L"searchpat1";
this->searchpat1->Size = System::Drawing::Size(173, 20);
this->searchpat1->TabIndex = 2;
this->searchpat1->Text = L"TOCS*.bmp";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(243, 345);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(77, 13);
this->label1->TabIndex = 3;
this->label1->Text = L"Search pattern";
//
// searchpat2
//
this->searchpat2->Location = System::Drawing::Point(626, 361);
this->searchpat2->Name = L"searchpat2";
this->searchpat2->Size = System::Drawing::Size(173, 20);
this->searchpat2->TabIndex = 2;
this->searchpat2->Text = L"TBCS*.bmp";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(664, 345);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(77, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"Search pattern";
//
// search1
//
this->search1->Location = System::Drawing::Point(185, 393);
this->search1->Name = L"search1";
this->search1->Size = System::Drawing::Size(103, 21);
this->search1->TabIndex = 4;
this->search1->Text = L"Search";
this->search1->UseVisualStyleBackColor = true;
this->search1->Click += gcnew System::EventHandler(this, &Form1::search1_Click);
//
// search2
//
this->search2->Location = System::Drawing::Point(696, 391);
this->search2->Name = L"search2";
this->search2->Size = System::Drawing::Size(103, 21);
this->search2->TabIndex = 4;
this->search2->Text = L"Search";
this->search2->UseVisualStyleBackColor = true;
this->search2->Click += gcnew System::EventHandler(this, &Form1::search2_Click);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 18, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label3->Location = System::Drawing::Point(160, 6);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(81, 29);
this->label3->TabIndex = 5;
this->label3->Text = L"POLE";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 18, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label4->Location = System::Drawing::Point(743, 6);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(93, 29);
this->label4->TabIndex = 5;
this->label4->Text = L"IMAGE";
//
// prev1
//
this->prev1->Enabled = false;
this->prev1->Location = System::Drawing::Point(294, 393);
this->prev1->Name = L"prev1";
this->prev1->Size = System::Drawing::Size(64, 21);
this->prev1->TabIndex = 6;
this->prev1->Text = L"<-";
this->prev1->UseVisualStyleBackColor = true;
this->prev1->Click += gcnew System::EventHandler(this, &Form1::prev1_Click);
//
// next1
//
this->next1->Enabled = false;
this->next1->Location = System::Drawing::Point(364, 393);
this->next1->Name = L"next1";
this->next1->Size = System::Drawing::Size(64, 21);
this->next1->TabIndex = 6;
this->next1->Text = L"->";
this->next1->UseVisualStyleBackColor = true;
this->next1->Click += gcnew System::EventHandler(this, &Form1::next1_Click);
//
// prev2
//
this->prev2->Enabled = false;
this->prev2->Location = System::Drawing::Point(556, 391);
this->prev2->Name = L"prev2";
this->prev2->Size = System::Drawing::Size(64, 21);
this->prev2->TabIndex = 6;
this->prev2->Text = L"<-";
this->prev2->UseVisualStyleBackColor = true;
this->prev2->Click += gcnew System::EventHandler(this, &Form1::prev2_Click);
//
// next2
//
this->next2->Enabled = false;
this->next2->Location = System::Drawing::Point(626, 391);
this->next2->Name = L"next2";
this->next2->Size = System::Drawing::Size(64, 21);
this->next2->TabIndex = 6;
this->next2->Text = L"->";
this->next2->UseVisualStyleBackColor = true;
this->next2->Click += gcnew System::EventHandler(this, &Form1::next2_Click);
//
// assign1
//
this->assign1->Location = System::Drawing::Point(434, 391);
this->assign1->Name = L"assign1";
this->assign1->Size = System::Drawing::Size(116, 22);
this->assign1->TabIndex = 7;
this->assign1->Text = L"Assign there >";
this->assign1->UseVisualStyleBackColor = true;
this->assign1->Click += gcnew System::EventHandler(this, &Form1::assign1_Click);
//
// assign2
//
this->assign2->Location = System::Drawing::Point(434, 414);
this->assign2->Name = L"assign2";
this->assign2->Size = System::Drawing::Size(116, 22);
this->assign2->TabIndex = 7;
this->assign2->Text = L"< Assign there";
this->assign2->UseVisualStyleBackColor = true;
this->assign2->Click += gcnew System::EventHandler(this, &Form1::assign2_Click);
//
// possibilites1
//
this->possibilites1->FormattingEnabled = true;
this->possibilites1->HorizontalScrollbar = true;
this->possibilites1->Location = System::Drawing::Point(185, 422);
this->possibilites1->Name = L"possibilites1";
this->possibilites1->Size = System::Drawing::Size(120, 108);
this->possibilites1->TabIndex = 8;
this->possibilites1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::possibilites1_SelectedIndexChanged);
//
// possibilites2
//
this->possibilites2->FormattingEnabled = true;
this->possibilites2->HorizontalScrollbar = true;
this->possibilites2->Location = System::Drawing::Point(679, 422);
this->possibilites2->Name = L"possibilites2";
this->possibilites2->Size = System::Drawing::Size(120, 108);
this->possibilites2->TabIndex = 8;
this->possibilites2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::possibilites2_SelectedIndexChanged);
//
// confirm1
//
this->confirm1->Location = System::Drawing::Point(312, 422);
this->confirm1->Name = L"confirm1";
this->confirm1->Size = System::Drawing::Size(116, 25);
this->confirm1->TabIndex = 9;
this->confirm1->Text = L"Confirm";
this->confirm1->UseVisualStyleBackColor = true;
this->confirm1->Click += gcnew System::EventHandler(this, &Form1::confirm1_Click);
//
// confirm2
//
this->confirm2->Location = System::Drawing::Point(557, 422);
this->confirm2->Name = L"confirm2";
this->confirm2->Size = System::Drawing::Size(116, 25);
this->confirm2->TabIndex = 9;
this->confirm2->Text = L"Confirm";
this->confirm2->UseVisualStyleBackColor = true;
this->confirm2->Click += gcnew System::EventHandler(this, &Form1::confirm2_Click);
//
// source1
//
this->source1->Location = System::Drawing::Point(312, 468);
this->source1->Name = L"source1";
this->source1->Size = System::Drawing::Size(116, 20);
this->source1->TabIndex = 10;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(335, 452);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(73, 13);
this->label5->TabIndex = 11;
this->label5->Text = L"Source folder:";
//
// source2
//
this->source2->Location = System::Drawing::Point(556, 468);
this->source2->Name = L"source2";
this->source2->Size = System::Drawing::Size(116, 20);
this->source2->TabIndex = 10;
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(579, 452);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(73, 13);
this->label6->TabIndex = 11;
this->label6->Text = L"Source folder:";
//
// browse1
//
this->browse1->Location = System::Drawing::Point(312, 494);
this->browse1->Name = L"browse1";
this->browse1->Size = System::Drawing::Size(116, 23);
this->browse1->TabIndex = 12;
this->browse1->Text = L"Browse";
this->browse1->UseVisualStyleBackColor = true;
this->browse1->Click += gcnew System::EventHandler(this, &Form1::browse1_Click);
//
// button1
//
this->button1->Location = System::Drawing::Point(557, 494);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(116, 23);
this->button1->TabIndex = 12;
this->button1->Text = L"Browse";
this->button1->UseVisualStyleBackColor = true;
//
// browse2
//
this->browse2->Location = System::Drawing::Point(556, 494);
this->browse2->Name = L"browse2";
this->browse2->Size = System::Drawing::Size(116, 23);
this->browse2->TabIndex = 12;
this->browse2->Text = L"Browse";
this->browse2->UseVisualStyleBackColor = true;
this->browse2->Click += gcnew System::EventHandler(this, &Form1::browse2_Click);
//
// label7
//
this->label7->AutoSize = true;
this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label7->Location = System::Drawing::Point(440, 472);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(104, 20);
this->label7->TabIndex = 13;
this->label7->Text = L"Obwodziciel";
//
// label8
//
this->label8->AutoSize = true;
this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label8->Location = System::Drawing::Point(442, 492);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(102, 20);
this->label8->TabIndex = 13;
this->label8->Text = L"VCMI Team";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label9->Location = System::Drawing::Point(459, 512);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(66, 20);
this->label9->TabIndex = 13;
this->label9->Text = L"© 2008";
//
// label10
//
this->label10->AutoSize = true;
this->label10->Location = System::Drawing::Point(463, 344);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(58, 13);
this->label10->TabIndex = 16;
this->label10->Text = L"Building ID";
//
// buildingTypes
//
this->buildingTypes->FormattingEnabled = true;
this->buildingTypes->Location = System::Drawing::Point(365, 364);
this->buildingTypes->Name = L"buildingTypes";
this->buildingTypes->Size = System::Drawing::Size(255, 21);
this->buildingTypes->TabIndex = 17;
//
// castleType
//
this->castleType->FormattingEnabled = true;
this->castleType->Location = System::Drawing::Point(434, 445);
this->castleType->Name = L"castleType";
this->castleType->Size = System::Drawing::Size(116, 21);
this->castleType->TabIndex = 18;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(984, 535);
this->Controls->Add(this->castleType);
this->Controls->Add(this->buildingTypes);
this->Controls->Add(this->label10);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->browse2);
this->Controls->Add(this->button1);
this->Controls->Add(this->browse1);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->source2);
this->Controls->Add(this->source1);
this->Controls->Add(this->confirm2);
this->Controls->Add(this->confirm1);
this->Controls->Add(this->possibilites2);
this->Controls->Add(this->possibilites1);
this->Controls->Add(this->assign2);
this->Controls->Add(this->assign1);
this->Controls->Add(this->next2);
this->Controls->Add(this->next1);
this->Controls->Add(this->prev2);
this->Controls->Add(this->prev1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->search2);
this->Controls->Add(this->search1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->searchpat2);
this->Controls->Add(this->searchpat1);
this->Controls->Add(this->listBox2);
this->Controls->Add(this->listBox1);
this->Controls->Add(this->pictureBox2);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Obwodziciel 1.00";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox2))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void browse1_Click(System::Object^ sender, System::EventArgs^ e) {
folderBrowserDialog1->ShowDialog();
source1->Text = folderBrowserDialog1->SelectedPath;
}
private: System::Void browse2_Click(System::Object^ sender, System::EventArgs^ e) {
folderBrowserDialog1->ShowDialog();
source2->Text = folderBrowserDialog1->SelectedPath;
}
private: System::Void search1_Click(System::Object^ sender, System::EventArgs^ e) {
listBox1->Items->Clear();
array<String^>^ pliki = IO::Directory::GetFiles(source1->Text,searchpat1->Text);
for each(String^ plik in pliki)
{
listBox1->Items->Add(plik);
}
if(listBox1->Items->Count>0)
listBox1->SelectedIndex=0;
}
private: System::Void search2_Click(System::Object^ sender, System::EventArgs^ e) {
listBox2->Items->Clear();
array<String^>^ pliki = IO::Directory::GetFiles(source2->Text,searchpat2->Text);
for each(String^ plik in pliki)
{
listBox2->Items->Add(plik);
}
if(listBox2->Items->Count>0)
listBox2->SelectedIndex=0;
}
private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if(listBox1->SelectedIndex<0)
return;
pictureBox1->Image = gcnew Drawing::Bitmap(dynamic_cast<String^>(listBox1->SelectedItem));
}
private: System::Void listBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if(listBox2->SelectedIndex<0)
return;
String^ s = dynamic_cast<String^>(listBox2->SelectedItem);
pictureBox2->Image = gcnew Drawing::Bitmap(s);
s = s->Substring(s->LastIndexOf(L"\\")+1);
s = s->Replace(L"_0_",L"");
s = s->Replace(L".bmp",L".def");
s = s->Replace(L".BMP",L".def");
for each(BuildingEntry b in lista)
{
if(b.defname == s)
buildingTypes->SelectedIndex = b.ID;
}
}
private: System::Void assign2_Click(System::Object^ sender, System::EventArgs^ e) {
possibilites1->Items->Clear();
for each(Object^ item in listBox1->Items)
{
String^ path = dynamic_cast<String^>(item);
Bitmap ^b = gcnew Bitmap(path);
if( (b->Width == pictureBox2->Image->Width) && (b->Height == pictureBox2->Image->Height) )
possibilites1->Items->Add(path);
delete b;
}
if (possibilites1->Items->Count>0)
{
possibilites1->SelectedIndex=0;
}
}
private: System::Void assign1_Click(System::Object^ sender, System::EventArgs^ e) {
possibilites2->Items->Clear();
for each(Object^ item in listBox2->Items)
{
String^ path = dynamic_cast<String^>(item);
Bitmap ^b = gcnew Bitmap(path);
if( (b->Width == pictureBox1->Image->Width) && (b->Height == pictureBox1->Image->Height) )
possibilites2->Items->Add(path);
delete b;
}
if (possibilites2->Items->Count>0)
{
possibilites2->SelectedIndex=0;
}
}
private: System::Void possibilites1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if(possibilites1->SelectedIndex<0)
return;
String^ s = dynamic_cast<String^>(possibilites1->SelectedItem);
pictureBox1->Image = gcnew Drawing::Bitmap(s);
s = s->Substring(s->LastIndexOf(L"\\")+1);
s = s->Replace(L"_0_",L"");
s = s->Replace(L".bmp",L".def");
s = s->Replace(L".BMP",L".def");
for each(BuildingEntry b in lista)
{
if(b.defname == s)
buildingTypes->SelectedIndex = b.ID;
}
}
private: System::Void possibilites2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if(possibilites2->SelectedIndex<0)
return;
String^ s = dynamic_cast<String^>(possibilites2->SelectedItem);
pictureBox2->Image = gcnew Drawing::Bitmap(s);
s = s->Substring(s->LastIndexOf(L"\\")+1);
s = s->Replace(L"_0_",L"");
s = s->Replace(L".bmp",L".def");
s = s->Replace(L".BMP",L".def");
for each(BuildingEntry b in lista)
{
if(b.defname == s)
buildingTypes->SelectedIndex = b.ID;
}
}
void confirm(bool first)
{
try
{
//out format:
// townId ID defname bordername areaname
String^ s, ^s2, ^s3;
if(first)
{
s = dynamic_cast<String^>(possibilites2->SelectedItem);
}
else
{
s = dynamic_cast<String^>(listBox2->SelectedItem);
}
s = s->Substring(s->LastIndexOf(L"\\")+1);
s = s->Replace(L"_0_",L"");
s = s->Replace(L".bmp",L".def");
s = s->Replace(L".BMP",L".def");
if(!first)
{
s2 = dynamic_cast<String^>(possibilites1->SelectedItem);
}
else
{
s2 = dynamic_cast<String^>(listBox1->SelectedItem);
}
s2 = s2->Substring(s2->LastIndexOf(L"\\")+1);
s3 = L"TZ" + s2->Substring(2);
String^ toOut;
toOut = castleType->SelectedIndex.ToString() + L"\t"
+ buildingTypes->SelectedIndex + (L"\t")
+ s + L"\t"
+ s2 + L"\t"
+ s3;
out->WriteLine(toOut);
out->Flush();
if(first)
{
for each(Object^ obj in listBox2->Items)
{
String^ str = dynamic_cast<String^>(obj),
^usw = dynamic_cast<String^>(possibilites2->SelectedItem);
if(str==usw)
{
listBox2->Items->Remove(obj);
if(listBox2->Items->Count>0)
listBox2->SelectedIndex = 0;
break;
}
}
listBox1->Items->Remove(listBox1->SelectedItem);
if(listBox1->Items->Count>0)
listBox1->SelectedIndex++;
}
else
{
for each(Object^ obj in listBox1->Items)
{
String^ str = dynamic_cast<String^>(obj),
^usw = dynamic_cast<String^>(possibilites1->SelectedItem);
if(str==usw)
{
listBox1->Items->Remove(obj);
if(listBox1->Items->Count>0)
listBox1->SelectedIndex = 0;
break;
}
}
int tempp = listBox2->SelectedIndex;
listBox2->Items->Remove(listBox2->SelectedItem);
if(listBox2->Items->Count>tempp)
listBox2->SelectedIndex=tempp;
}
possibilites1->Items->Clear();
possibilites2->Items->Clear();
}
catch(...)
{
possibilites1->Items->Clear();
possibilites2->Items->Clear();
}
}
private: System::Void confirm1_Click(System::Object^ sender, System::EventArgs^ e) {
confirm(true);
}
private: System::Void confirm2_Click(System::Object^ sender, System::EventArgs^ e) {
confirm(false);
}
private: System::Void prev1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void next1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void prev2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void next2_Click(System::Object^ sender, System::EventArgs^ e) {
}
};
}

View File

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>42</value>
</metadata>
</root>

View File

@ -1,17 +0,0 @@
// Obwodziciel.cpp : main project file.
#include "Form1.h"
using namespace Obwodziciel;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}

View File

@ -1,236 +0,0 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="Obwodziciel"
ProjectGUID="{0910DE2E-6C6C-48FE-9BCA-A961AFF5844F}"
RootNamespace="Obwodziciel"
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="2"
>
<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 "
LinkIncremental="2"
AdditionalLibraryDirectories="G:\tp\SDL\lib"
GenerateDebugInformation="true"
AssemblyDebug="1"
SubSystem="2"
EntryPointSymbol="main"
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="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="G:\tp\SDL\include"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib "
LinkIncremental="1"
AdditionalLibraryDirectories="G:\tp\SDL\lib"
GenerateDebugInformation="true"
SubSystem="2"
EntryPointSymbol="main"
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.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.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, 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=".\Obwodziciel.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Form1.h"
FileType="3"
>
<File
RelativePath=".\Form1.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>

View File

@ -1,9 +0,0 @@
Castle
Rampart
Tower
Inferno
Necropolis
Dungeon
Stronghold
Fortress
Conflux

View File

@ -1,37 +0,0 @@
0 16 TBCSBLAK.def 213 251
0 8 TBCSCAS2.def 478 66
0 9 TBCSCAS3.def 478 37
0 7 TBCSCSTL.def 595 66
0 6 TBCSDOCK.def 478 134
0 30 TBCSDW_0.def 304 92
0 31 TBCSDW_1.def 360 130
0 32 TBCSDW_2.def 76 57
0 33 TBCSDW_3.def 176 101
0 34 TBCSDW_4.def 563 211
0 35 TBCSDW_5.def 174 190
0 36 TBCSDW_6.def 303 0
0 21 TBCSEXT0.def 384 193
0 22 TBCSEXT1.def 0 198
0 11 TBCSHAL2.def 0 176
0 12 TBCSHAL3.def 0 164
0 13 TBCSHAL4.def 0 154
0 10 TBCSHALL.def 0 209
0 26 TBCSHOLY.def 456 109
0 18 TBCSHRD1.def 76 53
0 19 TBCSHRD2.def 76 35
0 1 TBCSMAG2.def 706 135
0 2 TBCSMAG3.def 704 107
0 3 TBCSMAG4.def 704 76
0 0 TBCSMAGE.def 707 166
0 14 TBCSMARK.def 413 264
0 15 TBCSSILO.def 488 228
0 17 TBCSSPEC.def 533 71
0 5 TBCSTVRN.def 0 230
0 37 TBCSUP_0.def 304 65
0 38 TBCSUP_1.def 360 115
0 39 TBCSUP_2.def 76 35
0 40 TBCSUP_3.def 176 85
0 41 TBCSUP_4.def 563 173
0 42 TBCSUP_5.def 160 190
0 43 TBCSUP_6.def 303 0
0 20 TBCSBOAT.def 478 134

View File

@ -1,38 +0,0 @@
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)];

View File

@ -1,361 +0,0 @@
// Wpasujbud.cpp : main project file.
//#include <msclr\marshal.h>
#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<String^>^ 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<Image^>(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<OpenFileDialog^>(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<String^>(bitmapList->SelectedItem);
Bitmap ^building = gcnew Bitmap(bmpname);
buildingImg->Image = dynamic_cast<Image^>(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;i<st->w;i+=Inaccuracy)
{
for(int j=0;j<st->h;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;i<st->Width;i++)
{
for(int j=0;j<st->Height;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<Bitmap^>(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<String^>(bitmapList->SelectedItem);
SDL_Surface *str = SDL_LoadBMP(ToString(sss).c_str());
Int32 colorPxs = 0;
int aq = 0x00ffff;
for (int x=0;x<str->w;x++)
{
for(int y=0;y<str->h;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;i<maxr;i++)
{
for (int j=0;j<maxr;j++)
{
int pom = zgodnosc(sbg,str,px+i,py+j);
if (pom>zgoda)
{
zgoda = pom;
retx = px+i;
rety = py+j;
}
}
}
//for(int r=0;r<maxr;r++)
//{
// for(int i=0;i<=r;i++)
// {
// int pom, pom2;
// pom = zgodnosc(sbg,str,px+i,py);
// if (pom>zgoda)
// {
// 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<String^>(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();
}

View File

@ -1,649 +0,0 @@
#pragma once
#include <cliext/vector>
#include "data.h"
#include "obrazek.h"
#include "dataEditor.h"
#include <string>
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>
/// 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.
/// </summary>
public ref class Wpasujbud : public System::Windows::Forms::Form
{
public:
cliext::vector<CBuildingData^> 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:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~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:
/// <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->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<System::ComponentModel::ISupportInitialize^ >(this->townBg))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(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<System::Byte>(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<System::Byte>(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<System::Byte>(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<System::Byte>(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<System::ComponentModel::ISupportInitialize^ >(this->townBg))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(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);
};
}

View File

@ -1,44 +0,0 @@
0 Mage guild 1
1 Mage guild 2
2 Mage guild 3
3 Mage guild 4
4 Mage guild 5
5 tavern
6 shipyard when it's present:))
7 fort
8 citadel
9 castle
10 village hall
11 town hall
12 city hall
13 capitol
14 marketplace
15 resource silo
16 blacksmith
17 lighthouse(0) mystic pond(1) artifact merchants(2,5,8) veil of darkness(4) escape tunnel(6) cage of warlords(7)
18 horde buildings for non-upgraded creatures: Griffins, dwarves, stone gargoyles, imps, skeletons, troglodytes, goblins, gnolls, pixies.
19 horde buildings for upgraded creatures Royal griffins, battle dwarves, obsidian gargoyles, familiars, skeleton warriors, infernal troglodytes, hobgoblins, gnoll marauders, sprites
20 Ship at the Shipyard
21 stables(0) fountain of fortune(1) lookout tower(2) brimstone clouds(3) necromancy amplifier(4) mana vortex(5) freelancer's guild(6) glyphs of fear(7) magic university(8)
22 brotherhood of sword(0) dwarven treasury(1) library(2) castle gates(3) skeleton transformer(4) portal of summoning(5) ballista yard(6) blood obelisk(7)
23 wall of Knowledge.(2) order of fire(3) academy of battle scholars(5) hall of valhalla(6)
24 horde buildings for non-upgraded creatures: dendroid guards, hell hounds
25 horde buildings for upgraded creatures: Dendroid soldiers, Cerberi
26 Grail
27 Houses near city hall
28 Houses near municipal
29 Houses near Capitol
30 dwelling 1
31 dwelling 2
32 dwelling 3
33 dwelling 4
34 dwelling 5
35 dwelling 6
36 dwelling 7
37 upgraded dwelling 1
38 upgraded dwelling 2
39 upgraded dwelling 3
40 upgraded dwelling 4
41 upgraded dwelling 5
42 upgraded dwelling 6
43 upgraded dwelling 7

View File

@ -1,9 +0,0 @@
Castle
Rampart
Tower
Inferno
Necropolis
Dungeon
Stronghold
Fortress
Conflux

View File

@ -1,12 +0,0 @@
#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";
}
};

View File

@ -1,2 +0,0 @@
#include "dataEditor.h"

View File

@ -1,209 +0,0 @@
#pragma once
#include "data.h"
#include <cliext/vector>
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>
/// 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.
/// </summary>
public ref class dataEditor : public System::Windows::Forms::Form
{
public:
dataEditor(cliext::vector<CBuildingData^> ^Data)
{
data = Data;
InitializeComponent();
dataGridView1->Rows->Add(data->size());
for (int i=0;i<data->size();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<CBuildingData^> ^data;
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~dataEditor()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::DataGridView^ dataGridView1;
protected:
protected:
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->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<System::ComponentModel::ISupportInitialize^ >(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<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void clear_Click(System::Object^ sender, System::EventArgs^ e) {
for (int i=0;i<data->size();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;i<data->size();i++)
{
data->at(i)->townID = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[0]->Value));
data->at(i)->ID = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[1]->Value));
data->at(i)->defname = static_cast<String^>(dataGridView1->Rows[i]->Cells[2]->Value);
data->at(i)->x = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[3]->Value));
data->at(i)->y = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[4]->Value));
}
}
};
}

View File

@ -1,2 +0,0 @@
#include "obrazek.h"

View File

@ -1,121 +0,0 @@
#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>
/// 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.
/// </summary>
public ref class obrazek : public System::Windows::Forms::Form
{
public:
obrazek(System::Drawing::Image^ img)
{
InitializeComponent(img);
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~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:
/// <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(System::Drawing::Image^ img)
{
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(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<System::ComponentModel::ISupportInitialize^ >(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);
}
};
}