mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Sporo zmian:
- troche zreorganizowana "obsluga" "defow/lodow". Dodanie lodhandlera. - poprawki w specyfikacji - dodanie klasy CPreGame i wyswietlanie menu glownego. Uwaga - ledwo to zaczalem, jest bardzo niedokończone. Dokończę w ciągu najbliższych dni, więc proszę nie grzeb mi w tym zanadto :) - pewnie trochu innych zmian, nie miałe otwartego notatnika ;)
This commit is contained in:
parent
17ceb855da
commit
93e2667e9e
@ -425,14 +425,14 @@ void CAmbarCendamo::loadDefs()
|
||||
if (loadedTypes.find(map.terrain[i][j].tertype)==loadedTypes.end())
|
||||
{
|
||||
CSemiDefHandler *sdh = new CSemiDefHandler();
|
||||
sdh->openDef(("H3sprite.lod\\"+sdh->nameFromType(map.terrain[i][j].tertype)).c_str());
|
||||
sdh->openDef((sdh->nameFromType(map.terrain[i][j].tertype)).c_str(),"H3sprite.lod");
|
||||
loadedTypes.insert(map.terrain[i][j].tertype);
|
||||
defs.push_back(sdh);
|
||||
}
|
||||
if (loadedTypes.find(map.undergroungTerrain[i][j].tertype)==loadedTypes.end())
|
||||
{
|
||||
CSemiDefHandler *sdh = new CSemiDefHandler();
|
||||
sdh->openDef(("H3sprite.lod\\"+sdh->nameFromType(map.undergroungTerrain[i][j].tertype)).c_str());
|
||||
sdh->openDef((sdh->nameFromType(map.undergroungTerrain[i][j].tertype)).c_str(),"H3sprite.lod");
|
||||
loadedTypes.insert(map.undergroungTerrain[i][j].tertype);
|
||||
defs.push_back(sdh);
|
||||
}
|
||||
|
10
CMT.cpp
10
CMT.cpp
@ -16,7 +16,6 @@
|
||||
#include "CAbilityHandler.h"
|
||||
#include "CSpellHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
@ -26,12 +25,11 @@
|
||||
#endif
|
||||
#define CHUNK 16384
|
||||
#define pi 3.14159
|
||||
const char * NAME = "VCMI 0.1";
|
||||
|
||||
|
||||
const char * NAME = "VCMI 0.2";
|
||||
#include "CAmbarCendamo.h"
|
||||
#include "mapHandler.h"
|
||||
#include "global.h"
|
||||
#include "CPreGame.h"
|
||||
/* Compress from file source to file dest until EOF on source.
|
||||
def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
|
||||
allocated for processing, Z_STREAM_ERROR if an invalid compression
|
||||
@ -208,7 +206,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER/*|SDL_INIT_EVENTTHREAD*/)==0)
|
||||
{
|
||||
|
||||
screen = SDL_SetVideoMode(1024,768,24,SDL_HWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
|
||||
screen = SDL_SetVideoMode(800,600,24,SDL_HWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
|
||||
ekran = screen;
|
||||
//FILE * zr = fopen("mal.txt","r");
|
||||
//FILE * ko = fopen("wyn.txt","w");
|
||||
@ -227,6 +225,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
// fclose(ko);fclose(zr);
|
||||
//}
|
||||
SDL_WM_SetCaption(NAME,"");
|
||||
CPreGame * cpg = new CPreGame();
|
||||
//cpg->runLoop();
|
||||
THC timeHandler tmh;
|
||||
CGameInfo * cgi = new CGameInfo;
|
||||
CGameInfo::mainObj = cgi;
|
||||
|
28
CPreGame.cpp
Normal file
28
CPreGame.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "stdafx.h"
|
||||
#include "CPreGame.h"
|
||||
#include "SDL.h";
|
||||
extern SDL_Surface * ekran;
|
||||
CPreGame::CPreGame()
|
||||
{
|
||||
initMainMenu();
|
||||
showMainMenu();
|
||||
}
|
||||
void CPreGame::initMainMenu()
|
||||
{
|
||||
ourMainMenu = new menuItems();
|
||||
ourMainMenu->background = SDL_LoadBMP("h3bitmap.lod\\ZPIC1005.bmp");
|
||||
CSemiLodHandler * slh = new CSemiLodHandler();
|
||||
slh->openLod("H3sprite.lod");
|
||||
ourMainMenu->newGame = slh->giveDef("ZMENUNG.DEF");
|
||||
handledLods.push_back(slh);
|
||||
delete slh;
|
||||
}
|
||||
void CPreGame::showMainMenu()
|
||||
{
|
||||
SDL_BlitSurface(ourMainMenu->background,NULL,ekran,NULL);
|
||||
SDL_Flip(ekran);
|
||||
SDL_BlitSurface(ourMainMenu->newGame->ourImages[0].bitmap,NULL,ekran,NULL);
|
||||
SDL_Flip(ekran);
|
||||
}
|
||||
void CPreGame::runLoop()
|
||||
{}
|
33
CPreGame.h
Normal file
33
CPreGame.h
Normal file
@ -0,0 +1,33 @@
|
||||
#include "SDL.h"
|
||||
#include "CSemiDefHandler.h"
|
||||
#include "CSemiLodHandler.h"
|
||||
struct AnimatedPic
|
||||
{
|
||||
std::vector<SDL_Surface*> frames;
|
||||
~AnimatedPic()
|
||||
{
|
||||
for (int i=0;i<frames.size();i++)
|
||||
{
|
||||
SDL_FreeSurface(frames[i]);
|
||||
delete frames[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
class CPreGame
|
||||
{
|
||||
public:
|
||||
enum EState { //where are we?
|
||||
mainMenu, ScenarioList
|
||||
} state;
|
||||
struct menuItems {
|
||||
SDL_Surface * background;
|
||||
CSemiDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
|
||||
SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
|
||||
} * ourMainMenu;
|
||||
std::string map; //selected map
|
||||
std::vector<CSemiLodHandler *> handledLods;
|
||||
CPreGame(); //c-tor
|
||||
void showMainMenu();
|
||||
void runLoop(); // runs mainloop of PreGame
|
||||
void initMainMenu(); //loads components for main menu
|
||||
};
|
@ -58,10 +58,10 @@ std::string CSemiDefHandler::nameFromType (EterrainType typ)
|
||||
}
|
||||
}
|
||||
}
|
||||
void CSemiDefHandler::openDef(const char *name)
|
||||
void CSemiDefHandler::openDef(std::string name, std::string lodName)
|
||||
{
|
||||
std::ifstream * is = new std::ifstream();
|
||||
is -> open(name,std::ios::binary);
|
||||
is -> open((lodName+"\\"+name).c_str(),std::ios::binary);
|
||||
is->seekg(0,std::ios::end); // na koniec
|
||||
int andame = is->tellg(); // read length
|
||||
is->seekg(0,std::ios::beg); // wracamy na poczatek
|
||||
@ -73,7 +73,7 @@ void CSemiDefHandler::openDef(const char *name)
|
||||
delete is;
|
||||
|
||||
readFileList();
|
||||
loadImages();
|
||||
loadImages(lodName);
|
||||
|
||||
}
|
||||
void CSemiDefHandler::readFileList()
|
||||
@ -96,11 +96,11 @@ void CSemiDefHandler::readFileList()
|
||||
else pom--;
|
||||
}
|
||||
}
|
||||
void CSemiDefHandler::loadImages()
|
||||
void CSemiDefHandler::loadImages(std::string path)
|
||||
{
|
||||
for (int i=0; i<namesOfImgs.size(); i++)
|
||||
{
|
||||
openImg(("H3sprite.lod\\_"+defName+"\\"+namesOfImgs[i]).c_str());
|
||||
openImg((path+"\\_"+defName+"\\"+namesOfImgs[i]).c_str());
|
||||
}
|
||||
}
|
||||
void SDL_DisplayBitmap(const char *file, SDL_Surface *ekran, int x, int y)
|
||||
@ -133,6 +133,7 @@ void CSemiDefHandler::openImg(const char *name)
|
||||
}
|
||||
Cimage vinya;
|
||||
vinya.bitmap = image;
|
||||
SDL_SetColorKey(vinya.bitmap,SDL_SRCCOLORKEY,SDL_MapRGB(vinya.bitmap->format,0,255,255));
|
||||
vinya.imName = name;
|
||||
ourImages.push_back(vinya);
|
||||
}
|
@ -21,8 +21,8 @@ public:
|
||||
|
||||
static std::string nameFromType(EterrainType typ);
|
||||
void openImg(const char *name);
|
||||
void openDef(const char *name);
|
||||
void openDef(std::string name, std::string lodName);
|
||||
void readFileList();
|
||||
void loadImages();
|
||||
void loadImages(std::string path);
|
||||
};
|
||||
#endif // SEMIDEF_H
|
12
CSemiLodHandler.cpp
Normal file
12
CSemiLodHandler.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "stdafx.h"
|
||||
#include "CSemiLodHandler.h"
|
||||
void CSemiLodHandler::openLod(std::string path)
|
||||
{
|
||||
ourName = path;
|
||||
};
|
||||
CSemiDefHandler * CSemiLodHandler::giveDef(std::string name)
|
||||
{
|
||||
CSemiDefHandler * ret = new CSemiDefHandler();
|
||||
ret->openDef(name, ourName);
|
||||
return ret;
|
||||
};
|
8
CSemiLodHandler.h
Normal file
8
CSemiLodHandler.h
Normal file
@ -0,0 +1,8 @@
|
||||
#include "CSemiDefHandler.h"
|
||||
class CSemiLodHandler
|
||||
{
|
||||
public:
|
||||
std::string ourName; // name of our lod
|
||||
void openLod(std::string path);
|
||||
CSemiDefHandler * giveDef(std::string name); //loads def from our lod
|
||||
};
|
Loading…
Reference in New Issue
Block a user