mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
* VCMI no longer needs h3bitmap and h3sprite folders - delete them. Now everything is readed directly from lod files
* names of lods changed - rename your lod files to h3sprite.lod and h3bitmap.lod and place them in \Data subfolder (as in H3). * added several clickable buttons to adv. map interface * underground/surface switch button is functional * reading more text from ZELP.txt, added CPreGameTextHandler to CGameInfo * a lot of minor improvements/fixes(/bugs)
This commit is contained in:
parent
ae279c79c5
commit
6b0f209626
@ -1,36 +1,57 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CAdvmapInterface.h"
|
#include "CAdvmapInterface.h"
|
||||||
|
|
||||||
CAdvMapInt::CAdvMapInt(int Player)
|
|
||||||
:player(Player)
|
|
||||||
{
|
|
||||||
bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
|
|
||||||
blueToPlayersAdv(bg,player);
|
|
||||||
scrollingLeft = false;
|
|
||||||
scrollingRight = false;
|
|
||||||
scrollingUp = false ;
|
|
||||||
scrollingDown = false ;
|
|
||||||
updateScreen = false;
|
|
||||||
anim=0;
|
|
||||||
animValHitCount=0; //animation frame
|
|
||||||
|
|
||||||
gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
|
|
||||||
gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
|
|
||||||
gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
|
|
||||||
gems.push_back(CGI->spriteh->giveDef("agemUR.def"));
|
|
||||||
}
|
|
||||||
CAdvMapInt::~CAdvMapInt()
|
CAdvMapInt::~CAdvMapInt()
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(bg);
|
SDL_FreeSurface(bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdventureMapButton::AdventureMapButton ()
|
||||||
|
{
|
||||||
|
type=2;
|
||||||
|
abs=true;
|
||||||
|
active=false;
|
||||||
|
ourObj=NULL;
|
||||||
|
state=0;
|
||||||
|
}
|
||||||
|
AdventureMapButton::AdventureMapButton
|
||||||
|
( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ )
|
||||||
|
{
|
||||||
|
type=2;
|
||||||
|
abs=true;
|
||||||
|
active=false;
|
||||||
|
ourObj=NULL;
|
||||||
|
state=0;
|
||||||
|
int est = LOCPLINT->playerID;
|
||||||
|
CDefHandler * temp = CGI->spriteh->giveDef(defName); //todo: moze cieknac
|
||||||
|
for (int i=0;i<temp->ourImages.size();i++)
|
||||||
|
{
|
||||||
|
imgs.push_back(temp->ourImages[i].bitmap);
|
||||||
|
blueToPlayersAdv(imgs[i],LOCPLINT->playerID);
|
||||||
|
}
|
||||||
|
function = Function;
|
||||||
|
pos.x=x;
|
||||||
|
pos.y=y;
|
||||||
|
pos.w = imgs[0]->w;
|
||||||
|
pos.h = imgs[0]->h;
|
||||||
|
if (activ)
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
|
||||||
void AdventureMapButton::clickLeft (tribool down)
|
void AdventureMapButton::clickLeft (tribool down)
|
||||||
{
|
{
|
||||||
if (down)
|
if (down)
|
||||||
|
{
|
||||||
state=1;
|
state=1;
|
||||||
else state=0;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state=0;
|
||||||
|
}
|
||||||
show();
|
show();
|
||||||
int i;
|
if (pressedL && (down==false))
|
||||||
|
(LOCPLINT->adventureInt->*function)();
|
||||||
|
pressedL=state;
|
||||||
}
|
}
|
||||||
void AdventureMapButton::clickRight (tribool down)
|
void AdventureMapButton::clickRight (tribool down)
|
||||||
{
|
{
|
||||||
@ -42,6 +63,8 @@ void AdventureMapButton::hover (bool on)
|
|||||||
}
|
}
|
||||||
void AdventureMapButton::activate()
|
void AdventureMapButton::activate()
|
||||||
{
|
{
|
||||||
|
if (active) return;
|
||||||
|
active=true;
|
||||||
ClickableL::activate();
|
ClickableL::activate();
|
||||||
Hoverable::activate();
|
Hoverable::activate();
|
||||||
KeyInterested::activate();
|
KeyInterested::activate();
|
||||||
@ -52,18 +75,13 @@ void AdventureMapButton::keyPressed (SDL_KeyboardEvent & key)
|
|||||||
}
|
}
|
||||||
void AdventureMapButton::deactivate()
|
void AdventureMapButton::deactivate()
|
||||||
{
|
{
|
||||||
|
if (!active) return;
|
||||||
|
active=false;
|
||||||
ClickableL::deactivate();
|
ClickableL::deactivate();
|
||||||
Hoverable::deactivate();
|
Hoverable::deactivate();
|
||||||
KeyInterested::deactivate();
|
KeyInterested::deactivate();
|
||||||
}
|
}
|
||||||
AdventureMapButton::AdventureMapButton ()
|
|
||||||
{
|
|
||||||
type=2;
|
|
||||||
abs=true;
|
|
||||||
active=false;
|
|
||||||
ourObj=NULL;
|
|
||||||
state=0;
|
|
||||||
}
|
|
||||||
void CList::activate()
|
void CList::activate()
|
||||||
{
|
{
|
||||||
ClickableL::activate();
|
ClickableL::activate();
|
||||||
@ -81,7 +99,13 @@ void CList::deactivate()
|
|||||||
void CList::clickLeft(tribool down)
|
void CList::clickLeft(tribool down)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
void CStatusBar::print(std::string text)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void CStatusBar::show()
|
||||||
|
{
|
||||||
|
}
|
||||||
void CTerrainRect::activate()
|
void CTerrainRect::activate()
|
||||||
{
|
{
|
||||||
ClickableL::activate();
|
ClickableL::activate();
|
||||||
@ -103,22 +127,130 @@ void CTerrainRect::keyPressed (SDL_KeyboardEvent & key){}
|
|||||||
void CTerrainRect::show()
|
void CTerrainRect::show()
|
||||||
{
|
{
|
||||||
SDL_Surface * teren = CGI->mh->terrainRect
|
SDL_Surface * teren = CGI->mh->terrainRect
|
||||||
(CURPLINT->adventureInt->position.x,CURPLINT->adventureInt->position.y,
|
(LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
|
||||||
19,18,CURPLINT->adventureInt->position.z,CURPLINT->adventureInt->anim);
|
19,18,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim);
|
||||||
SDL_BlitSurface(teren,&genRect(547,594,0,0),ekran,&genRect(547,594,7,6));
|
SDL_BlitSurface(teren,&genRect(547,594,0,0),ekran,&genRect(547,594,7,6));
|
||||||
SDL_FreeSurface(teren);
|
SDL_FreeSurface(teren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAdvMapInt::CAdvMapInt(int Player)
|
||||||
|
:player(Player),
|
||||||
|
statusbar(8,556),
|
||||||
|
kingOverview(CGI->preth->advKingdomOverview.first,CGI->preth->advKingdomOverview.second,
|
||||||
|
&CAdvMapInt::fshowOverview, 679, 196, "IAM002.DEF"),
|
||||||
|
|
||||||
|
undeground(CGI->preth->advSurfaceSwitch.first,CGI->preth->advSurfaceSwitch.second,
|
||||||
|
&CAdvMapInt::fswitchLevel, 711, 196, "IAM003.DEF"),
|
||||||
|
|
||||||
|
questlog(CGI->preth->advQuestlog.first,CGI->preth->advQuestlog.second,
|
||||||
|
&CAdvMapInt::fshowQuestlog, 679, 228, "IAM004.DEF"),
|
||||||
|
|
||||||
|
sleepWake(CGI->preth->advSleepWake.first,CGI->preth->advSleepWake.second,
|
||||||
|
&CAdvMapInt::fsleepWake, 711, 228, "IAM005.DEF"),
|
||||||
|
|
||||||
|
moveHero(CGI->preth->advMoveHero.first,CGI->preth->advMoveHero.second,
|
||||||
|
&CAdvMapInt::fmoveHero, 679, 260, "IAM006.DEF"),
|
||||||
|
|
||||||
|
spellbook(CGI->preth->advCastSpell.first,CGI->preth->advCastSpell.second,
|
||||||
|
&CAdvMapInt::fshowSpellbok, 711, 260, "IAM007.DEF"),
|
||||||
|
|
||||||
|
advOptions(CGI->preth->advAdvOptions.first,CGI->preth->advAdvOptions.second,
|
||||||
|
&CAdvMapInt::fadventureOPtions, 679, 292, "IAM008.DEF"),
|
||||||
|
|
||||||
|
sysOptions(CGI->preth->advSystemOptions.first,CGI->preth->advSystemOptions.second,
|
||||||
|
&CAdvMapInt::fsystemOptions, 711, 292, "IAM009.DEF"),
|
||||||
|
|
||||||
|
nextHero(CGI->preth->advNextHero.first,CGI->preth->advNextHero.second,
|
||||||
|
&CAdvMapInt::fnextHero, 679, 324, "IAM000.DEF"),
|
||||||
|
|
||||||
|
endTurn(CGI->preth->advEndTurn.first,CGI->preth->advEndTurn.second,
|
||||||
|
&CAdvMapInt::fendTurn, 679, 356, "IAM001.DEF")
|
||||||
|
{
|
||||||
|
bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
|
||||||
|
blueToPlayersAdv(bg,player);
|
||||||
|
scrollingLeft = false;
|
||||||
|
scrollingRight = false;
|
||||||
|
scrollingUp = false ;
|
||||||
|
scrollingDown = false ;
|
||||||
|
updateScreen = false;
|
||||||
|
anim=0;
|
||||||
|
animValHitCount=0; //animation frame
|
||||||
|
|
||||||
|
gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
|
||||||
|
gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
|
||||||
|
gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
|
||||||
|
gems.push_back(CGI->spriteh->giveDef("agemUR.def"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAdvMapInt::fshowOverview()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fswitchLevel()
|
||||||
|
{
|
||||||
|
if(!CGI->ac->map.twoLevel)
|
||||||
|
return;
|
||||||
|
if (position.z)
|
||||||
|
position.z--;
|
||||||
|
else position.z++;
|
||||||
|
updateScreen = true;
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fshowQuestlog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fsleepWake()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fmoveHero()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fshowSpellbok()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fadventureOPtions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fsystemOptions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fnextHero()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void CAdvMapInt::fendTurn()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void CAdvMapInt::show()
|
void CAdvMapInt::show()
|
||||||
{
|
{
|
||||||
blitAt(bg,0,0);
|
blitAt(bg,0,0);
|
||||||
|
|
||||||
|
kingOverview.show();
|
||||||
|
kingOverview.activate();
|
||||||
|
undeground.show();
|
||||||
|
undeground.activate();
|
||||||
|
questlog.show();
|
||||||
|
questlog.activate();
|
||||||
|
sleepWake.show();
|
||||||
|
sleepWake.activate();
|
||||||
|
moveHero.show();
|
||||||
|
moveHero.activate();
|
||||||
|
spellbook.show();
|
||||||
|
spellbook.activate();
|
||||||
|
advOptions.show();
|
||||||
|
advOptions.activate();
|
||||||
|
sysOptions.show();
|
||||||
|
sysOptions.activate();
|
||||||
|
nextHero.show();
|
||||||
|
nextHero.activate();
|
||||||
|
endTurn.show();
|
||||||
|
endTurn.activate();
|
||||||
SDL_Flip(ekran);
|
SDL_Flip(ekran);
|
||||||
}
|
}
|
||||||
void CAdvMapInt::update()
|
void CAdvMapInt::update()
|
||||||
{
|
{
|
||||||
terrain.show();
|
terrain.show();
|
||||||
blitAt(gems[2]->ourImages[CURPLINT->playerID].bitmap,6,6);
|
blitAt(gems[2]->ourImages[LOCPLINT->playerID].bitmap,6,6);
|
||||||
blitAt(gems[0]->ourImages[CURPLINT->playerID].bitmap,6,508);
|
blitAt(gems[0]->ourImages[LOCPLINT->playerID].bitmap,6,508);
|
||||||
blitAt(gems[1]->ourImages[CURPLINT->playerID].bitmap,556,508);
|
blitAt(gems[1]->ourImages[LOCPLINT->playerID].bitmap,556,508);
|
||||||
blitAt(gems[3]->ourImages[CURPLINT->playerID].bitmap,556,6);
|
blitAt(gems[3]->ourImages[LOCPLINT->playerID].bitmap,556,6);
|
||||||
updateRect(&genRect(550,600,6,6));
|
updateRect(&genRect(550,600,6,6));
|
||||||
}
|
}
|
@ -28,12 +28,12 @@ public:
|
|||||||
void deactivate(); // makes button inactive (but don't deletes)
|
void deactivate(); // makes button inactive (but don't deletes)
|
||||||
|
|
||||||
AdventureMapButton(); //c-tor
|
AdventureMapButton(); //c-tor
|
||||||
AdventureMapButton( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)() );//c-tor
|
AdventureMapButton( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ=false );//c-tor
|
||||||
|
|
||||||
};
|
};
|
||||||
/*****************************/
|
/*****************************/
|
||||||
class CList
|
class CList
|
||||||
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CIntObject
|
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject
|
||||||
{
|
{
|
||||||
SDL_Surface * bg;
|
SDL_Surface * bg;
|
||||||
//arrow up, arrow down
|
//arrow up, arrow down
|
||||||
@ -75,8 +75,14 @@ class CStatusBar
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDL_Surface * bg;
|
SDL_Surface * bg;
|
||||||
|
SDL_Surface * temp;
|
||||||
|
int tx, ty;
|
||||||
std::string current;
|
std::string current;
|
||||||
|
|
||||||
|
CStatusBar(int x, int y)
|
||||||
|
{bg=CGI->bitmaph->loadBitmap("ADROLLVR.bmp");pos.x=x;pos.y=y;pos.w=bg->w;pos.h=bg->h;temp=NULL;}
|
||||||
void print(std::string text);
|
void print(std::string text);
|
||||||
|
void show();
|
||||||
};
|
};
|
||||||
class CMinimap
|
class CMinimap
|
||||||
: public ClickableL, public ClickableR, public Hoverable, public CIntObject
|
: public ClickableL, public ClickableR, public Hoverable, public CIntObject
|
||||||
@ -138,11 +144,24 @@ public:
|
|||||||
endTurn;//- end turn
|
endTurn;//- end turn
|
||||||
//CHeroList herolist;
|
//CHeroList herolist;
|
||||||
|
|
||||||
CTerrainRect terrain;
|
CTerrainRect terrain; //visible terrain
|
||||||
|
|
||||||
void show();
|
CStatusBar statusbar;
|
||||||
|
|
||||||
void update();
|
//fuctions binded to buttons
|
||||||
|
void fshowOverview();
|
||||||
|
void fswitchLevel();
|
||||||
|
void fshowQuestlog();
|
||||||
|
void fsleepWake();
|
||||||
|
void fmoveHero();
|
||||||
|
void fshowSpellbok();
|
||||||
|
void fadventureOPtions();
|
||||||
|
void fsystemOptions();
|
||||||
|
void fnextHero();
|
||||||
|
void fendTurn();
|
||||||
|
|
||||||
|
void show(); //shows and activates adv. map interface
|
||||||
|
void update(); //redraws terrain
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
CSpellHandler * spellh;
|
CSpellHandler * spellh;
|
||||||
CMapHandler * mh;
|
CMapHandler * mh;
|
||||||
CAmbarCendamo * ac;
|
CAmbarCendamo * ac;
|
||||||
|
CPreGameTextHandler * preth ;
|
||||||
CBuildingHandler * buildh;
|
CBuildingHandler * buildh;
|
||||||
CObjectHandler * objh;
|
CObjectHandler * objh;
|
||||||
CMusicHandler * mush;
|
CMusicHandler * mush;
|
||||||
@ -50,6 +51,7 @@ public:
|
|||||||
CLodHandler * spriteh;
|
CLodHandler * spriteh;
|
||||||
CLodHandler * bitmaph;
|
CLodHandler * bitmaph;
|
||||||
CGeneralTextHandler * generaltexth;
|
CGeneralTextHandler * generaltexth;
|
||||||
|
int localPlayer;
|
||||||
std::vector<CGameInterface *> playerint;
|
std::vector<CGameInterface *> playerint;
|
||||||
std::vector<SDL_Color> playerColors;
|
std::vector<SDL_Color> playerColors;
|
||||||
SDL_Color neutralColor;
|
SDL_Color neutralColor;
|
||||||
|
@ -15,7 +15,7 @@ CButtonBase::CButtonBase()
|
|||||||
}
|
}
|
||||||
void CButtonBase::show()
|
void CButtonBase::show()
|
||||||
{
|
{
|
||||||
if (!abs)
|
if (abs)
|
||||||
{
|
{
|
||||||
blitAt(imgs[state],pos.x,pos.y);
|
blitAt(imgs[state],pos.x,pos.y);
|
||||||
updateRect(&pos);
|
updateRect(&pos);
|
||||||
@ -29,108 +29,115 @@ void CButtonBase::show()
|
|||||||
}
|
}
|
||||||
void ClickableL::activate()
|
void ClickableL::activate()
|
||||||
{
|
{
|
||||||
CURPLINT->lclickable.push_back(this);
|
LOCPLINT->lclickable.push_back(this);
|
||||||
}
|
}
|
||||||
void ClickableL::deactivate()
|
void ClickableL::deactivate()
|
||||||
{
|
{
|
||||||
CURPLINT->lclickable.erase
|
LOCPLINT->lclickable.erase
|
||||||
(std::find(CURPLINT->lclickable.begin(),CURPLINT->lclickable.end(),this));
|
(std::find(LOCPLINT->lclickable.begin(),LOCPLINT->lclickable.end(),this));
|
||||||
}
|
}
|
||||||
void ClickableR::activate()
|
void ClickableR::activate()
|
||||||
{
|
{
|
||||||
CURPLINT->rclickable.push_back(this);
|
LOCPLINT->rclickable.push_back(this);
|
||||||
}
|
}
|
||||||
void ClickableR::deactivate()
|
void ClickableR::deactivate()
|
||||||
{
|
{
|
||||||
CURPLINT->rclickable.erase(std::find(CURPLINT->rclickable.begin(),CURPLINT->rclickable.end(),this));
|
LOCPLINT->rclickable.erase(std::find(LOCPLINT->rclickable.begin(),LOCPLINT->rclickable.end(),this));
|
||||||
}
|
}
|
||||||
void Hoverable::activate()
|
void Hoverable::activate()
|
||||||
{
|
{
|
||||||
CURPLINT->hoverable.push_back(this);
|
LOCPLINT->hoverable.push_back(this);
|
||||||
}
|
}
|
||||||
void Hoverable::deactivate()
|
void Hoverable::deactivate()
|
||||||
{
|
{
|
||||||
CURPLINT->hoverable.erase(std::find(CURPLINT->hoverable.begin(),CURPLINT->hoverable.end(),this));
|
LOCPLINT->hoverable.erase(std::find(LOCPLINT->hoverable.begin(),LOCPLINT->hoverable.end(),this));
|
||||||
}
|
}
|
||||||
void KeyInterested::activate()
|
void KeyInterested::activate()
|
||||||
{
|
{
|
||||||
CURPLINT->keyinterested.push_back(this);
|
LOCPLINT->keyinterested.push_back(this);
|
||||||
}
|
}
|
||||||
void KeyInterested::deactivate()
|
void KeyInterested::deactivate()
|
||||||
{
|
{
|
||||||
CURPLINT->
|
LOCPLINT->
|
||||||
keyinterested.erase(std::find(CURPLINT->keyinterested.begin(),CURPLINT->keyinterested.end(),this));
|
keyinterested.erase(std::find(LOCPLINT->keyinterested.begin(),LOCPLINT->keyinterested.end(),this));
|
||||||
}
|
}
|
||||||
CPlayerInterface::CPlayerInterface(int Player)
|
CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||||
{
|
{
|
||||||
playerID=Player;
|
playerID=Player;
|
||||||
|
serialID=serial;
|
||||||
|
CGI->localPlayer = playerID;
|
||||||
human=true;
|
human=true;
|
||||||
adventureInt = new CAdvMapInt(Player);
|
}
|
||||||
|
void CPlayerInterface::init()
|
||||||
|
{
|
||||||
|
CGI->localPlayer = serialID;
|
||||||
|
adventureInt = new CAdvMapInt(playerID);
|
||||||
}
|
}
|
||||||
void CPlayerInterface::yourTurn()
|
void CPlayerInterface::yourTurn()
|
||||||
{
|
{
|
||||||
unsigned char & animVal = CURPLINT->adventureInt->anim; //for animations handling
|
CGI->localPlayer = serialID;
|
||||||
|
unsigned char & animVal = LOCPLINT->adventureInt->anim; //for animations handling
|
||||||
adventureInt->show();
|
adventureInt->show();
|
||||||
//show rest of things
|
//show rest of things
|
||||||
|
|
||||||
//initializing framerate keeper
|
//initializing framerate keeper
|
||||||
FPSmanager * mainLoopFramerateKeeper = new FPSmanager;
|
FPSmanager * mainLoopFramerateKeeper = new FPSmanager;
|
||||||
SDL_initFramerate(mainLoopFramerateKeeper);
|
SDL_initFramerate(mainLoopFramerateKeeper);
|
||||||
SDL_setFramerate(mainLoopFramerateKeeper, 30);
|
SDL_setFramerate(mainLoopFramerateKeeper, 24);
|
||||||
SDL_Event sEvent;
|
SDL_Event sEvent;
|
||||||
//framerate keeper initialized
|
//framerate keeper initialized
|
||||||
for(;;) // main loop
|
for(;;) // main loop
|
||||||
{
|
{
|
||||||
|
|
||||||
CURPLINT->adventureInt->updateScreen = false;
|
LOCPLINT->adventureInt->updateScreen = false;
|
||||||
if(SDL_PollEvent(&sEvent)) //wait for event...
|
if(SDL_PollEvent(&sEvent)) //wait for event...
|
||||||
{
|
{
|
||||||
handleEvent(&sEvent);
|
handleEvent(&sEvent);
|
||||||
}
|
}
|
||||||
++CURPLINT->adventureInt->animValHitCount; //for animations
|
++LOCPLINT->adventureInt->animValHitCount; //for animations
|
||||||
if(CURPLINT->adventureInt->animValHitCount == 2)
|
if(LOCPLINT->adventureInt->animValHitCount == 2)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->animValHitCount = 0;
|
LOCPLINT->adventureInt->animValHitCount = 0;
|
||||||
++animVal;
|
++animVal;
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
LOCPLINT->adventureInt->updateScreen = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(CURPLINT->adventureInt->scrollingLeft)
|
if(LOCPLINT->adventureInt->scrollingLeft)
|
||||||
{
|
{
|
||||||
if(CURPLINT->adventureInt->position.x>0)
|
if(LOCPLINT->adventureInt->position.x>0)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->position.x--;
|
LOCPLINT->adventureInt->position.x--;
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
LOCPLINT->adventureInt->updateScreen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CURPLINT->adventureInt->scrollingRight)
|
if(LOCPLINT->adventureInt->scrollingRight)
|
||||||
{
|
{
|
||||||
if(CURPLINT->adventureInt->position.x<CGI->ac->map.width-19+8)
|
if(LOCPLINT->adventureInt->position.x<CGI->ac->map.width-19+8)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->position.x++;
|
LOCPLINT->adventureInt->position.x++;
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
LOCPLINT->adventureInt->updateScreen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CURPLINT->adventureInt->scrollingUp)
|
if(LOCPLINT->adventureInt->scrollingUp)
|
||||||
{
|
{
|
||||||
if(CURPLINT->adventureInt->position.y>0)
|
if(LOCPLINT->adventureInt->position.y>0)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->position.y--;
|
LOCPLINT->adventureInt->position.y--;
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
LOCPLINT->adventureInt->updateScreen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CURPLINT->adventureInt->scrollingDown)
|
if(LOCPLINT->adventureInt->scrollingDown)
|
||||||
{
|
{
|
||||||
if(CURPLINT->adventureInt->position.y<CGI->ac->map.height-18+8)
|
if(LOCPLINT->adventureInt->position.y<CGI->ac->map.height-18+8)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->position.y++;
|
LOCPLINT->adventureInt->position.y++;
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
LOCPLINT->adventureInt->updateScreen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CURPLINT->adventureInt->updateScreen)
|
if(LOCPLINT->adventureInt->updateScreen)
|
||||||
{
|
{
|
||||||
adventureInt->update();
|
adventureInt->update();
|
||||||
CURPLINT->adventureInt->updateScreen=false;
|
LOCPLINT->adventureInt->updateScreen=false;
|
||||||
}
|
}
|
||||||
SDL_Delay(5); //give time for other apps
|
SDL_Delay(5); //give time for other apps
|
||||||
SDL_framerateDelay(mainLoopFramerateKeeper);
|
SDL_framerateDelay(mainLoopFramerateKeeper);
|
||||||
@ -151,22 +158,22 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
|
|||||||
{
|
{
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingLeft = true;
|
LOCPLINT->adventureInt->scrollingLeft = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_RIGHT):
|
case (SDLK_RIGHT):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingRight = true;
|
LOCPLINT->adventureInt->scrollingRight = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_UP):
|
case (SDLK_UP):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingUp = true;
|
LOCPLINT->adventureInt->scrollingUp = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_DOWN):
|
case (SDLK_DOWN):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingDown = true;
|
LOCPLINT->adventureInt->scrollingDown = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_q):
|
case (SDLK_q):
|
||||||
@ -176,13 +183,7 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
|
|||||||
}
|
}
|
||||||
case (SDLK_u):
|
case (SDLK_u):
|
||||||
{
|
{
|
||||||
if(!CGI->ac->map.twoLevel)
|
adventureInt->undeground.clickLeft(true);
|
||||||
break;
|
|
||||||
if (adventureInt->position.z)
|
|
||||||
adventureInt->position.z--;
|
|
||||||
else adventureInt->position.z++;
|
|
||||||
CURPLINT->adventureInt->updateScreen = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //keydown end
|
} //keydown end
|
||||||
@ -192,59 +193,99 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
|
|||||||
{
|
{
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingLeft = false;
|
LOCPLINT->adventureInt->scrollingLeft = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_RIGHT):
|
case (SDLK_RIGHT):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingRight = false;
|
LOCPLINT->adventureInt->scrollingRight = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_UP):
|
case (SDLK_UP):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingUp = false;
|
LOCPLINT->adventureInt->scrollingUp = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_DOWN):
|
case (SDLK_DOWN):
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingDown = false;
|
LOCPLINT->adventureInt->scrollingDown = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (SDLK_u):
|
||||||
|
{
|
||||||
|
adventureInt->undeground.clickLeft(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}//keyup end
|
}//keyup end
|
||||||
else if(sEvent->type==SDL_MOUSEMOTION)
|
else if(sEvent->type==SDL_MOUSEMOTION)
|
||||||
{
|
{
|
||||||
|
for (int i=0; i<hoverable.size();i++)
|
||||||
|
{
|
||||||
|
if (isItIn(&hoverable[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
||||||
|
{
|
||||||
|
if (!hoverable[i]->hovered)
|
||||||
|
hoverable[i]->hover(true);
|
||||||
|
}
|
||||||
|
else if (hoverable[i]->hovered)
|
||||||
|
{
|
||||||
|
hoverable[i]->hover(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(sEvent->motion.x<15)
|
if(sEvent->motion.x<15)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingLeft = true;
|
LOCPLINT->adventureInt->scrollingLeft = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingLeft = false;
|
LOCPLINT->adventureInt->scrollingLeft = false;
|
||||||
}
|
}
|
||||||
if(sEvent->motion.x>ekran->w-15)
|
if(sEvent->motion.x>ekran->w-15)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingRight = true;
|
LOCPLINT->adventureInt->scrollingRight = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingRight = false;
|
LOCPLINT->adventureInt->scrollingRight = false;
|
||||||
}
|
}
|
||||||
if(sEvent->motion.y<15)
|
if(sEvent->motion.y<15)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingUp = true;
|
LOCPLINT->adventureInt->scrollingUp = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingUp = false;
|
LOCPLINT->adventureInt->scrollingUp = false;
|
||||||
}
|
}
|
||||||
if(sEvent->motion.y>ekran->h-15)
|
if(sEvent->motion.y>ekran->h-15)
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingDown = true;
|
LOCPLINT->adventureInt->scrollingDown = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CURPLINT->adventureInt->scrollingDown = false;
|
LOCPLINT->adventureInt->scrollingDown = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if ((sEvent->type==SDL_MOUSEBUTTONDOWN) && (sEvent->button.button == SDL_BUTTON_LEFT))
|
||||||
|
{
|
||||||
|
for(int i=0; i<lclickable.size();i++)
|
||||||
|
{
|
||||||
|
if (isItIn(&lclickable[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
||||||
|
{
|
||||||
|
lclickable[i]->clickLeft(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT))
|
||||||
|
{
|
||||||
|
for(int i=0; i<lclickable.size();i++)
|
||||||
|
{
|
||||||
|
if (isItIn(&lclickable[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
||||||
|
{
|
||||||
|
lclickable[i]->clickLeft(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lclickable[i]->clickLeft(boost::logic::indeterminate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //event end
|
} //event end
|
@ -15,7 +15,7 @@ public:
|
|||||||
SDL_Rect pos;
|
SDL_Rect pos;
|
||||||
int ID;
|
int ID;
|
||||||
};
|
};
|
||||||
class CButtonBase : public CIntObject
|
class CButtonBase : public virtual CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int type; //advmapbutton=2
|
int type; //advmapbutton=2
|
||||||
@ -29,23 +29,23 @@ public:
|
|||||||
virtual void deactivate()=0;
|
virtual void deactivate()=0;
|
||||||
CButtonBase();
|
CButtonBase();
|
||||||
};
|
};
|
||||||
class ClickableL //for left-clicks
|
class ClickableL : public virtual CIntObject //for left-clicks
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool pressed;
|
bool pressedL;
|
||||||
virtual void clickLeft (tribool down)=0;
|
virtual void clickLeft (tribool down)=0;
|
||||||
virtual void activate()=0;
|
virtual void activate()=0;
|
||||||
virtual void deactivate()=0;
|
virtual void deactivate()=0;
|
||||||
};
|
};
|
||||||
class ClickableR //for right-clicks
|
class ClickableR : public virtual CIntObject //for right-clicks
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool pressed;
|
bool pressedR;
|
||||||
virtual void clickRight (tribool down)=0;
|
virtual void clickRight (tribool down)=0;
|
||||||
virtual void activate()=0;
|
virtual void activate()=0;
|
||||||
virtual void deactivate()=0;
|
virtual void deactivate()=0;
|
||||||
};
|
};
|
||||||
class Hoverable
|
class Hoverable : public virtual CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool hovered;
|
bool hovered;
|
||||||
@ -53,7 +53,7 @@ public:
|
|||||||
virtual void activate()=0;
|
virtual void activate()=0;
|
||||||
virtual void deactivate()=0;
|
virtual void deactivate()=0;
|
||||||
};
|
};
|
||||||
class KeyInterested
|
class KeyInterested : public virtual CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void keyPressed (SDL_KeyboardEvent & key)=0;
|
virtual void keyPressed (SDL_KeyboardEvent & key)=0;
|
||||||
@ -64,7 +64,7 @@ class CGameInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool human;
|
bool human;
|
||||||
int playerID;
|
int playerID, serialID;
|
||||||
|
|
||||||
virtual void yourTurn()=0{};
|
virtual void yourTurn()=0{};
|
||||||
};
|
};
|
||||||
@ -86,7 +86,8 @@ public:
|
|||||||
|
|
||||||
void yourTurn();
|
void yourTurn();
|
||||||
void handleEvent(SDL_Event * sEvent);
|
void handleEvent(SDL_Event * sEvent);
|
||||||
|
void init();
|
||||||
|
|
||||||
CPlayerInterface(int Player);
|
CPlayerInterface(int Player, int serial);
|
||||||
};
|
};
|
||||||
#endif //CGAMEINTERFACE_H
|
#endif //CGAMEINTERFACE_H
|
12
CMT.cpp
12
CMT.cpp
@ -240,9 +240,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
|
|
||||||
THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
|
THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
|
||||||
cgi->spriteh = new CLodHandler;
|
cgi->spriteh = new CLodHandler;
|
||||||
cgi->spriteh->init(std::string("newH3sprite.lod"));
|
cgi->spriteh->init(std::string("Data\\H3sprite.lod"));
|
||||||
cgi->bitmaph = new CLodHandler;
|
cgi->bitmaph = new CLodHandler;
|
||||||
cgi->bitmaph->init(std::string("newH3bitmap.lod"));
|
cgi->bitmaph->init(std::string("Data\\H3bitmap.lod"));
|
||||||
|
|
||||||
//colors initialization
|
//colors initialization
|
||||||
SDL_Color p;
|
SDL_Color p;
|
||||||
@ -366,7 +366,11 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
{
|
{
|
||||||
if(cgi->scenarioOps.playerInfos[i].name=="AI")
|
if(cgi->scenarioOps.playerInfos[i].name=="AI")
|
||||||
cgi->playerint.push_back(new CGlobalAI());
|
cgi->playerint.push_back(new CGlobalAI());
|
||||||
else cgi->playerint.push_back(new CPlayerInterface(cgi->scenarioOps.playerInfos[i].color));
|
else
|
||||||
|
{
|
||||||
|
cgi->playerint.push_back(new CPlayerInterface(cgi->scenarioOps.playerInfos[i].color,i));
|
||||||
|
((CPlayerInterface*)(cgi->playerint[i]))->init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -554,7 +558,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
|
|
||||||
updateScreen = true;
|
updateScreen = true;
|
||||||
++animValHitCount; //for animations
|
++animValHitCount; //for animations
|
||||||
if(animValHitCount == 2)
|
if(animValHitCount == 4)
|
||||||
{
|
{
|
||||||
animValHitCount = 0;
|
animValHitCount = 0;
|
||||||
++animVal;
|
++animVal;
|
||||||
|
@ -1,31 +1,17 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CObjectHandler.h"
|
#include "CObjectHandler.h"
|
||||||
|
#include "CGameInfo.h"
|
||||||
|
#include "CGeneralTextHandler.h"
|
||||||
|
|
||||||
void CObjectHandler::loadObjects()
|
void CObjectHandler::loadObjects()
|
||||||
{
|
{
|
||||||
std::ifstream inp("H3bitmap.lod\\OBJNAMES.TXT", std::ios::in | std::ios::binary);
|
int ID=0;
|
||||||
inp.seekg(0,std::ios::end); // na koniec
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("OBJNAMES.TXT");
|
||||||
int andame = inp.tellg(); // read length
|
int it=0;
|
||||||
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
while (it<buf.length()-1)
|
||||||
char * bufor = new char[andame]; // allocate memory
|
|
||||||
inp.read((char*)bufor, andame); // read map file to buffer
|
|
||||||
inp.close();
|
|
||||||
std::string buf = std::string(bufor);
|
|
||||||
delete [andame] bufor;
|
|
||||||
int i = 0; //buf iterator
|
|
||||||
while(!inp.eof())
|
|
||||||
{
|
{
|
||||||
if(objects.size()>200 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
|
|
||||||
break;
|
|
||||||
CObject nobj;
|
CObject nobj;
|
||||||
int befi=i;
|
CGeneralTextHandler::loadToIt(nobj.name,buf,it,3);
|
||||||
for(i; i<andame; ++i)
|
|
||||||
{
|
|
||||||
if(buf[i]=='\r')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nobj.name = buf.substr(befi, i-befi);
|
|
||||||
i+=2;
|
|
||||||
objects.push_back(nobj);
|
objects.push_back(nobj);
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
CPreGame.cpp
BIN
CPreGame.cpp
Binary file not shown.
@ -22,18 +22,10 @@ std::string CPreGameTextHandler::getDescr(std::string text)
|
|||||||
}
|
}
|
||||||
void CPreGameTextHandler::loadTexts()
|
void CPreGameTextHandler::loadTexts()
|
||||||
{
|
{
|
||||||
std::ifstream inp("H3bitmap.lod\\ZELP.TXT", std::ios::in|std::ios::binary);
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("ZELP.TXT");
|
||||||
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
|
|
||||||
inp.close();
|
|
||||||
std::string buf = std::string(bufor);
|
|
||||||
delete [andame] bufor;
|
|
||||||
int i=0; //buf iterator
|
int i=0; //buf iterator
|
||||||
int hmcr=0;
|
int hmcr=0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -43,7 +35,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
int befi=i;
|
int befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -52,7 +44,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -62,7 +54,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -71,7 +63,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -81,7 +73,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -90,7 +82,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -100,7 +92,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -109,7 +101,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -119,7 +111,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -128,7 +120,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -138,7 +130,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -147,7 +139,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -157,7 +149,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -166,7 +158,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -176,7 +168,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -185,7 +177,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -195,7 +187,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -204,7 +196,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -214,7 +206,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
i+=3;
|
i+=3;
|
||||||
|
|
||||||
befi=i;
|
befi=i;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\t')
|
if(buf[i]=='\t')
|
||||||
break;
|
break;
|
||||||
@ -223,7 +215,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
++i;
|
++i;
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -399,7 +391,7 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
loadToIt(singleStartingBonusHeaderID, buf, i, 0);
|
loadToIt(singleStartingBonusHeaderID, buf, i, 0);
|
||||||
|
|
||||||
hmcr = 0;
|
hmcr = 0;
|
||||||
for(i; i<andame; ++i)
|
for(i; i<buf.length(); ++i)
|
||||||
{
|
{
|
||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
++hmcr;
|
++hmcr;
|
||||||
@ -425,6 +417,35 @@ void CPreGameTextHandler::loadTexts()
|
|||||||
std::string dump;
|
std::string dump;
|
||||||
loadToIt(dump, buf, i, 1);
|
loadToIt(dump, buf, i, 1);
|
||||||
loadToIt(multiCancel, buf, i, 0);
|
loadToIt(multiCancel, buf, i, 0);
|
||||||
|
loadToIt(dump, buf, i, 0);
|
||||||
|
loadToIt(dump, buf, i, 4);
|
||||||
|
loadToIt(dump, buf, i, 2);
|
||||||
|
|
||||||
|
loadToIt(advWorldMap.first, buf, i, 4);
|
||||||
|
loadToIt(advWorldMap.second, buf, i, 2);
|
||||||
|
loadToIt(advStatusWindow1.first, buf, i, 4);
|
||||||
|
loadToIt(advStatusWindow1.second, buf, i, 2);
|
||||||
|
loadToIt(advKingdomOverview.first, buf, i, 4);
|
||||||
|
loadToIt(advKingdomOverview.second, buf, i, 2);
|
||||||
|
loadToIt(advSurfaceSwitch.first, buf, i, 4);
|
||||||
|
loadToIt(advSurfaceSwitch.second, buf, i, 2);
|
||||||
|
loadToIt(advQuestlog.first, buf, i, 4);
|
||||||
|
loadToIt(advQuestlog.second, buf, i, 2);
|
||||||
|
loadToIt(advSleepWake.first, buf, i, 4);
|
||||||
|
loadToIt(advSleepWake.second, buf, i, 2);
|
||||||
|
loadToIt(advMoveHero.first, buf, i, 4);
|
||||||
|
loadToIt(advMoveHero.second, buf, i, 2);
|
||||||
|
loadToIt(advCastSpell.first, buf, i, 4);
|
||||||
|
loadToIt(advCastSpell.second, buf, i, 2);
|
||||||
|
loadToIt(advAdvOptions.first, buf, i, 4);
|
||||||
|
loadToIt(advAdvOptions.second, buf, i, 2);
|
||||||
|
loadToIt(advSystemOptions.first, buf, i, 4);
|
||||||
|
loadToIt(advSystemOptions.second, buf, i, 2);
|
||||||
|
loadToIt(advNextHero.first, buf, i, 4);
|
||||||
|
loadToIt(advNextHero.second, buf, i, 2);
|
||||||
|
loadToIt(advEndTurn.first, buf, i, 4);
|
||||||
|
loadToIt(advEndTurn.second, buf, i, 2);
|
||||||
|
|
||||||
loadLossConditions();
|
loadLossConditions();
|
||||||
loadVictoryConditions();
|
loadVictoryConditions();
|
||||||
}
|
}
|
||||||
@ -485,6 +506,53 @@ void CPreGameTextHandler::loadToIt(std::string &dest, std::string &src, int &ite
|
|||||||
}
|
}
|
||||||
dest = src.substr(befi, iter-befi);
|
dest = src.substr(befi, iter-befi);
|
||||||
iter+=2;
|
iter+=2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
int befi=iter;
|
||||||
|
for(iter; iter<src.size(); ++iter)
|
||||||
|
{
|
||||||
|
if(src[iter]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dest = src.substr(befi, iter-befi);
|
||||||
|
++iter;
|
||||||
|
|
||||||
|
int hmcr = 0;
|
||||||
|
for(iter; iter<src.size(); ++iter)
|
||||||
|
{
|
||||||
|
if(src[iter]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iter+=2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
int befi=iter;
|
||||||
|
for(iter; iter<src.size(); ++iter)
|
||||||
|
{
|
||||||
|
if(src[iter]=='\r')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dest = src.substr(befi, iter-befi);
|
||||||
|
iter+=2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
int befi=iter;
|
||||||
|
for(iter; iter<src.size(); ++iter)
|
||||||
|
{
|
||||||
|
if(src[iter]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dest = src.substr(befi, iter-befi);
|
||||||
|
iter++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//loadLossConditions();
|
//loadLossConditions();
|
||||||
|
@ -37,8 +37,13 @@ public:
|
|||||||
|
|
||||||
std::string getTitle(std::string text);
|
std::string getTitle(std::string text);
|
||||||
std::string getDescr(std::string text);
|
std::string getDescr(std::string text);
|
||||||
|
|
||||||
|
std::pair<std::string, std::string> //first is statusbar text, second right-click help; they're all for adventure map interface
|
||||||
|
advKingdomOverview, advSurfaceSwitch, advQuestlog, advSleepWake, advMoveHero, advCastSpell, advAdvOptions, advSystemOptions, advNextHero, advEndTurn, //buttons
|
||||||
|
advWorldMap, advStatusWindow1;
|
||||||
|
|
||||||
void loadTexts();
|
void loadTexts();
|
||||||
void loadToIt(std::string & dest, std::string & src, int & iter, int mode = 0); //mode 0 - dump to tab, dest to tab, dump to eol //mode 1 - dump to tab, src to eol
|
void loadToIt(std::string & dest, std::string & src, int & iter, int mode = 0); //mode 0 - dump to tab, dest to tab, dump to eol //mode 1 - dump to tab, src to eol //mode 2 - copy to tab, dump to eol //mode 3 - copy to eol //mode 4 - copy to tab
|
||||||
void loadVictoryConditions();
|
void loadVictoryConditions();
|
||||||
void loadLossConditions();
|
void loadLossConditions();
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
bool isItIn(const SDL_Rect * rect, int x, int y)
|
bool isItIn(const SDL_Rect * rect, int x, int y)
|
||||||
{
|
{
|
||||||
if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h))
|
if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h))
|
||||||
@ -599,3 +600,20 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, int player)
|
|||||||
*(sur->format->palette->colors+5) = CGameInfo::mainObj->neutralColor;
|
*(sur->format->palette->colors+5) = CGameInfo::mainObj->neutralColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int readNormalNr (std::istream &in, int bytCon)
|
||||||
|
{
|
||||||
|
int ret=0;
|
||||||
|
int amp=1;
|
||||||
|
unsigned char byte;
|
||||||
|
if (in.good())
|
||||||
|
{
|
||||||
|
for (int i=0; i<bytCon; i++)
|
||||||
|
{
|
||||||
|
in.read((char*)&byte,1);
|
||||||
|
ret+=byte*amp;
|
||||||
|
amp*=256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return -1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ extern SDL_Color tytulowy, tlo, zwykly ;
|
|||||||
void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
|
void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
|
||||||
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
|
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
|
||||||
void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran);
|
void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran);
|
||||||
|
bool isItIn(const SDL_Rect * rect, int x, int y);
|
||||||
SDL_Rect genRect(int hh, int ww, int xx, int yy);
|
SDL_Rect genRect(int hh, int ww, int xx, int yy);
|
||||||
namespace CSDL_Ext
|
namespace CSDL_Ext
|
||||||
{
|
{
|
||||||
|
8
global.h
8
global.h
@ -19,7 +19,13 @@ enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
|
|||||||
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHEMIST, HERO_WIZARD,
|
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHEMIST, HERO_WIZARD,
|
||||||
HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
|
HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
|
||||||
HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
|
HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
|
||||||
#define CURPLINT (((CPlayerInterface*)(CGI->playerint[CGI->state->currentPlayer]))) //interface of current player (only human)
|
|
||||||
|
#define CURPLINT (((CPlayerInterface*)(CGI->playerint[CGI->state->currentPlayer])))
|
||||||
|
#define LOCPLINT (((CPlayerInterface*)(CGI->playerint[CGI->localPlayer])))
|
||||||
|
//CURPLINT gives pointer to the interface of human player which is currently making turn,
|
||||||
|
//LOCPLINT gives pointer to the interface which is currently showed (on this machine)
|
||||||
|
|
||||||
|
|
||||||
const int F_NUMBER = 9; //factions quantity
|
const int F_NUMBER = 9; //factions quantity
|
||||||
const int PLAYER_LIMIT = 8; //player limit per map
|
const int PLAYER_LIMIT = 8; //player limit per map
|
||||||
const int HEROES_PER_TYPE=8; //amount of heroes of each type
|
const int HEROES_PER_TYPE=8; //amount of heroes of each type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user