mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* improved minimap
* live event handling on adventure map * added CCallback * minor stuff (as usual)
This commit is contained in:
parent
4162103cf1
commit
210123ac33
@ -268,6 +268,10 @@ void CMinimap::clickRight (tribool down)
|
||||
{}
|
||||
void CMinimap::clickLeft (tribool down)
|
||||
{
|
||||
if (down && (!pressedL))
|
||||
MotionInterested::activate();
|
||||
else if (!down)
|
||||
MotionInterested::deactivate();
|
||||
ClickableL::clickLeft(down);
|
||||
if (!((bool)down))
|
||||
return;
|
||||
@ -300,14 +304,25 @@ void CMinimap::hover (bool on)
|
||||
else if (LOCPLINT->adventureInt->statusbar.current==statusbarTxt)
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
}
|
||||
void CMinimap::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
if (pressedL)
|
||||
{
|
||||
clickLeft(true);
|
||||
}
|
||||
}
|
||||
void CMinimap::activate()
|
||||
{
|
||||
ClickableL::activate();
|
||||
ClickableR::activate();
|
||||
Hoverable::activate();
|
||||
if (pressedL)
|
||||
MotionInterested::activate();
|
||||
}
|
||||
void CMinimap::deactivate()
|
||||
{
|
||||
if (pressedL)
|
||||
MotionInterested::deactivate();
|
||||
ClickableL::deactivate();
|
||||
ClickableR::deactivate();
|
||||
Hoverable::deactivate();
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
void show(); //shows statusbar (with current text)
|
||||
};
|
||||
class CMinimap
|
||||
: public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject
|
||||
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
CDefHandler * radar; //radar.def; TODO: radars for maps with custom dimensions
|
||||
@ -117,6 +117,7 @@ public:
|
||||
void clickRight (tribool down);
|
||||
void clickLeft (tribool down);
|
||||
void hover (bool on);
|
||||
void mouseMoved (SDL_MouseMotionEvent & sEvent);
|
||||
void activate(); // makes button active
|
||||
void deactivate(); // makes button inactive (but don't deletes)
|
||||
};
|
||||
|
@ -132,10 +132,9 @@ void CAmbarCendamo::deh3m()
|
||||
|
||||
|
||||
}
|
||||
|
||||
i++; //unknown
|
||||
|
||||
if(bufor[i++]!=0xff)
|
||||
map.players[pom].p8= bufor[i++];
|
||||
map.players[pom].p9= bufor[i++];
|
||||
if(map.players[pom].p9!=0xff)
|
||||
{
|
||||
map.players[pom].mainHeroPortrait = bufor[i++];
|
||||
int nameLength = bufor[i++];
|
||||
@ -144,7 +143,6 @@ void CAmbarCendamo::deh3m()
|
||||
map.players[pom].mainHeroName+=bufor[i++];
|
||||
}
|
||||
|
||||
//i++; //unknown byte
|
||||
if(map.version != Eformat::RoE)
|
||||
{
|
||||
i++; ////unknown byte
|
||||
|
7
CCallback.cpp
Normal file
7
CCallback.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "CCallback.h"
|
||||
|
||||
bool CCallback::moveHero(int ID, int3 destPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
12
CCallback.h
Normal file
12
CCallback.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef CCALLBACK_H
|
||||
#define CCALLBACK_H
|
||||
class CGameState;
|
||||
class CCallback
|
||||
{
|
||||
protected:
|
||||
CGameState * gs;
|
||||
public:
|
||||
bool moveHero(int ID, int3 destPoint);
|
||||
};
|
||||
|
||||
#endif //CCALLBACK_H
|
@ -81,6 +81,15 @@ void KeyInterested::deactivate()
|
||||
LOCPLINT->
|
||||
keyinterested.erase(std::find(LOCPLINT->keyinterested.begin(),LOCPLINT->keyinterested.end(),this));
|
||||
}
|
||||
void MotionInterested::activate()
|
||||
{
|
||||
LOCPLINT->motioninterested.push_back(this);
|
||||
}
|
||||
void MotionInterested::deactivate()
|
||||
{
|
||||
LOCPLINT->
|
||||
motioninterested.erase(std::find(LOCPLINT->motioninterested.begin(),LOCPLINT->motioninterested.end(),this));
|
||||
}
|
||||
CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||
{
|
||||
playerID=Player;
|
||||
@ -111,7 +120,7 @@ void CPlayerInterface::yourTurn()
|
||||
CGI->screenh->updateScreen();
|
||||
|
||||
LOCPLINT->adventureInt->updateScreen = false;
|
||||
if(SDL_PollEvent(&sEvent)) //wait for event...
|
||||
while (SDL_PollEvent(&sEvent)) //wait for event...
|
||||
{
|
||||
handleEvent(&sEvent);
|
||||
}
|
||||
@ -259,6 +268,13 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
|
||||
hoverable[i]->hover(false);
|
||||
}
|
||||
}
|
||||
for(int i=0; i<motioninterested.size();i++)
|
||||
{
|
||||
if (isItIn(&motioninterested[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
||||
{
|
||||
motioninterested[i]->mouseMoved(sEvent->motion);
|
||||
}
|
||||
}
|
||||
if(sEvent->motion.x<15)
|
||||
{
|
||||
LOCPLINT->adventureInt->scrollingLeft = true;
|
||||
|
@ -64,6 +64,13 @@ public:
|
||||
virtual void activate()=0;
|
||||
virtual void deactivate()=0;
|
||||
};
|
||||
class MotionInterested: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
|
||||
virtual void activate()=0;
|
||||
virtual void deactivate()=0;
|
||||
};
|
||||
class CGameInterface
|
||||
{
|
||||
public:
|
||||
@ -88,6 +95,7 @@ public:
|
||||
std::vector<ClickableR*> rclickable;
|
||||
std::vector<Hoverable*> hoverable;
|
||||
std::vector<KeyInterested*> keyinterested;
|
||||
std::vector<MotionInterested*> motioninterested;
|
||||
|
||||
void yourTurn();
|
||||
void handleEvent(SDL_Event * sEvent);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "CDefObjInfoHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
|
||||
class CCallback;
|
||||
struct PlayerState
|
||||
{
|
||||
public:
|
||||
@ -27,9 +27,12 @@ public:
|
||||
|
||||
class CGameState
|
||||
{
|
||||
public:
|
||||
int currentPlayer;
|
||||
std::map<int,PlayerState> players; //color <-> playerstate
|
||||
public:
|
||||
friend CCallback;
|
||||
friend int _tmain(int argc, _TCHAR* argv[]);
|
||||
CCallback * cb; //for communication between PlayerInterface/AI and GameState
|
||||
};
|
||||
|
||||
#endif //CGAMESTATE_H
|
7
map.cpp
7
map.cpp
@ -89,10 +89,9 @@ CMapHeader::CMapHeader(unsigned char *map)
|
||||
this->players[pom].posOfMainTown.y = map[i++];
|
||||
this->players[pom].posOfMainTown.z = map[i++];
|
||||
}
|
||||
|
||||
i++; //unknown byte
|
||||
int customPortrait = map[i++];
|
||||
if (customPortrait != 255)
|
||||
players[pom].p8= map[i++];
|
||||
players[pom].p9= map[i++];
|
||||
if(players[pom].p9!=0xff)
|
||||
{
|
||||
players[pom].mainHeroPortrait = map[i++];
|
||||
int nameLength = map[i++];
|
||||
|
Loading…
Reference in New Issue
Block a user