mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-05 23:28:14 +02:00
zaczytywanie tekstów do menu głównego, przygotowania do obsługi obiektów na mapie
This commit is contained in:
@@ -453,4 +453,27 @@ void CAmbarCendamo::loadDefs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
EDefType CAmbarCendamo::getDefType(DefInfo &a)
|
||||||
|
{
|
||||||
|
switch(a.bytes[16])
|
||||||
|
{
|
||||||
|
case 26:
|
||||||
|
return EDefType::EVENTOBJ_DEF;
|
||||||
|
case 33:
|
||||||
|
return EDefType::GARRISON_DEF;
|
||||||
|
case 34:
|
||||||
|
return EDefType::HERO_DEF;
|
||||||
|
case 79:
|
||||||
|
return EDefType::RESOURCE_DEF;
|
||||||
|
case 83:
|
||||||
|
return EDefType::SEERHUT_DEF;
|
||||||
|
case 91:
|
||||||
|
return EDefType::SIGN_DEF;
|
||||||
|
case 98:
|
||||||
|
return EDefType::TOWN_DEF;
|
||||||
|
case 219:
|
||||||
|
return EDefType::GARRISON_DEF;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "CSemiDefHandler.h"
|
#include "CSemiDefHandler.h"
|
||||||
|
|
||||||
|
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF};
|
||||||
|
|
||||||
class CAmbarCendamo
|
class CAmbarCendamo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -25,5 +27,6 @@ public:
|
|||||||
void teceDef (); // create files with info about defs
|
void teceDef (); // create files with info about defs
|
||||||
void deh3m(); // decode file, results are stored in map
|
void deh3m(); // decode file, results are stored in map
|
||||||
void loadDefs();
|
void loadDefs();
|
||||||
|
EDefType getDefType(DefInfo& a); //returns type of object in def
|
||||||
};
|
};
|
||||||
#endif //AMBARCENDD
|
#endif //AMBARCENDD
|
||||||
3
CMT.cpp
3
CMT.cpp
@@ -20,6 +20,7 @@
|
|||||||
#include "CBuildingHandler.h"
|
#include "CBuildingHandler.h"
|
||||||
#include "CObjectHandler.h"
|
#include "CObjectHandler.h"
|
||||||
#include "CGameInfo.h"
|
#include "CGameInfo.h"
|
||||||
|
#include "CPreGameTextHandler.h" //TODO - powinno by� w inicjowaniu preGame, ale to ty tam grzebiesz, wi�c ty to zr�b ;]
|
||||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
@@ -258,6 +259,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
CObjectHandler * objh = new CObjectHandler;
|
CObjectHandler * objh = new CObjectHandler;
|
||||||
objh->loadObjects();
|
objh->loadObjects();
|
||||||
cgi->objh = objh;
|
cgi->objh = objh;
|
||||||
|
CPreGameTextHandler * preth = new CPreGameTextHandler;
|
||||||
|
preth->loadTexts();
|
||||||
CAmbarCendamo * ac = new CAmbarCendamo("4gryf");
|
CAmbarCendamo * ac = new CAmbarCendamo("4gryf");
|
||||||
cgi->ac = ac;
|
cgi->ac = ac;
|
||||||
THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl;
|
THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl;
|
||||||
|
|||||||
109
CPreGameTextHandler.cpp
Normal file
109
CPreGameTextHandler.cpp
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
#include "CPreGameTextHandler.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
void CPreGameTextHandler::loadTexts()
|
||||||
|
{
|
||||||
|
std::ifstream inp("H3bitmap.lod\\ZELP.TXT", std::ios::in|std::ios::binary);
|
||||||
|
inp.seekg(0,std::ios::end); // na koniec
|
||||||
|
int andame = inp.tellg(); // read length
|
||||||
|
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
||||||
|
char * bufor = new char[andame]; // allocate memory
|
||||||
|
inp.read((char*)bufor, andame); // read map file to buffer
|
||||||
|
std::string buf = std::string(bufor);
|
||||||
|
delete [andame] bufor;
|
||||||
|
int i=0; //buf iterator
|
||||||
|
int hmcr=0;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==3)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=3;
|
||||||
|
|
||||||
|
int befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mainNewGame = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
hmcr = 0;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=3;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mainLoadGame = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
hmcr = 0;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=3;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mainHighScores = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
hmcr = 0;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=3;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mainCredits = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
hmcr = 0;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=3;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mainQuit = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
14
CPreGameTextHandler.h
Normal file
14
CPreGameTextHandler.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef CPREGAMETEXTHANDLER_H
|
||||||
|
#define CPREGAMETEXTHANDLER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class CPreGameTextHandler //handles pre - game texts
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string mainNewGame, mainLoadGame, mainHighScores, mainCredits, mainQuit; //right - click texts in main menu
|
||||||
|
void loadTexts();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //CPREGAMETEXTHANDLER_H
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_image.h"
|
#include "SDL_image.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct Cimage
|
struct Cimage
|
||||||
{
|
{
|
||||||
std::string imName; //name without extension
|
std::string imName; //name without extension
|
||||||
|
|||||||
2
map.h
2
map.h
@@ -52,7 +52,7 @@ struct TerrainTile
|
|||||||
struct DefInfo //information from def declaration
|
struct DefInfo //information from def declaration
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
int bytes [46];
|
int bytes [42];
|
||||||
};
|
};
|
||||||
struct Location
|
struct Location
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void mapHandler::init()
|
|||||||
{
|
{
|
||||||
TerrainTile zz = reader->map.terrain[i][j];
|
TerrainTile zz = reader->map.terrain[i][j];
|
||||||
std::string name = CSemiDefHandler::nameFromType(reader->map.terrain[i][j].tertype);
|
std::string name = CSemiDefHandler::nameFromType(reader->map.terrain[i][j].tertype);
|
||||||
for (int k=0; k<reader->defs.size(); k++)
|
for (unsigned int k=0; k<reader->defs.size(); k++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ void mapHandler::init()
|
|||||||
{
|
{
|
||||||
TerrainTile zz = reader->map.undergroungTerrain[i][j];
|
TerrainTile zz = reader->map.undergroungTerrain[i][j];
|
||||||
std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i][j].tertype);
|
std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i][j].tertype);
|
||||||
for (int k=0; k<reader->defs.size(); k++)
|
for (unsigned int k=0; k<reader->defs.size(); k++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user