1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
This commit is contained in:
Ivan Savenko 2011-05-28 10:05:25 +00:00
parent c6a69d35cf
commit 19f0836211
5 changed files with 37 additions and 13 deletions

View File

@ -47,7 +47,11 @@ void CButtonBase::update()
else
text->moveTo(Point(pos.x+pos.w/2, pos.y+pos.h/2));
}
size_t newPos = (int)state + bitmapOffset;
if (state == HIGHLIGHTED && image->size() < 4)
newPos = image->size()-1;
if (swappedImages)
{
if (newPos == 0) newPos = 1;
@ -55,7 +59,9 @@ void CButtonBase::update()
}
if (!keepFrame)
{
image->setFrame(newPos);
}
if (active)
{
@ -277,6 +283,7 @@ void AdventureMapButton::showAll(SDL_Surface *to)
void CHighlightableButton::select(bool on)
{
selected = on;
if (on)
{
setState(HIGHLIGHTED);
@ -311,7 +318,7 @@ void CHighlightableButton::clickLeft(tribool down, bool previousState)
if(previousState && down == false && getState() == PRESSED)
{
//if(!onlyOn || !isHighlighted())
select(!isHighlighted());
select(!selected);
}
}

View File

@ -104,6 +104,7 @@ public:
CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
bool onlyOn;//button can not be de-selected
bool selected;//state of highlightable button
int ID; //for identification
CFunctionList<void()> callback2; //when de-selecting
void select(bool on);

View File

@ -591,12 +591,18 @@ SDLImage::SDLImage(std::string filename, bool compressed):
}
else
{
tlog0<<"Error: file not found: "<<filename<<"\n";
surf = NULL;
return;
}
fullSize.x = surf->w;
fullSize.y = surf->h;
if (surf == NULL)
{
tlog1 << "Error: failed to load image "<<filename<<"\n";
}
else
{
fullSize.x = surf->w;
fullSize.y = surf->h;
}
}
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, unsigned char rotation) const
@ -1160,6 +1166,11 @@ CAnimImage::CAnimImage(CAnimation *Anim, size_t Frame, size_t Group, int x, int
init();
}
size_t CAnimImage::size()
{
return anim->size(group);
}
void CAnimImage::init()
{
anim->load(frame, group);

View File

@ -245,6 +245,9 @@ public:
CAnimImage(CAnimation* anim, size_t Frame, size_t Group=0, int x=0, int y=0, unsigned char Flags=0);
~CAnimImage();//d-tor
//size of animation
size_t size();
//change displayed frame on this one
void setFrame(size_t Frame, size_t Group=0);

View File

@ -1118,9 +1118,9 @@ void CBattleInterface::addNewAnim(CBattleAnimation * anim)
CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect, CPlayerInterface * att, CPlayerInterface * defen)
: queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), previouslyHoveredHex(-1),
currentlyHoveredHex(-1), spellDestSelectMode(false), spellToCast(NULL), siegeH(NULL),
attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), givenCommand(NULL),
myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL), tacticianInterface(NULL)
currentlyHoveredHex(-1), tacticianInterface(NULL), spellDestSelectMode(false), spellToCast(NULL),
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), givenCommand(NULL),
myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
{
ObjectConstruction h__l__p(this);
@ -2523,9 +2523,9 @@ void CBattleInterface::newRoundFirst( int round )
{
//handle regeneration
std::vector<const CStack*> stacks = curInt->cb->battleGetStacks(); //gets only alive stacks
BOOST_FOREACH(const CStack *s, stacks)
{
}
// BOOST_FOREACH(const CStack *s, stacks)
// {
// }
waitForAnims();
}
@ -3549,11 +3549,13 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
// Creature have to be in a shooting anim and the anim start delay must be over.
// Otherwise abort to start moving the projectile.
if (it->animStartDelay > 0)
{
if(it->animStartDelay == creAnims[it->stackID]->getAnimationFrame() + 1
&& creAnims[it->stackID]->getType() >= 14 && creAnims[it->stackID]->getType() <= 16)
it->animStartDelay = 0;
else
continue;
}
SDL_Rect dst;
dst.h = idToProjectile[it->creID]->ourImages[it->frameNum].bitmap->h;
@ -4372,10 +4374,10 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
animSpeeds->select(owner->getAnimSpeed(), 1);
animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
setToDefault = new AdventureMapButton (CGI->generaltexth->zelp[392].first, CGI->generaltexth->zelp[392].second, boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def");
setToDefault = new AdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 405, 443, "codefaul.def");
setToDefault->swappedImages = true;
setToDefault->update();
exit = new AdventureMapButton (CGI->generaltexth->zelp[393].first, CGI->generaltexth->zelp[393].second, boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def",SDLK_RETURN);
exit = new AdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 516, 443, "soretrn.def",SDLK_RETURN);
exit->swappedImages = true;
exit->update();