mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-13 22:06:58 +02:00
* Updated class - file - handling
* Renamed color constants * Renamed class AdventureMapButton to CAdventureMapButton * Moved basic controls like CTextBox from GuiClasses to CIntObjectClasses * Moved new creature window from GuiClasses to CCreatureWindow
This commit is contained in:
parent
2f5d6f2684
commit
156aa6e4d9
@ -526,7 +526,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SBattleHex> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
|
||||
std::vector<BattleHex> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
|
||||
|
||||
if(fields.size() == 0)
|
||||
{
|
||||
@ -540,11 +540,11 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
ba.destinationTile = static_cast<ui16>(dest_tile);
|
||||
//simplified checking for possibility of attack (previous was too simplified)
|
||||
int destStackPos = m_cb->battleGetPos(destinationID);
|
||||
if(SBattleHex::mutualPosition(dest_tile, destStackPos) != -1)
|
||||
if(BattleHex::mutualPosition(dest_tile, destStackPos) != -1)
|
||||
ba.additionalInfo = destStackPos;
|
||||
else if(SBattleHex::mutualPosition(dest_tile, destStackPos+1) != -1)
|
||||
else if(BattleHex::mutualPosition(dest_tile, destStackPos+1) != -1)
|
||||
ba.additionalInfo = destStackPos+1;
|
||||
else if(SBattleHex::mutualPosition(dest_tile, destStackPos-1) != -1)
|
||||
else if(BattleHex::mutualPosition(dest_tile, destStackPos-1) != -1)
|
||||
ba.additionalInfo = destStackPos-1;
|
||||
else
|
||||
return BattleAction::makeDefend(attackerStack);
|
||||
@ -581,7 +581,7 @@ BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
|
||||
}
|
||||
}
|
||||
|
||||
for (std::vector<SBattleHex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
for (std::vector<BattleHex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
{
|
||||
if (*it == dest_tile)
|
||||
{
|
||||
|
@ -1311,7 +1311,7 @@ void CGeniusAI::battleNewRound(int round)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<SBattleHex> dest, int distance)
|
||||
void CGeniusAI::battleStackMoved(int ID, std::vector<BattleHex> dest, int distance)
|
||||
{
|
||||
std::string message("\t\t\tCGeniusAI::battleStackMoved ID(");
|
||||
message += boost::lexical_cast<std::string>(ID);
|
||||
@ -1345,7 +1345,7 @@ void CGeniusAI::battleSpellCast(const BattleSpellCast *sc)
|
||||
*
|
||||
*/
|
||||
// void CGeniusAI::battleStackMoved(int ID,
|
||||
// SBattleHex dest,
|
||||
// BattleHex dest,
|
||||
// bool startMoving,
|
||||
// bool endMoving)
|
||||
// {
|
||||
|
@ -201,7 +201,7 @@ public:
|
||||
virtual void battleStacksAttacked(const std::set<BattleStackAttacked> & bsa); //called when stack receives damage (after battleAttack())
|
||||
virtual void battleEnd(const BattleResult *br);
|
||||
virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||
virtual void battleStackMoved(int ID, std::vector<SBattleHex> dest, int distance);
|
||||
virtual void battleStackMoved(int ID, std::vector<BattleHex> dest, int distance);
|
||||
virtual void battleSpellCast(const BattleSpellCast *sc);
|
||||
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
||||
|
@ -39,7 +39,7 @@ struct EnemyInfo
|
||||
{
|
||||
const CStack * s;
|
||||
int adi, adr;
|
||||
std::vector<SBattleHex> attackFrom; //for melee fight
|
||||
std::vector<BattleHex> attackFrom; //for melee fight
|
||||
EnemyInfo(const CStack * _s) : s(_s)
|
||||
{}
|
||||
void calcDmg(const CStack * ourStack)
|
||||
@ -60,10 +60,10 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2)
|
||||
return (ei1.adi-ei1.adr) < (ei2.adi - ei2.adr);
|
||||
}
|
||||
|
||||
int distToNearestNeighbour(SBattleHex hex, const std::vector<int> & dists, SBattleHex *chosenHex = NULL)
|
||||
int distToNearestNeighbour(BattleHex hex, const std::vector<int> & dists, BattleHex *chosenHex = NULL)
|
||||
{
|
||||
int ret = 1000000;
|
||||
BOOST_FOREACH(SBattleHex n, hex.neighbouringTiles())
|
||||
BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
|
||||
{
|
||||
if(dists[n] >= 0 && dists[n] < ret)
|
||||
{
|
||||
@ -81,12 +81,12 @@ bool isCloser(const EnemyInfo & ei1, const EnemyInfo & ei2, const std::vector<in
|
||||
return distToNearestNeighbour(ei1.s->position, dists) < distToNearestNeighbour(ei2.s->position, dists);
|
||||
}
|
||||
|
||||
static bool willSecondHexBlockMoreEnemyShooters(const SBattleHex &h1, const SBattleHex &h2)
|
||||
static bool willSecondHexBlockMoreEnemyShooters(const BattleHex &h1, const BattleHex &h2)
|
||||
{
|
||||
int shooters[2] = {0}; //count of shooters on hexes
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
BOOST_FOREACH(SBattleHex neighbour, (i ? h2 : h1).neighbouringTiles())
|
||||
BOOST_FOREACH(BattleHex neighbour, (i ? h2 : h1).neighbouringTiles())
|
||||
if(const CStack *s = cbc->battleGetStackByPos(neighbour))
|
||||
if(s->getCreature()->isShooting())
|
||||
shooters[i]++;
|
||||
@ -98,7 +98,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
||||
{
|
||||
//boost::this_thread::sleep(boost::posix_time::seconds(2));
|
||||
print("activeStack called");
|
||||
std::vector<SBattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<BattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<int> dists = cb->battleGetDistances(stack);
|
||||
std::vector<EnemyInfo> enemiesShootable, enemiesReachable, enemiesUnreachable;
|
||||
|
||||
@ -110,7 +110,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_FOREACH(SBattleHex hex, avHexes)
|
||||
BOOST_FOREACH(BattleHex hex, avHexes)
|
||||
{
|
||||
if(CStack::isMeleeAttackPossible(stack, s, hex))
|
||||
{
|
||||
@ -182,7 +182,7 @@ void CStupidAI::battleNewRound(int round)
|
||||
print("battleNewRound called");
|
||||
}
|
||||
|
||||
void CStupidAI::battleStackMoved(const CStack * stack, std::vector<SBattleHex> dest, int distance)
|
||||
void CStupidAI::battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance)
|
||||
{
|
||||
print("battleStackMoved called");;
|
||||
}
|
||||
@ -233,10 +233,10 @@ void CStupidAI::print(const std::string &text) const
|
||||
tlog0 << "CStupidAI [" << this <<"]: " << text << std::endl;
|
||||
}
|
||||
|
||||
BattleAction CStupidAI::goTowards(const CStack * stack, SBattleHex hex)
|
||||
BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex hex)
|
||||
{
|
||||
SBattleHex realDest = hex;
|
||||
SBattleHex predecessors[GameConstants::BFIELD_SIZE];
|
||||
BattleHex realDest = hex;
|
||||
BattleHex predecessors[GameConstants::BFIELD_SIZE];
|
||||
std::vector<int> dists = cb->battleGetDistances(stack, hex);
|
||||
if(distToNearestNeighbour(hex, dists, &realDest) > GameConstants::BFIELD_SIZE)
|
||||
{
|
||||
@ -245,7 +245,7 @@ BattleAction CStupidAI::goTowards(const CStack * stack, SBattleHex hex)
|
||||
}
|
||||
|
||||
dists = cb->battleGetDistances(stack, realDest, predecessors);
|
||||
std::vector<SBattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
std::vector<BattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
|
||||
|
||||
if(!avHexes.size())
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../lib/SBattleHex.h"
|
||||
#include "../../lib/BattleHex.h"
|
||||
|
||||
class CStupidAI : public CBattleGameInterface
|
||||
{
|
||||
@ -23,7 +23,7 @@ public:
|
||||
//void battleResultsApplied() OVERRIDE; //called when all effects of last battle are applied
|
||||
void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied;
|
||||
void battleNewRound(int round) OVERRIDE; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||
void battleStackMoved(const CStack * stack, std::vector<SBattleHex> dest, int distance) OVERRIDE;
|
||||
void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) OVERRIDE;
|
||||
void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks
|
||||
//void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE;
|
||||
@ -34,6 +34,6 @@ public:
|
||||
void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
|
||||
void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield
|
||||
|
||||
BattleAction goTowards(const CStack * stack, SBattleHex hex );
|
||||
BattleAction goTowards(const CStack * stack, BattleHex hex );
|
||||
};
|
||||
|
||||
|
@ -92,6 +92,7 @@
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/Zm207 %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -1,697 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "AdventureMapButton.h"
|
||||
|
||||
#include "CAnimation.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "BattleInterface/CBattleInterface.h"
|
||||
#include "BattleInterface/CBattleConsole.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "CMessage.h"
|
||||
#include "CMusicHandler.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
|
||||
/*
|
||||
* AdventureMapButton.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
CButtonBase::CButtonBase()
|
||||
{
|
||||
swappedImages = keepFrame = false;
|
||||
bitmapOffset = 0;
|
||||
state=NORMAL;
|
||||
image = NULL;
|
||||
text = NULL;
|
||||
}
|
||||
|
||||
CButtonBase::~CButtonBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CButtonBase::update()
|
||||
{
|
||||
if (text)
|
||||
{
|
||||
if (state == PRESSED)
|
||||
text->moveTo(SPoint(pos.x+pos.w/2+1, pos.y+pos.h/2+1));
|
||||
else
|
||||
text->moveTo(SPoint(pos.x+pos.w/2, pos.y+pos.h/2));
|
||||
}
|
||||
|
||||
int newPos = (int)state + bitmapOffset;
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
|
||||
if (state == HIGHLIGHTED && image->size() < 4)
|
||||
newPos = image->size()-1;
|
||||
|
||||
if (swappedImages)
|
||||
{
|
||||
if (newPos == 0) newPos = 1;
|
||||
else if (newPos == 1) newPos = 0;
|
||||
}
|
||||
|
||||
if (!keepFrame)
|
||||
image->setFrame(newPos);
|
||||
|
||||
if (active)
|
||||
redraw();
|
||||
}
|
||||
|
||||
void CButtonBase::addTextOverlay( const std::string &Text, EFonts font, SDL_Color color)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
delChild(text);
|
||||
text = new CLabel(pos.w/2, pos.h/2, font, CENTER, color, Text);
|
||||
update();
|
||||
}
|
||||
|
||||
void CButtonBase::setOffset(int newOffset)
|
||||
{
|
||||
if (bitmapOffset == newOffset)
|
||||
return;
|
||||
bitmapOffset = newOffset;
|
||||
update();
|
||||
}
|
||||
|
||||
void CButtonBase::setState(ButtonState newState)
|
||||
{
|
||||
if (state == newState)
|
||||
return;
|
||||
state = newState;
|
||||
update();
|
||||
}
|
||||
|
||||
CButtonBase::ButtonState CButtonBase::getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
bool CButtonBase::isBlocked()
|
||||
{
|
||||
return state == BLOCKED;
|
||||
}
|
||||
|
||||
bool CButtonBase::isHighlighted()
|
||||
{
|
||||
return state == HIGHLIGHTED;
|
||||
}
|
||||
|
||||
void CButtonBase::block(bool on)
|
||||
{
|
||||
setState(on?BLOCKED:NORMAL);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton ()
|
||||
{
|
||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||
used = LCLICK | RCLICK | HOVER | KEYBOARD;
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName,int key, std::vector<std::string> * add, bool playerColoredButton )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(Callback, pom, HelpBox, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key/*=0*/ )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(Callback, pom, HelpBox, info->playerColoured, info->defName, &info->additionalDefs, info->x, info->y, key);
|
||||
}
|
||||
|
||||
AdventureMapButton::AdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
|
||||
{
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = help.first;
|
||||
init(Callback, pom, help.second, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
void AdventureMapButton::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down)
|
||||
{
|
||||
if (!soundDisabled)
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
}
|
||||
else if(hoverable && hovered)
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
|
||||
if (actOnDown && down)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
else if (!actOnDown && previousState && (down==false))
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
void AdventureMapButton::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(down && helpBox.size()) //there is no point to show window with nothing inside...
|
||||
CRClickPopup::createAndPush(helpBox);
|
||||
}
|
||||
|
||||
void AdventureMapButton::hover (bool on)
|
||||
{
|
||||
if(hoverable)
|
||||
{
|
||||
if(on)
|
||||
setState(HIGHLIGHTED);
|
||||
else
|
||||
setState(NORMAL);
|
||||
}
|
||||
|
||||
if(pressedL && on)
|
||||
setState(PRESSED);
|
||||
|
||||
std::string *name = (vstd::contains(hoverTexts,getState()))
|
||||
? (&hoverTexts[getState()])
|
||||
: (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : NULL);
|
||||
if(name && name->size() && !isBlocked()) //if there is no name, there is nohing to display also
|
||||
{
|
||||
if (LOCPLINT && LOCPLINT->battleInt) //for battle buttons
|
||||
{
|
||||
if(on && LOCPLINT->battleInt->console->alterTxt == "")
|
||||
{
|
||||
LOCPLINT->battleInt->console->alterTxt = *name;
|
||||
LOCPLINT->battleInt->console->whoSetAlter = 1;
|
||||
}
|
||||
else if (LOCPLINT->battleInt->console->alterTxt == *name)
|
||||
{
|
||||
LOCPLINT->battleInt->console->alterTxt = "";
|
||||
LOCPLINT->battleInt->console->whoSetAlter = 0;
|
||||
}
|
||||
}
|
||||
else if(GH.statusbar) //for other buttons
|
||||
{
|
||||
if (on)
|
||||
GH.statusbar->print(*name);
|
||||
else if ( GH.statusbar->getCurrent()==(*name) )
|
||||
GH.statusbar->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
|
||||
{
|
||||
currentImage = -1;
|
||||
used = LCLICK | RCLICK | HOVER | KEYBOARD;
|
||||
callback = Callback;
|
||||
hoverable = actOnDown = borderEnabled = soundDisabled = false;
|
||||
borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
|
||||
assignedKeys.insert(key);
|
||||
hoverTexts = Name;
|
||||
helpBox=HelpBox;
|
||||
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
|
||||
if (!defName.empty())
|
||||
imageNames.push_back(defName);
|
||||
if (add)
|
||||
for (size_t i=0; i<add->size();i++ )
|
||||
imageNames.push_back(add->at(i));
|
||||
setIndex(0, playerColoredButton);
|
||||
}
|
||||
|
||||
void AdventureMapButton::setIndex(size_t index, bool playerColoredButton)
|
||||
{
|
||||
if (index == currentImage || index>=imageNames.size())
|
||||
return;
|
||||
currentImage = index;
|
||||
setImage(new CAnimation(imageNames[index]), playerColoredButton);
|
||||
}
|
||||
|
||||
void AdventureMapButton::setImage(CAnimation* anim, bool playerColoredButton)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
|
||||
if (image && active)
|
||||
image->deactivate();
|
||||
delChild(image);
|
||||
image = new CAnimImage(anim, getState());
|
||||
if (active)
|
||||
image->activate();
|
||||
if (playerColoredButton)
|
||||
image->playerColored(LOCPLINT->playerID);
|
||||
|
||||
pos.w = image->pos.w;
|
||||
pos.h = image->pos.h;
|
||||
}
|
||||
|
||||
void AdventureMapButton::setPlayerColor(int player)
|
||||
{
|
||||
if (image)
|
||||
image->playerColored(player);
|
||||
}
|
||||
|
||||
void AdventureMapButton::showAll(SDL_Surface *to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
||||
if (borderEnabled && borderColor.unused == 0)
|
||||
CSDL_Ext::drawBorder(to, pos.x - 1, pos.y - 1, pos.w + 2, pos.h + 2, int3(borderColor.r, borderColor.g, borderColor.b));
|
||||
}
|
||||
|
||||
void CHighlightableButton::select(bool on)
|
||||
{
|
||||
selected = on;
|
||||
if (on)
|
||||
{
|
||||
setState(HIGHLIGHTED);
|
||||
callback();
|
||||
borderEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setState(NORMAL);
|
||||
callback2();
|
||||
borderEnabled = false;
|
||||
}
|
||||
|
||||
if(hoverTexts.size()>1)
|
||||
{
|
||||
hover(false);
|
||||
hover(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CHighlightableButton::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(isBlocked())
|
||||
return;
|
||||
|
||||
if (down && !(onlyOn && isHighlighted()))
|
||||
{
|
||||
CCS->soundh->playSound(soundBase::button);
|
||||
setState(PRESSED);
|
||||
}
|
||||
|
||||
if(previousState && down == false && getState() == PRESSED)
|
||||
{
|
||||
//if(!onlyOn || !isHighlighted())
|
||||
select(!selected);
|
||||
}
|
||||
}
|
||||
|
||||
CHighlightableButton::CHighlightableButton( const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
|
||||
: onlyOn(false), selected(false), callback2(onDeselect)
|
||||
{
|
||||
init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,key);
|
||||
}
|
||||
|
||||
CHighlightableButton::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 */ )
|
||||
: onlyOn(false), selected(false) // TODO: callback2(???)
|
||||
{
|
||||
ID = myid;
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = help.first;
|
||||
init(onSelect, pom, help.second, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
CHighlightableButton::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 */ )
|
||||
: onlyOn(false), selected(false) // TODO: callback2(???)
|
||||
{
|
||||
ID = myid;
|
||||
std::map<int,std::string> pom;
|
||||
pom[0] = Name;
|
||||
init(onSelect, pom,HelpBox, playerColoredButton, defName, add, x, y, key);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::addButton(CHighlightableButton* bt)
|
||||
{
|
||||
if (bt->parent)
|
||||
bt->parent->removeChild(bt);
|
||||
addChild(bt);
|
||||
bt->recActions = defActions;//FIXME: not needed?
|
||||
|
||||
bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
|
||||
bt->onlyOn = true;
|
||||
buttons.push_back(bt);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect, int key)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
|
||||
if(musicLike)
|
||||
{
|
||||
if (buttons.size() > 3)
|
||||
bt->setOffset(buttons.size()-3);
|
||||
}
|
||||
bt->ID = uid;
|
||||
bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
|
||||
bt->onlyOn = true;
|
||||
buttons.push_back(bt);
|
||||
}
|
||||
|
||||
CHighlightableButtonsGroup::CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons)
|
||||
: onChange(OnChange), musicLike(musicLikeButtons)
|
||||
{}
|
||||
|
||||
CHighlightableButtonsGroup::~CHighlightableButtonsGroup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::select(int id, bool mode)
|
||||
{
|
||||
CHighlightableButton *bt = NULL;
|
||||
if(mode)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size() && !bt; ++i)
|
||||
if (buttons[i]->ID == id)
|
||||
bt = buttons[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = buttons[id];
|
||||
}
|
||||
bt->select(true);
|
||||
selectionChanged(bt->ID);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::selectionChanged(int to)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->ID!=to && buttons[i]->isHighlighted())
|
||||
buttons[i]->select(false);
|
||||
onChange(to);
|
||||
if (parent)
|
||||
parent->redraw();
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::show(SDL_Surface * to )
|
||||
{
|
||||
if (musicLike)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->isHighlighted())
|
||||
buttons[i]->show(to);
|
||||
}
|
||||
else
|
||||
CIntObject::show(to);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::showAll( SDL_Surface * to )
|
||||
{
|
||||
if (musicLike)
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
if(buttons[i]->isHighlighted())
|
||||
buttons[i]->showAll(to);
|
||||
}
|
||||
else
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CHighlightableButtonsGroup::block( ui8 on )
|
||||
{
|
||||
for(size_t i=0;i<buttons.size(); ++i)
|
||||
{
|
||||
buttons[i]->block(on);
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::sliderClicked()
|
||||
{
|
||||
if(!(active & MOVE))
|
||||
{
|
||||
activateMouseMove();
|
||||
used |= MOVE;
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
double v = 0;
|
||||
if(horizontal)
|
||||
{
|
||||
if( std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2 )
|
||||
return;
|
||||
v = sEvent.x - pos.x - 24;
|
||||
v *= positions;
|
||||
v /= (pos.w - 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2+40 || std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2 )
|
||||
return;
|
||||
v = sEvent.y - pos.y - 24;
|
||||
v *= positions;
|
||||
v /= (pos.h - 48);
|
||||
}
|
||||
v += 0.5;
|
||||
if(v!=value)
|
||||
{
|
||||
moveTo(v);
|
||||
redrawSlider();
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::redrawSlider()
|
||||
{
|
||||
//slider->show(screenBuf);
|
||||
}
|
||||
|
||||
void CSlider::moveLeft()
|
||||
{
|
||||
moveTo(value-1);
|
||||
}
|
||||
|
||||
void CSlider::moveRight()
|
||||
{
|
||||
moveTo(value+1);
|
||||
}
|
||||
|
||||
void CSlider::moveTo(int to)
|
||||
{
|
||||
vstd::amax(to, 0);
|
||||
vstd::amin(to, positions);
|
||||
|
||||
//same, old position?
|
||||
if(value == to)
|
||||
return;
|
||||
|
||||
value = to;
|
||||
if(horizontal)
|
||||
{
|
||||
if(positions)
|
||||
{
|
||||
double part = static_cast<double>(to) / positions;
|
||||
part*=(pos.w-48);
|
||||
int newPos = part + pos.x + 16 - slider->pos.x;
|
||||
slider->moveBy(SPoint(newPos, 0));
|
||||
}
|
||||
else
|
||||
slider->moveTo(SPoint(pos.x+16, pos.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(positions)
|
||||
{
|
||||
double part = static_cast<double>(to) / positions;
|
||||
part*=(pos.h-48);
|
||||
int newPos = part + pos.y + 16 - slider->pos.y;
|
||||
slider->moveBy(SPoint(0, newPos));
|
||||
}
|
||||
else
|
||||
slider->moveTo(SPoint(pos.x, pos.y+16));
|
||||
}
|
||||
|
||||
if(moved)
|
||||
moved(to);
|
||||
}
|
||||
|
||||
void CSlider::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(down && !slider->isBlocked())
|
||||
{
|
||||
double pw = 0;
|
||||
double rw = 0;
|
||||
if(horizontal)
|
||||
{
|
||||
pw = GH.current->motion.x-pos.x-25;
|
||||
rw = pw / static_cast<double>(pos.w - 48);
|
||||
}
|
||||
else
|
||||
{
|
||||
pw = GH.current->motion.y-pos.y-24;
|
||||
rw = pw / (pos.h-48);
|
||||
}
|
||||
if(pw < -8 || pw > (horizontal ? pos.w : pos.h) - 40)
|
||||
return;
|
||||
// if (rw>1) return;
|
||||
// if (rw<0) return;
|
||||
slider->clickLeft(true, slider->pressedL);
|
||||
moveTo(rw * positions + 0.5);
|
||||
return;
|
||||
}
|
||||
if(active & MOVE)
|
||||
{
|
||||
deactivateMouseMove();
|
||||
used &= ~MOVE;
|
||||
}
|
||||
}
|
||||
|
||||
CSlider::~CSlider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
|
||||
:capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
setAmount(amount);
|
||||
|
||||
used = LCLICK;
|
||||
strongInterest = true;
|
||||
|
||||
|
||||
left = new AdventureMapButton();
|
||||
right = new AdventureMapButton();
|
||||
slider = new AdventureMapButton();
|
||||
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
|
||||
if(horizontal)
|
||||
{
|
||||
left->pos.y = slider->pos.y = right->pos.y = pos.y;
|
||||
left->pos.x = pos.x;
|
||||
right->pos.x = pos.x + totalw - 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
left->pos.x = slider->pos.x = right->pos.x = pos.x;
|
||||
left->pos.y = pos.y;
|
||||
right->pos.y = pos.y + totalw - 16;
|
||||
}
|
||||
|
||||
left->callback = boost::bind(&CSlider::moveLeft,this);
|
||||
right->callback = boost::bind(&CSlider::moveRight,this);
|
||||
slider->callback = boost::bind(&CSlider::sliderClicked,this);
|
||||
left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
|
||||
if(horizontal)
|
||||
{
|
||||
pos.h = 16;
|
||||
pos.w = totalw;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = 16;
|
||||
pos.h = totalw;
|
||||
}
|
||||
|
||||
if(style == 0)
|
||||
{
|
||||
std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
|
||||
CAnimation *animLeft = new CAnimation(name);
|
||||
left->setImage(animLeft);
|
||||
left->setOffset(0);
|
||||
|
||||
CAnimation *animRight = new CAnimation(name);
|
||||
right->setImage(animRight);
|
||||
right->setOffset(2);
|
||||
|
||||
CAnimation *animSlider = new CAnimation(name);
|
||||
slider->setImage(animSlider);
|
||||
slider->setOffset(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
left->setImage(new CAnimation(horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF"));
|
||||
right->setImage(new CAnimation(horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF"));
|
||||
slider->setImage(new CAnimation("SCNRBSL.DEF"));
|
||||
}
|
||||
slider->actOnDown = true;
|
||||
slider->soundDisabled = true;
|
||||
left->soundDisabled = true;
|
||||
right->soundDisabled = true;
|
||||
|
||||
value = -1;
|
||||
moveTo(Value);
|
||||
}
|
||||
|
||||
void CSlider::block( bool on )
|
||||
{
|
||||
left->block(on);
|
||||
right->block(on);
|
||||
slider->block(on);
|
||||
}
|
||||
|
||||
void CSlider::setAmount( int to )
|
||||
{
|
||||
amount = to;
|
||||
positions = to - capacity;
|
||||
vstd::amax(positions, 0);
|
||||
}
|
||||
|
||||
void CSlider::showAll(SDL_Surface * to)
|
||||
{
|
||||
CSDL_Ext::fillRect(to, &pos, 0);
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CSlider::wheelScrolled(bool down, bool in)
|
||||
{
|
||||
moveTo(value + 3 * (down ? +1 : -1));
|
||||
}
|
||||
|
||||
void CSlider::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(key.state != SDL_PRESSED) return;
|
||||
|
||||
int moveDest = 0;
|
||||
switch(key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
moveDest = value - 1;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
moveDest = value + 1;
|
||||
break;
|
||||
case SDLK_PAGEUP:
|
||||
moveDest = value - capacity + 1;
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
moveDest = value + capacity - 1;
|
||||
break;
|
||||
case SDLK_HOME:
|
||||
moveDest = 0;
|
||||
break;
|
||||
case SDLK_END:
|
||||
moveDest = amount - capacity;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
moveTo(moveDest);
|
||||
}
|
||||
|
||||
void CSlider::moveToMax()
|
||||
{
|
||||
moveTo(amount);
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "FunctionList.h"
|
||||
#include "UIFramework/CKeyShortcut.h"
|
||||
#include "UIFramework/SRect.h"
|
||||
|
||||
/*
|
||||
* AdventureMapButton.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
extern SDL_Color tytulowy, tlo, zwykly ;
|
||||
|
||||
class CAnimation;
|
||||
class CAnimImage;
|
||||
class CLabel;
|
||||
|
||||
namespace config{struct ButtonInfo;}
|
||||
|
||||
/// Base class for buttons.
|
||||
class CButtonBase : public CKeyShortcut
|
||||
{
|
||||
public:
|
||||
enum ButtonState
|
||||
{
|
||||
NORMAL=0,
|
||||
PRESSED=1,
|
||||
BLOCKED=2,
|
||||
HIGHLIGHTED=3
|
||||
};
|
||||
private:
|
||||
int bitmapOffset; // base offset of visible bitmap from animation
|
||||
ButtonState state;//current state of button from enum
|
||||
|
||||
public:
|
||||
bool swappedImages,//fix for some buttons: normal and pressed image are swapped
|
||||
keepFrame; // don't change visual representation
|
||||
|
||||
void addTextOverlay(const std::string &Text, EFonts font, SDL_Color color = zwykly);
|
||||
void update();//to refresh button after image or text change
|
||||
|
||||
void setOffset(int newOffset);
|
||||
void setState(ButtonState newState);
|
||||
ButtonState getState();
|
||||
|
||||
//just to make code clearer
|
||||
void block(bool on);
|
||||
bool isBlocked();
|
||||
bool isHighlighted();
|
||||
|
||||
CAnimImage * image; //image for this button
|
||||
CLabel * text;//text overlay
|
||||
|
||||
CButtonBase(); //c-tor
|
||||
virtual ~CButtonBase(); //d-tor
|
||||
};
|
||||
|
||||
/// Typical Heroes 3 button which can be inactive or active and can
|
||||
/// hold further information if you right-click it
|
||||
class AdventureMapButton : public CButtonBase
|
||||
{
|
||||
std::vector<std::string> imageNames;//store list of images that can be used by this button
|
||||
size_t currentImage;
|
||||
public:
|
||||
std::map<int, std::string> hoverTexts; //text for statusbar
|
||||
std::string helpBox; //for right-click help
|
||||
CFunctionList<void()> callback;
|
||||
bool actOnDown,//runs when mouse is pressed down over it, not when up
|
||||
hoverable,//if true, button will be highlighted when hovered
|
||||
borderEnabled,
|
||||
soundDisabled;
|
||||
SDL_Color borderColor;
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
void hover (bool on);
|
||||
|
||||
AdventureMapButton(); //c-tor
|
||||
AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
AdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key=0);//c-tor
|
||||
|
||||
void init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key );
|
||||
|
||||
void setIndex(size_t index, bool playerColoredButton=false);
|
||||
void setImage(CAnimation* anim, bool playerColoredButton=false);
|
||||
void setPlayerColor(int player);
|
||||
void showAll(SDL_Surface *to);
|
||||
};
|
||||
|
||||
/// A button which can be selected/deselected
|
||||
class CHighlightableButton
|
||||
: public AdventureMapButton
|
||||
{
|
||||
public:
|
||||
CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key=0);
|
||||
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);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
};
|
||||
|
||||
/// A group of buttons where one button can be selected
|
||||
class CHighlightableButtonsGroup : public CIntObject
|
||||
{
|
||||
public:
|
||||
CFunctionList2<void(int)> onChange; //called when changing selected button with new button's id
|
||||
std::vector<CHighlightableButton*> buttons;
|
||||
bool musicLike; //determines the behaviour of this group
|
||||
|
||||
//void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid);
|
||||
void addButton(CHighlightableButton* bt);//add existing button, it'll be deleted by CHighlightableButtonsGroup destructor
|
||||
void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect=0, int key=0); //creates new button
|
||||
CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons = false);
|
||||
~CHighlightableButtonsGroup();
|
||||
void select(int id, bool mode); //mode==0: id is serial; mode==1: id is unique button id
|
||||
void selectionChanged(int to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void block(ui8 on);
|
||||
};
|
||||
|
||||
/// A typical slider which can be orientated horizontally/vertically.
|
||||
class CSlider : public CIntObject
|
||||
{
|
||||
public:
|
||||
AdventureMapButton *left, *right, *slider; //if vertical then left=up
|
||||
int capacity,//how many elements can be active at same time
|
||||
amount, //how many elements
|
||||
positions, //number of highest position (0 if there is only one)
|
||||
value; //first active element
|
||||
bool horizontal;
|
||||
bool wheelScrolling;
|
||||
bool keyScrolling;
|
||||
|
||||
boost::function<void(int)> moved;
|
||||
|
||||
void redrawSlider();
|
||||
void sliderClicked();
|
||||
void moveLeft();
|
||||
void moveRight();
|
||||
void moveTo(int to);
|
||||
void block(bool on);
|
||||
void setAmount(int to);
|
||||
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void wheelScrolled(bool down, bool in);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void showAll(SDL_Surface * to);
|
||||
|
||||
CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount,
|
||||
int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue
|
||||
~CSlider();
|
||||
void moveToMax();
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CAttackAnimation.h"
|
||||
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../CCallback.h"
|
||||
|
||||
void CAttackAnimation::nextFrame()
|
||||
{
|
||||
if(myAnim()->getType() != group)
|
||||
myAnim()->setType(group);
|
||||
|
||||
if(myAnim()->onFirstFrameInGroup())
|
||||
{
|
||||
if(shooting)
|
||||
CCS->soundh->playSound(battle_sound(attackingStack->getCreature(), shoot));
|
||||
else
|
||||
CCS->soundh->playSound(battle_sound(attackingStack->getCreature(), attack));
|
||||
}
|
||||
else if(myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
myAnim()->setType(CCreatureAnim::HOLDING);
|
||||
endAnim();
|
||||
return; //execution of endAnim deletes this !!!
|
||||
}
|
||||
}
|
||||
|
||||
bool CAttackAnimation::checkInitialConditions()
|
||||
{
|
||||
return isEarliest(false);
|
||||
}
|
||||
|
||||
CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender)
|
||||
: CBattleStackAnimation(_owner, attacker), dest(_dest), attackedStack(defender), attackingStack(attacker)
|
||||
{
|
||||
|
||||
assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
|
||||
if(attackingStack->getCreature()->idNumber != 145) //catapult is allowed to attack not-creature
|
||||
{
|
||||
assert(attackedStack && "attackedStack is NULL in CBattleAttack::CBattleAttack !\n");
|
||||
}
|
||||
else //catapult can attack walls only
|
||||
{
|
||||
assert(owner->curInt->cb->battleGetWallUnderHex(_dest) >= 0);
|
||||
}
|
||||
attackingStackPosBeforeReturn = attackingStack->position;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
#include "../CAnimation.h"
|
||||
#include "../../lib/SBattleHex.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CAttackAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// This class is responsible for managing the battle attack animation
|
||||
class CAttackAnimation : public CBattleStackAnimation
|
||||
{
|
||||
protected:
|
||||
SBattleHex dest; //attacked hex
|
||||
bool shooting;
|
||||
CCreatureAnim::EAnimType group; //if shooting is true, print this animation group
|
||||
const CStack *attackedStack;
|
||||
const CStack *attackingStack;
|
||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||
public:
|
||||
void nextFrame();
|
||||
bool checkInitialConditions();
|
||||
|
||||
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *defender);
|
||||
};
|
@ -1,49 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleAnimation.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "CSpellEffectAnimation.h"
|
||||
#include "CReverseAnimation.h"
|
||||
|
||||
void CBattleAnimation::endAnim()
|
||||
{
|
||||
for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
if(it->first == this)
|
||||
{
|
||||
it->first = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CBattleAnimation::isEarliest(bool perStackConcurrency)
|
||||
{
|
||||
int lowestMoveID = owner->animIDhelper + 5;
|
||||
CBattleStackAnimation * thAnim = dynamic_cast<CBattleStackAnimation *>(this);
|
||||
CSpellEffectAnimation * thSen = dynamic_cast<CSpellEffectAnimation *>(this);
|
||||
|
||||
for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(it->first);
|
||||
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(it->first);
|
||||
if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
|
||||
continue;
|
||||
|
||||
if(sen && thSen && sen != thSen && perStackConcurrency)
|
||||
continue;
|
||||
|
||||
CReverseAnimation * revAnim = dynamic_cast<CReverseAnimation *>(stAnim);
|
||||
|
||||
if(revAnim && thAnim && stAnim && stAnim->stack->ID == thAnim->stack->ID && revAnim->priority)
|
||||
return false;
|
||||
|
||||
if(it->first)
|
||||
vstd::amin(lowestMoveID, it->first->ID);
|
||||
}
|
||||
return (ID == lowestMoveID) || (lowestMoveID == (owner->animIDhelper + 5));
|
||||
}
|
||||
|
||||
CBattleAnimation::CBattleAnimation(CBattleInterface * _owner)
|
||||
: owner(_owner), ID(_owner->animIDhelper++)
|
||||
{}
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class CBattleInterface;
|
||||
|
||||
/*
|
||||
* CBattleAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Base class of battle animations
|
||||
class CBattleAnimation
|
||||
{
|
||||
protected:
|
||||
CBattleInterface * owner;
|
||||
public:
|
||||
virtual bool init()=0; //to be called - if returned false, call again until returns true
|
||||
virtual void nextFrame()=0; //call every new frame
|
||||
virtual void endAnim(); //to be called mostly internally; in this class it removes animation from pendingAnims list
|
||||
|
||||
bool isEarliest(bool perStackConcurrency); //determines if this animation is earliest of all
|
||||
|
||||
ui32 ID; //unique identifier
|
||||
|
||||
CBattleAnimation(CBattleInterface * _owner);
|
||||
};
|
1075
client/BattleInterface/CBattleAnimations.cpp
Normal file
1075
client/BattleInterface/CBattleAnimations.cpp
Normal file
File diff suppressed because it is too large
Load Diff
221
client/BattleInterface/CBattleAnimations.h
Normal file
221
client/BattleInterface/CBattleAnimations.h
Normal file
@ -0,0 +1,221 @@
|
||||
#pragma once
|
||||
|
||||
#include "../CAnimation.h"
|
||||
#include "../../lib/BattleHex.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
class CCreatureAnimation;
|
||||
struct CatapultProjectileInfo;
|
||||
struct StackAttackedInfo;
|
||||
|
||||
/*
|
||||
* CBattleAnimations.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Base class of battle animations
|
||||
class CBattleAnimation
|
||||
{
|
||||
protected:
|
||||
CBattleInterface * owner;
|
||||
public:
|
||||
virtual bool init()=0; //to be called - if returned false, call again until returns true
|
||||
virtual void nextFrame()=0; //call every new frame
|
||||
virtual void endAnim(); //to be called mostly internally; in this class it removes animation from pendingAnims list
|
||||
|
||||
bool isEarliest(bool perStackConcurrency); //determines if this animation is earliest of all
|
||||
|
||||
ui32 ID; //unique identifier
|
||||
|
||||
CBattleAnimation(CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
/// Sub-class which is responsible for managing the battle stack animation.
|
||||
class CBattleStackAnimation : public CBattleAnimation
|
||||
{
|
||||
public:
|
||||
const CStack * stack; //id of stack whose animation it is
|
||||
|
||||
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
|
||||
static bool isToReverseHlp(BattleHex hexFrom, BattleHex hexTo, bool curDir); //helper for isToReverse
|
||||
static bool isToReverse(BattleHex hexFrom, BattleHex hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo)
|
||||
|
||||
CCreatureAnimation * myAnim(); //animation for our stack
|
||||
};
|
||||
|
||||
/// This class is responsible for managing the battle attack animation
|
||||
class CAttackAnimation : public CBattleStackAnimation
|
||||
{
|
||||
protected:
|
||||
BattleHex dest; //attacked hex
|
||||
bool shooting;
|
||||
CCreatureAnim::EAnimType group; //if shooting is true, print this animation group
|
||||
const CStack *attackedStack;
|
||||
const CStack *attackingStack;
|
||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||
public:
|
||||
void nextFrame();
|
||||
bool checkInitialConditions();
|
||||
|
||||
CAttackAnimation(CBattleInterface *_owner, const CStack *attacker, BattleHex _dest, const CStack *defender);
|
||||
};
|
||||
|
||||
/// Animation of a defending unit
|
||||
class CDefenceAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
//std::vector<StackAttackedInfo> attackedInfos;
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner);
|
||||
};
|
||||
|
||||
class CDummyAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
int counter;
|
||||
int howMany;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDummyAnimation(CBattleInterface * _owner, int howManyFrames);
|
||||
};
|
||||
|
||||
/// Hand-to-hand attack
|
||||
class CMeleeAttackAnimation : public CAttackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked);
|
||||
};
|
||||
|
||||
/// Move animation of a creature
|
||||
class CMovementAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
std::vector<BattleHex> destTiles; //destination
|
||||
BattleHex nextHex;
|
||||
ui32 nextPos;
|
||||
int distance;
|
||||
double stepX, stepY; //how far stack is moved in one frame
|
||||
double posX, posY;
|
||||
int steps, whichStep;
|
||||
int curStackPos; //position of stack before move
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<BattleHex> _destTiles, int _distance);
|
||||
};
|
||||
|
||||
/// Move end animation of a creature
|
||||
class CMovementEndAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
BattleHex destinationTile;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, BattleHex destTile);
|
||||
};
|
||||
|
||||
/// Move start animation of a creature
|
||||
class CMovementStartAnimation : public CBattleStackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
};
|
||||
|
||||
/// Class responsible for animation of stack chaning direction (left <-> right)
|
||||
class CReverseAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
int partOfAnim; //1 - first, 2 - second
|
||||
bool secondPartSetup;
|
||||
BattleHex hex;
|
||||
public:
|
||||
bool priority; //true - high, false - low
|
||||
bool init();
|
||||
void nextFrame();
|
||||
|
||||
void setupSecondPart();
|
||||
void endAnim();
|
||||
|
||||
CReverseAnimation(CBattleInterface * _owner, const CStack * stack, BattleHex dest, bool _priority);
|
||||
};
|
||||
|
||||
/// Small struct which contains information about the position and the velocity of a projectile
|
||||
struct ProjectileInfo
|
||||
{
|
||||
double x, y; //position on the screen
|
||||
double dx, dy; //change in position in one step
|
||||
int step, lastStep; //to know when finish showing this projectile
|
||||
int creID; //ID of creature that shot this projectile
|
||||
int stackID; //ID of stack
|
||||
int frameNum; //frame to display form projectile animation
|
||||
bool spin; //if true, frameNum will be increased
|
||||
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
|
||||
bool reverse; //if true, projectile will be flipped by vertical asix
|
||||
CatapultProjectileInfo * catapultInfo; // holds info about the parabolic trajectory of the cannon
|
||||
};
|
||||
|
||||
/// Shooting attack
|
||||
class CShootingAnimation : public CAttackAnimation
|
||||
{
|
||||
private:
|
||||
int catapultDamage;
|
||||
bool catapult;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
//last two params only for catapult attacks
|
||||
CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex _dest,
|
||||
const CStack * _attacked, bool _catapult = false, int _catapultDmg = 0);
|
||||
};
|
||||
|
||||
/// This class manages a spell effect animation
|
||||
class CSpellEffectAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
ui32 effect;
|
||||
BattleHex destTile;
|
||||
std::string customAnim;
|
||||
int x, y, dx, dy;
|
||||
bool Vflip;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, BattleHex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
};
|
@ -1,84 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleConsole.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
|
||||
CBattleConsole::CBattleConsole() : lastShown(-1), alterTxt(""), whoSetAlter(0)
|
||||
{
|
||||
}
|
||||
|
||||
CBattleConsole::~CBattleConsole()
|
||||
{
|
||||
texts.clear();
|
||||
}
|
||||
|
||||
void CBattleConsole::show(SDL_Surface * to)
|
||||
{
|
||||
if(ingcAlter.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(ingcAlter, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, zwykly, to);
|
||||
}
|
||||
else if(alterTxt.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(alterTxt, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, zwykly, to);
|
||||
}
|
||||
else if(texts.size())
|
||||
{
|
||||
if(texts.size()==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[0], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, zwykly, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown-1], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, zwykly, to);
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown], pos.x + pos.w/2, pos.y + 27, FONT_SMALL, 80, zwykly, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleConsole::addText(const std::string & text)
|
||||
{
|
||||
if(text.size()>70)
|
||||
return false; //text too long!
|
||||
int firstInToken = 0;
|
||||
for(size_t i = 0; i < text.size(); ++i) //tokenize
|
||||
{
|
||||
if(text[i] == 10)
|
||||
{
|
||||
texts.push_back( text.substr(firstInToken, i-firstInToken) );
|
||||
firstInToken = i+1;
|
||||
}
|
||||
}
|
||||
|
||||
texts.push_back( text.substr(firstInToken, text.size()) );
|
||||
lastShown = texts.size()-1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBattleConsole::eraseText(ui32 pos)
|
||||
{
|
||||
if(pos < texts.size())
|
||||
{
|
||||
texts.erase(texts.begin() + pos);
|
||||
if(lastShown == texts.size())
|
||||
--lastShown;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleConsole::changeTextAt(const std::string & text, ui32 pos)
|
||||
{
|
||||
if(pos >= texts.size()) //no such pos
|
||||
return;
|
||||
texts[pos] = text;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollUp(ui32 by)
|
||||
{
|
||||
if(lastShown > static_cast<int>(by))
|
||||
lastShown -= by;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollDown(ui32 by)
|
||||
{
|
||||
if(lastShown + by < texts.size())
|
||||
lastShown += by;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
/*
|
||||
* CBattleConsole.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class CBattleConsole : public CIntObject
|
||||
{
|
||||
private:
|
||||
std::vector< std::string > texts; //a place where texts are stored
|
||||
int lastShown; //last shown line of text
|
||||
public:
|
||||
std::string alterTxt; //if it's not empty, this text is displayed
|
||||
std::string ingcAlter; //alternative text set by in-game console - very important!
|
||||
int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button
|
||||
CBattleConsole(); //c-tor
|
||||
~CBattleConsole(); //d-tor
|
||||
void show(SDL_Surface *to = 0);
|
||||
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
||||
void eraseText(ui32 pos); //erases added text at position pos
|
||||
void changeTextAt(const std::string &text, ui32 pos); //if we have more than pos texts, pos-th is changed to given one
|
||||
void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
void scrollDown(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
};
|
@ -1,154 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleHero.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CDefHandler.h"
|
||||
#include "../CCursorHandler.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../CSpellWindow.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../CConfigHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
void CBattleHero::show(SDL_Surface *to)
|
||||
{
|
||||
//animation of flag
|
||||
if(flip)
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 61,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 72,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
++flagAnimCount;
|
||||
if(flagAnimCount%4==0)
|
||||
{
|
||||
++flagAnim;
|
||||
flagAnim %= flag->ourImages.size();
|
||||
}
|
||||
//animation of hero
|
||||
int tick=-1;
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i)
|
||||
{
|
||||
if(dh->ourImages[i].groupNumber==phase)
|
||||
++tick;
|
||||
if(tick==image)
|
||||
{
|
||||
SDL_Rect posb = pos;
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb);
|
||||
if(phase != 4 || nextPhase != -1 || image < 4)
|
||||
{
|
||||
if(flagAnimCount%2==0)
|
||||
{
|
||||
++image;
|
||||
}
|
||||
if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame
|
||||
{
|
||||
image = 0;
|
||||
}
|
||||
}
|
||||
if(phase == 4 && nextPhase != -1 && image == 7)
|
||||
{
|
||||
phase = nextPhase;
|
||||
nextPhase = -1;
|
||||
image = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::activate()
|
||||
{
|
||||
activateLClick();
|
||||
}
|
||||
void CBattleHero::deactivate()
|
||||
{
|
||||
deactivateLClick();
|
||||
}
|
||||
|
||||
void CBattleHero::setPhase(int newPhase)
|
||||
{
|
||||
if(phase != 4)
|
||||
{
|
||||
phase = newPhase;
|
||||
image = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPhase = newPhase;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(myOwner->spellDestSelectMode) //we are casting a spell
|
||||
return;
|
||||
|
||||
if(!down && myHero != NULL && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
|
||||
{
|
||||
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
||||
{
|
||||
if(myOwner->bfield[it].hovered && myOwner->bfield[it].strictHovered)
|
||||
return;
|
||||
}
|
||||
CCS->curh->changeGraphic(0,0);
|
||||
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), myHero, myOwner->curInt);
|
||||
GH.pushInt(spellWindow);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, ui8 player, const CGHeroInstance * hero, const CBattleInterface * owner): flip(flipG), myHero(hero), myOwner(owner), phase(phaseG), nextPhase(-1), image(imageG), flagAnim(0), flagAnimCount(0)
|
||||
{
|
||||
dh = CDefHandler::giveDef( defName );
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i) //transforming images
|
||||
{
|
||||
if(flip)
|
||||
{
|
||||
SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
|
||||
SDL_FreeSurface(dh->ourImages[i].bitmap);
|
||||
dh->ourImages[i].bitmap = hlp;
|
||||
}
|
||||
CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
|
||||
}
|
||||
|
||||
if(flip)
|
||||
flag = CDefHandler::giveDef("CMFLAGR.DEF");
|
||||
else
|
||||
flag = CDefHandler::giveDef("CMFLAGL.DEF");
|
||||
|
||||
//coloring flag and adding transparency
|
||||
for(size_t i = 0; i < flag->ourImages.size(); ++i)
|
||||
{
|
||||
CSDL_Ext::alphaTransform(flag->ourImages[i].bitmap);
|
||||
graphics->blueToPlayersAdv(flag->ourImages[i].bitmap, player);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::~CBattleHero()
|
||||
{
|
||||
delete dh;
|
||||
delete flag;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CDefHandler;
|
||||
class CGHeroInstance;
|
||||
struct SDL_Surface;
|
||||
|
||||
/*
|
||||
* CBattleHero.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Hero battle animation
|
||||
class CBattleHero : public CIntObject
|
||||
{
|
||||
public:
|
||||
bool flip; //false if it's attacking hero, true otherwise
|
||||
CDefHandler *dh, *flag; //animation and flag
|
||||
const CGHeroInstance *myHero; //this animation's hero instance
|
||||
const CBattleInterface *myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
||||
int image; //frame of animation
|
||||
ui8 flagAnim, flagAnimCount; //for flag animation
|
||||
void show(SDL_Surface *to); //prints next frame of animation to to
|
||||
void activate();
|
||||
void deactivate();
|
||||
void setPhase(int newPhase); //sets phase of hero animation
|
||||
void clickLeft(tribool down, bool previousState); //call-in
|
||||
CBattleHero(const std::string &defName, int phaseG, int imageG, bool filpG, ui8 player, const CGHeroInstance *hero, const CBattleInterface *owner); //c-tor
|
||||
~CBattleHero(); //d-tor
|
||||
};
|
@ -3,9 +3,8 @@
|
||||
|
||||
#include "../CGameInfo.h"
|
||||
#include "../../lib/CLodHandler.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../UIFramework/SDL_Extensions.h"
|
||||
#include "../CAdvmapInterface.h"
|
||||
#include "../AdventureMapButton.h"
|
||||
#include "../CAnimation.h"
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
#include "../../lib/CHeroHandler.h"
|
||||
@ -13,7 +12,6 @@
|
||||
#include "../../lib/CSpellHandler.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CMessage.h"
|
||||
#include "../CCursorHandler.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
@ -29,23 +27,10 @@
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "../../lib/map.h"
|
||||
|
||||
#include "CBattleHero.h"
|
||||
#include "CStackQueue.h"
|
||||
#include "CBattleConsole.h"
|
||||
#include "CBattleResultWindow.h"
|
||||
#include "CBattleAnimation.h"
|
||||
#include "CBattleOptionsWindow.h"
|
||||
#include "CDummyAnimation.h"
|
||||
#include "CClickableHex.h"
|
||||
#include "CShootingAnimation.h"
|
||||
#include "CSpellEffectAnimation.h"
|
||||
#include "CMeleeAttackAnimation.h"
|
||||
#include "CReverseAnimation.h"
|
||||
#include "CMovementStartAnimation.h"
|
||||
#include "CMovementEndAnimation.h"
|
||||
#include "CDefenceAnimation.h"
|
||||
#include "CMovementAnimation.h"
|
||||
#include "CBattleAnimations.h"
|
||||
#include "CBattleInterfaceClasses.h"
|
||||
|
||||
#include "../UIFramework/CCursorHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
@ -69,7 +54,6 @@ const time_t CBattleInterface::HOVER_ANIM_DELTA = 1;
|
||||
*/
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
extern SDL_Color zwykly;
|
||||
|
||||
CondSh<bool> CBattleInterface::animsAreDisplayed;
|
||||
|
||||
@ -109,7 +93,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
activeStack(NULL), stackToActivate(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
|
||||
currentlyHoveredHex(-1), attackingHex(-1), tacticianInterface(NULL), stackCanCastSpell(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL),
|
||||
siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0), givenCommand(NULL),
|
||||
myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
|
||||
myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL), bfield(GameConstants::BFIELD_SIZE)
|
||||
|
||||
{
|
||||
OBJ_CONSTRUCTION;
|
||||
@ -136,7 +120,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
if(curInt->sysOpts.showQueue)
|
||||
pos.y += queue->pos.h / 2; //center whole window
|
||||
|
||||
queue->moveTo(SPoint(pos.x, pos.y - queue->pos.h));
|
||||
queue->moveTo(Point(pos.x, pos.y - queue->pos.h));
|
||||
// queue->pos.x = pos.x;
|
||||
// queue->pos.y = pos.y - queue->pos.h;
|
||||
// pos.h += queue->pos.h;
|
||||
@ -173,7 +157,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
SDL_Surface * moat = BitmapHandler::loadBitmap( siegeH->getSiegeName(13) ),
|
||||
* mlip = BitmapHandler::loadBitmap( siegeH->getSiegeName(14) );
|
||||
|
||||
SPoint moatPos = graphics->wallPositions[siegeH->town->town->typeID][12],
|
||||
Point moatPos = graphics->wallPositions[siegeH->town->town->typeID][12],
|
||||
mlipPos = graphics->wallPositions[siegeH->town->town->typeID][13];
|
||||
|
||||
if(moat) //eg. tower has no moat
|
||||
@ -216,19 +200,19 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
// blitAt(menu, pos.x, 556 + pos.y);
|
||||
|
||||
//preparing buttons and console
|
||||
bOptions = new AdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, boost::bind(&CBattleInterface::bOptionsf,this), 3 + pos.x, 561 + pos.y, "icm003.def", SDLK_o);
|
||||
bSurrender = new AdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, boost::bind(&CBattleInterface::bSurrenderf,this), 54 + pos.x, 561 + pos.y, "icm001.def", SDLK_s);
|
||||
bFlee = new AdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, boost::bind(&CBattleInterface::bFleef,this), 105 + pos.x, 561 + pos.y, "icm002.def", SDLK_r);
|
||||
bOptions = new CAdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, boost::bind(&CBattleInterface::bOptionsf,this), 3 + pos.x, 561 + pos.y, "icm003.def", SDLK_o);
|
||||
bSurrender = new CAdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, boost::bind(&CBattleInterface::bSurrenderf,this), 54 + pos.x, 561 + pos.y, "icm001.def", SDLK_s);
|
||||
bFlee = new CAdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, boost::bind(&CBattleInterface::bFleef,this), 105 + pos.x, 561 + pos.y, "icm002.def", SDLK_r);
|
||||
bFlee->block(!curInt->cb->battleCanFlee());
|
||||
bSurrender->block(curInt->cb->battleGetSurrenderCost() < 0);
|
||||
bAutofight = new AdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, boost::bind(&CBattleInterface::bAutofightf,this), 157 + pos.x, 561 + pos.y, "icm004.def", SDLK_a);
|
||||
bSpell = new AdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, boost::bind(&CBattleInterface::bSpellf,this), 645 + pos.x, 561 + pos.y, "icm005.def", SDLK_c);
|
||||
bAutofight = new CAdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, boost::bind(&CBattleInterface::bAutofightf,this), 157 + pos.x, 561 + pos.y, "icm004.def", SDLK_a);
|
||||
bSpell = new CAdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, boost::bind(&CBattleInterface::bSpellf,this), 645 + pos.x, 561 + pos.y, "icm005.def", SDLK_c);
|
||||
bSpell->block(true);
|
||||
bWait = new AdventureMapButton (CGI->generaltexth->zelp[386].first, CGI->generaltexth->zelp[386].second, boost::bind(&CBattleInterface::bWaitf,this), 696 + pos.x, 561 + pos.y, "icm006.def", SDLK_w);
|
||||
bDefence = new AdventureMapButton (CGI->generaltexth->zelp[387].first, CGI->generaltexth->zelp[387].second, boost::bind(&CBattleInterface::bDefencef,this), 747 + pos.x, 561 + pos.y, "icm007.def", SDLK_d);
|
||||
bWait = new CAdventureMapButton (CGI->generaltexth->zelp[386].first, CGI->generaltexth->zelp[386].second, boost::bind(&CBattleInterface::bWaitf,this), 696 + pos.x, 561 + pos.y, "icm006.def", SDLK_w);
|
||||
bDefence = new CAdventureMapButton (CGI->generaltexth->zelp[387].first, CGI->generaltexth->zelp[387].second, boost::bind(&CBattleInterface::bDefencef,this), 747 + pos.x, 561 + pos.y, "icm007.def", SDLK_d);
|
||||
bDefence->assignedKeys.insert(SDLK_SPACE);
|
||||
bConsoleUp = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624 + pos.x, 561 + pos.y, "ComSlide.def", SDLK_UP);
|
||||
bConsoleDown = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624 + pos.x, 580 + pos.y, "ComSlide.def", SDLK_DOWN);
|
||||
bConsoleUp = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624 + pos.x, 561 + pos.y, "ComSlide.def", SDLK_UP);
|
||||
bConsoleDown = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624 + pos.x, 580 + pos.y, "ComSlide.def", SDLK_DOWN);
|
||||
bConsoleDown->setOffset(2);
|
||||
console = new CBattleConsole();
|
||||
console->pos.x = 211 + pos.x;
|
||||
@ -237,8 +221,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
console->pos.h = 38;
|
||||
if(tacticsMode)
|
||||
{
|
||||
btactNext = new AdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bTacticNextStack,this), 213 + pos.x, 560 + pos.y, "icm011.def", SDLK_SPACE);
|
||||
btactEnd = new AdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bEndTacticPhase,this), 419 + pos.x, 560 + pos.y, "icm012.def", SDLK_RETURN);
|
||||
btactNext = new CAdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bTacticNextStack,this), 213 + pos.x, 560 + pos.y, "icm011.def", SDLK_SPACE);
|
||||
btactEnd = new CAdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bEndTacticPhase,this), 419 + pos.x, 560 + pos.y, "icm012.def", SDLK_RETURN);
|
||||
bDefence->block(true);
|
||||
bWait->block(true);
|
||||
menu = BitmapHandler::loadBitmap("COPLACBR.BMP");
|
||||
@ -281,7 +265,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
CSDL_Ext::alphaTransform(cellBorder);
|
||||
cellShade = BitmapHandler::loadBitmap("CCELLSHD.BMP");
|
||||
CSDL_Ext::alphaTransform(cellShade);
|
||||
for(int h = 0; h < ARRAY_COUNT(bfield); ++h)
|
||||
for(int h = 0; h < bfield.size(); ++h)
|
||||
{
|
||||
bfield[h].myNumber = h;
|
||||
|
||||
@ -362,7 +346,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_COUNT(bfield); i++)
|
||||
for (int i = 0; i < bfield.size(); i++)
|
||||
{
|
||||
children.push_back(&bfield[i]);
|
||||
}
|
||||
@ -603,8 +587,8 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
{//TODO: do not check it every frame
|
||||
if (activeStack) //highlight all attackable hexes
|
||||
{
|
||||
std::set<SBattleHex> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
|
||||
BOOST_FOREACH(SBattleHex hex, set)
|
||||
std::set<BattleHex> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
|
||||
BOOST_FOREACH(BattleHex hex, set)
|
||||
{
|
||||
int x = 14 + ((hex/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(hex%GameConstants::BFIELD_WIDTH) + pos.x;
|
||||
int y = 86 + 42 * (hex/GameConstants::BFIELD_WIDTH) + pos.y;
|
||||
@ -630,10 +614,10 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
|
||||
//preparing obstacles to be shown
|
||||
std::vector<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
|
||||
std::multimap<SBattleHex, int> hexToObstacle;
|
||||
std::multimap<BattleHex, int> hexToObstacle;
|
||||
for(size_t b = 0; b < obstacles.size(); ++b)
|
||||
{
|
||||
SBattleHex position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos);
|
||||
BattleHex position = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getMaxBlocked(obstacles[b].pos);
|
||||
hexToObstacle.insert(std::make_pair(position, b));
|
||||
}
|
||||
|
||||
@ -713,7 +697,6 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
{
|
||||
showAliveStacks(stackAliveByHex, b, &flyingStacks, to);
|
||||
showObstacles(&hexToObstacle, obstacles, b, to);
|
||||
showPieceOfWall(to, b, stacks);
|
||||
}
|
||||
}
|
||||
// Siege drawing
|
||||
@ -802,7 +785,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
//showing spell effects
|
||||
if(battleEffects.size())
|
||||
{
|
||||
for(std::list<SBattleEffect>::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it)
|
||||
for(std::list<BattleEffect>::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it)
|
||||
{
|
||||
SDL_Surface * bitmapToBlit = it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap;
|
||||
SDL_Rect temp_rect = genRect(bitmapToBlit->h, bitmapToBlit->w, it->x, it->y);
|
||||
@ -845,7 +828,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
//showing in-game console
|
||||
LOCPLINT->cingconsole->show(to);
|
||||
|
||||
SRect posWithQueue = SRect(pos.x, pos.y, 800, 600);
|
||||
Rect posWithQueue = Rect(pos.x, pos.y, 800, 600);
|
||||
|
||||
if(curInt->sysOpts.showQueue)
|
||||
{
|
||||
@ -891,12 +874,12 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
|
||||
void CBattleInterface::showObstacles(std::multimap<BattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to)
|
||||
{
|
||||
std::pair<std::multimap<SBattleHex, int>::const_iterator, std::multimap<SBattleHex, int>::const_iterator> obstRange =
|
||||
std::pair<std::multimap<BattleHex, int>::const_iterator, std::multimap<BattleHex, int>::const_iterator> obstRange =
|
||||
hexToObstacle->equal_range(hex);
|
||||
|
||||
for(std::multimap<SBattleHex, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
|
||||
for(std::multimap<BattleHex, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
|
||||
{
|
||||
CObstacleInstance & curOb = obstacles[it->second];
|
||||
std::pair<si16, si16> shift = CGI->heroh->obstacles.find(curOb.ID)->second.posShift;
|
||||
@ -963,7 +946,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel)
|
||||
{
|
||||
const CSpell * spell = CGI->spellh->spells[creatureSpellToCast];
|
||||
if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(myNumber)) == ESpellCastProblem::OK)
|
||||
if (curInt->cb->battleCanCastThisSpell(spell, BattleHex(myNumber)) == ESpellCastProblem::OK)
|
||||
{
|
||||
if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack))
|
||||
{
|
||||
@ -1368,7 +1351,7 @@ void CBattleInterface::setBattleCursor(const int myNumber)
|
||||
attackingHex = myNumber + GameConstants::BFIELD_WIDTH - 1 + zigzagCorrection; //bottom left
|
||||
break;
|
||||
}
|
||||
SBattleHex hex(attackingHex);
|
||||
BattleHex hex(attackingHex);
|
||||
if (!hex.isValid())
|
||||
attackingHex = -1;
|
||||
}
|
||||
@ -1388,7 +1371,7 @@ void CBattleInterface::bOptionsf()
|
||||
|
||||
CCS->curh->changeGraphic(0,0);
|
||||
|
||||
SRect tempRect = genRect(431, 481, 160, 84);
|
||||
Rect tempRect = genRect(431, 481, 160, 84);
|
||||
tempRect += pos.topLeft();
|
||||
CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(tempRect, this);
|
||||
GH.pushInt(optionsWin);
|
||||
@ -1405,7 +1388,7 @@ void CBattleInterface::bSurrenderf()
|
||||
const CGHeroInstance *opponent = curInt->cb->battleGetFightingHero(1);
|
||||
std::string enemyHeroName = opponent ? opponent->name : "#ENEMY#"; //TODO: should surrendering without enemy hero be enabled?
|
||||
std::string surrenderMessage = boost::str(boost::format(CGI->generaltexth->allTexts[32]) % enemyHeroName % cost); //%s states: "I will accept your surrender and grant you and your troops safe passage for the price of %d gold."
|
||||
curInt->showYesNoDialog(surrenderMessage, std::vector<SComponent*>(), boost::bind(&CBattleInterface::reallySurrender,this), 0, false);
|
||||
curInt->showYesNoDialog(surrenderMessage, std::vector<CComponent*>(), boost::bind(&CBattleInterface::reallySurrender,this), 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1417,11 +1400,11 @@ void CBattleInterface::bFleef()
|
||||
if( curInt->cb->battleCanFlee() )
|
||||
{
|
||||
CFunctionList<void()> ony = boost::bind(&CBattleInterface::reallyFlee,this);
|
||||
curInt->showYesNoDialog(CGI->generaltexth->allTexts[28],std::vector<SComponent*>(), ony, 0, false); //Are you sure you want to retreat?
|
||||
curInt->showYesNoDialog(CGI->generaltexth->allTexts[28],std::vector<CComponent*>(), ony, 0, false); //Are you sure you want to retreat?
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<SComponent*> comps;
|
||||
std::vector<CComponent*> comps;
|
||||
std::string heroName;
|
||||
//calculating fleeing hero's name
|
||||
if(attackingHeroInstance)
|
||||
@ -1516,7 +1499,7 @@ void CBattleInterface::bConsoleDownf()
|
||||
|
||||
void CBattleInterface::newStack(const CStack * stack)
|
||||
{
|
||||
SPoint coords = CClickableHex::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);;
|
||||
Point coords = CClickableHex::getXYUnitAnim(stack->position, stack->owner == attackingHeroInstance->tempOwner, stack, this);;
|
||||
|
||||
if(stack->position < 0) //turret
|
||||
{
|
||||
@ -1549,7 +1532,7 @@ void CBattleInterface::newStack(const CStack * stack)
|
||||
creAnims[stack->ID] = new CCreatureAnimation(stack->getCreature()->animDefName);
|
||||
}
|
||||
creAnims[stack->ID]->setType(CCreatureAnim::HOLDING);
|
||||
creAnims[stack->ID]->pos = SRect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight);
|
||||
creAnims[stack->ID]->pos = Rect(coords.x, coords.y, creAnims[stack->ID]->fullWidth, creAnims[stack->ID]->fullHeight);
|
||||
creDir[stack->ID] = stack->attackerOwned;
|
||||
}
|
||||
|
||||
@ -1568,13 +1551,13 @@ void CBattleInterface::stackActivated(const CStack * stack) //TODO: check it all
|
||||
activateStack();
|
||||
}
|
||||
|
||||
void CBattleInterface::stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance)
|
||||
void CBattleInterface::stackMoved(const CStack * stack, std::vector<BattleHex> destHex, int distance)
|
||||
{
|
||||
addNewAnim(new CMovementAnimation(this, stack, destHex, distance));
|
||||
waitForAnims();
|
||||
}
|
||||
|
||||
void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos)
|
||||
void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
|
||||
{
|
||||
for(size_t h = 0; h < attackedInfos.size(); ++h)
|
||||
{
|
||||
@ -1605,7 +1588,7 @@ void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> attacke
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::stackAttacking( const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting )
|
||||
void CBattleInterface::stackAttacking( const CStack * attacker, BattleHex dest, const CStack * attacked, bool shooting )
|
||||
{
|
||||
if (shooting)
|
||||
{
|
||||
@ -1639,7 +1622,7 @@ void CBattleInterface::newRound(int number)
|
||||
|
||||
}
|
||||
|
||||
void CBattleInterface::giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional)
|
||||
void CBattleInterface::giveCommand(ui8 action, BattleHex tile, ui32 stack, si32 additional)
|
||||
{
|
||||
if(!curInt->cb->battleGetStackByID(stack) && action != 1 && action != 4 && action != 5)
|
||||
{
|
||||
@ -1678,30 +1661,30 @@ void CBattleInterface::giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleInterface::isTileAttackable(const SBattleHex & number) const
|
||||
bool CBattleInterface::isTileAttackable(const BattleHex & number) const
|
||||
{
|
||||
for(size_t b=0; b<occupyableHexes.size(); ++b)
|
||||
{
|
||||
if(SBattleHex::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
|
||||
if(BattleHex::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBattleInterface::blockedByObstacle(SBattleHex hex) const
|
||||
bool CBattleInterface::blockedByObstacle(BattleHex hex) const
|
||||
{
|
||||
std::vector<CObstacleInstance> obstacles = curInt->cb->battleGetAllObstacles();
|
||||
std::set<SBattleHex> coveredHexes;
|
||||
std::set<BattleHex> coveredHexes;
|
||||
for(size_t b = 0; b < obstacles.size(); ++b)
|
||||
{
|
||||
std::vector<SBattleHex> blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
|
||||
std::vector<BattleHex> blocked = CGI->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
|
||||
for(size_t w = 0; w < blocked.size(); ++w)
|
||||
coveredHexes.insert(blocked[w]);
|
||||
}
|
||||
return vstd::contains(coveredHexes, hex);
|
||||
}
|
||||
|
||||
bool CBattleInterface::isCatapultAttackable(SBattleHex hex) const
|
||||
bool CBattleInterface::isCatapultAttackable(BattleHex hex) const
|
||||
{
|
||||
if(!siegeH)
|
||||
return false;
|
||||
@ -1799,7 +1782,7 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
if ((int)creatureSpellToCast > -1) //use randomized spell (Faerie Dragon), or only avaliable spell (Archangel)
|
||||
{
|
||||
const CSpell * spell = CGI->spellh->spells[creatureSpellToCast];
|
||||
if (curInt->cb->battleCanCastThisSpell(spell, SBattleHex(whichOne)) == ESpellCastProblem::OK)
|
||||
if (curInt->cb->battleCanCastThisSpell(spell, BattleHex(whichOne)) == ESpellCastProblem::OK)
|
||||
{
|
||||
if ((spell->positiveness > -1 && ourStack) || (spell->positiveness < 1 && !ourStack))
|
||||
{
|
||||
@ -1880,7 +1863,7 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
{
|
||||
if(actStack->doubleWide() && !actStack->attackerOwned)
|
||||
{
|
||||
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
if(vstd::contains(acc, whichOne))
|
||||
attackFromHex = whichOne - 1;
|
||||
else
|
||||
@ -1932,7 +1915,7 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
{
|
||||
if(actStack->doubleWide() && actStack->attackerOwned)
|
||||
{
|
||||
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
if(vstd::contains(acc, whichOne))
|
||||
attackFromHex = whichOne + 1;
|
||||
else
|
||||
@ -2018,7 +2001,7 @@ void CBattleInterface::hexLclicked(int whichOne)
|
||||
CCS->curh->changeGraphic(1, 6); //cursor should be changed
|
||||
if(activeStack->doubleWide())
|
||||
{
|
||||
std::vector<SBattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
|
||||
int shiftedDest = whichOne + (activeStack->attackerOwned ? 1 : -1);
|
||||
if(vstd::contains(acc, whichOne))
|
||||
giveCommand (BattleAction::WALK ,whichOne, activeStack->ID);
|
||||
@ -2101,8 +2084,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
{ //common ice bolt and magic arrow part
|
||||
//initial variables
|
||||
std::string animToDisplay;
|
||||
SPoint srccoord = (sc->side ? SPoint(770, 60) : SPoint(30, 60)) + pos;
|
||||
SPoint destcoord = CClickableHex::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow
|
||||
Point srccoord = (sc->side ? Point(770, 60) : Point(30, 60)) + pos;
|
||||
Point destcoord = CClickableHex::getXYUnitAnim(sc->tile, !sc->side, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by arrow
|
||||
destcoord.x += 250; destcoord.y += 240;
|
||||
|
||||
//animation angle
|
||||
@ -2320,8 +2303,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
|
||||
//mana absorption
|
||||
if (sc->manaGained)
|
||||
{
|
||||
SPoint leftHero = SPoint(15, 30) + pos;
|
||||
SPoint rightHero = SPoint(755, 30) + pos;
|
||||
Point leftHero = Point(15, 30) + pos;
|
||||
Point rightHero = Point(755, 30) + pos;
|
||||
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_A.DEF" : "SP07_B.DEF", leftHero.x, leftHero.y, 0, 0, false));
|
||||
addNewAnim(new CSpellEffectAnimation(this, sc->side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero.x, rightHero.y, 0, 0, false));
|
||||
}
|
||||
@ -2608,7 +2591,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
||||
|
||||
// As long as the projectile of the shooter-stack is flying incrementFrame should be false
|
||||
bool shootingFinished = true;
|
||||
for (std::list<SProjectileInfo>::iterator it = projectiles.begin(); it != projectiles.end(); ++it)
|
||||
for (std::list<ProjectileInfo>::iterator it = projectiles.begin(); it != projectiles.end(); ++it)
|
||||
{
|
||||
if (it->stackID == ID)
|
||||
{
|
||||
@ -2632,7 +2615,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
||||
&& !stack->hasBonusOfType(Bonus::SIEGE_WEAPON) //and not a war machine...
|
||||
)
|
||||
{
|
||||
const SBattleHex nextPos = stack->position + (stack->attackerOwned ? 1 : -1);
|
||||
const BattleHex nextPos = stack->position + (stack->attackerOwned ? 1 : -1);
|
||||
const bool edge = stack->position % GameConstants::BFIELD_WIDTH == (stack->attackerOwned ? GameConstants::BFIELD_WIDTH - 2 : 1);
|
||||
const bool moveInside = !edge && !stackCountOutsideHexes[nextPos];
|
||||
int xAdd = (stack->attackerOwned ? 220 : 202) +
|
||||
@ -2675,7 +2658,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
|
||||
creAnims[ID]->pos.x + xAdd + 15,
|
||||
creAnims[ID]->pos.y + yAdd + 5,
|
||||
FONT_TINY,
|
||||
zwykly,
|
||||
Colors::Cornsilk,
|
||||
to
|
||||
);
|
||||
}
|
||||
@ -2769,9 +2752,9 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
|
||||
|
||||
if(curInt->sysOpts.printStackRange)
|
||||
{
|
||||
std::vector<SBattleHex> hexesToShade = occupyableHexes;
|
||||
std::vector<BattleHex> hexesToShade = occupyableHexes;
|
||||
hexesToShade.insert(hexesToShade.end(), attackableHexes.begin(), attackableHexes.end());
|
||||
BOOST_FOREACH(SBattleHex hex, hexesToShade)
|
||||
BOOST_FOREACH(BattleHex hex, hexesToShade)
|
||||
{
|
||||
int i = hex.getY(); //row
|
||||
int j = hex.getX()-1; //column
|
||||
@ -2813,8 +2796,8 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
|
||||
{
|
||||
if(to == NULL)
|
||||
to = screen;
|
||||
std::list< std::list<SProjectileInfo>::iterator > toBeDeleted;
|
||||
for(std::list<SProjectileInfo>::iterator it=projectiles.begin(); it!=projectiles.end(); ++it)
|
||||
std::list< std::list<ProjectileInfo>::iterator > toBeDeleted;
|
||||
for(std::list<ProjectileInfo>::iterator it=projectiles.begin(); it!=projectiles.end(); ++it)
|
||||
{
|
||||
// Creature have to be in a shooting anim and the anim start delay must be over.
|
||||
// Otherwise abort to start moving the projectile.
|
||||
@ -2880,7 +2863,7 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
|
||||
}
|
||||
}
|
||||
}
|
||||
for(std::list< std::list<SProjectileInfo>::iterator >::iterator it = toBeDeleted.begin(); it!= toBeDeleted.end(); ++it)
|
||||
for(std::list< std::list<ProjectileInfo>::iterator >::iterator it = toBeDeleted.begin(); it!= toBeDeleted.end(); ++it)
|
||||
{
|
||||
projectiles.erase(*it);
|
||||
}
|
||||
@ -2937,7 +2920,7 @@ void CBattleInterface::hideQueue()
|
||||
|
||||
if(!queue->embedded)
|
||||
{
|
||||
moveBy(SPoint(0, -queue->pos.h / 2));
|
||||
moveBy(Point(0, -queue->pos.h / 2));
|
||||
GH.totalRedraw();
|
||||
}
|
||||
}
|
||||
@ -2950,7 +2933,7 @@ void CBattleInterface::showQueue()
|
||||
|
||||
if(!queue->embedded)
|
||||
{
|
||||
moveBy(SPoint(0, +queue->pos.h / 2));
|
||||
moveBy(Point(0, +queue->pos.h / 2));
|
||||
GH.totalRedraw();
|
||||
}
|
||||
}
|
||||
@ -3170,7 +3153,7 @@ std::string CBattleInterface::SiegeHelper::getSiegeName(ui16 what, ui16 additInf
|
||||
/// Positions are loaded from the config file: /config/wall_pos.txt
|
||||
void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what)
|
||||
{
|
||||
SPoint pos = SPoint(-1, -1);
|
||||
Point pos = Point(-1, -1);
|
||||
|
||||
if (what >= 1 && what <= 17)
|
||||
{
|
||||
@ -3184,7 +3167,7 @@ void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what)
|
||||
}
|
||||
}
|
||||
|
||||
double SCatapultSProjectileInfo::calculateY(double x)
|
||||
double CatapultProjectileInfo::calculateY(double x)
|
||||
{
|
||||
return (facA * pow(10., -3.)) * pow(x, 2.0) + facB * x + facC;
|
||||
}
|
||||
|
@ -4,10 +4,6 @@
|
||||
#include "../../lib/CCreatureSet.h"
|
||||
#include "../../lib/ConstTransitivePtr.h" //may be reundant
|
||||
#include "../CAnimation.h"
|
||||
#include "SStackAttackedInfo.h"
|
||||
#include "CClickableHex.h"
|
||||
#include "CShootingAnimation.h"
|
||||
#include "../../lib/SBattleHex.h"
|
||||
#include "../../lib/GameConstants.h"
|
||||
|
||||
/*
|
||||
@ -26,7 +22,7 @@ class CGHeroInstance;
|
||||
class CDefHandler;
|
||||
class CStack;
|
||||
class CCallback;
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
struct BattleResult;
|
||||
@ -37,8 +33,7 @@ struct SetStackEffect;;
|
||||
struct BattleAction;
|
||||
class CGTownInstance;
|
||||
struct CatapultAttack;
|
||||
class CBattleInterface;
|
||||
struct SCatapultSProjectileInfo;
|
||||
struct CatapultProjectileInfo;
|
||||
struct BattleTriggerEffect;
|
||||
class CBattleAnimation;
|
||||
class CBattleHero;
|
||||
@ -46,6 +41,10 @@ class CBattleConsole;
|
||||
class CBattleResultWindow;
|
||||
class CStackQueue;
|
||||
class CPlayerInterface;
|
||||
class CCreatureAnimation;
|
||||
struct ProjectileInfo;
|
||||
class CClickableHex;
|
||||
struct BattleHex;
|
||||
|
||||
/// Class which manages the locked hex fields that are blocked e.g. by obstacles
|
||||
class CBattleObstacle
|
||||
@ -53,8 +52,20 @@ class CBattleObstacle
|
||||
std::vector<int> lockedHexes;
|
||||
};
|
||||
|
||||
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
|
||||
struct StackAttackedInfo
|
||||
{
|
||||
const CStack * defender; //attacked stack
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
bool rebirth; //if true, play rebirth animation after all
|
||||
};
|
||||
|
||||
/// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
|
||||
struct SBattleEffect
|
||||
struct BattleEffect
|
||||
{
|
||||
int x, y; //position on the screen
|
||||
int frame, maxFrame;
|
||||
@ -63,13 +74,13 @@ struct SBattleEffect
|
||||
};
|
||||
|
||||
/// Small struct which is needed for drawing the parabolic trajectory of the catapult cannon
|
||||
struct SCatapultSProjectileInfo
|
||||
struct CatapultProjectileInfo
|
||||
{
|
||||
const double facA, facB, facC;
|
||||
const int fromX, toX;
|
||||
|
||||
SCatapultSProjectileInfo() : facA(0), facB(0), facC(0), fromX(0), toX(0) { };
|
||||
SCatapultSProjectileInfo(double factorA, double factorB, double factorC, int fromXX, int toXX) : facA(factorA), facB(factorB), facC(factorC),
|
||||
CatapultProjectileInfo() : facA(0), facB(0), facC(0), fromX(0), toX(0) { };
|
||||
CatapultProjectileInfo(double factorA, double factorB, double factorC, int fromXX, int toXX) : facA(factorA), facB(factorB), facC(factorC),
|
||||
fromX(fromXX), toX(toXX) { };
|
||||
|
||||
double calculateY(double x);
|
||||
@ -85,7 +96,7 @@ class CBattleInterface : public CIntObject
|
||||
};
|
||||
private:
|
||||
SDL_Surface * background, * menu, * amountNormal, * amountNegative, * amountPositive, * amountEffNeutral, * cellBorders, * backgroundWithHexes;
|
||||
AdventureMapButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
|
||||
CAdventureMapButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell,
|
||||
* bWait, * bDefence, * bConsoleUp, * bConsoleDown, *btactNext, *btactEnd;
|
||||
CBattleConsole * console;
|
||||
CBattleHero * attackingHero, * defendingHero; //fighting heroes
|
||||
@ -103,7 +114,7 @@ private:
|
||||
int mouseHoveredStack; //stack hovered by mouse; if -1 -> none
|
||||
time_t lastMouseHoveredStackAnimationTime; // time when last mouse hovered animation occurred
|
||||
static const time_t HOVER_ANIM_DELTA;
|
||||
std::vector<SBattleHex> occupyableHexes, //hexes available for active stack
|
||||
std::vector<BattleHex> occupyableHexes, //hexes available for active stack
|
||||
attackableHexes; //hexes attackable by active stack
|
||||
bool stackCountOutsideHexes[GameConstants::BFIELD_SIZE]; // hexes that when in front of a unit cause it's amount box to move back
|
||||
int previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago
|
||||
@ -124,18 +135,18 @@ private:
|
||||
void showAliveStack(const CStack *stack, SDL_Surface * to); //helper function for function show
|
||||
void showAliveStacks(std::vector<const CStack *> *aliveStacks, int hex, std::vector<const CStack *> *flyingStacks, SDL_Surface *to); // loops through all stacks at a given hex position
|
||||
void showPieceOfWall(SDL_Surface * to, int hex, const std::vector<const CStack*> & stacks); //helper function for show
|
||||
void showObstacles(std::multimap<SBattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
|
||||
void showObstacles(std::multimap<BattleHex, int> *hexToObstacle, std::vector<CObstacleInstance> &obstacles, int hex, SDL_Surface *to); // show all obstacles at a given hex position
|
||||
void redrawBackgroundWithHexes(const CStack * activeStack);
|
||||
void printConsoleAttacked(const CStack * defender, int dmg, int killed, const CStack * attacker, bool Multiple);
|
||||
|
||||
std::list<SProjectileInfo> projectiles; //projectiles flying on battlefield
|
||||
std::list<ProjectileInfo> projectiles; //projectiles flying on battlefield
|
||||
void projectileShowHelper(SDL_Surface * to); //prints projectiles present on the battlefield
|
||||
void giveCommand(ui8 action, SBattleHex tile, ui32 stack, si32 additional=-1);
|
||||
bool isTileAttackable(const SBattleHex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
|
||||
bool blockedByObstacle(SBattleHex hex) const;
|
||||
bool isCatapultAttackable(SBattleHex hex) const; //returns true if given tile can be attacked by catapult
|
||||
void giveCommand(ui8 action, BattleHex tile, ui32 stack, si32 additional=-1);
|
||||
bool isTileAttackable(const BattleHex & number) const; //returns true if tile 'number' is neighboring any tile from active stack's range or is one of these tiles
|
||||
bool blockedByObstacle(BattleHex hex) const;
|
||||
bool isCatapultAttackable(BattleHex hex) const; //returns true if given tile can be attacked by catapult
|
||||
|
||||
std::list<SBattleEffect> battleEffects; //different animations to display on the screen like spell effects
|
||||
std::list<BattleEffect> battleEffects; //different animations to display on the screen like spell effects
|
||||
|
||||
/// Class which is responsible for drawing the wall of a siege during battle
|
||||
class SiegeHelper
|
||||
@ -177,7 +188,7 @@ public:
|
||||
void setAnimSpeed(int set); //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
||||
int getAnimSpeed() const; //speed of animation; 1 - slowest, 2 - medium, 4 - fastest
|
||||
|
||||
CClickableHex bfield[GameConstants::BFIELD_SIZE]; //11 lines, 17 hexes on each
|
||||
std::vector<CClickableHex> bfield; //11 lines, 17 hexes on each
|
||||
//std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
|
||||
SDL_Surface * cellBorder, * cellShade;
|
||||
CondSh<BattleAction *> *givenCommand; //data != NULL if we have i.e. moved current unit
|
||||
@ -215,10 +226,10 @@ public:
|
||||
void newStack(const CStack * stack); //new stack appeared on battlefield
|
||||
void stackRemoved(int stackID); //stack disappeared from batlefiled
|
||||
void stackActivated(const CStack * stack); //active stack has been changed
|
||||
void stackMoved(const CStack * stack, std::vector<SBattleHex> destHex, int distance); //stack with id number moved to destHex
|
||||
void stackMoved(const CStack * stack, std::vector<BattleHex> destHex, int distance); //stack with id number moved to destHex
|
||||
void waitForAnims();
|
||||
void stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
|
||||
void stackAttacking(const CStack * attacker, SBattleHex dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
|
||||
void stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
|
||||
void stackAttacking(const CStack * attacker, BattleHex dest, const CStack * attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
|
||||
void newRoundFirst( int round );
|
||||
void newRound(int number); //caled when round is ended; number is the number of round
|
||||
void hexLclicked(int whichOne); //hex only call-in
|
||||
@ -238,7 +249,7 @@ public:
|
||||
|
||||
|
||||
friend class CPlayerInterface;
|
||||
friend class AdventureMapButton;
|
||||
friend class CAdventureMapButton;
|
||||
friend class CInGameConsole;
|
||||
|
||||
friend class CBattleResultWindow;
|
||||
|
754
client/BattleInterface/CBattleInterfaceClasses.cpp
Normal file
754
client/BattleInterface/CBattleInterfaceClasses.cpp
Normal file
@ -0,0 +1,754 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleInterfaceClasses.h"
|
||||
|
||||
#include "../UIFramework/SDL_Extensions.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CDefHandler.h"
|
||||
#include "../UIFramework/CCursorHandler.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../CSpellWindow.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../CConfigHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
#include "../UIFramework/CIntObjectClasses.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../../lib/NetPacks.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CVideoHandler.h"
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../CCreatureWindow.h"
|
||||
|
||||
CBattleConsole::~CBattleConsole()
|
||||
{
|
||||
texts.clear();
|
||||
}
|
||||
|
||||
void CBattleConsole::show(SDL_Surface * to)
|
||||
{
|
||||
if(ingcAlter.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(ingcAlter, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else if(alterTxt.size())
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(alterTxt, pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else if(texts.size())
|
||||
{
|
||||
if(texts.size()==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[0], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown-1], pos.x + pos.w/2, pos.y + 11, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
CSDL_Ext::printAtMiddleWB(texts[lastShown], pos.x + pos.w/2, pos.y + 27, FONT_SMALL, 80, Colors::Cornsilk, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CBattleConsole::addText(const std::string & text)
|
||||
{
|
||||
if(text.size()>70)
|
||||
return false; //text too long!
|
||||
int firstInToken = 0;
|
||||
for(size_t i = 0; i < text.size(); ++i) //tokenize
|
||||
{
|
||||
if(text[i] == 10)
|
||||
{
|
||||
texts.push_back( text.substr(firstInToken, i-firstInToken) );
|
||||
firstInToken = i+1;
|
||||
}
|
||||
}
|
||||
|
||||
texts.push_back( text.substr(firstInToken, text.size()) );
|
||||
lastShown = texts.size()-1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBattleConsole::eraseText(ui32 pos)
|
||||
{
|
||||
if(pos < texts.size())
|
||||
{
|
||||
texts.erase(texts.begin() + pos);
|
||||
if(lastShown == texts.size())
|
||||
--lastShown;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleConsole::changeTextAt(const std::string & text, ui32 pos)
|
||||
{
|
||||
if(pos >= texts.size()) //no such pos
|
||||
return;
|
||||
texts[pos] = text;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollUp(ui32 by)
|
||||
{
|
||||
if(lastShown > static_cast<int>(by))
|
||||
lastShown -= by;
|
||||
}
|
||||
|
||||
void CBattleConsole::scrollDown(ui32 by)
|
||||
{
|
||||
if(lastShown + by < texts.size())
|
||||
lastShown += by;
|
||||
}
|
||||
|
||||
void CBattleHero::show(SDL_Surface * to)
|
||||
{
|
||||
//animation of flag
|
||||
if(flip)
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 61,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
pos.x + 72,
|
||||
pos.y + 39);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&temp_rect);
|
||||
}
|
||||
++flagAnimCount;
|
||||
if(flagAnimCount%4==0)
|
||||
{
|
||||
++flagAnim;
|
||||
flagAnim %= flag->ourImages.size();
|
||||
}
|
||||
//animation of hero
|
||||
int tick=-1;
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i)
|
||||
{
|
||||
if(dh->ourImages[i].groupNumber==phase)
|
||||
++tick;
|
||||
if(tick==image)
|
||||
{
|
||||
SDL_Rect posb = pos;
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb);
|
||||
if(phase != 4 || nextPhase != -1 || image < 4)
|
||||
{
|
||||
if(flagAnimCount%2==0)
|
||||
{
|
||||
++image;
|
||||
}
|
||||
if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame
|
||||
{
|
||||
image = 0;
|
||||
}
|
||||
}
|
||||
if(phase == 4 && nextPhase != -1 && image == 7)
|
||||
{
|
||||
phase = nextPhase;
|
||||
nextPhase = -1;
|
||||
image = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::activate()
|
||||
{
|
||||
activateLClick();
|
||||
}
|
||||
void CBattleHero::deactivate()
|
||||
{
|
||||
deactivateLClick();
|
||||
}
|
||||
|
||||
void CBattleHero::setPhase(int newPhase)
|
||||
{
|
||||
if(phase != 4)
|
||||
{
|
||||
phase = newPhase;
|
||||
image = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPhase = newPhase;
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleHero::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(myOwner->spellDestSelectMode) //we are casting a spell
|
||||
return;
|
||||
|
||||
if(!down && myHero != NULL && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
|
||||
{
|
||||
for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
|
||||
{
|
||||
if(myOwner->bfield[it].hovered && myOwner->bfield[it].strictHovered)
|
||||
return;
|
||||
}
|
||||
CCS->curh->changeGraphic(0,0);
|
||||
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), myHero, myOwner->curInt);
|
||||
GH.pushInt(spellWindow);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::CBattleHero(const std::string & defName, int phaseG, int imageG, bool flipG, ui8 player, const CGHeroInstance * hero, const CBattleInterface * owner): flip(flipG), myHero(hero), myOwner(owner), phase(phaseG), nextPhase(-1), image(imageG), flagAnim(0), flagAnimCount(0)
|
||||
{
|
||||
dh = CDefHandler::giveDef( defName );
|
||||
for(size_t i = 0; i < dh->ourImages.size(); ++i) //transforming images
|
||||
{
|
||||
if(flip)
|
||||
{
|
||||
SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
|
||||
SDL_FreeSurface(dh->ourImages[i].bitmap);
|
||||
dh->ourImages[i].bitmap = hlp;
|
||||
}
|
||||
CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
|
||||
}
|
||||
|
||||
if(flip)
|
||||
flag = CDefHandler::giveDef("CMFLAGR.DEF");
|
||||
else
|
||||
flag = CDefHandler::giveDef("CMFLAGL.DEF");
|
||||
|
||||
//coloring flag and adding transparency
|
||||
for(size_t i = 0; i < flag->ourImages.size(); ++i)
|
||||
{
|
||||
CSDL_Ext::alphaTransform(flag->ourImages[i].bitmap);
|
||||
graphics->blueToPlayersAdv(flag->ourImages[i].bitmap, player);
|
||||
}
|
||||
}
|
||||
|
||||
CBattleHero::~CBattleHero()
|
||||
{
|
||||
delete dh;
|
||||
delete flag;
|
||||
}
|
||||
|
||||
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
pos = position;
|
||||
background = new CPicture("comopbck.bmp");
|
||||
background->colorize(owner->curInt->playerID);
|
||||
|
||||
viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", NULL, 25, 56, false);
|
||||
viewGrid->select(owner->curInt->sysOpts.printCellBorders);
|
||||
movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", NULL, 25, 89, false);
|
||||
movementShadow->select(owner->curInt->sysOpts.printStackRange);
|
||||
mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", NULL, 25, 122, false);
|
||||
mouseShadow->select(owner->curInt->sysOpts.printMouseShadow);
|
||||
|
||||
animSpeeds = new CHighlightableButtonsGroup(0);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[422].first),CGI->generaltexth->zelp[422].second, "sysopb9.def", 28, 225, 1);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[423].first),CGI->generaltexth->zelp[423].second, "sysob10.def", 92, 225, 2);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[424].first),CGI->generaltexth->zelp[424].second, "sysob11.def",156, 225, 4);
|
||||
animSpeeds->select(owner->getAnimSpeed(), 1);
|
||||
animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
|
||||
|
||||
setToDefault = new CAdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
|
||||
setToDefault->swappedImages = true;
|
||||
setToDefault->update();
|
||||
exit = new CAdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
|
||||
exit->swappedImages = true;
|
||||
exit->update();
|
||||
|
||||
//creating labels
|
||||
labels.push_back(new CLabel(242, 32, FONT_BIG, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[392]));//window title
|
||||
labels.push_back(new CLabel(122, 214, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[393]));//animation speed
|
||||
labels.push_back(new CLabel(122, 293, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[394]));//music volume
|
||||
labels.push_back(new CLabel(122, 359, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[395]));//effects' volume
|
||||
labels.push_back(new CLabel(353, 66, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[396]));//auto - combat options
|
||||
labels.push_back(new CLabel(353, 265, FONT_MEDIUM, CENTER, Colors::Jasmine, CGI->generaltexth->allTexts[397]));//creature info
|
||||
|
||||
//auto - combat options
|
||||
labels.push_back(new CLabel(283, 86, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[398]));//creatures
|
||||
labels.push_back(new CLabel(283, 116, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[399]));//spells
|
||||
labels.push_back(new CLabel(283, 146, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[400]));//catapult
|
||||
labels.push_back(new CLabel(283, 176, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[151]));//ballista
|
||||
labels.push_back(new CLabel(283, 206, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[401]));//first aid tent
|
||||
|
||||
//creature info
|
||||
labels.push_back(new CLabel(283, 285, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[402]));//all stats
|
||||
labels.push_back(new CLabel(283, 315, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[403]));//spells only
|
||||
|
||||
//general options
|
||||
labels.push_back(new CLabel(61, 57, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[404]));
|
||||
labels.push_back(new CLabel(61, 90, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[405]));
|
||||
labels.push_back(new CLabel(61, 123, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[406]));
|
||||
labels.push_back(new CLabel(61, 156, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bDefaultf()
|
||||
{
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bExitf()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner)
|
||||
: owner(_owner)
|
||||
{
|
||||
this->pos = pos;
|
||||
background = BitmapHandler::loadBitmap("CPRESULT.BMP", true);
|
||||
graphics->blueToPlayersAdv(background, owner->curInt->playerID);
|
||||
SDL_Surface * pom = SDL_ConvertSurface(background, screen->format, screen->flags);
|
||||
SDL_FreeSurface(background);
|
||||
background = pom;
|
||||
exit = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleResultWindow::bExitf,this), 384 + pos.x, 505 + pos.y, "iok6432.def", SDLK_RETURN);
|
||||
exit->borderColor = Colors::MetallicGold;
|
||||
exit->borderEnabled = true;
|
||||
|
||||
if(br.winner==0) //attacker won
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 59, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 408, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
else //if(br.winner==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 59, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 412, 124, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
|
||||
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[407], 232, 302, FONT_BIG, Colors::Jasmine, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[408], 232, 332, FONT_BIG, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[409], 237, 428, FONT_BIG, Colors::Cornsilk, background);
|
||||
|
||||
std::string attackerName, defenderName;
|
||||
|
||||
if(owner->attackingHeroInstance) //a hero attacked
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->attackingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = owner->attackingHeroInstance->name;
|
||||
}
|
||||
else //a monster attacked
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army1->Slots().begin(); it!=owner->army1->Slots().end(); ++it)
|
||||
{
|
||||
if(it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
if(owner->defendingHeroInstance) //a hero defended
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->defendingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = owner->defendingHeroInstance->name;
|
||||
}
|
||||
else //a monster defended
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army2->Slots().begin(); it!=owner->army2->Slots().end(); ++it)
|
||||
{
|
||||
if( it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
|
||||
//printing attacker and defender's names
|
||||
CSDL_Ext::printAt(attackerName, 89, 37, FONT_SMALL, Colors::Cornsilk, background);
|
||||
CSDL_Ext::printTo(defenderName, 381, 53, FONT_SMALL, Colors::Cornsilk, background);
|
||||
//printing casualities
|
||||
for(int step = 0; step < 2; ++step)
|
||||
{
|
||||
if(br.casualties[step].size()==0)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[523], 235, 360 + 97*step, FONT_SMALL, Colors::Cornsilk, background);
|
||||
}
|
||||
else
|
||||
{
|
||||
int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
|
||||
int yPos = 344 + step*97;
|
||||
for(std::map<ui32,si32>::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it)
|
||||
{
|
||||
blitAt(graphics->smallImgs[it->first], xPos, yPos, background);
|
||||
std::ostringstream amount;
|
||||
amount<<it->second;
|
||||
CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, FONT_SMALL, Colors::Cornsilk, background);
|
||||
xPos += 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printing result description
|
||||
bool weAreAttacker = (owner->curInt->playerID == owner->attackingHeroInstance->tempOwner);
|
||||
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
||||
{
|
||||
int text=-1;
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: text = 304; break;
|
||||
case 1: text = 303; break;
|
||||
case 2: text = 302; break;
|
||||
}
|
||||
|
||||
CCS->musich->playMusic(musicBase::winBattle);
|
||||
CCS->videoh->open(VIDEO_WIN);
|
||||
std::string str = CGI->generaltexth->allTexts[text];
|
||||
|
||||
const CGHeroInstance * ourHero = weAreAttacker? owner->attackingHeroInstance : owner->defendingHeroInstance;
|
||||
if (ourHero)
|
||||
{
|
||||
str += CGI->generaltexth->allTexts[305];
|
||||
boost::algorithm::replace_first(str,"%s",ourHero->name);
|
||||
boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
|
||||
}
|
||||
CSDL_Ext::printAtMiddleWB(str, 235, 235, FONT_SMALL, 55, Colors::Cornsilk, background);
|
||||
}
|
||||
else // we lose
|
||||
{
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: //normal victory
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::loseCombat);
|
||||
CCS->videoh->open(VIDEO_LOSE_BATTLE_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[311], 235, 235, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
case 1: //flee
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::retreatBattle);
|
||||
CCS->videoh->open(VIDEO_RETREAT_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[310], 235, 235, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
case 2: //surrender
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::surrenderBattle);
|
||||
CCS->videoh->open(VIDEO_SURRENDER);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[309], 235, 220, FONT_SMALL, Colors::Cornsilk, background);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBattleResultWindow::~CBattleResultWindow()
|
||||
{
|
||||
SDL_FreeSurface(background);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::activate()
|
||||
{
|
||||
owner->curInt->showingDialog->set(true);
|
||||
exit->activate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::deactivate()
|
||||
{
|
||||
exit->deactivate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::show(SDL_Surface * to)
|
||||
{
|
||||
//evaluating to
|
||||
if(!to)
|
||||
to = screen;
|
||||
|
||||
CCS->videoh->update(107, 70, background, false, true);
|
||||
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
exit->showAll(to);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::bExitf()
|
||||
{
|
||||
if(LOCPLINT->cb->getStartInfo()->mode == StartInfo::DUEL)
|
||||
{
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
CPlayerInterface * intTmp = owner->curInt;
|
||||
GH.popInts(2); //first - we; second - battle interface
|
||||
intTmp->showingDialog->setn(false);
|
||||
CCS->videoh->close();
|
||||
}
|
||||
|
||||
Point CClickableHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi)
|
||||
{
|
||||
Point ret(-500, -500); //returned value
|
||||
if(stack && stack->position < 0) //creatures in turrets
|
||||
{
|
||||
switch(stack->position)
|
||||
{
|
||||
case -2: //keep
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][17];
|
||||
break;
|
||||
case -3: //lower turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][18];
|
||||
break;
|
||||
case -4: //upper turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][19];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.y = -139 + 42 * (hexNum/GameConstants::BFIELD_WIDTH); //counting y
|
||||
//counting x
|
||||
if(attacker)
|
||||
{
|
||||
ret.x = -160 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x = -219 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
//shifting position for double - hex creatures
|
||||
if(stack && stack->doubleWide())
|
||||
{
|
||||
if(attacker)
|
||||
{
|
||||
ret.x -= 44;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x += 45;
|
||||
}
|
||||
}
|
||||
}
|
||||
//returning
|
||||
return ret +CPlayerInterface::battleInt->pos;
|
||||
}
|
||||
void CClickableHex::activate()
|
||||
{
|
||||
activateHover();
|
||||
activateMouseMove();
|
||||
activateLClick();
|
||||
activateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::deactivate()
|
||||
{
|
||||
deactivateHover();
|
||||
deactivateMouseMove();
|
||||
deactivateLClick();
|
||||
deactivateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::hover(bool on)
|
||||
{
|
||||
hovered = on;
|
||||
//Hoverable::hover(on);
|
||||
if(!on && setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
if(myInterface->cellShade)
|
||||
{
|
||||
if(CSDL_Ext::SDL_GetPixel(myInterface->cellShade, sEvent.x-pos.x, sEvent.y-pos.y) == 0) //hovered pixel is outside hex
|
||||
{
|
||||
strictHovered = false;
|
||||
}
|
||||
else //hovered pixel is inside hex
|
||||
{
|
||||
strictHovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hovered && strictHovered) //print attacked creature to console
|
||||
{
|
||||
const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
|
||||
if(myInterface->console->alterTxt.size() == 0 &&attackedStack != NULL &&
|
||||
attackedStack->owner != myInterface->curInt->playerID &&
|
||||
attackedStack->alive())
|
||||
{
|
||||
char tabh[160];
|
||||
const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl;
|
||||
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
|
||||
myInterface->console->alterTxt = std::string(tabh);
|
||||
setAlterText = true;
|
||||
}
|
||||
}
|
||||
else if(setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(!down && hovered && strictHovered) //we've been really clicked!
|
||||
{
|
||||
myInterface->hexLclicked(myNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
|
||||
if(hovered && strictHovered && myst!=NULL)
|
||||
{
|
||||
|
||||
if(!myst->alive()) return;
|
||||
if(down)
|
||||
{
|
||||
GH.pushInt(createCreWindow(myst));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::update()
|
||||
{
|
||||
stacksSorted.clear();
|
||||
owner->curInt->cb->getStackQueue(stacksSorted, QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE ; i++)
|
||||
{
|
||||
stackBoxes[i]->setStack(stacksSorted[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
||||
:embedded(Embedded), owner(_owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
if(embedded)
|
||||
{
|
||||
box = NULL;
|
||||
bg = NULL;
|
||||
pos.w = QUEUE_SIZE * 37;
|
||||
pos.h = 32; //height of small creature img
|
||||
pos.x = screen->w/2 - pos.w/2;
|
||||
pos.y = (screen->h - 600)/2 + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
box = BitmapHandler::loadBitmap("CHRROP.pcx");
|
||||
bg = BitmapHandler::loadBitmap("DIBOXPI.pcx");
|
||||
pos.w = 600;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
|
||||
stackBoxes.resize(QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE; i++)
|
||||
{
|
||||
stackBoxes[i] = new StackBox(box);
|
||||
stackBoxes[i]->pos.x += 6 + (embedded ? 37 : 79)*i;
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::~CStackQueue()
|
||||
{
|
||||
SDL_FreeSurface(box);
|
||||
}
|
||||
|
||||
void CStackQueue::showAll(SDL_Surface * to)
|
||||
{
|
||||
blitBg(to);
|
||||
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CStackQueue::blitBg( SDL_Surface * to )
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
for (int w = 0; w < pos.w; w += bg->w)
|
||||
{
|
||||
blitAtLoc(bg, w, 0, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::showAll(SDL_Surface * to)
|
||||
{
|
||||
assert(my);
|
||||
if(bg)
|
||||
{
|
||||
graphics->blueToPlayersAdv(bg, my->owner);
|
||||
//SDL_UpdateRect(bg, 0, 0, 0, 0);
|
||||
SDL_Rect temp_rect = genRect(bg->h, bg->w, pos.x, pos.y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(bg, NULL, to, &temp_rect);
|
||||
//blitAt(bg, pos, to);
|
||||
blitAt(graphics->bigImgs[my->getCreature()->idNumber], pos.x +9, pos.y + 1, to);
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 12, FONT_MEDIUM, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
blitAt(graphics->smallImgs[-2], pos, to);
|
||||
blitAt(graphics->smallImgs[my->getCreature()->idNumber], pos, to);
|
||||
const SDL_Color &ownerColor = (my->owner == 255 ? *graphics->neutralColor : graphics->playerColors[my->owner]);
|
||||
CSDL_Ext::drawBorder(to, pos, int3(ownerColor.r, ownerColor.g, ownerColor.b));
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 8, FONT_TINY, Colors::Cornsilk, to);
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::setStack( const CStack *nStack )
|
||||
{
|
||||
my = nStack;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::StackBox(SDL_Surface *BG)
|
||||
:my(NULL), bg(BG)
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
pos.w = bg->w;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = pos.h = 32;
|
||||
}
|
||||
|
||||
pos.y += 2;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::~StackBox()
|
||||
{
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::hover( bool on )
|
||||
{
|
||||
|
||||
}
|
159
client/BattleInterface/CBattleInterfaceClasses.h
Normal file
159
client/BattleInterface/CBattleInterfaceClasses.h
Normal file
@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class CDefHandler;
|
||||
class CGHeroInstance;
|
||||
class CBattleInterface;
|
||||
class CPicture;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CLabel;
|
||||
class BattleResult;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CBattleInterfaceClasses.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class CBattleConsole : public CIntObject
|
||||
{
|
||||
private:
|
||||
std::vector< std::string > texts; //a place where texts are stored
|
||||
int lastShown; //last shown line of text
|
||||
public:
|
||||
std::string alterTxt; //if it's not empty, this text is displayed
|
||||
std::string ingcAlter; //alternative text set by in-game console - very important!
|
||||
int whoSetAlter; //who set alter text; 0 - battle interface or none, 1 - button
|
||||
CBattleConsole() : lastShown(-1), alterTxt(""), whoSetAlter(0) {}
|
||||
~CBattleConsole(); //d-tor
|
||||
void show(SDL_Surface * to = 0);
|
||||
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
|
||||
void eraseText(ui32 pos); //erases added text at position pos
|
||||
void changeTextAt(const std::string &text, ui32 pos); //if we have more than pos texts, pos-th is changed to given one
|
||||
void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
void scrollDown(ui32 by = 1); //scrolls console up by 'by' positions
|
||||
};
|
||||
|
||||
/// Hero battle animation
|
||||
class CBattleHero : public CIntObject
|
||||
{
|
||||
public:
|
||||
bool flip; //false if it's attacking hero, true otherwise
|
||||
CDefHandler *dh, *flag; //animation and flag
|
||||
const CGHeroInstance * myHero; //this animation's hero instance
|
||||
const CBattleInterface * myOwner; //battle interface to which this animation is assigned
|
||||
int phase; //stage of animation
|
||||
int nextPhase; //stage of animation to be set after current phase is fully displayed
|
||||
int image; //frame of animation
|
||||
ui8 flagAnim, flagAnimCount; //for flag animation
|
||||
void show(SDL_Surface * to); //prints next frame of animation to to
|
||||
void activate();
|
||||
void deactivate();
|
||||
void setPhase(int newPhase); //sets phase of hero animation
|
||||
void clickLeft(tribool down, bool previousState); //call-in
|
||||
CBattleHero(const std::string &defName, int phaseG, int imageG, bool filpG, ui8 player, const CGHeroInstance *hero, const CBattleInterface *owner); //c-tor
|
||||
~CBattleHero(); //d-tor
|
||||
};
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class CBattleOptionsWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
CBattleInterface * myInt;
|
||||
CPicture * background;
|
||||
CAdventureMapButton * setToDefault, * exit;
|
||||
CHighlightableButton * viewGrid, * movementShadow, * mouseShadow;
|
||||
CHighlightableButtonsGroup * animSpeeds;
|
||||
|
||||
std::vector<CLabel*> labels;
|
||||
public:
|
||||
CBattleOptionsWindow(const SDL_Rect &position, CBattleInterface *owner); //c-tor
|
||||
|
||||
void bDefaultf(); //default button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class CBattleResultWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface *background;
|
||||
CAdventureMapButton *exit;
|
||||
CBattleInterface *owner;
|
||||
public:
|
||||
CBattleResultWindow(const BattleResult & br, const SDL_Rect & pos, CBattleInterface * _owner); //c-tor
|
||||
~CBattleResultWindow(); //d-tor
|
||||
|
||||
void bExitf(); //exit button callback
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = 0);
|
||||
};
|
||||
|
||||
/// Class which stands for a single hex field on a battlefield
|
||||
class CClickableHex : public CIntObject
|
||||
{
|
||||
private:
|
||||
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
||||
public:
|
||||
ui32 myNumber; //number of hex in commonly used format
|
||||
bool accessible; //if true, this hex is accessible for units
|
||||
//CStack * ourStack;
|
||||
bool hovered, strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering)
|
||||
CBattleInterface * myInterface; //interface that owns me
|
||||
static Point getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * creature, const CBattleInterface * cbi); //returns (x, y) of left top corner of animation
|
||||
|
||||
//for user interactions
|
||||
void hover (bool on);
|
||||
void activate();
|
||||
void deactivate();
|
||||
void mouseMoved (const SDL_MouseMotionEvent &sEvent);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
CClickableHex();
|
||||
};
|
||||
|
||||
/// Shows the stack queue
|
||||
class CStackQueue : public CIntObject
|
||||
{
|
||||
class StackBox : public CIntObject
|
||||
{
|
||||
public:
|
||||
const CStack *my;
|
||||
SDL_Surface *bg;
|
||||
|
||||
void hover (bool on);
|
||||
void showAll(SDL_Surface * to);
|
||||
void setStack(const CStack *nStack);
|
||||
StackBox(SDL_Surface *BG);
|
||||
~StackBox();
|
||||
};
|
||||
|
||||
public:
|
||||
static const int QUEUE_SIZE = 10;
|
||||
const bool embedded;
|
||||
std::vector<const CStack *> stacksSorted;
|
||||
std::vector<StackBox *> stackBoxes;
|
||||
|
||||
SDL_Surface *box;
|
||||
SDL_Surface *bg;
|
||||
CBattleInterface * owner;
|
||||
|
||||
void showAll(SDL_Surface * to);
|
||||
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
||||
~CStackQueue();
|
||||
void update();
|
||||
void blitBg( SDL_Surface * to );
|
||||
//void showAll(SDL_Surface * to);
|
||||
};
|
@ -1,73 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleOptionsWindow.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "../GUIClasses.h"
|
||||
#include "../AdventureMapButton.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInterface *owner): myInt(owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
pos = position;
|
||||
background = new CPicture("comopbck.bmp");
|
||||
background->colorize(owner->curInt->playerID);
|
||||
|
||||
viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", NULL, 25, 56, false);
|
||||
viewGrid->select(owner->curInt->sysOpts.printCellBorders);
|
||||
movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", NULL, 25, 89, false);
|
||||
movementShadow->select(owner->curInt->sysOpts.printStackRange);
|
||||
mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", NULL, 25, 122, false);
|
||||
mouseShadow->select(owner->curInt->sysOpts.printMouseShadow);
|
||||
|
||||
animSpeeds = new CHighlightableButtonsGroup(0);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[422].first),CGI->generaltexth->zelp[422].second, "sysopb9.def", 28, 225, 1);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[423].first),CGI->generaltexth->zelp[423].second, "sysob10.def", 92, 225, 2);
|
||||
animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[424].first),CGI->generaltexth->zelp[424].second, "sysob11.def",156, 225, 4);
|
||||
animSpeeds->select(owner->getAnimSpeed(), 1);
|
||||
animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
|
||||
|
||||
setToDefault = new AdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
|
||||
setToDefault->swappedImages = true;
|
||||
setToDefault->update();
|
||||
exit = new AdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
|
||||
exit->swappedImages = true;
|
||||
exit->update();
|
||||
|
||||
//creating labels
|
||||
labels.push_back(new CLabel(242, 32, FONT_BIG, CENTER, tytulowy, CGI->generaltexth->allTexts[392]));//window title
|
||||
labels.push_back(new CLabel(122, 214, FONT_MEDIUM, CENTER, tytulowy, CGI->generaltexth->allTexts[393]));//animation speed
|
||||
labels.push_back(new CLabel(122, 293, FONT_MEDIUM, CENTER, tytulowy, CGI->generaltexth->allTexts[394]));//music volume
|
||||
labels.push_back(new CLabel(122, 359, FONT_MEDIUM, CENTER, tytulowy, CGI->generaltexth->allTexts[395]));//effects' volume
|
||||
labels.push_back(new CLabel(353, 66, FONT_MEDIUM, CENTER, tytulowy, CGI->generaltexth->allTexts[396]));//auto - combat options
|
||||
labels.push_back(new CLabel(353, 265, FONT_MEDIUM, CENTER, tytulowy, CGI->generaltexth->allTexts[397]));//creature info
|
||||
|
||||
//auto - combat options
|
||||
labels.push_back(new CLabel(283, 86, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[398]));//creatures
|
||||
labels.push_back(new CLabel(283, 116, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[399]));//spells
|
||||
labels.push_back(new CLabel(283, 146, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[400]));//catapult
|
||||
labels.push_back(new CLabel(283, 176, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[151]));//ballista
|
||||
labels.push_back(new CLabel(283, 206, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[401]));//first aid tent
|
||||
|
||||
//creature info
|
||||
labels.push_back(new CLabel(283, 285, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[402]));//all stats
|
||||
labels.push_back(new CLabel(283, 315, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[403]));//spells only
|
||||
|
||||
//general options
|
||||
labels.push_back(new CLabel(61, 57, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[404]));
|
||||
labels.push_back(new CLabel(61, 90, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[405]));
|
||||
labels.push_back(new CLabel(61, 123, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[406]));
|
||||
labels.push_back(new CLabel(61, 156, FONT_MEDIUM, TOPLEFT, zwykly, CGI->generaltexth->allTexts[407]));
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bDefaultf()
|
||||
{
|
||||
}
|
||||
|
||||
void CBattleOptionsWindow::bExitf()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CPicture;
|
||||
class AdventureMapButton;
|
||||
class CHighlightableButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CLabel;
|
||||
struct SDL_Rect;
|
||||
|
||||
/*
|
||||
* CBattleOptionsWindow.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class which manages the battle options window
|
||||
class CBattleOptionsWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
CBattleInterface *myInt;
|
||||
CPicture *background;
|
||||
AdventureMapButton *setToDefault, *exit;
|
||||
CHighlightableButton *viewGrid, *movementShadow, *mouseShadow;
|
||||
CHighlightableButtonsGroup *animSpeeds;
|
||||
|
||||
std::vector<CLabel*> labels;
|
||||
public:
|
||||
CBattleOptionsWindow(const SDL_Rect &position, CBattleInterface *owner); //c-tor
|
||||
|
||||
void bDefaultf(); //default button callback
|
||||
void bExitf(); //exit button callback
|
||||
};
|
@ -1,217 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleResultWindow.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "../AdventureMapButton.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../../lib/CObjectHandler.h"
|
||||
#include "../../lib/NetPacks.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../CVideoHandler.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner)
|
||||
: owner(_owner)
|
||||
{
|
||||
this->pos = pos;
|
||||
background = BitmapHandler::loadBitmap("CPRESULT.BMP", true);
|
||||
graphics->blueToPlayersAdv(background, owner->curInt->playerID);
|
||||
SDL_Surface * pom = SDL_ConvertSurface(background, screen->format, screen->flags);
|
||||
SDL_FreeSurface(background);
|
||||
background = pom;
|
||||
exit = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleResultWindow::bExitf,this), 384 + pos.x, 505 + pos.y, "iok6432.def", SDLK_RETURN);
|
||||
exit->borderColor = Colors::MetallicGold;
|
||||
exit->borderEnabled = true;
|
||||
|
||||
if(br.winner==0) //attacker won
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 59, 124, FONT_SMALL, zwykly, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 408, 124, FONT_SMALL, zwykly, background);
|
||||
}
|
||||
else //if(br.winner==1)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[411], 59, 124, FONT_SMALL, zwykly, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[410], 412, 124, FONT_SMALL, zwykly, background);
|
||||
}
|
||||
|
||||
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[407], 232, 302, FONT_BIG, tytulowy, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[408], 232, 332, FONT_BIG, zwykly, background);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[409], 237, 428, FONT_BIG, zwykly, background);
|
||||
|
||||
std::string attackerName, defenderName;
|
||||
|
||||
if(owner->attackingHeroInstance) //a hero attacked
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->attackingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = owner->attackingHeroInstance->name;
|
||||
}
|
||||
else //a monster attacked
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army1->Slots().begin(); it!=owner->army1->Slots().end(); ++it)
|
||||
{
|
||||
if(it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 21, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting attackerName
|
||||
attackerName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
if(owner->defendingHeroInstance) //a hero defended
|
||||
{
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->portraitLarge[owner->defendingHeroInstance->portrait], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = owner->defendingHeroInstance->name;
|
||||
}
|
||||
else //a monster defended
|
||||
{
|
||||
int bestMonsterID = -1;
|
||||
ui32 bestPower = 0;
|
||||
for(TSlots::const_iterator it = owner->army2->Slots().begin(); it!=owner->army2->Slots().end(); ++it)
|
||||
{
|
||||
if( it->second->type->AIValue > bestPower)
|
||||
{
|
||||
bestPower = it->second->type->AIValue;
|
||||
bestMonsterID = it->second->type->idNumber;
|
||||
}
|
||||
}
|
||||
SDL_Rect temp_rect = genRect(64, 58, 392, 38);
|
||||
SDL_BlitSurface(graphics->bigImgs[bestMonsterID], NULL, background, &temp_rect);
|
||||
//setting defenderName
|
||||
defenderName = CGI->creh->creatures[bestMonsterID]->namePl;
|
||||
}
|
||||
|
||||
//printing attacker and defender's names
|
||||
CSDL_Ext::printAt(attackerName, 89, 37, FONT_SMALL, zwykly, background);
|
||||
CSDL_Ext::printTo(defenderName, 381, 53, FONT_SMALL, zwykly, background);
|
||||
//printing casualities
|
||||
for(int step = 0; step < 2; ++step)
|
||||
{
|
||||
if(br.casualties[step].size()==0)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[523], 235, 360 + 97*step, FONT_SMALL, zwykly, background);
|
||||
}
|
||||
else
|
||||
{
|
||||
int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
|
||||
int yPos = 344 + step*97;
|
||||
for(std::map<ui32,si32>::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it)
|
||||
{
|
||||
blitAt(graphics->smallImgs[it->first], xPos, yPos, background);
|
||||
std::ostringstream amount;
|
||||
amount<<it->second;
|
||||
CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, FONT_SMALL, zwykly, background);
|
||||
xPos += 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printing result description
|
||||
bool weAreAttacker = (owner->curInt->playerID == owner->attackingHeroInstance->tempOwner);
|
||||
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
||||
{
|
||||
int text=-1;
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: text = 304; break;
|
||||
case 1: text = 303; break;
|
||||
case 2: text = 302; break;
|
||||
}
|
||||
|
||||
CCS->musich->playMusic(musicBase::winBattle);
|
||||
CCS->videoh->open(VIDEO_WIN);
|
||||
std::string str = CGI->generaltexth->allTexts[text];
|
||||
|
||||
const CGHeroInstance * ourHero = weAreAttacker? owner->attackingHeroInstance : owner->defendingHeroInstance;
|
||||
if (ourHero)
|
||||
{
|
||||
str += CGI->generaltexth->allTexts[305];
|
||||
boost::algorithm::replace_first(str,"%s",ourHero->name);
|
||||
boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
|
||||
}
|
||||
CSDL_Ext::printAtMiddleWB(str, 235, 235, FONT_SMALL, 55, zwykly, background);
|
||||
}
|
||||
else // we lose
|
||||
{
|
||||
switch(br.result)
|
||||
{
|
||||
case 0: //normal victory
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::loseCombat);
|
||||
CCS->videoh->open(VIDEO_LOSE_BATTLE_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[311], 235, 235, FONT_SMALL, zwykly, background);
|
||||
break;
|
||||
}
|
||||
case 1: //flee
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::retreatBattle);
|
||||
CCS->videoh->open(VIDEO_RETREAT_START);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[310], 235, 235, FONT_SMALL, zwykly, background);
|
||||
break;
|
||||
}
|
||||
case 2: //surrender
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::surrenderBattle);
|
||||
CCS->videoh->open(VIDEO_SURRENDER);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[309], 235, 220, FONT_SMALL, zwykly, background);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBattleResultWindow::~CBattleResultWindow()
|
||||
{
|
||||
SDL_FreeSurface(background);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::activate()
|
||||
{
|
||||
owner->curInt->showingDialog->set(true);
|
||||
exit->activate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::deactivate()
|
||||
{
|
||||
exit->deactivate();
|
||||
}
|
||||
|
||||
void CBattleResultWindow::show(SDL_Surface *to)
|
||||
{
|
||||
//evaluating to
|
||||
if(!to)
|
||||
to = screen;
|
||||
|
||||
CCS->videoh->update(107, 70, background, false, true);
|
||||
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
exit->showAll(to);
|
||||
}
|
||||
|
||||
void CBattleResultWindow::bExitf()
|
||||
{
|
||||
if(LOCPLINT->cb->getStartInfo()->mode == StartInfo::DUEL)
|
||||
{
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
CPlayerInterface * intTmp = owner->curInt;
|
||||
GH.popInts(2); //first - we; second - battle interface
|
||||
intTmp->showingDialog->setn(false);
|
||||
CCS->videoh->close();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class AdventureMapButton;
|
||||
class CBattleInterface;
|
||||
struct SDL_Rect;
|
||||
struct BattleResult;
|
||||
|
||||
/*
|
||||
* CBattleResultWindow.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class which is responsible for showing the battle result window
|
||||
class CBattleResultWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface *background;
|
||||
AdventureMapButton *exit;
|
||||
CBattleInterface *owner;
|
||||
public:
|
||||
CBattleResultWindow(const BattleResult &br, const SDL_Rect &pos, CBattleInterface *_owner); //c-tor
|
||||
~CBattleResultWindow(); //d-tor
|
||||
|
||||
void bExitf(); //exit button callback
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = 0);
|
||||
};
|
@ -1,57 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CBattleStackAnimation.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
|
||||
CBattleStackAnimation::CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack)
|
||||
: CBattleAnimation(_owner), stack(_stack)
|
||||
{
|
||||
}
|
||||
|
||||
bool CBattleStackAnimation::isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir)
|
||||
{
|
||||
int fromMod = hexFrom % GameConstants::BFIELD_WIDTH;
|
||||
int fromDiv = hexFrom / GameConstants::BFIELD_WIDTH;
|
||||
int toMod = hexTo % GameConstants::BFIELD_WIDTH;
|
||||
|
||||
if(curDir && fromMod < toMod)
|
||||
return false;
|
||||
else if(curDir && fromMod > toMod)
|
||||
return true;
|
||||
else if(curDir && fromMod == toMod)
|
||||
{
|
||||
return fromDiv % 2 == 0;
|
||||
}
|
||||
else if(!curDir && fromMod < toMod)
|
||||
return true;
|
||||
else if(!curDir && fromMod > toMod)
|
||||
return false;
|
||||
else if(!curDir && fromMod == toMod)
|
||||
{
|
||||
return fromDiv % 2 == 1;
|
||||
}
|
||||
tlog1 << "Catastrope in CBattleStackAnimation::isToReverse!" << std::endl;
|
||||
return false; //should never happen
|
||||
}
|
||||
|
||||
bool CBattleStackAnimation::isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir)
|
||||
{
|
||||
if(hexTo < 0) //turret
|
||||
return false;
|
||||
|
||||
if(toDoubleWide)
|
||||
{
|
||||
return isToReverseHlp(hexFrom, hexTo, curDir) &&
|
||||
(toDir ? isToReverseHlp(hexFrom, hexTo-1, curDir) : isToReverseHlp(hexFrom, hexTo+1, curDir) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return isToReverseHlp(hexFrom, hexTo, curDir);
|
||||
}
|
||||
}
|
||||
|
||||
CCreatureAnimation* CBattleStackAnimation::myAnim()
|
||||
{
|
||||
return owner->creAnims[stack->ID];
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleAnimation.h"
|
||||
#include "../../lib/SBattleHex.h"
|
||||
|
||||
class CStack;
|
||||
class CBattleInterface;
|
||||
class CCreatureAnimation;
|
||||
|
||||
/*
|
||||
* CBattleStackAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Sub-class which is responsible for managing the battle stack animation.
|
||||
class CBattleStackAnimation : public CBattleAnimation
|
||||
{
|
||||
public:
|
||||
const CStack * stack; //id of stack whose animation it is
|
||||
|
||||
CBattleStackAnimation(CBattleInterface * _owner, const CStack * _stack);
|
||||
static bool isToReverseHlp(SBattleHex hexFrom, SBattleHex hexTo, bool curDir); //helper for isToReverse
|
||||
static bool isToReverse(SBattleHex hexFrom, SBattleHex hexTo, bool curDir /*if true, creature is in attacker's direction*/, bool toDoubleWide, bool toDir); //determines if creature should be reversed (it stands on hexFrom and should 'see' hexTo)
|
||||
|
||||
CCreatureAnimation *myAnim(); //animation for our stack
|
||||
};
|
@ -1,148 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CClickableHex.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../GUIClasses.h"
|
||||
#include "CBattleConsole.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
SPoint CClickableHex::getXYUnitAnim(const int & hexNum, const bool & attacker, const CStack * stack, const CBattleInterface * cbi)
|
||||
{
|
||||
SPoint ret(-500, -500); //returned value
|
||||
if(stack && stack->position < 0) //creatures in turrets
|
||||
{
|
||||
switch(stack->position)
|
||||
{
|
||||
case -2: //keep
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][17];
|
||||
break;
|
||||
case -3: //lower turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][18];
|
||||
break;
|
||||
case -4: //upper turret
|
||||
ret = graphics->wallPositions[cbi->siegeH->town->town->typeID][19];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.y = -139 + 42 * (hexNum/GameConstants::BFIELD_WIDTH); //counting y
|
||||
//counting x
|
||||
if(attacker)
|
||||
{
|
||||
ret.x = -160 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x = -219 + 22 * ( ((hexNum/GameConstants::BFIELD_WIDTH) + 1)%2 ) + 44 * (hexNum % GameConstants::BFIELD_WIDTH);
|
||||
}
|
||||
//shifting position for double - hex creatures
|
||||
if(stack && stack->doubleWide())
|
||||
{
|
||||
if(attacker)
|
||||
{
|
||||
ret.x -= 44;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.x += 45;
|
||||
}
|
||||
}
|
||||
}
|
||||
//returning
|
||||
return ret +CPlayerInterface::battleInt->pos;
|
||||
}
|
||||
void CClickableHex::activate()
|
||||
{
|
||||
activateHover();
|
||||
activateMouseMove();
|
||||
activateLClick();
|
||||
activateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::deactivate()
|
||||
{
|
||||
deactivateHover();
|
||||
deactivateMouseMove();
|
||||
deactivateLClick();
|
||||
deactivateRClick();
|
||||
}
|
||||
|
||||
void CClickableHex::hover(bool on)
|
||||
{
|
||||
hovered = on;
|
||||
//Hoverable::hover(on);
|
||||
if(!on && setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
if(myInterface->cellShade)
|
||||
{
|
||||
if(CSDL_Ext::SDL_GetPixel(myInterface->cellShade, sEvent.x-pos.x, sEvent.y-pos.y) == 0) //hovered pixel is outside hex
|
||||
{
|
||||
strictHovered = false;
|
||||
}
|
||||
else //hovered pixel is inside hex
|
||||
{
|
||||
strictHovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hovered && strictHovered) //print attacked creature to console
|
||||
{
|
||||
const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
|
||||
if(myInterface->console->alterTxt.size() == 0 &&attackedStack != NULL &&
|
||||
attackedStack->owner != myInterface->curInt->playerID &&
|
||||
attackedStack->alive())
|
||||
{
|
||||
char tabh[160];
|
||||
const std::string & attackedName = attackedStack->count == 1 ? attackedStack->getCreature()->nameSing : attackedStack->getCreature()->namePl;
|
||||
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
|
||||
myInterface->console->alterTxt = std::string(tabh);
|
||||
setAlterText = true;
|
||||
}
|
||||
}
|
||||
else if(setAlterText)
|
||||
{
|
||||
myInterface->console->alterTxt = std::string();
|
||||
setAlterText = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(!down && hovered && strictHovered) //we've been really clicked!
|
||||
{
|
||||
myInterface->hexLclicked(myNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void CClickableHex::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
|
||||
if(hovered && strictHovered && myst!=NULL)
|
||||
{
|
||||
|
||||
if(!myst->alive()) return;
|
||||
if(down)
|
||||
{
|
||||
GH.pushInt(createCreWindow(myst));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
struct SDL_MouseMotionEvent;
|
||||
|
||||
/*
|
||||
* CClickableHex.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class which stands for a single hex field on a battlefield
|
||||
class CClickableHex : public CIntObject
|
||||
{
|
||||
private:
|
||||
bool setAlterText; //if true, this hex has set alternative text in console and will clean it
|
||||
public:
|
||||
ui32 myNumber; //number of hex in commonly used format
|
||||
bool accessible; //if true, this hex is accessible for units
|
||||
//CStack * ourStack;
|
||||
bool hovered, strictHovered; //for determining if hex is hovered by mouse (this is different problem than hex's graphic hovering)
|
||||
CBattleInterface * myInterface; //interface that owns me
|
||||
static SPoint getXYUnitAnim(const int &hexNum, const bool &attacker, const CStack *creature, const CBattleInterface *cbi); //returns (x, y) of left top corner of animation
|
||||
|
||||
//for user interactions
|
||||
void hover (bool on);
|
||||
void activate();
|
||||
void deactivate();
|
||||
void mouseMoved (const SDL_MouseMotionEvent &sEvent);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
CClickableHex();
|
||||
};
|
@ -4,7 +4,7 @@
|
||||
#include "../../lib/CLodHandler.h"
|
||||
#include "../../lib/VCMI_Lib.h"
|
||||
#include "../../lib/vcmi_endian.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../UIFramework/SDL_Extensions.h"
|
||||
|
||||
/*
|
||||
* CCreatureAnimation.cpp, part of VCMI engine
|
||||
|
@ -1,139 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CDefenceAnimation.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "CReverseAnimation.h"
|
||||
#include "CAttackAnimation.h"
|
||||
#include "CShootingAnimation.h"
|
||||
|
||||
bool CDefenceAnimation::init()
|
||||
{
|
||||
//checking initial conditions
|
||||
|
||||
//if(owner->creAnims[stackID]->getType() != 2)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if(attacker == NULL && owner->battleEffects.size() > 0)
|
||||
return false;
|
||||
|
||||
ui32 lowestMoveID = owner->animIDhelper + 5;
|
||||
for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(it->first);
|
||||
if(defAnim && defAnim->stack->ID != stack->ID)
|
||||
continue;
|
||||
|
||||
CAttackAnimation * attAnim = dynamic_cast<CAttackAnimation *>(it->first);
|
||||
if(attAnim && attAnim->stack->ID != stack->ID)
|
||||
continue;
|
||||
|
||||
if(attacker != NULL)
|
||||
{
|
||||
int attackerAnimType = owner->creAnims[attacker->ID]->getType();
|
||||
if( attackerAnimType == 11 && attackerAnimType == 12 && attackerAnimType == 13 && owner->creAnims[attacker->ID]->getFrame() < attacker->getCreature()->attackClimaxFrame )
|
||||
return false;
|
||||
}
|
||||
|
||||
CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(it->first);
|
||||
|
||||
if(animAsRev && animAsRev->priority)
|
||||
return false;
|
||||
|
||||
if(it->first)
|
||||
vstd::amin(lowestMoveID, it->first->ID);
|
||||
}
|
||||
if(ID > lowestMoveID)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
//reverse unit if necessary
|
||||
if(attacker && isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
|
||||
{
|
||||
owner->addNewAnim(new CReverseAnimation(owner, stack, stack->position, true));
|
||||
return false;
|
||||
}
|
||||
//unit reversed
|
||||
|
||||
if(byShooting) //delay hit animation
|
||||
{
|
||||
for(std::list<SProjectileInfo>::const_iterator it = owner->projectiles.begin(); it != owner->projectiles.end(); ++it)
|
||||
{
|
||||
if(it->creID == attacker->getCreature()->idNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//initializing
|
||||
if(killed)
|
||||
{
|
||||
CCS->soundh->playSound(battle_sound(stack->getCreature(), killed));
|
||||
myAnim()->setType(CCreatureAnim::DEATH); //death
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: this block doesn't seems correct if the unit is defending.
|
||||
CCS->soundh->playSound(battle_sound(stack->getCreature(), wince));
|
||||
myAnim()->setType(CCreatureAnim::HITTED); //getting hit
|
||||
}
|
||||
|
||||
return true; //initialized successfuly
|
||||
}
|
||||
|
||||
void CDefenceAnimation::nextFrame()
|
||||
{
|
||||
if(!killed && myAnim()->getType() != CCreatureAnim::HITTED)
|
||||
{
|
||||
myAnim()->setType(CCreatureAnim::HITTED);
|
||||
}
|
||||
|
||||
if(!myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
if( myAnim()->getType() == CCreatureAnim::DEATH && (owner->animCount+1)%(4/owner->curInt->sysOpts.animSpeed)==0
|
||||
&& !myAnim()->onLastFrameInGroup() )
|
||||
{
|
||||
myAnim()->incrementFrame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
endAnim();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CDefenceAnimation::endAnim()
|
||||
{
|
||||
//restoring animType
|
||||
|
||||
if(myAnim()->getType() == CCreatureAnim::HITTED)
|
||||
myAnim()->setType(CCreatureAnim::HOLDING);
|
||||
|
||||
//printing info to console
|
||||
|
||||
//if(attacker!=NULL)
|
||||
// owner->printConsoleAttacked(stack, dmg, amountKilled, attacker);
|
||||
|
||||
//const CStack * attacker = owner->curInt->cb->battleGetStackByID(IDby, false);
|
||||
//const CStack * attacked = owner->curInt->cb->battleGetStackByID(stackID, false);
|
||||
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CDefenceAnimation::CDefenceAnimation(SStackAttackedInfo _attackedInfo, CBattleInterface * _owner)
|
||||
: CBattleStackAnimation(_owner, _attackedInfo.defender), dmg(_attackedInfo.dmg),
|
||||
amountKilled(_attackedInfo.amountKilled), attacker(_attackedInfo.attacker), byShooting(_attackedInfo.byShooting),
|
||||
killed(_attackedInfo.killed)
|
||||
{
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
#include "SStackAttackedInfo.h"
|
||||
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CDefenceAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Animation of a defending unit
|
||||
class CDefenceAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
//std::vector<SSStackAttackedInfo> attackedInfos;
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDefenceAnimation(SStackAttackedInfo _attackedInfo, CBattleInterface * _owner);
|
||||
};
|
@ -1,27 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CDummyAnimation.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
|
||||
bool CDummyAnimation::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDummyAnimation::nextFrame()
|
||||
{
|
||||
counter++;
|
||||
if(counter > howMany)
|
||||
endAnim();
|
||||
}
|
||||
|
||||
void CDummyAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CDummyAnimation::CDummyAnimation(CBattleInterface * _owner, int howManyFrames) : CBattleAnimation(_owner), counter(0), howMany(howManyFrames)
|
||||
{
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleAnimation.h"
|
||||
|
||||
class CBattleInterface;
|
||||
|
||||
/*
|
||||
* CDummyAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
class CDummyAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
int counter;
|
||||
int howMany;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CDummyAnimation(CBattleInterface *_owner, int howManyFrames);
|
||||
};
|
@ -1,95 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMeleeAttackAnimation.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "CReverseAnimation.h"
|
||||
|
||||
bool CMeleeAttackAnimation::init()
|
||||
{
|
||||
if( !CAttackAnimation::checkInitialConditions() )
|
||||
return false;
|
||||
|
||||
//if(owner->creAnims[stackID]->getType()!=2)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if(!attackingStack || myAnim()->getType() == 5)
|
||||
{
|
||||
endAnim();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool toReverse = isToReverse(attackingStackPosBeforeReturn, dest, owner->creDir[stack->ID], attackedStack->doubleWide(), owner->creDir[attackedStack->ID]);
|
||||
|
||||
if(toReverse)
|
||||
{
|
||||
|
||||
owner->addNewAnim(new CReverseAnimation(owner, stack, attackingStackPosBeforeReturn, true));
|
||||
return false;
|
||||
}
|
||||
//reversed
|
||||
|
||||
shooting = false;
|
||||
|
||||
static const CCreatureAnim::EAnimType mutPosToGroup[] = {CCreatureAnim::ATTACK_UP, CCreatureAnim::ATTACK_UP,
|
||||
CCreatureAnim::ATTACK_FRONT, CCreatureAnim::ATTACK_DOWN, CCreatureAnim::ATTACK_DOWN, CCreatureAnim::ATTACK_FRONT};
|
||||
|
||||
int revShiftattacker = (attackingStack->attackerOwned ? -1 : 1);
|
||||
|
||||
int mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, dest);
|
||||
if(mutPos == -1 && attackingStack->doubleWide())
|
||||
{
|
||||
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position);
|
||||
}
|
||||
if (mutPos == -1 && attackedStack->doubleWide())
|
||||
{
|
||||
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn, attackedStack->occupiedHex());
|
||||
}
|
||||
if (mutPos == -1 && attackedStack->doubleWide() && attackingStack->doubleWide())
|
||||
{
|
||||
mutPos = SBattleHex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->occupiedHex());
|
||||
}
|
||||
|
||||
|
||||
switch(mutPos) //attack direction
|
||||
{
|
||||
case 0: case 1: case 2: case 3: case 4: case 5:
|
||||
group = mutPosToGroup[mutPos];
|
||||
break;
|
||||
default:
|
||||
tlog1<<"Critical Error! Wrong dest in stackAttacking! dest: "<<dest<<" attacking stack pos: "<<attackingStackPosBeforeReturn<<" mutual pos: "<<mutPos<<std::endl;
|
||||
group = CCreatureAnim::ATTACK_FRONT;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMeleeAttackAnimation::nextFrame()
|
||||
{
|
||||
/*for(std::list<std::pair<CBattleAnimation *, bool> >::const_iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
CBattleMoveStart * anim = dynamic_cast<CBattleMoveStart *>(it->first);
|
||||
CReverseAnim * anim2 = dynamic_cast<CReverseAnim *>(it->first);
|
||||
if( (anim && anim->stackID == stackID) || (anim2 && anim2->stackID == stackID ) )
|
||||
return;
|
||||
}*/
|
||||
|
||||
CAttackAnimation::nextFrame();
|
||||
}
|
||||
|
||||
void CMeleeAttackAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CMeleeAttackAnimation::CMeleeAttackAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked)
|
||||
: CAttackAnimation(_owner, attacker, _dest, _attacked)
|
||||
{
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CAttackAnimation.h"
|
||||
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CMeleeAttackAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Hand-to-hand attack
|
||||
class CMeleeAttackAnimation : public CAttackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMeleeAttackAnimation(CBattleInterface *_owner, const CStack *attacker, SBattleHex _dest, const CStack *_attacked);
|
||||
};
|
@ -1,176 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMovementAnimation.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "CReverseAnimation.h"
|
||||
#include "CMovementEndAnimation.h"
|
||||
#include "CClickableHex.h"
|
||||
|
||||
bool CMovementAnimation::init()
|
||||
{
|
||||
if( !isEarliest(false) )
|
||||
return false;
|
||||
|
||||
//a few useful variables
|
||||
steps = static_cast<int>(myAnim()->framesInGroup(CCreatureAnim::MOVING) * owner->getAnimSpeedMultiplier() - 1);
|
||||
if(steps == 0) //this creature seems to have no move animation so we can end it immediately
|
||||
{
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
whichStep = 0;
|
||||
int hexWbase = 44, hexHbase = 42;
|
||||
const CStack * movedStack = stack;
|
||||
if(!movedStack || myAnim()->getType() == 5)
|
||||
{
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
//bool twoTiles = movedStack->doubleWide();
|
||||
|
||||
SPoint begPosition = CClickableHex::getXYUnitAnim(curStackPos, movedStack->attackerOwned, movedStack, owner);
|
||||
SPoint endPosition = CClickableHex::getXYUnitAnim(nextHex, movedStack->attackerOwned, movedStack, owner);
|
||||
|
||||
int mutPos = SBattleHex::mutualPosition(curStackPos, nextHex);
|
||||
|
||||
//reverse unit if necessary
|
||||
if((begPosition.x > endPosition.x) && owner->creDir[stack->ID] == true)
|
||||
{
|
||||
owner->addNewAnim(new CReverseAnimation(owner, stack, curStackPos, true));
|
||||
return false;
|
||||
}
|
||||
else if ((begPosition.x < endPosition.x) && owner->creDir[stack->ID] == false)
|
||||
{
|
||||
owner->addNewAnim(new CReverseAnimation(owner, stack, curStackPos, true));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(myAnim()->getType() != CCreatureAnim::MOVING)
|
||||
{
|
||||
myAnim()->setType(CCreatureAnim::MOVING);
|
||||
}
|
||||
//unit reversed
|
||||
|
||||
// if(owner->moveSh <= 0)
|
||||
// owner->moveSh = CCS->soundh->playSound(battle_sound(movedStack->getCreature(), move), -1);
|
||||
|
||||
//step shift calculation
|
||||
posX = myAnim()->pos.x, posY = myAnim()->pos.y; // for precise calculations ;]
|
||||
if(mutPos == -1 && movedStack->hasBonusOfType(Bonus::FLYING))
|
||||
{
|
||||
steps *= distance;
|
||||
steps /= 2; //to make animation faster
|
||||
|
||||
stepX = (endPosition.x - begPosition.x) / static_cast<double>(steps);
|
||||
stepY = (endPosition.y - begPosition.y) / static_cast<double>(steps);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(mutPos)
|
||||
{
|
||||
case 0:
|
||||
stepX = -1.0 * (hexWbase / (2.0 * steps));
|
||||
stepY = -1.0 * (hexHbase / (static_cast<double>(steps)));
|
||||
break;
|
||||
case 1:
|
||||
stepX = hexWbase / (2.0 * steps);
|
||||
stepY = -1.0 * hexHbase / (static_cast<double>(steps));
|
||||
break;
|
||||
case 2:
|
||||
stepX = hexWbase / static_cast<double>(steps);
|
||||
stepY = 0.0;
|
||||
break;
|
||||
case 3:
|
||||
stepX = hexWbase / (2.0 * steps);
|
||||
stepY = hexHbase / static_cast<double>(steps);
|
||||
break;
|
||||
case 4:
|
||||
stepX = -1.0 * hexWbase / (2.0 * steps);
|
||||
stepY = hexHbase / static_cast<double>(steps);
|
||||
break;
|
||||
case 5:
|
||||
stepX = -1.0 * hexWbase / static_cast<double>(steps);
|
||||
stepY = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//step shifts calculated
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMovementAnimation::nextFrame()
|
||||
{
|
||||
//moving instructions
|
||||
posX += stepX;
|
||||
myAnim()->pos.x = static_cast<Sint16>(posX);
|
||||
posY += stepY;
|
||||
myAnim()->pos.y = static_cast<Sint16>(posY);
|
||||
|
||||
// Increments step count and check if we are finished with current animation
|
||||
++whichStep;
|
||||
if(whichStep == steps)
|
||||
{
|
||||
// Sets the position of the creature animation sprites
|
||||
SPoint coords = CClickableHex::getXYUnitAnim(nextHex, owner->creDir[stack->ID], stack, owner);
|
||||
myAnim()->pos = coords;
|
||||
|
||||
// true if creature haven't reached the final destination hex
|
||||
if ((nextPos + 1) < destTiles.size())
|
||||
{
|
||||
// update the next hex field which has to be reached by the stack
|
||||
nextPos++;
|
||||
curStackPos = nextHex;
|
||||
nextHex = destTiles[nextPos];
|
||||
|
||||
// update position of double wide creatures
|
||||
bool twoTiles = stack->doubleWide();
|
||||
if(twoTiles && bool(stack->attackerOwned) && (owner->creDir[stack->ID] != bool(stack->attackerOwned) )) //big attacker creature is reversed
|
||||
myAnim()->pos.x -= 44;
|
||||
else if(twoTiles && (! bool(stack->attackerOwned) ) && (owner->creDir[stack->ID] != bool(stack->attackerOwned) )) //big defender creature is reversed
|
||||
myAnim()->pos.x += 44;
|
||||
|
||||
// re-init animation
|
||||
for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
if (it->first == this)
|
||||
{
|
||||
it->second = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
endAnim();
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementAnimation::endAnim()
|
||||
{
|
||||
const CStack * movedStack = stack;
|
||||
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
if(movedStack)
|
||||
owner->addNewAnim(new CMovementEndAnimation(owner, stack, nextHex));
|
||||
|
||||
|
||||
if(owner->moveSh >= 0)
|
||||
{
|
||||
CCS->soundh->stopSound(owner->moveSh);
|
||||
owner->moveSh = -1;
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CMovementAnimation::CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance)
|
||||
: CBattleStackAnimation(_owner, _stack), destTiles(_destTiles), nextPos(0), distance(_distance), stepX(0.0), stepY(0.0)
|
||||
{
|
||||
curStackPos = stack->position;
|
||||
nextHex = destTiles.front();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CMovementAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Move animation of a creature
|
||||
class CMovementAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
std::vector<SBattleHex> destTiles; //destination
|
||||
SBattleHex nextHex;
|
||||
ui32 nextPos;
|
||||
int distance;
|
||||
double stepX, stepY; //how far stack is moved in one frame
|
||||
double posX, posY;
|
||||
int steps, whichStep;
|
||||
int curStackPos; //position of stack before move
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementAnimation(CBattleInterface *_owner, const CStack *_stack, std::vector<SBattleHex> _destTiles, int _distance);
|
||||
};
|
@ -1,52 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMovementEndAnimation.h"
|
||||
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../CMusicHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CCursorHandler.h"
|
||||
|
||||
bool CMovementEndAnimation::init()
|
||||
{
|
||||
if( !isEarliest(true) )
|
||||
return false;
|
||||
|
||||
if(!stack || myAnim()->framesInGroup(CCreatureAnim::MOVE_END) == 0 ||
|
||||
myAnim()->getType() == CCreatureAnim::DEATH)
|
||||
{
|
||||
endAnim();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CCS->soundh->playSound(battle_sound(stack->getCreature(), endMoving));
|
||||
|
||||
myAnim()->setType(CCreatureAnim::MOVE_END);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMovementEndAnimation::nextFrame()
|
||||
{
|
||||
if(myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
endAnim();
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementEndAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
if(myAnim()->getType() != CCreatureAnim::DEATH)
|
||||
myAnim()->setType(CCreatureAnim::HOLDING); //resetting to default
|
||||
|
||||
CCS->curh->show();
|
||||
delete this;
|
||||
}
|
||||
|
||||
CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SBattleHex destTile)
|
||||
: CBattleStackAnimation(_owner, _stack), destinationTile(destTile)
|
||||
{
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CMovementEndAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Move end animation of a creature
|
||||
class CMovementEndAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
SBattleHex destinationTile;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementEndAnimation(CBattleInterface *_owner, const CStack *_stack, SBattleHex destTile);
|
||||
};
|
@ -1,52 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMovementStartAnimation.h"
|
||||
|
||||
#include "../CMusicHandler.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
|
||||
bool CMovementStartAnimation::init()
|
||||
{
|
||||
if( !isEarliest(false) )
|
||||
return false;
|
||||
|
||||
|
||||
if(!stack || myAnim()->getType() == 5)
|
||||
{
|
||||
CMovementStartAnimation::endAnim();
|
||||
return false;
|
||||
}
|
||||
|
||||
CCS->soundh->playSound(battle_sound(stack->getCreature(), startMoving));
|
||||
myAnim()->setType(CCreatureAnim::MOVE_START);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMovementStartAnimation::nextFrame()
|
||||
{
|
||||
if(myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
endAnim();
|
||||
}
|
||||
else
|
||||
{
|
||||
if((owner->animCount+1)%(4/owner->curInt->sysOpts.animSpeed)==0)
|
||||
myAnim()->incrementFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementStartAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CMovementStartAnimation::CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack)
|
||||
: CBattleStackAnimation(_owner, _stack)
|
||||
{
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CMovementStartAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Move start animation of a creature
|
||||
class CMovementStartAnimation : public CBattleStackAnimation
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CMovementStartAnimation(CBattleInterface *_owner, const CStack *_stack);
|
||||
};
|
@ -1,100 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CReverseAnimation.h"
|
||||
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "CClickableHex.h"
|
||||
|
||||
bool CReverseAnimation::init()
|
||||
{
|
||||
if(myAnim() == NULL || myAnim()->getType() == 5)
|
||||
{
|
||||
endAnim();
|
||||
|
||||
return false; //there is no such creature
|
||||
}
|
||||
|
||||
if(!priority && !isEarliest(false))
|
||||
return false;
|
||||
|
||||
if(myAnim()->framesInGroup(CCreatureAnim::TURN_R))
|
||||
myAnim()->setType(CCreatureAnim::TURN_R);
|
||||
else
|
||||
setupSecondPart();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CReverseAnimation::nextFrame()
|
||||
{
|
||||
if(partOfAnim == 1) //first part of animation
|
||||
{
|
||||
if(myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
partOfAnim = 2;
|
||||
}
|
||||
}
|
||||
else if(partOfAnim == 2)
|
||||
{
|
||||
if(!secondPartSetup)
|
||||
{
|
||||
setupSecondPart();
|
||||
}
|
||||
if(myAnim()->onLastFrameInGroup())
|
||||
{
|
||||
endAnim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CReverseAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
if( stack->alive() )//don't do that if stack is dead
|
||||
myAnim()->setType(CCreatureAnim::HOLDING);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SBattleHex dest, bool _priority)
|
||||
: CBattleStackAnimation(_owner, stack), partOfAnim(1), secondPartSetup(false), hex(dest), priority(_priority)
|
||||
{
|
||||
}
|
||||
|
||||
void CReverseAnimation::setupSecondPart()
|
||||
{
|
||||
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
||||
|
||||
if(!stack)
|
||||
{
|
||||
endAnim();
|
||||
return;
|
||||
}
|
||||
|
||||
SPoint coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
||||
myAnim()->pos.x = coords.x;
|
||||
//creAnims[stackID]->pos.y = coords.second;
|
||||
|
||||
if(stack->doubleWide())
|
||||
{
|
||||
if(stack->attackerOwned)
|
||||
{
|
||||
if(!owner->creDir[stack->ID])
|
||||
myAnim()->pos.x -= 44;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(owner->creDir[stack->ID])
|
||||
myAnim()->pos.x += 44;
|
||||
}
|
||||
}
|
||||
|
||||
secondPartSetup = true;
|
||||
|
||||
if(myAnim()->framesInGroup(CCreatureAnim::TURN_L))
|
||||
myAnim()->setType(CCreatureAnim::TURN_L);
|
||||
else
|
||||
endAnim();
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CBattleStackAnimation.h"
|
||||
|
||||
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* CReverseAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class responsible for animation of stack chaning direction (left <-> right)
|
||||
class CReverseAnimation : public CBattleStackAnimation
|
||||
{
|
||||
private:
|
||||
int partOfAnim; //1 - first, 2 - second
|
||||
bool secondPartSetup;
|
||||
SBattleHex hex;
|
||||
public:
|
||||
bool priority; //true - high, false - low
|
||||
bool init();
|
||||
void nextFrame();
|
||||
|
||||
void setupSecondPart();
|
||||
void endAnim();
|
||||
|
||||
CReverseAnimation(CBattleInterface *_owner, const CStack *stack, SBattleHex dest, bool _priority);
|
||||
};
|
@ -1,192 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include "CShootingAnimation.h"
|
||||
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "CCreatureAnimation.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../../lib/CTownHandler.h"
|
||||
#include "CMovementStartAnimation.h"
|
||||
#include "CReverseAnimation.h"
|
||||
#include "CSpellEffectAnimation.h"
|
||||
#include "CClickableHex.h"
|
||||
|
||||
bool CShootingAnimation::init()
|
||||
{
|
||||
if( !CAttackAnimation::checkInitialConditions() )
|
||||
return false;
|
||||
|
||||
const CStack * shooter = attackingStack;
|
||||
|
||||
if(!shooter || myAnim()->getType() == 5)
|
||||
{
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the projectile animation
|
||||
|
||||
double projectileAngle; //in radians; if positive, projectiles goes up
|
||||
double straightAngle = 0.2; //maximal angle in radians between straight horizontal line and shooting line for which shot is considered to be straight (absoulte value)
|
||||
int fromHex = shooter->position;
|
||||
projectileAngle = atan2(static_cast<double>(abs(dest - fromHex) / GameConstants::BFIELD_WIDTH), static_cast<double>(abs(dest - fromHex) % GameConstants::BFIELD_WIDTH));
|
||||
if(fromHex < dest)
|
||||
projectileAngle = -projectileAngle;
|
||||
|
||||
// Get further info about the shooter e.g. relative pos of projectile to unit.
|
||||
// If the creature id is 149 then it's a arrow tower which has no additional info so get the
|
||||
// actual arrow tower shooter instead.
|
||||
const CCreature *shooterInfo = shooter->getCreature();
|
||||
if (shooterInfo->idNumber == 149)
|
||||
{
|
||||
int creID = CGI->creh->factionToTurretCreature[owner->siegeH->town->town->typeID];
|
||||
shooterInfo = CGI->creh->creatures[creID];
|
||||
}
|
||||
|
||||
SProjectileInfo spi;
|
||||
spi.creID = shooter->getCreature()->idNumber;
|
||||
spi.stackID = shooter->ID;
|
||||
spi.reverse = !shooter->attackerOwned;
|
||||
|
||||
spi.step = 0;
|
||||
spi.frameNum = 0;
|
||||
if(vstd::contains(CGI->creh->idToProjectileSpin, shooterInfo->idNumber))
|
||||
spi.spin = CGI->creh->idToProjectileSpin[shooterInfo->idNumber];
|
||||
else
|
||||
{
|
||||
tlog2 << "Warning - no projectile spin for spi.creID " << shooterInfo->idNumber << std::endl;
|
||||
spi.spin = false;
|
||||
}
|
||||
|
||||
SPoint xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
|
||||
SPoint destcoord;
|
||||
|
||||
|
||||
// The "master" point where all projectile positions relate to.
|
||||
static const SPoint projectileOrigin(181, 252);
|
||||
|
||||
if (attackedStack)
|
||||
{
|
||||
destcoord = CClickableHex::getXYUnitAnim(dest, false, attackedStack, owner);
|
||||
destcoord.x += 250; destcoord.y += 210; //TODO: find a better place to shoot
|
||||
|
||||
// Calculate projectile start position. Offsets are read out of the CRANIM.TXT.
|
||||
if (projectileAngle > straightAngle)
|
||||
{
|
||||
//upper shot
|
||||
spi.x = xycoord.x + projectileOrigin.x + shooterInfo->upperRightMissleOffsetX;
|
||||
spi.y = xycoord.y + projectileOrigin.y + shooterInfo->upperRightMissleOffsetY;
|
||||
}
|
||||
else if (projectileAngle < -straightAngle)
|
||||
{
|
||||
//lower shot
|
||||
spi.x = xycoord.x + projectileOrigin.x + shooterInfo->lowerRightMissleOffsetX;
|
||||
spi.y = xycoord.y + projectileOrigin.y + shooterInfo->lowerRightMissleOffsetY;
|
||||
}
|
||||
else
|
||||
{
|
||||
//straight shot
|
||||
spi.x = xycoord.x + projectileOrigin.x + shooterInfo->rightMissleOffsetX;
|
||||
spi.y = xycoord.y + projectileOrigin.y + shooterInfo->rightMissleOffsetY;
|
||||
}
|
||||
|
||||
double animSpeed = 23.0 * owner->getAnimSpeed(); // flight speed of projectile
|
||||
spi.lastStep = static_cast<int>(sqrt(static_cast<double>((destcoord.x - spi.x) * (destcoord.x - spi.x) + (destcoord.y - spi.y) * (destcoord.y - spi.y))) / animSpeed);
|
||||
if(spi.lastStep == 0)
|
||||
spi.lastStep = 1;
|
||||
spi.dx = (destcoord.x - spi.x) / spi.lastStep;
|
||||
spi.dy = (destcoord.y - spi.y) / spi.lastStep;
|
||||
spi.catapultInfo = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Catapult attack
|
||||
// These are the values for equations of this kind: f(x) = ax^2 + bx + c
|
||||
static const std::vector<SCatapultSProjectileInfo*> trajectoryCurves = boost::assign::list_of<SCatapultSProjectileInfo*>(new SCatapultSProjectileInfo(4.309, -3.198, 569.2, -296, 182))
|
||||
(new SCatapultSProjectileInfo(4.710, -3.11, 558.68, -258, 175))(new SCatapultSProjectileInfo(5.056, -3.003, 546.9, -236, 174))
|
||||
(new SCatapultSProjectileInfo(4.760, -2.74, 526.47, -216, 215))(new SCatapultSProjectileInfo(4.288, -2.496, 508.98, -223, 274))
|
||||
(new SCatapultSProjectileInfo(3.683, -3.018, 558.39, -324, 176))(new SCatapultSProjectileInfo(2.884, -2.607, 528.95, -366, 312))
|
||||
(new SCatapultSProjectileInfo(3.783, -2.364, 501.35, -227, 318));
|
||||
|
||||
static std::map<int, int> hexToCurve = boost::assign::map_list_of<int, int>(29, 0)(62, 1)(95, 2)(130, 3)(182, 4)(12, 5)(50, 6)(183, 7);
|
||||
|
||||
std::map<int, int>::iterator it = hexToCurve.find(dest.hex);
|
||||
|
||||
if (it == hexToCurve.end())
|
||||
{
|
||||
tlog1 << "For the hex position " << dest.hex << " is no curve defined.";
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int curveID = it->second;
|
||||
spi.catapultInfo = trajectoryCurves[curveID];
|
||||
double animSpeed = 3.318 * owner->getAnimSpeed();
|
||||
spi.lastStep = static_cast<int>((spi.catapultInfo->toX - spi.catapultInfo->fromX) / animSpeed);
|
||||
spi.dx = animSpeed;
|
||||
spi.dy = 0;
|
||||
spi.x = xycoord.x + projectileOrigin.x + shooterInfo->rightMissleOffsetX + 17.;
|
||||
spi.y = xycoord.y + projectileOrigin.y + shooterInfo->rightMissleOffsetY + 10.;
|
||||
|
||||
// Add explosion anim
|
||||
int xEnd = static_cast<int>(spi.x + spi.lastStep * spi.dx);
|
||||
int yEnd = static_cast<int>(spi.catapultInfo->calculateY(xEnd));
|
||||
owner->addNewAnim( new CSpellEffectAnimation(owner, "SGEXPL.DEF", xEnd - 126, yEnd - 105));
|
||||
}
|
||||
}
|
||||
|
||||
// Set starting frame
|
||||
if(spi.spin)
|
||||
{
|
||||
spi.frameNum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double pi = boost::math::constants::pi<double>();
|
||||
spi.frameNum = static_cast<int>(((pi / 2.0 - projectileAngle) / (2.0 * pi) + 1/(static_cast<double>(2*(owner->idToProjectile[spi.creID]->ourImages.size()-1)))) * (owner->idToProjectile[spi.creID]->ourImages.size()-1));
|
||||
}
|
||||
|
||||
// Set projectile animation start delay which is specified in frames
|
||||
spi.animStartDelay = shooterInfo->attackClimaxFrame;
|
||||
owner->projectiles.push_back(spi);
|
||||
|
||||
//attack animation
|
||||
|
||||
shooting = true;
|
||||
|
||||
if(projectileAngle > straightAngle) //upper shot
|
||||
group = CCreatureAnim::SHOOT_UP;
|
||||
else if(projectileAngle < -straightAngle) //lower shot
|
||||
group = CCreatureAnim::SHOOT_DOWN;
|
||||
else //straight shot
|
||||
group = CCreatureAnim::SHOOT_FRONT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CShootingAnimation::nextFrame()
|
||||
{
|
||||
for(std::list<std::pair<CBattleAnimation *, bool> >::const_iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
|
||||
{
|
||||
CMovementStartAnimation * anim = dynamic_cast<CMovementStartAnimation *>(it->first);
|
||||
CReverseAnimation * anim2 = dynamic_cast<CReverseAnimation *>(it->first);
|
||||
if( (anim && anim->stack->ID == stack->ID) || (anim2 && anim2->stack->ID == stack->ID && anim2->priority ) )
|
||||
return;
|
||||
}
|
||||
|
||||
CAttackAnimation::nextFrame();
|
||||
}
|
||||
|
||||
void CShootingAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
delete this;
|
||||
}
|
||||
|
||||
CShootingAnimation::CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, SBattleHex _dest, const CStack * _attacked, bool _catapult, int _catapultDmg)
|
||||
: CAttackAnimation(_owner, attacker, _dest, _attacked), catapultDamage(_catapultDmg), catapult(_catapult)
|
||||
{
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CAttackAnimation.h"
|
||||
#include "../../lib/SBattleHex.h"
|
||||
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
struct SCatapultSProjectileInfo;
|
||||
|
||||
/*
|
||||
* CShootingAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Small struct which contains information about the position and the velocity of a projectile
|
||||
struct SProjectileInfo
|
||||
{
|
||||
double x, y; //position on the screen
|
||||
double dx, dy; //change in position in one step
|
||||
int step, lastStep; //to know when finish showing this projectile
|
||||
int creID; //ID of creature that shot this projectile
|
||||
int stackID; //ID of stack
|
||||
int frameNum; //frame to display form projectile animation
|
||||
bool spin; //if true, frameNum will be increased
|
||||
int animStartDelay; //how many times projectile must be attempted to be shown till it's really show (decremented after hit)
|
||||
bool reverse; //if true, projectile will be flipped by vertical asix
|
||||
SCatapultSProjectileInfo *catapultInfo; // holds info about the parabolic trajectory of the cannon
|
||||
};
|
||||
|
||||
/// Shooting attack
|
||||
class CShootingAnimation : public CAttackAnimation
|
||||
{
|
||||
private:
|
||||
int catapultDamage;
|
||||
bool catapult;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
//last param only for catapult attacks
|
||||
CShootingAnimation(CBattleInterface *_owner, const CStack *attacker,
|
||||
SBattleHex _dest, const CStack *_attacked, bool _catapult = false, int _catapultDmg = 0);
|
||||
};
|
@ -1,182 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CSpellEffectAnimation.h"
|
||||
|
||||
#include "../Graphics.h"
|
||||
#include "CBattleInterface.h"
|
||||
#include "../CDefHandler.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../UIFramework/SRect.h"
|
||||
|
||||
//effect animation
|
||||
bool CSpellEffectAnimation::init()
|
||||
{
|
||||
if(!isEarliest(true))
|
||||
return false;
|
||||
|
||||
if(effect == 12) //armageddon
|
||||
{
|
||||
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
|
||||
{
|
||||
CDefHandler * anim;
|
||||
if(customAnim.size())
|
||||
anim = CDefHandler::giveDef(customAnim);
|
||||
else
|
||||
anim = CDefHandler::giveDef(graphics->battleACToDef[effect][0]);
|
||||
|
||||
if (Vflip)
|
||||
{
|
||||
for (size_t v = 0; v < anim->ourImages.size(); ++v)
|
||||
{
|
||||
CSDL_Ext::VflipSurf(anim->ourImages[v].bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i * anim->width < owner->pos.w ; ++i)
|
||||
{
|
||||
for(int j=0; j * anim->height < owner->pos.h ; ++j)
|
||||
{
|
||||
SBattleEffect be;
|
||||
be.effectID = ID;
|
||||
be.anim = CDefHandler::giveDef(graphics->battleACToDef[effect][0]);
|
||||
if (Vflip)
|
||||
{
|
||||
for (size_t v = 0; v < be.anim->ourImages.size(); ++v)
|
||||
{
|
||||
CSDL_Ext::VflipSurf(be.anim->ourImages[v].bitmap);
|
||||
}
|
||||
}
|
||||
be.frame = 0;
|
||||
be.maxFrame = be.anim->ourImages.size();
|
||||
be.x = i * anim->width + owner->pos.x;
|
||||
be.y = j * anim->height + owner->pos.y;
|
||||
|
||||
owner->battleEffects.push_back(be);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //there is nothing to play
|
||||
{
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // Effects targeted at a specific creature/hex.
|
||||
{
|
||||
if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
|
||||
{
|
||||
const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
|
||||
SRect &tilePos = owner->bfield[destTile].pos;
|
||||
SBattleEffect be;
|
||||
be.effectID = ID;
|
||||
if(customAnim.size())
|
||||
be.anim = CDefHandler::giveDef(customAnim);
|
||||
else
|
||||
be.anim = CDefHandler::giveDef(graphics->battleACToDef[effect][0]);
|
||||
|
||||
if (Vflip)
|
||||
{
|
||||
for (size_t v = 0; v < be.anim->ourImages.size(); ++v)
|
||||
{
|
||||
CSDL_Ext::VflipSurf(be.anim->ourImages[v].bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
be.frame = 0;
|
||||
be.maxFrame = be.anim->ourImages.size();
|
||||
if(effect == 1)
|
||||
be.maxFrame = 3;
|
||||
|
||||
switch (effect)
|
||||
{
|
||||
case -1:
|
||||
be.x = x;
|
||||
be.y = y;
|
||||
break;
|
||||
case 0: // Prayer and Lightning Bolt.
|
||||
case 1:
|
||||
// Position effect with it's bottom center touching the bottom center of affected tile(s).
|
||||
be.x = tilePos.x + tilePos.w/2 - be.anim->width/2;
|
||||
be.y = tilePos.y + tilePos.h - be.anim->height;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Position effect with it's center touching the top center of affected tile(s).
|
||||
be.x = tilePos.x + tilePos.w/2 - be.anim->width/2;
|
||||
be.y = tilePos.y - be.anim->height/2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Correction for 2-hex creatures.
|
||||
if (destStack != NULL && destStack->doubleWide())
|
||||
be.x += (destStack->attackerOwned ? -1 : 1)*tilePos.w/2;
|
||||
|
||||
owner->battleEffects.push_back(be);
|
||||
}
|
||||
else //there is nothing to play
|
||||
{
|
||||
endAnim();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//battleEffects
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSpellEffectAnimation::nextFrame()
|
||||
{
|
||||
//notice: there may be more than one effect in owner->battleEffects correcponding to this animation (ie. armageddon)
|
||||
for(std::list<SBattleEffect>::iterator it = owner->battleEffects.begin(); it != owner->battleEffects.end(); ++it)
|
||||
{
|
||||
if(it->effectID == ID)
|
||||
{
|
||||
++(it->frame);
|
||||
|
||||
if(it->frame == it->maxFrame)
|
||||
{
|
||||
endAnim();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
it->x += dx;
|
||||
it->y += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSpellEffectAnimation::endAnim()
|
||||
{
|
||||
CBattleAnimation::endAnim();
|
||||
|
||||
std::vector<std::list<SBattleEffect>::iterator> toDel;
|
||||
|
||||
for(std::list<SBattleEffect>::iterator it = owner->battleEffects.begin(); it != owner->battleEffects.end(); ++it)
|
||||
{
|
||||
if(it->effectID == ID)
|
||||
{
|
||||
toDel.push_back(it);
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t b = 0; b < toDel.size(); ++b)
|
||||
{
|
||||
delete toDel[b]->anim;
|
||||
owner->battleEffects.erase(toDel[b]);
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, ui32 _effect, SBattleHex _destTile, int _dx, int _dy, bool _Vflip)
|
||||
:CBattleAnimation(_owner), effect(_effect), destTile(_destTile), customAnim(""), dx(_dx), dy(_dy), Vflip(_Vflip)
|
||||
{
|
||||
}
|
||||
|
||||
CSpellEffectAnimation::CSpellEffectAnimation(CBattleInterface * _owner, std::string _customAnim, int _x, int _y, int _dx, int _dy, bool _Vflip)
|
||||
:CBattleAnimation(_owner), effect(-1), destTile(0), customAnim(_customAnim), x(_x), y(_y), dx(_dx), dy(_dy), Vflip(_Vflip)
|
||||
{
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CBattleAnimation.h"
|
||||
#include "../../lib/SBattleHex.h"
|
||||
|
||||
class CBattleInterface;
|
||||
|
||||
/*
|
||||
* CSpellEffectAnimation.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// This class manages a spell effect animation
|
||||
class CSpellEffectAnimation : public CBattleAnimation
|
||||
{
|
||||
private:
|
||||
ui32 effect;
|
||||
SBattleHex destTile;
|
||||
std::string customAnim;
|
||||
int x, y, dx, dy;
|
||||
bool Vflip;
|
||||
public:
|
||||
bool init();
|
||||
void nextFrame();
|
||||
void endAnim();
|
||||
|
||||
CSpellEffectAnimation(CBattleInterface *_owner, ui32 _effect, SBattleHex _destTile, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
CSpellEffectAnimation(CBattleInterface *_owner, std::string _customAnim, int _x, int _y, int _dx = 0, int _dy = 0, bool _Vflip = false);
|
||||
};
|
@ -1,126 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CStackQueue.h"
|
||||
|
||||
#include "CBattleInterface.h"
|
||||
#include "../../lib/BattleState.h"
|
||||
#include "../Graphics.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../CPlayerInterface.h"
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../../CCallback.h"
|
||||
#include "../UIFramework/CGuiHandler.h"
|
||||
|
||||
void CStackQueue::update()
|
||||
{
|
||||
stacksSorted.clear();
|
||||
owner->curInt->cb->getStackQueue(stacksSorted, QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE ; i++)
|
||||
{
|
||||
stackBoxes[i]->setStack(stacksSorted[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
|
||||
:embedded(Embedded), owner(_owner)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
if(embedded)
|
||||
{
|
||||
box = NULL;
|
||||
bg = NULL;
|
||||
pos.w = QUEUE_SIZE * 37;
|
||||
pos.h = 32; //height of small creature img
|
||||
pos.x = screen->w/2 - pos.w/2;
|
||||
pos.y = (screen->h - 600)/2 + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
box = BitmapHandler::loadBitmap("CHRROP.pcx");
|
||||
bg = BitmapHandler::loadBitmap("DIBOXPI.pcx");
|
||||
pos.w = 600;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
|
||||
stackBoxes.resize(QUEUE_SIZE);
|
||||
for (int i = 0; i < QUEUE_SIZE; i++)
|
||||
{
|
||||
stackBoxes[i] = new StackBox(box);
|
||||
stackBoxes[i]->pos.x += 6 + (embedded ? 37 : 79)*i;
|
||||
}
|
||||
}
|
||||
|
||||
CStackQueue::~CStackQueue()
|
||||
{
|
||||
SDL_FreeSurface(box);
|
||||
}
|
||||
|
||||
void CStackQueue::showAll( SDL_Surface *to )
|
||||
{
|
||||
blitBg(to);
|
||||
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CStackQueue::blitBg( SDL_Surface * to )
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
for (int w = 0; w < pos.w; w += bg->w)
|
||||
{
|
||||
blitAtLoc(bg, w, 0, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::showAll( SDL_Surface *to )
|
||||
{
|
||||
assert(my);
|
||||
if(bg)
|
||||
{
|
||||
graphics->blueToPlayersAdv(bg, my->owner);
|
||||
//SDL_UpdateRect(bg, 0, 0, 0, 0);
|
||||
SDL_Rect temp_rect = genRect(bg->h, bg->w, pos.x, pos.y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(bg, NULL, to, &temp_rect);
|
||||
//blitAt(bg, pos, to);
|
||||
blitAt(graphics->bigImgs[my->getCreature()->idNumber], pos.x +9, pos.y + 1, to);
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 12, FONT_MEDIUM, zwykly, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
blitAt(graphics->smallImgs[-2], pos, to);
|
||||
blitAt(graphics->smallImgs[my->getCreature()->idNumber], pos, to);
|
||||
const SDL_Color &ownerColor = (my->owner == 255 ? *graphics->neutralColor : graphics->playerColors[my->owner]);
|
||||
CSDL_Ext::drawBorder(to, pos, int3(ownerColor.r, ownerColor.g, ownerColor.b));
|
||||
printAtMiddleLoc(makeNumberShort(my->count), pos.w/2, pos.h - 8, FONT_TINY, zwykly, to);
|
||||
}
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::setStack( const CStack *nStack )
|
||||
{
|
||||
my = nStack;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::StackBox(SDL_Surface *BG)
|
||||
:my(NULL), bg(BG)
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
pos.w = bg->w;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = pos.h = 32;
|
||||
}
|
||||
|
||||
pos.y += 2;
|
||||
}
|
||||
|
||||
CStackQueue::StackBox::~StackBox()
|
||||
{
|
||||
}
|
||||
|
||||
void CStackQueue::StackBox::hover( bool on )
|
||||
{
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../UIFramework/CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class CStack;
|
||||
class CBattleInterface;
|
||||
|
||||
/*
|
||||
* CStackQueue.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Shows the stack queue
|
||||
class CStackQueue : public CIntObject
|
||||
{
|
||||
class StackBox : public CIntObject
|
||||
{
|
||||
public:
|
||||
const CStack *my;
|
||||
SDL_Surface *bg;
|
||||
|
||||
void hover (bool on);
|
||||
void showAll(SDL_Surface *to);
|
||||
void setStack(const CStack *nStack);
|
||||
StackBox(SDL_Surface *BG);
|
||||
~StackBox();
|
||||
};
|
||||
|
||||
public:
|
||||
static const int QUEUE_SIZE = 10;
|
||||
const bool embedded;
|
||||
std::vector<const CStack *> stacksSorted;
|
||||
std::vector<StackBox *> stackBoxes;
|
||||
|
||||
SDL_Surface *box;
|
||||
SDL_Surface *bg;
|
||||
CBattleInterface * owner;
|
||||
|
||||
void showAll(SDL_Surface *to);
|
||||
CStackQueue(bool Embedded, CBattleInterface * _owner);
|
||||
~CStackQueue();
|
||||
void update();
|
||||
void blitBg( SDL_Surface * to );
|
||||
//void showAll(SDL_Surface *to);
|
||||
};
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class CStack;
|
||||
|
||||
/*
|
||||
* SStackAttackedInfo.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Small struct which contains information about the id of the attacked stack, the damage dealt,...
|
||||
struct SStackAttackedInfo
|
||||
{
|
||||
const CStack * defender; //attacked stack
|
||||
int dmg; //damage dealt
|
||||
int amountKilled; //how many creatures in stack has been killed
|
||||
const CStack * attacker; //attacking stack
|
||||
bool byShooting; //if true, stack has been attacked by shooting
|
||||
bool killed; //if true, stack has been killed
|
||||
bool rebirth; //if true, play rebirth animation after all
|
||||
};
|
@ -1,16 +1,15 @@
|
||||
#include "StdInc.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
|
||||
#include "AdventureMapButton.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "CMessage.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CSpellWindow.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "../lib/CGameState.h"
|
||||
#include "CMusicHandler.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4355)
|
||||
@ -143,7 +143,7 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
rx = static_cast<int>((tilesw / static_cast<double>(mapSizes.x)) * pos.w), //width
|
||||
ry = static_cast<int>((tilesh / static_cast<double>(mapSizes.y)) * pos.h); //height
|
||||
|
||||
CSDL_Ext::drawDashedBorder(temps, SRect(bx, by, rx, ry), int3(255,75,125));
|
||||
CSDL_Ext::drawDashedBorder(temps, Rect(bx, by, rx, ry), int3(255,75,125));
|
||||
|
||||
//blitAt(radar,bx,by,temps);
|
||||
blitAt(temps,pos.x,pos.y,to);
|
||||
@ -181,7 +181,7 @@ void CMinimapSurfacesRef::initMap(int level)
|
||||
SDL_FreeSurface(map[g]);
|
||||
}
|
||||
map.clear();*/
|
||||
const SRect &minimap_pos = adventureInt->minimap.pos;
|
||||
const Rect &minimap_pos = adventureInt->minimap.pos;
|
||||
std::map<int,SDL_Color> &colors = adventureInt->minimap.colors;
|
||||
std::map<int,SDL_Color> &colorsBlocked = adventureInt->minimap.colorsBlocked;
|
||||
int3 mapSizes = LOCPLINT->cb->getMapSize();
|
||||
@ -221,7 +221,7 @@ void CMinimapSurfacesRef::initFoW(int level)
|
||||
}
|
||||
FoW.clear();*/
|
||||
|
||||
const SRect &minimap_pos = adventureInt->minimap.pos;
|
||||
const Rect &minimap_pos = adventureInt->minimap.pos;
|
||||
int3 mapSizes = LOCPLINT->cb->getMapSize();
|
||||
int mw = map_[0]->w, mh = map_[0]->h;//,
|
||||
//wo = mw/mapSizes.x, ho = mh/mapSizes.y; //TODO use me
|
||||
@ -253,7 +253,7 @@ void CMinimapSurfacesRef::initFlaggableObjs(int level)
|
||||
}
|
||||
flObjs.clear();*/
|
||||
|
||||
const SRect &minimap_pos = adventureInt->minimap.pos;
|
||||
const Rect &minimap_pos = adventureInt->minimap.pos;
|
||||
int3 mapSizes = LOCPLINT->cb->getMapSize();
|
||||
int mw = map_[0]->w, mh = map_[0]->h;
|
||||
for(int d=0; d<CGI->mh->map->twoLevel+1; ++d)
|
||||
@ -630,25 +630,25 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
||||
{
|
||||
if (hvx<0 && hvy<0)
|
||||
{
|
||||
SRect dstRect = genRect(32, 32, x + moveX, y + moveY);
|
||||
Rect dstRect = genRect(32, 32, x + moveX, y + moveY);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect);
|
||||
}
|
||||
else if(hvx<0)
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
else if (hvy<0)
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
}
|
||||
@ -656,25 +656,25 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
||||
{
|
||||
if (hvx<0 && hvy<0)
|
||||
{
|
||||
SRect dstRect = genRect(32, 32, x, y);
|
||||
Rect dstRect = genRect(32, 32, x, y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect);
|
||||
}
|
||||
else if(hvx<0)
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
else if (hvy<0)
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
SRect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
SRect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
||||
Rect srcRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, 0, 0);
|
||||
Rect dstRect = genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, &srcRect, to, &dstRect);
|
||||
}
|
||||
}
|
||||
@ -774,24 +774,24 @@ void CResDataBar::draw(SDL_Surface * to)
|
||||
for (int i=0;i<7;i++)
|
||||
{
|
||||
SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,FONT_SMALL,zwykly,to);
|
||||
printAt(buf,txtpos[i].first,txtpos[i].second,FONT_SMALL,Colors::Cornsilk,to);
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
|
||||
SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
|
||||
printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,FONT_SMALL,zwykly,to);
|
||||
printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,FONT_SMALL,Colors::Cornsilk,to);
|
||||
temp.clear();
|
||||
//updateRect(&pos,screen);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void CResDataBar::show( SDL_Surface * to )
|
||||
void CResDataBar::show(SDL_Surface * to)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CResDataBar::showAll( SDL_Surface * to )
|
||||
void CResDataBar::showAll(SDL_Surface * to)
|
||||
{
|
||||
draw(to);
|
||||
}
|
||||
@ -874,7 +874,7 @@ void CInfoBar::blitAnim(int mode)//0 - day, 1 - week
|
||||
txt << CGI->generaltexth->allTexts[64] << " " << LOCPLINT->cb->getDate(1);
|
||||
}
|
||||
blitAt(anim->ourImages[pom].bitmap,pos.x+9,pos.y+10);
|
||||
printAtMiddle(txt.str(),pos.x+95,pos.y+31,FONT_MEDIUM,zwykly);
|
||||
printAtMiddle(txt.str(),pos.x+95,pos.y+31,FONT_MEDIUM,Colors::Cornsilk);
|
||||
if (pom == anim->ourImages.size()-1)
|
||||
toNextTick+=750;
|
||||
}
|
||||
@ -914,9 +914,9 @@ void CInfoBar::newDay(int Day)
|
||||
blitAnim(mode);
|
||||
}
|
||||
|
||||
void CInfoBar::showComp(SComponent * comp, int time)
|
||||
void CInfoBar::showComp(CComponent * comp, int time)
|
||||
{
|
||||
if(comp->type != SComponent::hero)
|
||||
if(comp->type != CComponent::hero)
|
||||
{
|
||||
curSel = NULL;
|
||||
}
|
||||
@ -924,8 +924,8 @@ void CInfoBar::showComp(SComponent * comp, int time)
|
||||
SDL_Surface * b = BitmapHandler::loadBitmap("ADSTATOT.bmp");
|
||||
blitAt(b,pos.x+8,pos.y+11);
|
||||
blitAt(comp->getImg(),pos.x+52,pos.y+54);
|
||||
printAtMiddle(comp->subtitle,pos.x+91,pos.y+158,FONT_SMALL,zwykly);
|
||||
printAtMiddleWB(comp->description,pos.x+94,pos.y+31,FONT_SMALL,26,zwykly);
|
||||
printAtMiddle(comp->subtitle,pos.x+91,pos.y+158,FONT_SMALL,Colors::Cornsilk);
|
||||
printAtMiddleWB(comp->description,pos.x+94,pos.y+31,FONT_SMALL,26,Colors::Cornsilk);
|
||||
SDL_FreeSurface(b);
|
||||
if(!(active & TIME))
|
||||
activateTimer();
|
||||
@ -958,7 +958,7 @@ void CInfoBar::tick()
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBar::show( SDL_Surface * to )
|
||||
void CInfoBar::show(SDL_Surface * to)
|
||||
{
|
||||
|
||||
}
|
||||
@ -1130,7 +1130,7 @@ void CAdvMapInt::fadventureOPtions()
|
||||
|
||||
void CAdvMapInt::fsystemOptions()
|
||||
{
|
||||
CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(SRect::createCentered(487, 481), LOCPLINT);
|
||||
CSystemOptionsWindow * sysopWindow = new CSystemOptionsWindow(Rect::createCentered(487, 481), LOCPLINT);
|
||||
GH.pushInt(sysopWindow);
|
||||
}
|
||||
|
||||
@ -1150,7 +1150,7 @@ void CAdvMapInt::fendTurn()
|
||||
for (int i = 0; i < LOCPLINT->wanderingHeroes.size(); i++)
|
||||
if (!isHeroSleeping(LOCPLINT->wanderingHeroes[i]) && (LOCPLINT->wanderingHeroes[i]->movement > 0))
|
||||
{
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::vector<SComponent*>(), boost::bind(&CAdvMapInt::endingTurn, this), 0, false);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::vector<CComponent*>(), boost::bind(&CAdvMapInt::endingTurn, this), 0, false);
|
||||
return;
|
||||
}
|
||||
endingTurn();
|
||||
@ -1274,7 +1274,7 @@ void CAdvMapInt::deactivate()
|
||||
if(LOCPLINT->cingconsole->active) //TODO
|
||||
LOCPLINT->cingconsole->deactivate();
|
||||
}
|
||||
void CAdvMapInt::showAll(SDL_Surface *to)
|
||||
void CAdvMapInt::showAll(SDL_Surface * to)
|
||||
{
|
||||
blitAt(bg,0,0,to);
|
||||
|
||||
@ -1323,7 +1323,7 @@ void CAdvMapInt::setHeroSleeping(const CGHeroInstance *hero, bool sleep)
|
||||
updateNextHero(NULL);
|
||||
}
|
||||
|
||||
void CAdvMapInt::show(SDL_Surface *to)
|
||||
void CAdvMapInt::show(SDL_Surface * to)
|
||||
{
|
||||
if(state != INGAME)
|
||||
return;
|
||||
@ -1482,7 +1482,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
if(townWithMarket) //if any town has marketplace, open window
|
||||
GH.pushInt(new CMarketplaceWindow(townWithMarket));
|
||||
else //if not - complain
|
||||
LOCPLINT->showInfoDialog("No available marketplace!", std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
LOCPLINT->showInfoDialog("No available marketplace!", std::vector<CComponent*>(), soundBase::sound_todo);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
@ -2068,18 +2068,18 @@ CAdventureOptions::CAdventureOptions()
|
||||
bg = new CPicture("ADVOPTS.bmp");
|
||||
graphics->blueToPlayersAdv(bg->bg, LOCPLINT->playerID);
|
||||
pos = bg->center();
|
||||
exit = new AdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
exit = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
//scenInfo = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 24, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 198, "ADVINFO.DEF",SDLK_i);
|
||||
//scenInfo = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 24, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 198, "ADVINFO.DEF",SDLK_i);
|
||||
scenInfo->callback += CAdventureOptions::showScenarioInfo;
|
||||
//viewWorld = new AdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
//viewWorld = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
|
||||
|
||||
puzzle = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 81, "ADVPUZ.DEF");
|
||||
puzzle = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 81, "ADVPUZ.DEF");
|
||||
puzzle->callback += boost::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
|
||||
|
||||
dig = new AdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 139, "ADVDIG.DEF");
|
||||
dig = new CAdventureMapButton("","", boost::bind(&CGuiHandler::popIntTotally, &GH, this), 24, 139, "ADVDIG.DEF");
|
||||
if(const CGHeroInstance *h = adventureInt->curHero())
|
||||
dig->callback += boost::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
|
||||
else
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <typeinfo>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class CDefHandler;
|
||||
@ -33,7 +33,7 @@ class CAdventureOptions : public CIntObject
|
||||
{
|
||||
public:
|
||||
CPicture *bg;
|
||||
AdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
|
||||
CAdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
|
||||
|
||||
CAdventureOptions();
|
||||
~CAdventureOptions();
|
||||
@ -135,7 +135,7 @@ public:
|
||||
class CInfoBar : public CIntObject
|
||||
{
|
||||
CDefHandler *day, *week1, *week2, *week3, *week4;
|
||||
SComponent * current;
|
||||
CComponent * current;
|
||||
int pom;
|
||||
SDL_Surface *selInfoWin; //info box for selection
|
||||
CDefHandler * getAnim(int mode);
|
||||
@ -146,7 +146,7 @@ public:
|
||||
CInfoBar();
|
||||
~CInfoBar();
|
||||
void newDay(int Day); //start showing new day/week animation
|
||||
void showComp(SComponent * comp, int time=5000);
|
||||
void showComp(CComponent * comp, int time=5000);
|
||||
void tick();
|
||||
void showAll(SDL_Surface * to); // if specific==0 function draws info about selected hero/town
|
||||
void blitAnim(int mode);//0 - day, 1 - week
|
||||
@ -184,7 +184,7 @@ public:
|
||||
CMinimap minimap;
|
||||
CStatusBar statusbar;
|
||||
|
||||
AdventureMapButton kingOverview,//- kingdom overview
|
||||
CAdventureMapButton kingOverview,//- kingdom overview
|
||||
underground,//- underground switch
|
||||
questlog,//- questlog
|
||||
sleepWake, //- sleep/wake hero
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "CBitmapHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "CAnimation.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
|
||||
/*
|
||||
* CAnimation.cpp, part of VCMI engine
|
||||
@ -39,7 +39,7 @@ public:
|
||||
inline void Load(size_t size, ui8 color=0);
|
||||
inline void EndLine();
|
||||
//init image with these sizes and palette
|
||||
inline void init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal);
|
||||
inline void init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal);
|
||||
|
||||
SDLImageLoader(SDLImage * Img);
|
||||
~SDLImageLoader();
|
||||
@ -63,7 +63,7 @@ public:
|
||||
inline void Load(size_t size, ui8 color=0);
|
||||
inline void EndLine();
|
||||
//init image with these sizes and palette
|
||||
inline void init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal);
|
||||
inline void init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal);
|
||||
|
||||
CompImageLoader(CompImage * Img);
|
||||
~CompImageLoader();
|
||||
@ -158,9 +158,9 @@ void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
|
||||
ui32 currentOffset = sizeof(SSpriteDef);
|
||||
ui32 BaseOffset = sizeof(SSpriteDef);
|
||||
|
||||
loader.init(SPoint(sprite.width, sprite.height),
|
||||
SPoint(sprite.leftMargin, sprite.topMargin),
|
||||
SPoint(sprite.fullWidth, sprite.fullHeight), palette);
|
||||
loader.init(Point(sprite.width, sprite.height),
|
||||
Point(sprite.leftMargin, sprite.topMargin),
|
||||
Point(sprite.fullWidth, sprite.fullHeight), palette);
|
||||
|
||||
switch (sprite.format)
|
||||
{
|
||||
@ -297,7 +297,7 @@ SDLImageLoader::SDLImageLoader(SDLImage * Img):
|
||||
{
|
||||
}
|
||||
|
||||
void SDLImageLoader::init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal)
|
||||
void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal)
|
||||
{
|
||||
//Init image
|
||||
image->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SpriteSize.x, SpriteSize.y, 8, 0, 0, 0, 0);
|
||||
@ -353,9 +353,9 @@ CompImageLoader::CompImageLoader(CompImage * Img):
|
||||
|
||||
}
|
||||
|
||||
void CompImageLoader::init(SPoint SpriteSize, SPoint Margins, SPoint FullSize, SDL_Color *pal)
|
||||
void CompImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal)
|
||||
{
|
||||
image->sprite = SRect(Margins, SpriteSize);
|
||||
image->sprite = Rect(Margins, SpriteSize);
|
||||
image->fullSize = FullSize;
|
||||
if (SpriteSize.x && SpriteSize.y)
|
||||
{
|
||||
@ -588,17 +588,17 @@ SDLImage::SDLImage(std::string filename, bool compressed):
|
||||
}
|
||||
}
|
||||
|
||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, SRect *src, ui8 rotation) const
|
||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 rotation) const
|
||||
{
|
||||
if (!surf)
|
||||
return;
|
||||
SRect sourceRect(margins.x, margins.y, surf->w, surf->h);
|
||||
Rect sourceRect(margins.x, margins.y, surf->w, surf->h);
|
||||
//TODO: rotation and scaling
|
||||
if (src)
|
||||
{
|
||||
sourceRect = sourceRect & *src;
|
||||
}
|
||||
SRect destRect(posX, posY, surf->w, surf->h);
|
||||
Rect destRect(posX, posY, surf->w, surf->h);
|
||||
destRect += sourceRect.topLeft();
|
||||
sourceRect -= margins;
|
||||
CSDL_Ext::blitSurface(surf, &sourceRect, where, &destRect);
|
||||
@ -640,22 +640,22 @@ CompImage::CompImage(SDL_Surface * surf)
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CompImage::draw(SDL_Surface *where, int posX, int posY, SRect *src, ui8 alpha) const
|
||||
void CompImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha) const
|
||||
{
|
||||
int rotation = 0; //TODO
|
||||
//rotation & 2 = horizontal rotation
|
||||
//rotation & 4 = vertical rotation
|
||||
if (!surf)
|
||||
return;
|
||||
SRect sourceRect(sprite);
|
||||
Rect sourceRect(sprite);
|
||||
//TODO: rotation and scaling
|
||||
if (src)
|
||||
sourceRect = sourceRect & *src;
|
||||
//Limit source rect to sizes of surface
|
||||
sourceRect = sourceRect & SRect(0, 0, where->w, where->h);
|
||||
sourceRect = sourceRect & Rect(0, 0, where->w, where->h);
|
||||
|
||||
//Starting point on SDL surface
|
||||
SPoint dest(posX+sourceRect.x, posY+sourceRect.y);
|
||||
Point dest(posX+sourceRect.x, posY+sourceRect.y);
|
||||
if (rotation & 2)
|
||||
dest.y += sourceRect.h;
|
||||
if (rotation & 4)
|
||||
@ -1166,7 +1166,7 @@ CAnimImage::~CAnimImage()
|
||||
delete anim;
|
||||
}
|
||||
|
||||
void CAnimImage::showAll(SDL_Surface *to)
|
||||
void CAnimImage::showAll(SDL_Surface * to)
|
||||
{
|
||||
IImage *img = anim->getImage(frame, group);
|
||||
if (img)
|
||||
@ -1285,7 +1285,7 @@ void CShowableAnim::clipRect(int posX, int posY, int width, int height)
|
||||
pos.h = height;
|
||||
}
|
||||
|
||||
void CShowableAnim::show(SDL_Surface *to)
|
||||
void CShowableAnim::show(SDL_Surface * to)
|
||||
{
|
||||
if ( flags & BASE && frame != first)
|
||||
blitImage(first, group, to);
|
||||
@ -1299,7 +1299,7 @@ void CShowableAnim::show(SDL_Surface *to)
|
||||
}
|
||||
}
|
||||
|
||||
void CShowableAnim::showAll(SDL_Surface *to)
|
||||
void CShowableAnim::showAll(SDL_Surface * to)
|
||||
{
|
||||
if ( flags & BASE && frame != first)
|
||||
blitImage(first, group, to);
|
||||
@ -1309,7 +1309,7 @@ void CShowableAnim::showAll(SDL_Surface *to)
|
||||
void CShowableAnim::blitImage(size_t frame, size_t group, SDL_Surface *to)
|
||||
{
|
||||
assert(to);
|
||||
SRect src( xOffset, yOffset, pos.w, pos.h);
|
||||
Rect src( xOffset, yOffset, pos.w, pos.h);
|
||||
IImage * img = anim.getImage(frame, group);
|
||||
if (img)
|
||||
img->draw(to, pos.x-xOffset, pos.y-yOffset, &src, alpha);
|
||||
@ -1324,7 +1324,7 @@ void CShowableAnim::rotate(bool on, bool vertical)
|
||||
flags &= ~flag;
|
||||
}
|
||||
|
||||
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, SRect picPos, ui8 flags, EAnimType type):
|
||||
CCreatureAnim::CCreatureAnim(int x, int y, std::string name, Rect picPos, ui8 flags, EAnimType type):
|
||||
CShowableAnim(x,y,name,flags,3,type)
|
||||
{
|
||||
xOffset = picPos.x;
|
||||
|
@ -60,7 +60,7 @@ class IImage
|
||||
public:
|
||||
|
||||
//draws image on surface "where" at position
|
||||
virtual void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const=0;
|
||||
virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const=0;
|
||||
|
||||
//decrease ref count, returns true if image can be deleted (refCount <= 0)
|
||||
bool decreaseRef();
|
||||
@ -83,9 +83,9 @@ public:
|
||||
//Surface without empty borders
|
||||
SDL_Surface * surf;
|
||||
//size of left and top borders
|
||||
SPoint margins;
|
||||
Point margins;
|
||||
//total size including borders
|
||||
SPoint fullSize;
|
||||
Point fullSize;
|
||||
|
||||
public:
|
||||
//Load image from def file
|
||||
@ -96,7 +96,7 @@ public:
|
||||
SDLImage(SDL_Surface * from, bool extraRef);
|
||||
~SDLImage();
|
||||
|
||||
void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const;
|
||||
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const;
|
||||
void playerColored(int player);
|
||||
int width() const;
|
||||
int height() const;
|
||||
@ -119,9 +119,9 @@ public:
|
||||
class CompImage : public IImage
|
||||
{
|
||||
//x,y - margins, w,h - sprite size
|
||||
SRect sprite;
|
||||
Rect sprite;
|
||||
//total size including borders
|
||||
SPoint fullSize;
|
||||
Point fullSize;
|
||||
|
||||
//RLE-d data
|
||||
ui8 * surf;
|
||||
@ -142,7 +142,7 @@ public:
|
||||
CompImage(SDL_Surface * surf);
|
||||
~CompImage();
|
||||
|
||||
void draw(SDL_Surface *where, int posX=0, int posY=0, SRect *src=NULL, ui8 alpha=255) const;
|
||||
void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const;
|
||||
void playerColored(int player);
|
||||
int width() const;
|
||||
int height() const;
|
||||
@ -246,7 +246,7 @@ public:
|
||||
//makes image player-colored
|
||||
void playerColored(int player);
|
||||
|
||||
void showAll(SDL_Surface *to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Base class for displaying animation, used as superclass for different animations
|
||||
@ -306,8 +306,8 @@ public:
|
||||
virtual void reset();
|
||||
|
||||
//show current frame and increase counter
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Creature-dependend animations like attacking, moving,...
|
||||
@ -366,7 +366,7 @@ public:
|
||||
//clear queue and set animation to this sequence
|
||||
void clearAndSet(EAnimType type);
|
||||
|
||||
CCreatureAnim(int x, int y, std::string name, SRect picPos,
|
||||
CCreatureAnim(int x, int y, std::string name, Rect picPos,
|
||||
ui8 flags= USE_RLE, EAnimType = HOLDING );
|
||||
|
||||
};
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "../lib/CObjectHandler.h"
|
||||
#include "../lib/CSpellHandler.h"
|
||||
#include "../lib/CTownHandler.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "CAnimation.h"
|
||||
#include "CBitmapHandler.h"
|
||||
@ -20,9 +19,10 @@
|
||||
#include "CMusicHandler.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "Graphics.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
using namespace boost::assign;
|
||||
|
||||
@ -123,8 +123,8 @@ void CBuildingRect::clickRight(tribool down, bool previousState)
|
||||
const CBuilding *bld = CGI->buildh->buildings[str->townID].find(bid)->second;
|
||||
if (bid < EBuilding::DWELL_FIRST)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building, bld->tid, bld->bid,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building, bld->tid, bld->bid,
|
||||
LOCPLINT->castleInt->bicons->ourImages[bld->bid].bitmap, false));
|
||||
|
||||
CRClickPopup::createAndPush(bld->Description(), comps);
|
||||
@ -146,7 +146,7 @@ SDL_Color multiplyColors (const SDL_Color &b, const SDL_Color &a, double f)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CBuildingRect::show(SDL_Surface *to)
|
||||
void CBuildingRect::show(SDL_Surface * to)
|
||||
{
|
||||
const ui32 stageDelay = 16;
|
||||
|
||||
@ -200,7 +200,7 @@ void CBuildingRect::show(SDL_Surface *to)
|
||||
stateCounter++;
|
||||
}
|
||||
|
||||
void CBuildingRect::showAll(SDL_Surface *to)
|
||||
void CBuildingRect::showAll(SDL_Surface * to)
|
||||
{
|
||||
if (stateCounter == 0)
|
||||
return;
|
||||
@ -256,23 +256,23 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
pos.w = background->pos.w;
|
||||
pos.h = background->pos.h;
|
||||
moveTo(SPoint(centerX - pos.w/2, centerY - pos.h/2));
|
||||
moveTo(Point(centerX - pos.w/2, centerY - pos.h/2));
|
||||
|
||||
const CCreature * creature = CGI->creh->creatures[Town->creatures[level].second.back()];
|
||||
|
||||
title = new CLabel(80, 30, FONT_SMALL, CENTER, zwykly, creature->namePl);
|
||||
title = new CLabel(80, 30, FONT_SMALL, CENTER, Colors::Cornsilk, creature->namePl);
|
||||
animation = new CCreaturePic(30, 44, creature, true, true);
|
||||
|
||||
std::string text = boost::lexical_cast<std::string>(Town->creatures[level].first);
|
||||
available = new CLabel(80,190, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[217] + text);
|
||||
costPerTroop = new CLabel(80, 227, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->allTexts[346]);
|
||||
available = new CLabel(80,190, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->allTexts[217] + text);
|
||||
costPerTroop = new CLabel(80, 227, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->allTexts[346]);
|
||||
|
||||
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||
{
|
||||
if(creature->cost[i])
|
||||
{
|
||||
resPicture.push_back(new CPicture(graphics->resources32->ourImages[i].bitmap, 0, 0, false));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, zwykly, boost::lexical_cast<std::string>(creature->cost[i])));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, Colors::Cornsilk, boost::lexical_cast<std::string>(creature->cost[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,8 +280,8 @@ CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstanc
|
||||
int posX = pos.w/2 - resAmount.size() * 25 + 5;
|
||||
for (size_t i=0; i<resAmount.size(); i++)
|
||||
{
|
||||
resPicture[i]->moveBy(SPoint(posX, posY));
|
||||
resAmount[i]->moveBy(SPoint(posX+16, posY+43));
|
||||
resPicture[i]->moveBy(Point(posX, posY));
|
||||
resAmount[i]->moveBy(Point(posX+16, posY+43));
|
||||
posX += 50;
|
||||
}
|
||||
}
|
||||
@ -366,12 +366,12 @@ void CHeroGSlot::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
std::string tmp = CGI->generaltexth->allTexts[18]; //You already have %d adventuring heroes under your command.
|
||||
boost::algorithm::replace_first(tmp,"%d",boost::lexical_cast<std::string>(LOCPLINT->cb->howManyHeroes(false)));
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<SComponent*>(), soundBase::sound_todo);
|
||||
LOCPLINT->showInfoDialog(tmp,std::vector<CComponent*>(), soundBase::sound_todo);
|
||||
allow = false;
|
||||
}
|
||||
else if(!other->hero->stacksCount()) //hero has no creatures - strange, but if we have appropriate error message...
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<SComponent*>(), soundBase::sound_todo); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[19],std::vector<CComponent*>(), soundBase::sound_todo); //This hero has no creatures. A hero must have creatures before he can brave the dangers of the countryside.
|
||||
allow = false;
|
||||
}
|
||||
}
|
||||
@ -618,14 +618,14 @@ void CCastleBuildings::removeBuilding(int building)
|
||||
checkRules();
|
||||
}
|
||||
|
||||
void CCastleBuildings::show(SDL_Surface *to)
|
||||
void CCastleBuildings::show(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
for (std::vector< CBuildingRect* >::const_iterator it=buildings.begin() ; it !=buildings.end(); it++ )
|
||||
(*it)->show(to);
|
||||
}
|
||||
|
||||
void CCastleBuildings::showAll(SDL_Surface *to)
|
||||
void CCastleBuildings::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
for (std::vector< CBuildingRect* >::const_iterator it=buildings.begin() ; it !=buildings.end(); it++ )
|
||||
@ -797,8 +797,8 @@ void CCastleBuildings::enterBlacksmith(int ArtifactID)
|
||||
|
||||
void CCastleBuildings::enterBuilding(int building)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building, town->subID,building,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building, town->subID,building,
|
||||
LOCPLINT->castleInt->bicons->ourImages[building].bitmap, false));
|
||||
|
||||
LOCPLINT->showInfoDialog(
|
||||
@ -836,8 +836,8 @@ void CCastleBuildings::enterDwelling(int level)
|
||||
|
||||
void CCastleBuildings::enterFountain(int building)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::building,town->subID,building,
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::building,town->subID,building,
|
||||
LOCPLINT->castleInt->bicons->ourImages[building].bitmap,false));
|
||||
|
||||
std::string descr = CGI->buildh->buildings[town->subID].find(building)->second->Description();
|
||||
@ -868,7 +868,7 @@ void CCastleBuildings::enterMagesGuild()
|
||||
{
|
||||
CFunctionList<void()> functionList = boost::bind(&CCallback::buyArtifact,LOCPLINT->cb, hero,0);
|
||||
functionList += boost::bind(&CCastleBuildings::openMagesGuild,this);
|
||||
std::vector<SComponent*> components(1, new SComponent(SComponent::artifact,0,0));
|
||||
std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,0,0));
|
||||
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[214], components, functionList, 0, true);
|
||||
}
|
||||
@ -887,7 +887,7 @@ void CCastleBuildings::enterTownHall()
|
||||
if(!vstd::contains(town->forbiddenBuildings, EBuilding::GRAIL))
|
||||
{
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[597], //Do you wish this to be the permanent home of the Grail?
|
||||
std::vector<SComponent*>(),
|
||||
std::vector<CComponent*>(),
|
||||
boost::bind(&CCallback::buildBuilding, LOCPLINT->cb, town, EBuilding::GRAIL),
|
||||
boost::bind(&CCastleBuildings::openTownHall, this), true);
|
||||
}
|
||||
@ -928,22 +928,22 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, int listPos):
|
||||
pos.h = builds->pos.h + panel->pos.h;
|
||||
center();
|
||||
|
||||
garr = new CGarrisonInt(305, 387, 4, SPoint(0,96), panel->bg, SPoint(62,374), town->getUpperArmy(), town->visitingHero);
|
||||
heroes = new HeroSlots(town, SPoint(241, 387), SPoint(241, 483), garr, true);
|
||||
title = new CLabel(85, 387, FONT_MEDIUM, TOPLEFT, zwykly, town->name);
|
||||
garr = new CGarrisonInt(305, 387, 4, Point(0,96), panel->bg, Point(62,374), town->getUpperArmy(), town->visitingHero);
|
||||
heroes = new HeroSlots(town, Point(241, 387), Point(241, 483), garr, true);
|
||||
title = new CLabel(85, 387, FONT_MEDIUM, TOPLEFT, Colors::Cornsilk, town->name);
|
||||
income = new CLabel(195, 443, FONT_SMALL, CENTER);
|
||||
icon = new CAnimImage("ITPT", 0, 0, 15, 387);
|
||||
|
||||
exit = new AdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
|
||||
exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
exit->setOffset(4);
|
||||
|
||||
split = new AdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
|
||||
split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
|
||||
split->callback += boost::bind(&HeroSlots::splitClicked, heroes);
|
||||
removeChild(split);
|
||||
garr->addSplitBtn(split);
|
||||
|
||||
SRect barRect(9, 182, 732, 18);
|
||||
Rect barRect(9, 182, 732, 18);
|
||||
statusbar = new CGStatusBar(new CPicture(*panel, barRect, 9, 555, false));
|
||||
resdatabar = new CResDataBar("ZRESBAR", 3, 575, 32, 2, 85, 85);
|
||||
|
||||
@ -980,7 +980,7 @@ void CCastleInterface::close()
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
void CCastleInterface::showAll(SDL_Surface *to)
|
||||
void CCastleInterface::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
if(screen->w != 800 || screen->h !=600)
|
||||
@ -1045,13 +1045,13 @@ void CCastleInterface::recreateIcons()
|
||||
creainfo.clear();
|
||||
|
||||
for (size_t i=0; i<4; i++)
|
||||
creainfo.push_back(new CCreaInfo(SPoint(14+55*i, 459), town, i));
|
||||
creainfo.push_back(new CCreaInfo(Point(14+55*i, 459), town, i));
|
||||
|
||||
for (size_t i=0; i<4; i++)
|
||||
creainfo.push_back(new CCreaInfo(SPoint(14+55*i, 507), town, i+4));
|
||||
creainfo.push_back(new CCreaInfo(Point(14+55*i, 507), town, i+4));
|
||||
}
|
||||
|
||||
CCreaInfo::CCreaInfo(SPoint position, const CGTownInstance *Town, int Level, bool compact, bool ShowAvailable):
|
||||
CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool compact, bool ShowAvailable):
|
||||
town(Town),
|
||||
level(Level),
|
||||
showAvailable(ShowAvailable)
|
||||
@ -1081,14 +1081,14 @@ CCreaInfo::CCreaInfo(SPoint position, const CGTownInstance *Town, int Level, boo
|
||||
|
||||
if (compact)
|
||||
{
|
||||
label = new CLabel(40, 32, FONT_TINY, BOTTOMRIGHT, zwykly, value);
|
||||
label = new CLabel(40, 32, FONT_TINY, BOTTOMRIGHT, Colors::Cornsilk, value);
|
||||
pos.x += 8;
|
||||
pos.w = 32;
|
||||
pos.h = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
label = new CLabel(24, 40, FONT_SMALL, CENTER, zwykly, value);
|
||||
label = new CLabel(24, 40, FONT_SMALL, CENTER, Colors::Cornsilk, value);
|
||||
pos.w = 48;
|
||||
pos.h = 48;
|
||||
}
|
||||
@ -1263,7 +1263,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
|
||||
}
|
||||
}
|
||||
|
||||
HeroSlots::HeroSlots(const CGTownInstance * Town, SPoint garrPos, SPoint visitPos, CGarrisonInt *Garrison, bool ShowEmpty):
|
||||
HeroSlots::HeroSlots(const CGTownInstance * Town, Point garrPos, Point visitPos, CGarrisonInt *Garrison, bool ShowEmpty):
|
||||
showEmpty(ShowEmpty),
|
||||
town(Town),
|
||||
garr(Garrison)
|
||||
@ -1337,7 +1337,7 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
|
||||
panel = new CAnimImage("TPTHBAR", panelIndex[state], 0, 1, 73);
|
||||
if ( iconIndex[state] >=0 )
|
||||
icon = new CAnimImage("TPTHCHK", iconIndex[state], 0, 136, 56);
|
||||
label = new CLabel(75, 81, FONT_SMALL, CENTER, zwykly, building->Name());
|
||||
label = new CLabel(75, 81, FONT_SMALL, CENTER, Colors::Cornsilk, building->Name());
|
||||
}
|
||||
|
||||
CHallInterface::CHallInterface(const CGTownInstance *Town):
|
||||
@ -1351,11 +1351,11 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
|
||||
resdatabar = new CMinorResDataBar;
|
||||
resdatabar->pos.x += pos.x;
|
||||
resdatabar->pos.y += pos.y;
|
||||
SRect barRect(5, 556, 740, 18);
|
||||
Rect barRect(5, 556, 740, 18);
|
||||
statusBar = new CGStatusBar(new CPicture(*background, barRect, 5, 556, false));
|
||||
|
||||
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, zwykly, CGI->buildh->buildings[town->subID][town->hallLevel()+EBuilding::VILLAGE_HALL]->Name());
|
||||
exit = new AdventureMapButton(CGI->generaltexth->hcommands[8], "",
|
||||
title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->buildh->buildings[town->subID][town->hallLevel()+EBuilding::VILLAGE_HALL]->Name());
|
||||
exit = new CAdventureMapButton(CGI->generaltexth->hcommands[8], "",
|
||||
boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
@ -1454,13 +1454,13 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
|
||||
buildingPic = new CAnimImage(graphics->buildingPics[town->subID], building->bid, 0, 125, 50);
|
||||
SRect barRect(9, 494, 380, 18);
|
||||
Rect barRect(9, 494, 380, 18);
|
||||
statusBar = new CGStatusBar(new CPicture(*background, barRect, 9, 494, false));
|
||||
|
||||
title = new CLabel(197, 30, FONT_MEDIUM, CENTER, zwykly,
|
||||
title = new CLabel(197, 30, FONT_MEDIUM, CENTER, Colors::Cornsilk,
|
||||
boost::str(boost::format(CGI->generaltexth->hcommands[7]) % building->Name()));
|
||||
buildingDescr = new CTextBox(building->Description(), SRect(33, 135, 329, 67), 0, FONT_MEDIUM, CENTER);
|
||||
buildingState = new CTextBox(getTextForState(state), SRect(33, 216, 329, 67), 0, FONT_SMALL, CENTER);
|
||||
buildingDescr = new CTextBox(building->Description(), Rect(33, 135, 329, 67), 0, FONT_MEDIUM, CENTER);
|
||||
buildingState = new CTextBox(getTextForState(state), Rect(33, 216, 329, 67), 0, FONT_SMALL, CENTER);
|
||||
|
||||
//Create objects for all required resources
|
||||
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||
@ -1468,7 +1468,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
if(building->resources[i])
|
||||
{
|
||||
resPicture.push_back(new CPicture(graphics->resources32->ourImages[i].bitmap, 0, 0, false));
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, zwykly,
|
||||
resAmount.push_back(new CLabel(0,0, FONT_SMALL, CENTER, Colors::Cornsilk,
|
||||
boost::lexical_cast<std::string>(building->resources[i])));
|
||||
}
|
||||
}
|
||||
@ -1493,8 +1493,8 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
int posX = pos.w/2 - rowSize[row] * 40 + 24;
|
||||
for (size_t i=0; i<rowSize[row]; i++)
|
||||
{//Move current resource to correct position
|
||||
resPicture[index]->moveBy(SPoint(posX, posY));
|
||||
resAmount[index]->moveBy(SPoint(posX+16, posY+48));
|
||||
resPicture[index]->moveBy(Point(posX, posY));
|
||||
resAmount[index]->moveBy(Point(posX+16, posY+48));
|
||||
posX += 80;
|
||||
index++;
|
||||
}
|
||||
@ -1503,12 +1503,12 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
|
||||
if(!mode)
|
||||
{
|
||||
buy = new AdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
|
||||
buy = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
|
||||
"", boost::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
|
||||
buy->borderColor = Colors::MetallicGold;
|
||||
buy->borderEnabled = true;
|
||||
|
||||
cancel = new AdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
|
||||
cancel = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
|
||||
"", boost::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
|
||||
cancel->borderColor = Colors::MetallicGold;
|
||||
cancel->borderEnabled = true;
|
||||
@ -1539,20 +1539,20 @@ CFortScreen::CFortScreen(const CGTownInstance * town)
|
||||
pos = background->center();
|
||||
|
||||
const CBuilding *fortBuilding = CGI->buildh->buildings[town->subID][town->fortLevel()+6];
|
||||
title = new CLabel(400, 12, FONT_BIG, CENTER, zwykly, fortBuilding->Name());
|
||||
title = new CLabel(400, 12, FONT_BIG, CENTER, Colors::Cornsilk, fortBuilding->Name());
|
||||
|
||||
std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name());
|
||||
exit = new AdventureMapButton(text, "", boost::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
|
||||
exit = new CAdventureMapButton(text, "", boost::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
|
||||
|
||||
std::vector<SPoint> positions;
|
||||
positions += SPoint(10, 22), SPoint(404, 22),
|
||||
SPoint(10, 155), SPoint(404,155),
|
||||
SPoint(10, 288), SPoint(404,288);
|
||||
std::vector<Point> positions;
|
||||
positions += Point(10, 22), Point(404, 22),
|
||||
Point(10, 155), Point(404,155),
|
||||
Point(10, 288), Point(404,288);
|
||||
|
||||
if (fortSize == GameConstants::CREATURES_PER_TOWN)
|
||||
positions += SPoint(206,421);
|
||||
positions += Point(206,421);
|
||||
else
|
||||
positions += SPoint(10, 421), SPoint(404,421);
|
||||
positions += Point(10, 421), Point(404,421);
|
||||
|
||||
for (ui32 i=0; i<fortSize; i++)
|
||||
{
|
||||
@ -1573,7 +1573,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town)
|
||||
resdatabar->pos.x += pos.x;
|
||||
resdatabar->pos.y += pos.y;
|
||||
|
||||
SRect barRect(4, 554, 740, 18);
|
||||
Rect barRect(4, 554, 740, 18);
|
||||
statusBar = new CGStatusBar(new CPicture(*background, barRect, 4, 554, false));
|
||||
}
|
||||
|
||||
@ -1583,7 +1583,7 @@ void CFortScreen::creaturesChanged()
|
||||
recAreas[i]->creaturesChanged();
|
||||
}
|
||||
|
||||
LabeledValue::LabeledValue(SRect size, std::string name, std::string descr, int min, int max)
|
||||
LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int min, int max)
|
||||
{
|
||||
pos.x+=size.x;
|
||||
pos.y+=size.y;
|
||||
@ -1592,7 +1592,7 @@ LabeledValue::LabeledValue(SRect size, std::string name, std::string descr, int
|
||||
init(name, descr, min, max);
|
||||
}
|
||||
|
||||
LabeledValue::LabeledValue(SRect size, std::string name, std::string descr, int val)
|
||||
LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int val)
|
||||
{
|
||||
pos.x+=size.x;
|
||||
pos.y+=size.y;
|
||||
@ -1613,8 +1613,8 @@ void LabeledValue::init(std::string nameText, std::string descr, int min, int ma
|
||||
if (min != max)
|
||||
valueText += '-' + boost::lexical_cast<std::string>(max);
|
||||
}
|
||||
name = new CLabel(3, 0, FONT_SMALL, TOPLEFT, zwykly, nameText);
|
||||
value = new CLabel(pos.w-3, pos.h-2, FONT_SMALL, BOTTOMRIGHT, zwykly, valueText);
|
||||
name = new CLabel(3, 0, FONT_SMALL, TOPLEFT, Colors::Cornsilk, nameText);
|
||||
value = new CLabel(pos.w-3, pos.h-2, FONT_SMALL, BOTTOMRIGHT, Colors::Cornsilk, valueText);
|
||||
}
|
||||
|
||||
void LabeledValue::hover(bool on)
|
||||
@ -1655,7 +1655,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
||||
hoverText = boost::str(boost::format(CGI->generaltexth->tcommands[21]) % creature->namePl);
|
||||
creatureAnim = new CCreaturePic(159, 4, creature, false);
|
||||
|
||||
SRect sizes(287, 4, 96, 18);
|
||||
Rect sizes(287, 4, 96, 18);
|
||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], creature->attack));
|
||||
sizes.y+=20;
|
||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[191], CGI->generaltexth->fcommands[1], creature->defence));
|
||||
@ -1668,14 +1668,14 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
||||
sizes.y+=20;
|
||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[194], CGI->generaltexth->fcommands[5], town->creatureGrowth(level)));
|
||||
|
||||
creatureName = new CLabel(78, 11, FONT_SMALL, CENTER, zwykly, creature->namePl);
|
||||
dwellingName = new CLabel(78, 101, FONT_SMALL, CENTER, zwykly, CGI->buildh->buildings[town->subID][buildingID]->Name());
|
||||
creatureName = new CLabel(78, 11, FONT_SMALL, CENTER, Colors::Cornsilk, creature->namePl);
|
||||
dwellingName = new CLabel(78, 101, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->buildh->buildings[town->subID][buildingID]->Name());
|
||||
|
||||
if (vstd::contains(town->builtBuildings, buildingID))
|
||||
{
|
||||
ui32 available = town->creatures[level].first;
|
||||
std::string availableText = CGI->generaltexth->allTexts[217]+ boost::lexical_cast<std::string>(available);
|
||||
availableCount = new CLabel(78, 119, FONT_SMALL, CENTER, zwykly, availableText);
|
||||
availableCount = new CLabel(78, 119, FONT_SMALL, CENTER, Colors::Cornsilk, availableText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1719,20 +1719,20 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner)
|
||||
resdatabar = new CMinorResDataBar;
|
||||
resdatabar->pos.x += pos.x;
|
||||
resdatabar->pos.y += pos.y;
|
||||
SRect barRect(7, 556, 737, 18);
|
||||
Rect barRect(7, 556, 737, 18);
|
||||
statusBar = new CGStatusBar(new CPicture(*background, barRect, 7, 556, false));
|
||||
|
||||
exit = new AdventureMapButton(CGI->generaltexth->allTexts[593],"",boost::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
|
||||
exit = new CAdventureMapButton(CGI->generaltexth->allTexts[593],"",boost::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
|
||||
exit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
|
||||
std::vector<std::vector<SPoint> > positions;
|
||||
std::vector<std::vector<Point> > positions;
|
||||
|
||||
positions.resize(5);
|
||||
positions[0] += SPoint(222,445), SPoint(312,445), SPoint(402,445), SPoint(520,445), SPoint(610,445), SPoint(700,445);
|
||||
positions[1] += SPoint(48,53), SPoint(48,147), SPoint(48,241), SPoint(48,335), SPoint(48,429);
|
||||
positions[2] += SPoint(570,82), SPoint(672,82), SPoint(570,157), SPoint(672,157);
|
||||
positions[3] += SPoint(183,42), SPoint(183,148), SPoint(183,253);
|
||||
positions[4] += SPoint(491,325), SPoint(591,325);
|
||||
positions[0] += Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445);
|
||||
positions[1] += Point(48,53), Point(48,147), Point(48,241), Point(48,335), Point(48,429);
|
||||
positions[2] += Point(570,82), Point(672,82), Point(570,157), Point(672,157);
|
||||
positions[3] += Point(183,42), Point(183,148), Point(183,253);
|
||||
positions[4] += Point(491,325), Point(591,325);
|
||||
|
||||
for(size_t i=0; i<owner->town->town->mageLevel; i++)
|
||||
{
|
||||
@ -1752,7 +1752,7 @@ void CMageGuildScreen::close()
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
CMageGuildScreen::Scroll::Scroll(SPoint position, const CSpell *Spell)
|
||||
CMageGuildScreen::Scroll::Scroll(Point position, const CSpell *Spell)
|
||||
:spell(Spell)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
@ -1766,8 +1766,8 @@ void CMageGuildScreen::Scroll::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(down)
|
||||
{
|
||||
std::vector<SComponent*> comps(1,
|
||||
new SComponent(SComponent::spell,spell->id,0)
|
||||
std::vector<CComponent*> comps(1,
|
||||
new CComponent(CComponent::spell,spell->id,0)
|
||||
);
|
||||
LOCPLINT->showInfoDialog(spell->descriptions[0],comps, soundBase::sound_todo);
|
||||
}
|
||||
@ -1811,20 +1811,20 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, int aid, i
|
||||
animBG->needRefresh = true;
|
||||
|
||||
const CCreature *creature = CGI->creh->creatures[creMachineID];
|
||||
anim = new CCreatureAnim(64, 50, creature->animDefName, SRect());
|
||||
anim = new CCreatureAnim(64, 50, creature->animDefName, Rect());
|
||||
anim->clipRect(113,125,200,150);
|
||||
|
||||
title = new CLabel(165, 28, FONT_BIG, CENTER, tytulowy,
|
||||
title = new CLabel(165, 28, FONT_BIG, CENTER, Colors::Jasmine,
|
||||
boost::str(boost::format(CGI->generaltexth->allTexts[274]) % creature->nameSing));
|
||||
costText = new CLabel(165, 218, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->jktexts[43]);
|
||||
costValue = new CLabel(165, 290, FONT_MEDIUM, CENTER, zwykly,
|
||||
costText = new CLabel(165, 218, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->jktexts[43]);
|
||||
costValue = new CLabel(165, 290, FONT_MEDIUM, CENTER, Colors::Cornsilk,
|
||||
boost::lexical_cast<std::string>(CGI->arth->artifacts[aid]->price));
|
||||
|
||||
std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing);
|
||||
buy = new AdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
|
||||
buy = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
|
||||
|
||||
text = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % creature->nameSing);
|
||||
cancel = new AdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
|
||||
cancel = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
|
||||
|
||||
if(possible)
|
||||
buy->callback += boost::bind(&CCallback::buyArtifact,LOCPLINT->cb,LOCPLINT->cb->getHero(hid),aid);
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "CAnimation.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CBuilding;
|
||||
class CCastleBuildings;
|
||||
class CCreaturePic;
|
||||
@ -53,8 +53,8 @@ public:
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Dwelling info box - right-click screen for dwellings
|
||||
@ -104,7 +104,7 @@ public:
|
||||
CHeroGSlot * garrisonedHero;
|
||||
CHeroGSlot * visitingHero;
|
||||
|
||||
HeroSlots(const CGTownInstance * town, SPoint garrPos, SPoint visitPos, CGarrisonInt *Garrison, bool ShowEmpty);
|
||||
HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, CGarrisonInt *Garrison, bool ShowEmpty);
|
||||
|
||||
void splitClicked(); //for hero meeting only (splitting stacks is handled by garrison int)
|
||||
void update();
|
||||
@ -146,8 +146,8 @@ public:
|
||||
void addBuilding(int building);
|
||||
void removeBuilding(int building);//FIXME: not tested!!!
|
||||
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Creature info window
|
||||
@ -165,7 +165,7 @@ class CCreaInfo : public CIntObject
|
||||
std::string genGrowthText();
|
||||
|
||||
public:
|
||||
CCreaInfo(SPoint position, const CGTownInstance *Town, int Level, bool compact=false, bool showAvailable=false);
|
||||
CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool compact=false, bool showAvailable=false);
|
||||
|
||||
void update();
|
||||
void hover(bool on);
|
||||
@ -201,8 +201,8 @@ class CCastleInterface : public CWindowWithGarrison
|
||||
CTownInfo *hall, *fort;
|
||||
CTownList * townlist;
|
||||
|
||||
AdventureMapButton *exit;
|
||||
AdventureMapButton *split;
|
||||
CAdventureMapButton *exit;
|
||||
CAdventureMapButton *split;
|
||||
|
||||
std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
|
||||
|
||||
@ -221,7 +221,7 @@ public:
|
||||
void castleTeleport(int where);
|
||||
void townChange();
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void showAll(SDL_Surface *to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void close();
|
||||
void addBuilding(int bid);
|
||||
void removeBuilding(int bid);
|
||||
@ -257,7 +257,7 @@ class CHallInterface : public CIntObject
|
||||
CLabel *title;
|
||||
CGStatusBar *statusBar;
|
||||
CMinorResDataBar * resdatabar;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
|
||||
public:
|
||||
CHallInterface(const CGTownInstance * Town); //c-tor
|
||||
@ -274,8 +274,8 @@ class CBuildWindow: public CIntObject
|
||||
|
||||
CPicture *background;
|
||||
CAnimImage *buildingPic;
|
||||
AdventureMapButton *buy;
|
||||
AdventureMapButton *cancel;
|
||||
CAdventureMapButton *buy;
|
||||
CAdventureMapButton *cancel;
|
||||
|
||||
CLabel * title;
|
||||
CTextBox * buildingDescr;
|
||||
@ -304,8 +304,8 @@ class LabeledValue : public CIntObject
|
||||
void init(std::string name, std::string descr, int min, int max);
|
||||
|
||||
public:
|
||||
LabeledValue(SRect size, std::string name, std::string descr, int min, int max);
|
||||
LabeledValue(SRect size, std::string name, std::string descr, int val);
|
||||
LabeledValue(Rect size, std::string name, std::string descr, int min, int max);
|
||||
LabeledValue(Rect size, std::string name, std::string descr, int val);
|
||||
void hover(bool on);
|
||||
};
|
||||
|
||||
@ -341,7 +341,7 @@ class CFortScreen : public CIntObject
|
||||
std::vector<RecruitArea*> recAreas;
|
||||
CMinorResDataBar * resdatabar;
|
||||
CGStatusBar *statusBar;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
|
||||
public:
|
||||
CFortScreen(const CGTownInstance * town); //c-tor
|
||||
@ -359,14 +359,14 @@ class CMageGuildScreen : public CIntObject
|
||||
CAnimImage *image;
|
||||
|
||||
public:
|
||||
Scroll(SPoint position, const CSpell *Spell);
|
||||
Scroll(Point position, const CSpell *Spell);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void hover(bool on);
|
||||
};
|
||||
CPicture *background;
|
||||
CPicture *window;
|
||||
AdventureMapButton *exit;
|
||||
CAdventureMapButton *exit;
|
||||
std::vector<Scroll *> spells;
|
||||
CMinorResDataBar * resdatabar;
|
||||
CGStatusBar *statusBar;
|
||||
@ -380,7 +380,7 @@ public:
|
||||
/// The blacksmith window where you can buy available in town war machine
|
||||
class CBlacksmithDialog : public CIntObject
|
||||
{
|
||||
AdventureMapButton *buy, *cancel;
|
||||
CAdventureMapButton *buy, *cancel;
|
||||
CPicture *background;
|
||||
CPicture *animBG;
|
||||
CCreatureAnim * anim;
|
||||
|
@ -8,19 +8,20 @@
|
||||
#include "../CCallback.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CAnimation.h"
|
||||
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../lib/BattleState.h"
|
||||
#include "../lib/CSpellHandler.h"
|
||||
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
using namespace CSDL_Ext;
|
||||
|
||||
@ -83,7 +84,7 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
|
||||
{
|
||||
BLOCK_CAPTURING;
|
||||
upgResCost.push_back(new SComponent(SComponent::resource, i->resType, i->resVal));
|
||||
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
|
||||
}
|
||||
|
||||
if(LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost))
|
||||
@ -93,11 +94,11 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
fs += boost::bind(&CCreatureWindow::close,this);
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog, LOCPLINT, CGI->generaltexth->allTexts[207], boost::ref(upgResCost), fs, 0, false);
|
||||
upgrade = new AdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,385, 148,"IVIEWCR.DEF",SDLK_u);
|
||||
upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,385, 148,"IVIEWCR.DEF",SDLK_u);
|
||||
}
|
||||
else
|
||||
{
|
||||
upgrade = new AdventureMapButton("",CGI->generaltexth->zelp[446].second,boost::function<void()>(),385, 148,"IVIEWCR.DEF");
|
||||
upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,boost::function<void()>(),385, 148,"IVIEWCR.DEF");
|
||||
upgrade->callback.funcs.clear();
|
||||
upgrade->setOffset(2);
|
||||
}
|
||||
@ -110,8 +111,8 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, int Type, boost::func
|
||||
fs[0] += Dsm; //dismiss
|
||||
fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
|
||||
CFunctionList<void()> cfl;
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],std::vector<SComponent*>(),fs[0],fs[1],false);
|
||||
dismiss = new AdventureMapButton("",CGI->generaltexth->zelp[445].second,cfl,333, 148,"IVIEWCR2.DEF",SDLK_d);
|
||||
cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],std::vector<CComponent*>(),fs[0],fs[1],false);
|
||||
dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second,cfl,333, 148,"IVIEWCR2.DEF",SDLK_d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,7 +186,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
pos = bitmap->center();
|
||||
|
||||
//Buttons
|
||||
ok = new AdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
|
||||
ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
|
||||
|
||||
if (type <= BATTLE) //in battle or info window
|
||||
{
|
||||
@ -206,8 +207,8 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
if (GameConstants::STACK_EXP)
|
||||
{
|
||||
int rank = std::min(stack->getExpRank(), 10); //hopefully nobody adds more
|
||||
printAtMiddle(CGI->generaltexth->zcrexp[rank] + " [" + boost::lexical_cast<std::string>(rank) + "]", 436, 62, FONT_MEDIUM, tytulowy,*bitmap);
|
||||
printAtMiddle(boost::lexical_cast<std::string>(stack->experience), 436, 82, FONT_SMALL, zwykly,*bitmap);
|
||||
printAtMiddle(CGI->generaltexth->zcrexp[rank] + " [" + boost::lexical_cast<std::string>(rank) + "]", 436, 62, FONT_MEDIUM, Colors::Jasmine,*bitmap);
|
||||
printAtMiddle(boost::lexical_cast<std::string>(stack->experience), 436, 82, FONT_SMALL, Colors::Cornsilk,*bitmap);
|
||||
if (type > BATTLE) //we need it only on adv. map
|
||||
{
|
||||
int tier = stack->type->level;
|
||||
@ -244,7 +245,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
number = (stack->count * (expmax - expmin)) / expmin;
|
||||
boost::replace_first (expText, "%i", boost::lexical_cast<std::string>(number)); //Maximum New Recruits to remain at Rank 10 if at Maximum Experience
|
||||
|
||||
expArea = new LRClickableAreaWTextComp(SRect(334, 49, 160, 44),SComponent::experience);
|
||||
expArea = new LRClickableAreaWTextComp(Rect(334, 49, 160, 44),CComponent::experience);
|
||||
expArea->text = expText;
|
||||
expArea->bonusValue = 0; //TDO: some specific value or no number at all
|
||||
}
|
||||
@ -256,8 +257,8 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
//creatureArtifact = new CArtPlace(NULL);
|
||||
//creatureArtifact->pos = rect;
|
||||
//creatureArtifact->ourOwner = NULL; //hmm?
|
||||
leftArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||
rightArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
||||
leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||
rightArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
||||
}
|
||||
else
|
||||
creatureArtifact = NULL;
|
||||
@ -278,7 +279,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
int duration = battleStack->getBonus(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain;
|
||||
boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration));
|
||||
blitAt(graphics->spellEffectsPics->ourImages[effect + 1].bitmap, 20 + 52 * printed, 184, *bitmap);
|
||||
spellEffects.push_back(new LRClickableAreaWText(SRect(20 + 52 * printed, 184, 50, 38), spellText, spellText));
|
||||
spellEffects.push_back(new LRClickableAreaWText(Rect(20 + 52 * printed, 184, 50, 38), spellText, spellText));
|
||||
if (++printed >= 10) //we can fit only 10 effects
|
||||
break;
|
||||
}
|
||||
@ -302,7 +303,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
|
||||
void CCreatureWindow::printLine(int nr, const std::string &text, int baseVal, int val/*=-1*/, bool range/*=false*/)
|
||||
{
|
||||
printAt(text, 162, 48 + nr*19, FONT_SMALL, zwykly, *bitmap);
|
||||
printAt(text, 162, 48 + nr*19, FONT_SMALL, Colors::Cornsilk, *bitmap);
|
||||
|
||||
std::string hlp;
|
||||
if(range && baseVal != val)
|
||||
@ -312,7 +313,7 @@ void CCreatureWindow::printLine(int nr, const std::string &text, int baseVal, in
|
||||
else
|
||||
hlp = boost::lexical_cast<std::string>(baseVal);
|
||||
|
||||
printTo(hlp, 325, 64 + nr*19, FONT_SMALL, zwykly, *bitmap);
|
||||
printTo(hlp, 325, 64 + nr*19, FONT_SMALL, Colors::Cornsilk, *bitmap);
|
||||
}
|
||||
|
||||
void CCreatureWindow::recreateSkillList(int Pos)
|
||||
@ -329,7 +330,7 @@ void CCreatureWindow::recreateSkillList(int Pos)
|
||||
int offsetx = 257*j - (bonusRows == 4 ? 1 : 0);
|
||||
int offsety = 60*i + (bonusRows > 1 ? 1 : 0); //lack of precision :/
|
||||
|
||||
bonusItems[n]->moveTo (SPoint(pos.x + offsetx + 10, pos.y + offsety + 230), true);
|
||||
bonusItems[n]->moveTo (Point(pos.x + offsetx + 10, pos.y + offsety + 230), true);
|
||||
bonusItems[n]->visible = true;
|
||||
|
||||
if (++j > 1) //next line
|
||||
@ -348,7 +349,7 @@ void CCreatureWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
||||
printAtMiddle(c->namePl, 180, 30, FONT_SMALL, tytulowy,*bitmap); //creature name
|
||||
printAtMiddle(c->namePl, 180, 30, FONT_SMALL, Colors::Jasmine,*bitmap); //creature name
|
||||
|
||||
printLine(0, CGI->generaltexth->primarySkillNames[0], c->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK), stackNode->Attack());
|
||||
printLine(1, CGI->generaltexth->primarySkillNames[1], c->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE), stackNode->Defense());
|
||||
@ -377,7 +378,7 @@ void CCreatureWindow::showAll(SDL_Surface * to)
|
||||
void CCreatureWindow::show(SDL_Surface * to)
|
||||
{
|
||||
if (count.size()) //army stack
|
||||
printTo(count, pos.x + 114, pos.y + 174,FONT_TIMES, zwykly, to);
|
||||
printTo(count, pos.x + 114, pos.y + 174,FONT_TIMES, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
|
||||
@ -428,7 +429,7 @@ CBonusItem::CBonusItem()
|
||||
|
||||
}
|
||||
|
||||
CBonusItem::CBonusItem(const SRect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName)
|
||||
CBonusItem::CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName)
|
||||
{
|
||||
OBJ_CONSTRUCTION;
|
||||
visible = false;
|
||||
@ -447,8 +448,8 @@ void CBonusItem::showAll (SDL_Surface * to)
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
printAt(name, pos.x + 72, pos.y + 6, FONT_SMALL, tytulowy, to);
|
||||
printAt(description, pos.x + 72, pos.y + 30, FONT_SMALL, zwykly, to);
|
||||
printAt(name, pos.x + 72, pos.y + 6, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAt(description, pos.x + 72, pos.y + 30, FONT_SMALL, Colors::Cornsilk, to);
|
||||
if (bonusGraphics && bonusGraphics->bg)
|
||||
blitAtLoc(bonusGraphics->bg, 12, 2, to);
|
||||
}
|
||||
@ -458,3 +459,192 @@ CBonusItem::~CBonusItem()
|
||||
{
|
||||
//delete bonusGraphics; //automatic destruction
|
||||
}
|
||||
|
||||
void CCreInfoWindow::show(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
creatureCount->showAll(to);
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost::function<void()> upgradeFunc, boost::function<void()> dismissFunc, UpgradeInfo *upgradeInfo)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
init(stack.type, &stack, dynamic_cast<const CGHeroInstance*>(stack.armyObj), stack.count, LClicked);
|
||||
|
||||
//additional buttons if opened with left click
|
||||
if(LClicked)
|
||||
{
|
||||
boost::function<void()> closeFunc = boost::bind(&CCreInfoWindow::close,this);
|
||||
|
||||
if(upgradeFunc && upgradeInfo)
|
||||
{
|
||||
TResources upgradeCost = upgradeInfo->cost[0] * stack.count;
|
||||
for(TResources::nziterator i(upgradeCost); i.valid(); i++)
|
||||
{
|
||||
BLOCK_CAPTURING;
|
||||
upgResCost.push_back(new CComponent(CComponent::resource, i->resType, i->resVal));
|
||||
}
|
||||
|
||||
CFunctionList<void()> onUpgrade;
|
||||
onUpgrade += upgradeFunc;
|
||||
onUpgrade += closeFunc;
|
||||
|
||||
boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
|
||||
LOCPLINT,
|
||||
CGI->generaltexth->allTexts[207],
|
||||
boost::ref(upgResCost),
|
||||
onUpgrade, 0, false);
|
||||
|
||||
upgrade = new CAdventureMapButton("", CGI->generaltexth->zelp[446].second, dialog, 76, 237, "IVIEWCR", SDLK_u);
|
||||
upgrade->block(!LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost));
|
||||
}
|
||||
|
||||
if(dismissFunc)
|
||||
{
|
||||
CFunctionList<void()> onDismiss;
|
||||
onDismiss += dismissFunc;
|
||||
onDismiss += closeFunc;
|
||||
|
||||
boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
|
||||
LOCPLINT,
|
||||
CGI->generaltexth->allTexts[12],
|
||||
std::vector<CComponent*>(),
|
||||
onDismiss, 0, true);
|
||||
|
||||
dismiss = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second, dialog, 21, 237, "IVIEWCR2",SDLK_d);
|
||||
}
|
||||
|
||||
ok = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second,
|
||||
boost::bind(&CCreInfoWindow::close,this), 216, 237, "IOKAY.DEF", SDLK_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(int creatureID, bool LClicked, int creatureCount)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
const CCreature *creature = CGI->creh->creatures[creatureID];
|
||||
init(creature, NULL, NULL, creatureCount, LClicked);
|
||||
}
|
||||
|
||||
CCreInfoWindow::CCreInfoWindow(const CStack &stack, bool LClicked)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
init(stack.getCreature(), &stack, stack.getMyHero(), stack.count, LClicked);
|
||||
}
|
||||
|
||||
CCreInfoWindow::~CCreInfoWindow()
|
||||
{
|
||||
BOOST_FOREACH(CComponent* object, upgResCost)
|
||||
delete object;
|
||||
}
|
||||
|
||||
void CCreInfoWindow::printLine(int position, const std::string &text, int baseVal, int val/*=-1*/, bool range/*=false*/)
|
||||
{
|
||||
infoTexts[position].first = new CLabel(155, 48 + position*19, FONT_SMALL, TOPLEFT, Colors::Cornsilk, text);
|
||||
std::string valueStr;
|
||||
|
||||
if(range && baseVal != val)
|
||||
valueStr = boost::str(boost::format("%d - %d") % baseVal % val);
|
||||
|
||||
else if(baseVal != val && val>=0)
|
||||
valueStr = boost::str(boost::format("%d (%d)") % baseVal % val);
|
||||
|
||||
else
|
||||
valueStr = boost::lexical_cast<std::string>(baseVal);
|
||||
|
||||
infoTexts[position].second = new CLabel(276, 63 + position*19, FONT_SMALL, BOTTOMRIGHT, Colors::Cornsilk, valueStr);
|
||||
}
|
||||
|
||||
void CCreInfoWindow::init(const CCreature *creature, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner, int count, bool LClicked)
|
||||
{
|
||||
used = 0;
|
||||
if (!LClicked)
|
||||
used |= RCLICK;
|
||||
|
||||
if(!stackNode)
|
||||
stackNode = creature;
|
||||
|
||||
background = new CPicture("CRSTKPU");
|
||||
background->colorize(LOCPLINT->playerID);
|
||||
pos = background->center();
|
||||
|
||||
animation = new CCreaturePic(21, 48, creature);
|
||||
|
||||
std::string countStr = boost::lexical_cast<std::string>(count);
|
||||
creatureCount = new CLabel(114, 174, FONT_TIMES, BOTTOMRIGHT, Colors::Cornsilk, countStr);
|
||||
|
||||
creatureName = new CLabel(149, 30, FONT_SMALL, CENTER, Colors::Jasmine, creature->namePl);
|
||||
|
||||
printLine(0, CGI->generaltexth->primarySkillNames[0], creature->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK), stackNode->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK));
|
||||
printLine(1, CGI->generaltexth->primarySkillNames[1], creature->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE), stackNode->valOfBonuses(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE));
|
||||
|
||||
if(stackNode->valOfBonuses(Bonus::SHOTS))
|
||||
printLine(2, CGI->generaltexth->allTexts[198], stackNode->valOfBonuses(Bonus::SHOTS));
|
||||
|
||||
//TODO
|
||||
int dmgMultiply = 1;
|
||||
if(heroOwner && stackNode->hasBonusOfType(Bonus::SIEGE_WEAPON))
|
||||
dmgMultiply += heroOwner->Attack();
|
||||
|
||||
printLine(3, CGI->generaltexth->allTexts[199], stackNode->getMinDamage() * dmgMultiply, stackNode->getMaxDamage() * dmgMultiply, true);
|
||||
printLine(4, CGI->generaltexth->allTexts[388], creature->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH));
|
||||
printLine(6, CGI->generaltexth->zelp[441].first, creature->valOfBonuses(Bonus::STACKS_SPEED), stackNode->valOfBonuses(Bonus::STACKS_SPEED));
|
||||
|
||||
//setting morale
|
||||
morale = new MoraleLuckBox(true, genRect(42, 42, 22, 186));
|
||||
morale->set(stackNode);
|
||||
//setting luck
|
||||
luck = new MoraleLuckBox(false, genRect(42, 42, 75, 186));
|
||||
luck->set(stackNode);
|
||||
|
||||
if(!LClicked)
|
||||
abilityText = new CLabel(17, 231, FONT_SMALL, TOPLEFT, Colors::Cornsilk, creature->abilityText);
|
||||
else
|
||||
abilityText = NULL;
|
||||
|
||||
//if we are displying window fo r stack in battle, there are several more things that we need to display
|
||||
if(const CStack *battleStack = dynamic_cast<const CStack*>(stackNode))
|
||||
{
|
||||
//print at most 3 spell effects
|
||||
std::vector<si32> spells = battleStack->activeSpells();
|
||||
for (size_t i=0; i< std::min(spells.size(), size_t(3)); i++)
|
||||
effects.push_back(new CAnimImage("SpellInt", spells[i]+1, 0, 127 + 52*i, 186));
|
||||
|
||||
//print current health
|
||||
printLine(5, CGI->generaltexth->allTexts[200], battleStack->firstHPleft);
|
||||
}
|
||||
}
|
||||
|
||||
void CCreInfoWindow::close()
|
||||
{
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
void CCreInfoWindow::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(const CStack *s)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(*s);
|
||||
else
|
||||
return new CCreatureWindow(*s, CCreatureWindow::BATTLE);
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(int Cid, int Type, int creatureCount)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(Cid, Type, creatureCount);
|
||||
else
|
||||
return new CCreatureWindow(Cid, Type, creatureCount);
|
||||
}
|
||||
|
||||
CIntObject * createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui)
|
||||
{
|
||||
if(conf.cc.classicCreatureWindow)
|
||||
return new CCreInfoWindow(*s, type==3, Upg, Dsm, ui);
|
||||
else
|
||||
return new CCreatureWindow(*s, type, Upg, Dsm, ui);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "GUIClasses.h"
|
||||
#include "UIFramework/CIntObject.h"
|
||||
#include "../lib/HeroBonus.h"
|
||||
#include "GUIClasses.h"
|
||||
|
||||
/*
|
||||
* CCreatureWindow.h, part of VCMI engine
|
||||
@ -18,9 +18,23 @@ struct Bonus;
|
||||
class CCreature;
|
||||
class CStackInstance;
|
||||
class CStack;
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CBonusItem;
|
||||
class CGHeroInstance;
|
||||
class CComponent;
|
||||
class LRClickableAreaWText;
|
||||
class MoraleLuckBox;
|
||||
class CAdventureMapButton;
|
||||
struct UpgradeInfo;
|
||||
class CPicture;
|
||||
class CCreaturePic;
|
||||
class LRClickableAreaWTextComp;
|
||||
class CArtPlace;
|
||||
class CSlider;
|
||||
class CLabel;
|
||||
class CAnimImage;
|
||||
|
||||
// Classical creature window
|
||||
class CCreatureWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
@ -34,7 +48,7 @@ public:
|
||||
const CStackInstance *stack;
|
||||
const CBonusSystemNode *stackNode;
|
||||
const CGHeroInstance *heroOwner;
|
||||
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CBonusItem*> bonusItems;
|
||||
std::vector<LRClickableAreaWText*> spellEffects;
|
||||
|
||||
@ -44,8 +58,8 @@ public:
|
||||
LRClickableAreaWTextComp * expArea; //displays exp details
|
||||
CArtPlace *creatureArtifact;
|
||||
CSlider * slider; //Abilities
|
||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||
AdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
||||
CAdventureMapButton *dismiss, *upgrade, *ok;
|
||||
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
||||
//TODO: Artifact drop
|
||||
|
||||
boost::function<void()> dsm; //dismiss button callback
|
||||
@ -78,9 +92,44 @@ public:
|
||||
bool visible;
|
||||
|
||||
CBonusItem();
|
||||
CBonusItem(const SRect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
|
||||
CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
|
||||
~CBonusItem();
|
||||
|
||||
void setBonus (const Bonus &bonus);
|
||||
void showAll (SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// New Creature info window
|
||||
class CCreInfoWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
CPicture * background;
|
||||
CLabel * creatureCount;
|
||||
CLabel * creatureName;
|
||||
CLabel * abilityText;
|
||||
|
||||
CCreaturePic * animation;
|
||||
std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CAnimImage *> effects;
|
||||
std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
|
||||
|
||||
MoraleLuckBox * luck, * morale;
|
||||
|
||||
CAdventureMapButton * dismiss, * upgrade, * ok;
|
||||
|
||||
CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
|
||||
CCreInfoWindow(const CStack & st, bool LClicked = 0);
|
||||
CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
|
||||
~CCreInfoWindow();
|
||||
|
||||
void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
|
||||
void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void close();
|
||||
void show(SDL_Surface * to);
|
||||
};
|
||||
|
||||
CIntObject *createCreWindow(const CStack *s);
|
||||
CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
|
||||
CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CGameInfo.h"
|
||||
@ -8,7 +7,7 @@
|
||||
#include "CMessage.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "CSpellWindow.h"
|
||||
@ -23,6 +22,7 @@
|
||||
#include "../lib/CObjectHandler.h"
|
||||
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
#undef min
|
||||
|
||||
@ -84,7 +84,7 @@ CHeroWindow * CHeroSwitcher::getOwner()
|
||||
|
||||
CHeroSwitcher::CHeroSwitcher(int serial)
|
||||
{
|
||||
pos = SRect(612, 87 + serial * 54, 48, 32) + pos;
|
||||
pos = Rect(612, 87 + serial * 54, 48, 32) + pos;
|
||||
id = serial;
|
||||
used = LCLICK;
|
||||
}
|
||||
@ -105,10 +105,10 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero)
|
||||
//artifs = new CArtifactsOfHero(pos.topLeft(), true);
|
||||
ourBar = new CGStatusBar(7, 559, "ADROLLVR.bmp", 660); // new CStatusBar(pos.x+72, pos.y+567, "ADROLLVR.bmp", 660);
|
||||
|
||||
quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),boost::bind(&CHeroWindow::quit,this), 609, 516, "hsbtns.def", SDLK_RETURN);
|
||||
quitButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),boost::bind(&CHeroWindow::quit,this), 609, 516, "hsbtns.def", SDLK_RETURN);
|
||||
quitButton->assignedKeys.insert(SDLK_ESCAPE);
|
||||
dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
|
||||
questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
|
||||
dismissButton = new CAdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
|
||||
questlogButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
|
||||
|
||||
formations = new CHighlightableButtonsGroup(0);
|
||||
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[23]),CGI->generaltexth->heroscrn[29], "hsbtns6.def", 481, 483, 0, 0, SDLK_t);
|
||||
@ -124,27 +124,27 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero)
|
||||
flags = CDefHandler::giveDefEss("CREST58.DEF");
|
||||
|
||||
//areas
|
||||
portraitArea = new LRClickableAreaWText(SRect(18, 18, 58, 64));
|
||||
portraitArea = new LRClickableAreaWText(Rect(18, 18, 58, 64));
|
||||
|
||||
for(int v=0; v<GameConstants::PRIMARY_SKILLS; ++v)
|
||||
{
|
||||
LRClickableAreaWTextComp *area = new LRClickableAreaWTextComp(SRect(30 + 70*v, 109, 42, 64), SComponent::primskill);
|
||||
LRClickableAreaWTextComp *area = new LRClickableAreaWTextComp(Rect(30 + 70*v, 109, 42, 64), CComponent::primskill);
|
||||
area->text = CGI->generaltexth->arraytxt[2+v];
|
||||
area->type = v;
|
||||
area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]);
|
||||
primSkillAreas.push_back(area);
|
||||
}
|
||||
|
||||
specArea = new LRClickableAreaWText(SRect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]);
|
||||
expArea = new LRClickableAreaWText(SRect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]);
|
||||
morale = new MoraleLuckBox(true, SRect(175,179,53,45));
|
||||
luck = new MoraleLuckBox(false, SRect(233,179,53,45));
|
||||
spellPointsArea = new LRClickableAreaWText(SRect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]);
|
||||
specArea = new LRClickableAreaWText(Rect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]);
|
||||
expArea = new LRClickableAreaWText(Rect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]);
|
||||
morale = new MoraleLuckBox(true, Rect(175,179,53,45));
|
||||
luck = new MoraleLuckBox(false, Rect(233,179,53,45));
|
||||
spellPointsArea = new LRClickableAreaWText(Rect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]);
|
||||
|
||||
for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i)
|
||||
{
|
||||
SRect r = SRect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42);
|
||||
secSkillAreas.push_back(new LRClickableAreaWTextComp(r, SComponent::secskill));
|
||||
Rect r = Rect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42);
|
||||
secSkillAreas.push_back(new LRClickableAreaWTextComp(r, CComponent::secskill));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////???????????????
|
||||
@ -193,21 +193,21 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
|
||||
portraitArea->text = curHero->getBiography();
|
||||
|
||||
{
|
||||
AdventureMapButton * split = NULL;
|
||||
CAdventureMapButton * split = NULL;
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
if(!garr)
|
||||
{
|
||||
garr = new CGarrisonInt(15, 485, 8, SPoint(), background->bg, SPoint(15,485), curHero);
|
||||
garr = new CGarrisonInt(15, 485, 8, Point(), background->bg, Point(15,485), curHero);
|
||||
{
|
||||
BLOCK_CAPTURING;
|
||||
split = new AdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::bind(&CGarrisonInt::splitClick,garr), pos.x + 539, pos.y + 519, "hsbtns9.def", false, NULL, false); //deleted by garrison destructor
|
||||
split = new CAdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::bind(&CGarrisonInt::splitClick,garr), pos.x + 539, pos.y + 519, "hsbtns9.def", false, NULL, false); //deleted by garrison destructor
|
||||
boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
||||
}
|
||||
garr->addSplitBtn(split);
|
||||
}
|
||||
if(!artSets.size())
|
||||
{
|
||||
CArtifactsOfHero *arts = new CArtifactsOfHero(SPoint(-65, -8), true);
|
||||
CArtifactsOfHero *arts = new CArtifactsOfHero(Point(-65, -8), true);
|
||||
arts->setHero(curHero);
|
||||
artSets.push_back(arts);
|
||||
}
|
||||
@ -287,7 +287,7 @@ void CHeroWindow::dismissCurrent()
|
||||
{
|
||||
CFunctionList<void()> ony = boost::bind(&CHeroWindow::quit,this);
|
||||
ony += boost::bind(&CCallback::dismissHero,LOCPLINT->cb,curHero);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22],std::vector<SComponent*>(), ony, 0, false);
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22],std::vector<CComponent*>(), ony, 0, false);
|
||||
}
|
||||
|
||||
void CHeroWindow::questlog()
|
||||
@ -301,41 +301,41 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
blitAtLoc(graphics->portraitLarge[curHero->portrait], 19, 19, to);
|
||||
|
||||
//printing hero's name
|
||||
printAtMiddleLoc(curHero->name, 190, 38, FONT_BIG, tytulowy, to);
|
||||
printAtMiddleLoc(curHero->name, 190, 38, FONT_BIG, Colors::Jasmine, to);
|
||||
|
||||
//printing hero's level
|
||||
std::string secondLine= CGI->generaltexth->allTexts[342];
|
||||
boost::algorithm::replace_first(secondLine,"%d",boost::lexical_cast<std::string>(curHero->level));
|
||||
boost::algorithm::replace_first(secondLine,"%s",curHero->type->heroClass->name);
|
||||
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, zwykly, to);
|
||||
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, Colors::Cornsilk, to);
|
||||
|
||||
//primary skills names
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[3], 193, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[4], 262, 99, FONT_SMALL, tytulowy, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[1], 52, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[2], 123, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[3], 193, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtMiddleLoc(CGI->generaltexth->jktexts[4], 262, 99, FONT_SMALL, Colors::Jasmine, to);
|
||||
|
||||
//dismiss / quest log
|
||||
std::vector<std::string> toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8]);
|
||||
if(toPrin.size()==1)
|
||||
{
|
||||
printAtLoc(toPrin[0], 372, 439, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 372, 439, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
printAtLoc(toPrin[0], 372, 430, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[1], 372, 446, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 372, 430, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(toPrin[1], 372, 446, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9]);
|
||||
if(toPrin.size()==1)
|
||||
{
|
||||
printAtLoc(toPrin[0], 512, 439, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 512, 439, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
printAtLoc(toPrin[0], 512, 430, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[1], 512, 446, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(toPrin[0], 512, 430, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(toPrin[1], 512, 446, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
//printing primary skills' amounts
|
||||
@ -343,7 +343,7 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
std::ostringstream primarySkill;
|
||||
primarySkill << primSkillAreas[m]->bonusValue;
|
||||
printAtMiddleLoc(primarySkill.str(), 53 + 70 * m, 166, FONT_SMALL, zwykly, to);
|
||||
printAtMiddleLoc(primarySkill.str(), 53 + 70 * m, 166, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
blitAtLoc(flags->ourImages[player].bitmap, 606, 8, to);
|
||||
@ -376,22 +376,22 @@ void CHeroWindow::showAll(SDL_Surface * to)
|
||||
for(size_t v=0; v<std::min(secSkillAreas.size(), curHero->secSkills.size()); ++v)
|
||||
{
|
||||
blitAtLoc(graphics->abils44->ourImages[curHero->secSkills[v].first*3+3+curHero->secSkills[v].second-1].bitmap, v%2 ? 161 : 18, 276 + 48 * (v/2), to);
|
||||
printAtLoc(CGI->generaltexth->levels[curHero->secSkills[v].second-1], v%2 ? 212 : 68, 280 + 48 * (v/2), FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->skillName[curHero->secSkills[v].first], v%2 ? 212 : 68, 300 + 48 * (v/2), FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->levels[curHero->secSkills[v].second-1], v%2 ? 212 : 68, 280 + 48 * (v/2), FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(CGI->generaltexth->skillName[curHero->secSkills[v].first], v%2 ? 212 : 68, 300 + 48 * (v/2), FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
//printing special ability
|
||||
blitAtLoc(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(CGI->generaltexth->hTxts[curHero->subID].bonusName, 69, 205, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[5].substr(1, CGI->generaltexth->jktexts[5].size()-2), 69, 183, FONT_SMALL, Colors::Jasmine, to);
|
||||
printAtLoc(CGI->generaltexth->hTxts[curHero->subID].bonusName, 69, 205, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
//printing necessery texts
|
||||
printAtLoc(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 232, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 232, FONT_SMALL, Colors::Jasmine, to);
|
||||
std::ostringstream expstr;
|
||||
expstr << curHero->exp;
|
||||
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 213, 232, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtLoc(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 213, 232, FONT_SMALL, Colors::Jasmine, to);
|
||||
std::ostringstream manastr;
|
||||
manastr << curHero->mana << '/' << heroWArt.manaLimit();
|
||||
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
struct SDL_Surface;
|
||||
class CGHeroInstance;
|
||||
class CDefHandler;
|
||||
@ -60,7 +60,7 @@ class CHeroWindow: public CWindowWithGarrison, public CWindowWithArtifacts
|
||||
CDefEssential *flags;
|
||||
|
||||
//buttons
|
||||
//AdventureMapButton * gar4button; //splitting
|
||||
//CAdventureMapButton * gar4button; //splitting
|
||||
std::vector<CHeroSwitcher *> heroListMi; //new better list of heroes
|
||||
|
||||
//clickable areas
|
||||
@ -75,7 +75,7 @@ class CHeroWindow: public CWindowWithGarrison, public CWindowWithArtifacts
|
||||
|
||||
public:
|
||||
const CGHeroInstance * curHero;
|
||||
AdventureMapButton * quitButton, * dismissButton, * questlogButton; //general
|
||||
CAdventureMapButton * quitButton, * dismissButton, * questlogButton; //general
|
||||
|
||||
CHighlightableButton *tacticsButton; //garrison / formation handling;
|
||||
CHighlightableButtonsGroup *formations;
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "../lib/CGeneralTextHandler.h"
|
||||
#include "../lib/CObjectHandler.h" //Hero/Town objects
|
||||
#include "../lib/CHeroHandler.h" // only for calculating required xp? worth it?
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CAnimation.h" //CAnimImage
|
||||
#include "CAdvmapInterface.h" //CResDataBar
|
||||
#include "CCastleInterface.h" //various town-specific classes
|
||||
@ -14,6 +13,7 @@
|
||||
#include "CGameInfo.h"
|
||||
#include "CPlayerInterface.h" //LOCPLINT
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
/*
|
||||
* CKingdomInterface.cpp, part of VCMI engine
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
extern SDL_Surface *screenBuf;
|
||||
|
||||
InfoBox::InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data):
|
||||
InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data):
|
||||
size(Size),
|
||||
infoPos(Pos),
|
||||
data(Data),
|
||||
@ -45,21 +45,21 @@ InfoBox::InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data
|
||||
pos = image->pos;
|
||||
|
||||
if (infoPos == POS_CORNER)
|
||||
value = new CLabel(pos.w, pos.h, font, BOTTOMRIGHT, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w, pos.h, font, BOTTOMRIGHT, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_INSIDE)
|
||||
value = new CLabel(pos.w/2, pos.h-6, font, CENTER, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w/2, pos.h-6, font, CENTER, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_UP_DOWN || infoPos == POS_DOWN)
|
||||
value = new CLabel(pos.w/2, pos.h+8, font, CENTER, zwykly, data->getValueText());
|
||||
value = new CLabel(pos.w/2, pos.h+8, font, CENTER, Colors::Cornsilk, data->getValueText());
|
||||
|
||||
if (infoPos == POS_UP_DOWN)
|
||||
name = new CLabel(pos.w/2, -12, font, CENTER, zwykly, data->getNameText());
|
||||
name = new CLabel(pos.w/2, -12, font, CENTER, Colors::Cornsilk, data->getNameText());
|
||||
|
||||
if (infoPos == POS_RIGHT)
|
||||
{
|
||||
name = new CLabel(pos.w+6, 6, font, TOPLEFT, zwykly, data->getNameText());
|
||||
value = new CLabel(pos.w+6, pos.h-16, font, TOPLEFT, zwykly, data->getValueText());
|
||||
name = new CLabel(pos.w+6, 6, font, TOPLEFT, Colors::Cornsilk, data->getNameText());
|
||||
value = new CLabel(pos.w+6, pos.h-16, font, TOPLEFT, Colors::Cornsilk, data->getValueText());
|
||||
}
|
||||
pos = image->pos;
|
||||
if (name)
|
||||
@ -67,7 +67,7 @@ InfoBox::InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data
|
||||
if (value)
|
||||
pos = pos | value->pos;
|
||||
|
||||
hover = new HoverableArea;
|
||||
hover = new CHoverableArea;
|
||||
hover->hoverText = data->getHoverText();
|
||||
hover->pos = pos;
|
||||
}
|
||||
@ -81,7 +81,7 @@ void InfoBox::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
SComponent *comp;
|
||||
CComponent *comp;
|
||||
std::string text;
|
||||
data->prepareMessage(text, &comp);
|
||||
if (comp)
|
||||
@ -95,11 +95,11 @@ void InfoBox::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if((!down) && previousState)
|
||||
{
|
||||
SComponent *comp;
|
||||
CComponent *comp;
|
||||
std::string text;
|
||||
data->prepareMessage(text, &comp);
|
||||
|
||||
std::vector<SComponent*> compVector;
|
||||
std::vector<CComponent*> compVector;
|
||||
if (comp)
|
||||
compVector.push_back(comp);
|
||||
LOCPLINT->showInfoDialog(text, compVector);
|
||||
@ -253,7 +253,7 @@ size_t InfoBoxAbstractHeroData::getImageIndex()
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **comp)
|
||||
bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, CComponent **comp)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -263,7 +263,7 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **com
|
||||
return true;
|
||||
case HERO_PRIMARY_SKILL:
|
||||
text = CGI->generaltexth->arraytxt[2+getSubID()];
|
||||
*comp =new SComponent(SComponent::primskill, getSubID(), getValue());
|
||||
*comp =new CComponent(CComponent::primskill, getSubID(), getValue());
|
||||
return true;
|
||||
case HERO_MANA:
|
||||
text = CGI->generaltexth->allTexts[149];
|
||||
@ -281,7 +281,7 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **com
|
||||
return false;
|
||||
|
||||
text = CGI->generaltexth->skillInfoTexts[subID][value-1];
|
||||
*comp = new SComponent(SComponent::secskill, subID, value);
|
||||
*comp = new CComponent(CComponent::secskill, subID, value);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@ -380,7 +380,7 @@ std::string InfoBoxHeroData::getValueText()
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoBoxHeroData::prepareMessage(std::string &text, SComponent**comp)
|
||||
bool InfoBoxHeroData::prepareMessage(std::string &text, CComponent**comp)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
@ -457,7 +457,7 @@ std::string InfoBoxCustom::getValueText()
|
||||
return valueText;
|
||||
}
|
||||
|
||||
bool InfoBoxCustom::prepareMessage(std::string &text, SComponent **comp)
|
||||
bool InfoBoxCustom::prepareMessage(std::string &text, CComponent **comp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -470,7 +470,7 @@ CKingdomInterface::CKingdomInterface()
|
||||
pos = background->center();
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
|
||||
tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), SPoint(4,4));
|
||||
tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4));
|
||||
|
||||
std::vector<const CGObjectInstance * > ownedObjects = LOCPLINT->cb->getMyObjects();
|
||||
generateObjectsList(ownedObjects);
|
||||
@ -531,7 +531,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
|
||||
objects.push_back(element.second);
|
||||
}
|
||||
dwellingsList = new CListBox(boost::bind(&CKingdomInterface::createOwnedObject, this, _1), CListBox::DestroyFunc(),
|
||||
SPoint(740,44), SPoint(0,57), dwellSize, visibleObjects.size());
|
||||
Point(740,44), Point(0,57), dwellSize, visibleObjects.size());
|
||||
}
|
||||
|
||||
CIntObject* CKingdomInterface::createOwnedObject(size_t index)
|
||||
@ -540,7 +540,7 @@ CIntObject* CKingdomInterface::createOwnedObject(size_t index)
|
||||
{
|
||||
OwnedObjectInfo &obj = objects[index];
|
||||
std::string value = boost::lexical_cast<std::string>(obj.count);
|
||||
return new InfoBox(SPoint(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
|
||||
return new InfoBox(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText));
|
||||
}
|
||||
return NULL;
|
||||
@ -594,13 +594,13 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
|
||||
for (int i=0; i<7; i++)
|
||||
{
|
||||
std::string value = boost::lexical_cast<std::string>(minesCount[i]);
|
||||
minesBox[i] = new InfoBox(SPoint(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
minesBox[i] = new InfoBox(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxCustom(value, "", "OVMINES", i, CGI->generaltexth->mines[i].first));
|
||||
}
|
||||
incomeArea = new HoverableArea;
|
||||
incomeArea->pos = SRect(pos.x+580, pos.y+31+footerPos, 136, 68);
|
||||
incomeArea = new CHoverableArea;
|
||||
incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
|
||||
incomeArea->hoverText = CGI->generaltexth->allTexts[255];
|
||||
incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, zwykly, boost::lexical_cast<std::string>(totalIncome));
|
||||
incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, Colors::Cornsilk, boost::lexical_cast<std::string>(totalIncome));
|
||||
}
|
||||
|
||||
void CKingdomInterface::generateButtons()
|
||||
@ -608,31 +608,31 @@ void CKingdomInterface::generateButtons()
|
||||
ui32 footerPos = conf.go()->ac.overviewSize * 116;
|
||||
|
||||
//Main control buttons
|
||||
btnHeroes = new AdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
|
||||
btnHeroes = new CAdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
|
||||
boost::bind(&CKingdomInterface::activateTab, this, 0),748,28+footerPos,"OVBUTN1.DEF", SDLK_h);
|
||||
btnHeroes->block(true);
|
||||
|
||||
btnTowns = new AdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
|
||||
btnTowns = new CAdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
|
||||
boost::bind(&CKingdomInterface::activateTab, this, 1),748,64+footerPos,"OVBUTN6.DEF", SDLK_t);
|
||||
|
||||
btnExit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
||||
btnExit = new CAdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
||||
boost::bind(&CGuiHandler::popIntTotally,&GH, this),748,99+footerPos,"OVBUTN1.DEF", SDLK_RETURN);
|
||||
btnExit->assignedKeys.insert(SDLK_ESCAPE);
|
||||
btnExit->setOffset(3);
|
||||
|
||||
//Object list control buttons
|
||||
dwellTop = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
|
||||
dwellTop = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
|
||||
733, 4, "OVBUTN4.DEF");
|
||||
|
||||
dwellBottom = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
|
||||
dwellBottom = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
|
||||
733, footerPos+2, "OVBUTN4.DEF");
|
||||
dwellBottom->setOffset(2);
|
||||
|
||||
dwellUp = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
|
||||
dwellUp = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
|
||||
733, 24, "OVBUTN4.DEF");
|
||||
dwellUp->setOffset(4);
|
||||
|
||||
dwellDown = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
|
||||
dwellDown = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
|
||||
733, footerPos-18, "OVBUTN4.DEF");
|
||||
dwellDown->setOffset(6);
|
||||
}
|
||||
@ -685,13 +685,13 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
title = new CPicture("OVTITLE",16,0);
|
||||
title->colorize(LOCPLINT->playerID);
|
||||
heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[0]);
|
||||
skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[1]);
|
||||
heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[0]);
|
||||
skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[1]);
|
||||
|
||||
ui32 townCount = LOCPLINT->cb->howManyHeroes(false);
|
||||
ui32 size = conf.go()->ac.overviewSize*116 + 19;
|
||||
heroes = new CListBox(boost::bind(&CKingdHeroList::createHeroItem, this, _1), boost::bind(&CKingdHeroList::destroyHeroItem, this, _1),
|
||||
SPoint(19,21), SPoint(0,116), maxSize, townCount, 0, 1, SRect(-19, -21, size, size) );
|
||||
Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
|
||||
}
|
||||
|
||||
void CKingdHeroList::updateGarrisons()
|
||||
@ -737,14 +737,14 @@ CKingdTownList::CKingdTownList(size_t maxSize)
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
title = new CPicture("OVTITLE",16,0);
|
||||
title->colorize(LOCPLINT->playerID);
|
||||
townLabel = new CLabel(146,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[3]);
|
||||
garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[4]);
|
||||
visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[5]);
|
||||
townLabel = new CLabel(146,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[3]);
|
||||
garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[4]);
|
||||
visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[5]);
|
||||
|
||||
ui32 townCount = LOCPLINT->cb->howManyTowns();
|
||||
ui32 size = conf.go()->ac.overviewSize*116 + 19;
|
||||
towns = new CListBox(boost::bind(&CKingdTownList::createTownItem, this, _1), CListBox::DestroyFunc(),
|
||||
SPoint(19,21), SPoint(0,116), maxSize, townCount, 0, 1, SRect(-19, -21, size, size) );
|
||||
Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
|
||||
}
|
||||
|
||||
void CKingdTownList::townChanged(const CGTownInstance *town)
|
||||
@ -784,14 +784,14 @@ CTownItem::CTownItem(const CGTownInstance* Town):
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
background = new CAnimImage("OVSLOT", 6);
|
||||
name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, zwykly, town->name);
|
||||
name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, Colors::Cornsilk, town->name);
|
||||
|
||||
income = new CLabel( 190, 60, FONT_SMALL, CENTER, zwykly, boost::lexical_cast<std::string>(town->dailyIncome()));
|
||||
income = new CLabel( 190, 60, FONT_SMALL, CENTER, Colors::Cornsilk, boost::lexical_cast<std::string>(town->dailyIncome()));
|
||||
hall = new CTownInfo( 69, 31, town, true);
|
||||
fort = new CTownInfo(111, 31, town, false);
|
||||
|
||||
garr = new CGarrisonInt(313, 3, 4, SPoint(232,0), NULL, SPoint(313,2), town->getUpperArmy(), town->visitingHero, true, true, true);
|
||||
heroes = new HeroSlots(town, SPoint(244,6), SPoint(475,6), garr, false);
|
||||
garr = new CGarrisonInt(313, 3, 4, Point(232,0), NULL, Point(313,2), town->getUpperArmy(), town->visitingHero, true, true, true);
|
||||
heroes = new HeroSlots(town, Point(244,6), Point(475,6), garr, false);
|
||||
|
||||
size_t iconIndex = town->subID*2;
|
||||
if (!town->hasFort())
|
||||
@ -802,13 +802,13 @@ CTownItem::CTownItem(const CGTownInstance* Town):
|
||||
|
||||
picture = new CAnimImage("ITPT", iconIndex, 0, 5, 6);
|
||||
townArea = new LRClickableAreaOpenTown;
|
||||
townArea->pos = SRect(pos.x+5, pos.y+6, 58, 64);
|
||||
townArea->pos = Rect(pos.x+5, pos.y+6, 58, 64);
|
||||
townArea->town = town;
|
||||
|
||||
for (size_t i=0; i<town->creatures.size(); i++)
|
||||
{
|
||||
growth.push_back(new CCreaInfo(SPoint(401+37*i, 78), town, i, true, true));
|
||||
available.push_back(new CCreaInfo(SPoint(48+37*i, 78), town, i, true, false));
|
||||
growth.push_back(new CCreaInfo(Point(401+37*i, 78), town, i, true, true));
|
||||
available.push_back(new CCreaInfo(Point(48+37*i, 78), town, i, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -847,7 +847,7 @@ public:
|
||||
background = new CAnimImage("OVSLOT", 4);
|
||||
pos = background->pos;
|
||||
for (size_t i=0; i<9; i++)
|
||||
arts.push_back(new CArtPlace(SPoint(270+i*48, 65)));
|
||||
arts.push_back(new CArtPlace(Point(270+i*48, 65)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -856,18 +856,18 @@ class BackpackTab : public CIntObject
|
||||
public:
|
||||
CAnimImage * background;
|
||||
std::vector<CArtPlace*> arts;
|
||||
AdventureMapButton *btnLeft;
|
||||
AdventureMapButton *btnRight;
|
||||
CAdventureMapButton *btnLeft;
|
||||
CAdventureMapButton *btnRight;
|
||||
|
||||
BackpackTab()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
background = new CAnimImage("OVSLOT", 5);
|
||||
pos = background->pos;
|
||||
btnLeft = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 269, 66, "HSBTNS3");
|
||||
btnRight = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 675, 66, "HSBTNS5");
|
||||
btnLeft = new CAdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 269, 66, "HSBTNS3");
|
||||
btnRight = new CAdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 675, 66, "HSBTNS5");
|
||||
for (size_t i=0; i<8; i++)
|
||||
arts.push_back(new CArtPlace(SPoint(295+i*48, 65)));
|
||||
arts.push_back(new CArtPlace(Point(295+i*48, 65)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -887,7 +887,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
||||
arts2->recActions = DISPOSE | SHARE_POS;
|
||||
backpack->recActions = DISPOSE | SHARE_POS;
|
||||
|
||||
name = new CLabel(75, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
||||
name = new CLabel(75, 7, FONT_SMALL, TOPLEFT, Colors::Cornsilk, hero->name);
|
||||
|
||||
std::vector<CArtPlace*> arts;
|
||||
arts.insert(arts.end(), arts1->arts.begin(), arts1->arts.end());
|
||||
@ -911,39 +911,39 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
||||
size_t begin = overlay.find('{');
|
||||
size_t end = overlay.find('}', begin);
|
||||
overlay = overlay.substr(begin+1, end - begin);
|
||||
artButtons->buttons[it]->addTextOverlay(overlay, FONT_SMALL, tytulowy);
|
||||
artButtons->buttons[it]->addTextOverlay(overlay, FONT_SMALL, Colors::Jasmine);
|
||||
}
|
||||
artButtons->onChange += boost::bind(&CTabbedInt::setActive, artsTabs, _1);
|
||||
artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
|
||||
artButtons->select(0,0);
|
||||
|
||||
garr = new CGarrisonInt(6, 78, 4, SPoint(), NULL, SPoint(), hero, NULL, true, true);
|
||||
garr = new CGarrisonInt(6, 78, 4, Point(), NULL, Point(), hero, NULL, true, true);
|
||||
|
||||
portrait = new CAnimImage("PortraitsLarge", hero->subID, 0, 5, 6);
|
||||
heroArea = new CHeroArea(5, 6, hero);
|
||||
|
||||
name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
||||
artsText = new CLabel(320, 55, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->overview[2]);
|
||||
name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, Colors::Cornsilk, hero->name);
|
||||
artsText = new CLabel(320, 55, FONT_SMALL, CENTER, Colors::Cornsilk, CGI->generaltexth->overview[2]);
|
||||
|
||||
for (size_t i=0; i<GameConstants::PRIMARY_SKILLS; i++)
|
||||
heroInfo.push_back(new InfoBox(SPoint(78+i*36, 26), InfoBox::POS_DOWN, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(Point(78+i*36, 26), InfoBox::POS_DOWN, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_PRIMARY_SKILL, hero, i)));
|
||||
|
||||
for (size_t i=0; i<GameConstants::SKILL_PER_HERO; i++)
|
||||
heroInfo.push_back(new InfoBox(SPoint(410+i*36, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(Point(410+i*36, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_SECONDARY_SKILL, hero, i)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(SPoint(375, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(Point(375, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_SPECIAL, hero)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(SPoint(330, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(Point(330, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_EXPERIENCE, hero)));
|
||||
|
||||
heroInfo.push_back(new InfoBox(SPoint(280, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
heroInfo.push_back(new InfoBox(Point(280, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
||||
new InfoBoxHeroData(IInfoBoxData::HERO_MANA, hero)));
|
||||
|
||||
morale = new MoraleLuckBox(true, SRect(225, 53, 30, 22), true);
|
||||
luck = new MoraleLuckBox(false, SRect(225, 28, 30, 22), true);
|
||||
morale = new MoraleLuckBox(true, Rect(225, 53, 30, 22), true);
|
||||
luck = new MoraleLuckBox(false, Rect(225, 28, 30, 22), true);
|
||||
|
||||
morale->set(hero);
|
||||
luck->set(hero);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "GUIClasses.h"
|
||||
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CAnimImage;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CResDataBar;
|
||||
@ -61,10 +61,10 @@ private:
|
||||
CLabel * value;
|
||||
CLabel * name;
|
||||
CAnimImage * image;
|
||||
HoverableArea *hover;
|
||||
CHoverableArea *hover;
|
||||
|
||||
public:
|
||||
InfoBox(SPoint position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data);
|
||||
InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data);
|
||||
~InfoBox();
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
@ -100,7 +100,7 @@ public:
|
||||
virtual size_t getImageIndex()=0;
|
||||
|
||||
//TODO: replace with something better
|
||||
virtual bool prepareMessage(std::string &text, SComponent **comp)=0;
|
||||
virtual bool prepareMessage(std::string &text, CComponent **comp)=0;
|
||||
};
|
||||
|
||||
class InfoBoxAbstractHeroData : public IInfoBoxData
|
||||
@ -118,7 +118,7 @@ public:
|
||||
std::string getHoverText();
|
||||
size_t getImageIndex();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
class InfoBoxHeroData : public InfoBoxAbstractHeroData
|
||||
@ -136,7 +136,7 @@ public:
|
||||
std::string getHoverText();
|
||||
std::string getValueText();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
class InfoBoxCustomHeroData : public InfoBoxAbstractHeroData
|
||||
@ -168,7 +168,7 @@ public:
|
||||
std::string getHoverText();
|
||||
size_t getImageIndex();
|
||||
|
||||
bool prepareMessage(std::string &text, SComponent **comp);
|
||||
bool prepareMessage(std::string &text, CComponent **comp);
|
||||
};
|
||||
|
||||
//TODO!!!
|
||||
@ -208,17 +208,17 @@ private:
|
||||
CPicture * background;
|
||||
|
||||
//Main buttons
|
||||
AdventureMapButton *btnTowns;
|
||||
AdventureMapButton *btnHeroes;
|
||||
AdventureMapButton *btnExit;
|
||||
CAdventureMapButton *btnTowns;
|
||||
CAdventureMapButton *btnHeroes;
|
||||
CAdventureMapButton *btnExit;
|
||||
|
||||
//Buttons for scrolling dwellings list
|
||||
AdventureMapButton *dwellUp, *dwellDown;
|
||||
AdventureMapButton *dwellTop, *dwellBottom;
|
||||
CAdventureMapButton *dwellUp, *dwellDown;
|
||||
CAdventureMapButton *dwellTop, *dwellBottom;
|
||||
|
||||
InfoBox * minesBox[7];
|
||||
|
||||
HoverableArea * incomeArea;
|
||||
CHoverableArea * incomeArea;
|
||||
CLabel * incomeAmount;
|
||||
|
||||
CGStatusBar * statusbar;
|
||||
|
@ -3,15 +3,14 @@
|
||||
#include "StdInc.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <SDL_mixer.h>
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_framerate.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "mapHandler.h"
|
||||
|
||||
#include "CPreGame.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "../lib/CConsoleHandler.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "../lib/CGameState.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CPlayerInterface.h"
|
||||
|
@ -5,14 +5,14 @@
|
||||
#include "CDefHandler.h"
|
||||
#include "CAnimation.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "../lib/CLodHandler.h"
|
||||
#include "../lib/CGeneralTextHandler.h"
|
||||
#include "Graphics.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CBitmapHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
/*
|
||||
* CMessage.cpp, part of VCMI engine
|
||||
@ -24,11 +24,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
SDL_Color tytulowy = {229, 215, 123, 0},
|
||||
tlo = {66, 44, 24, 0},
|
||||
zwykly = {255, 243, 222, 0},
|
||||
darkTitle = {215, 175, 78, 0};
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
|
||||
using namespace NMessage;
|
||||
@ -106,8 +101,8 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
|
||||
{
|
||||
for (int j=0; j<h; j+=background->h)
|
||||
{
|
||||
SRect srcR(0,0,background->w, background->h);
|
||||
SRect dstR(i,j,w,h);
|
||||
Rect srcR(0,0,background->w, background->h);
|
||||
Rect dstR(i,j,w,h);
|
||||
CSDL_Ext::blitSurface(background, &srcR, ret, &dstR);
|
||||
}
|
||||
}
|
||||
@ -261,7 +256,7 @@ SDL_Surface * CMessage::blitTextOnSur(std::vector<std::vector<SDL_Surface*> > *
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_Surface * FNT_RenderText (EFonts font, std::string text, SDL_Color kolor= zwykly)
|
||||
SDL_Surface * FNT_RenderText (EFonts font, std::string text, SDL_Color kolor= Colors::Cornsilk)
|
||||
{
|
||||
if (graphics->fontsTrueType[font])
|
||||
return TTF_RenderText_Blended(graphics->fontsTrueType[font], text.c_str(), kolor);
|
||||
@ -296,7 +291,7 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
|
||||
z++;
|
||||
|
||||
if (z)
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), zwykly));
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), Colors::Cornsilk));
|
||||
(*brtext)[i].erase(0,z);
|
||||
|
||||
if ((*brtext)[i].length() && (*brtext)[i][0] == '{')
|
||||
@ -313,7 +308,7 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
|
||||
z++;
|
||||
|
||||
if (z)
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), tytulowy));
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), Colors::Jasmine));
|
||||
(*brtext)[i].erase(0,z);
|
||||
|
||||
if ((*brtext)[i].length() && (*brtext)[i][0] == '}')
|
||||
@ -377,7 +372,7 @@ SDL_Surface * CMessage::drawBoxTextBitmapSub( int player, std::string text, SDL_
|
||||
curh += imgToBmp;
|
||||
blitAt(bitmap,(ret->w/2)-(bitmap->w/2),curh,ret);
|
||||
curh += bitmap->h + 5;
|
||||
CSDL_Ext::printAtMiddle(sub,ret->w/2,curh+10,FONT_SMALL,zwykly,ret);
|
||||
CSDL_Ext::printAtMiddle(sub,ret->w/2,curh+10,FONT_SMALL,Colors::Cornsilk,ret);
|
||||
delete txtg;
|
||||
return ret;
|
||||
}
|
||||
@ -389,7 +384,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player)
|
||||
//int fontHeight = f.height;
|
||||
|
||||
if(dynamic_cast<CSelWindow*>(ret)) //it's selection window, so we'll blit "or" between components
|
||||
_or = FNT_RenderText(FONT_MEDIUM,CGI->generaltexth->allTexts[4],zwykly);
|
||||
_or = FNT_RenderText(FONT_MEDIUM,CGI->generaltexth->allTexts[4],Colors::Cornsilk);
|
||||
|
||||
const int sizes[][2] = {{400, 125}, {500, 150}, {600, 200}, {480, 400}};
|
||||
|
||||
@ -446,7 +441,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player)
|
||||
curh = (ret->bitmap->h - ret->text->pos.h)/2;
|
||||
}
|
||||
|
||||
ret->text->moveBy(SPoint(xOffset, curh));
|
||||
ret->text->moveBy(Point(xOffset, curh));
|
||||
|
||||
curh += ret->text->pos.h;
|
||||
|
||||
@ -463,7 +458,7 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player)
|
||||
|
||||
for(size_t i=0; i<ret->buttons.size(); i++)
|
||||
{
|
||||
ret->buttons[i]->moveBy(SPoint(bw, curh));
|
||||
ret->buttons[i]->moveBy(Point(bw, curh));
|
||||
bw += ret->buttons[i]->pos.w + 20;
|
||||
}
|
||||
}
|
||||
@ -493,8 +488,8 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int
|
||||
cur_w = box[6]->w;
|
||||
|
||||
// Top border
|
||||
SRect srcR(0, 0, cur_w, box[6]->h);
|
||||
SRect dstR(start_x, y, 0, 0);
|
||||
Rect srcR(0, 0, cur_w, box[6]->h);
|
||||
Rect dstR(start_x, y, 0, 0);
|
||||
CSDL_Ext::blitSurface(box[6], &srcR, ret, &dstR);
|
||||
|
||||
// Bottom border
|
||||
@ -514,8 +509,8 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int
|
||||
cur_h = box[4]->h;
|
||||
|
||||
// Left border
|
||||
SRect srcR(0, 0, box[4]->w, cur_h);
|
||||
SRect dstR(x, start_y, 0, 0);
|
||||
Rect srcR(0, 0, box[4]->w, cur_h);
|
||||
Rect dstR(x, start_y, 0, 0);
|
||||
CSDL_Ext::blitSurface(box[4], &srcR, ret, &dstR);
|
||||
|
||||
// Right border
|
||||
@ -526,16 +521,16 @@ void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int
|
||||
}
|
||||
|
||||
//corners
|
||||
SRect dstR(x, y, box[0]->w, box[0]->h);
|
||||
Rect dstR(x, y, box[0]->w, box[0]->h);
|
||||
CSDL_Ext::blitSurface(box[0], NULL, ret, &dstR);
|
||||
|
||||
dstR=SRect(x+w-box[1]->w, y, box[1]->w, box[1]->h);
|
||||
dstR=Rect(x+w-box[1]->w, y, box[1]->w, box[1]->h);
|
||||
CSDL_Ext::blitSurface(box[1], NULL, ret, &dstR);
|
||||
|
||||
dstR=SRect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h);
|
||||
dstR=Rect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h);
|
||||
CSDL_Ext::blitSurface(box[2], NULL, ret, &dstR);
|
||||
|
||||
dstR=SRect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h);
|
||||
dstR=Rect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h);
|
||||
CSDL_Ext::blitSurface(box[3], NULL, ret, &dstR);
|
||||
}
|
||||
|
||||
@ -547,7 +542,7 @@ ComponentResolved::ComponentResolved()
|
||||
txtFontHeight = 0;
|
||||
}
|
||||
|
||||
ComponentResolved::ComponentResolved( SComponent *Comp )
|
||||
ComponentResolved::ComponentResolved( CComponent *Comp )
|
||||
{
|
||||
comp = Comp;
|
||||
img = comp->getImg();
|
||||
@ -577,7 +572,7 @@ ComponentsToBlit::~ComponentsToBlit()
|
||||
|
||||
}
|
||||
|
||||
ComponentsToBlit::ComponentsToBlit(std::vector<SComponent*> & SComps, int maxw, SDL_Surface* _or)
|
||||
ComponentsToBlit::ComponentsToBlit(std::vector<CComponent*> & SComps, int maxw, SDL_Surface* _or)
|
||||
{
|
||||
w = h = 0;
|
||||
if(SComps.empty())
|
||||
|
@ -20,7 +20,7 @@ class MapSel;
|
||||
class CSimpleWindow;
|
||||
class CInfoWindow;
|
||||
class CDefHandler;
|
||||
class SComponent;
|
||||
class CComponent;
|
||||
class CSelWindow;
|
||||
class CSelectableComponent;
|
||||
namespace NMessage
|
||||
@ -32,14 +32,14 @@ namespace NMessage
|
||||
|
||||
struct ComponentResolved
|
||||
{
|
||||
SComponent *comp;
|
||||
CComponent *comp;
|
||||
|
||||
SDL_Surface *img;
|
||||
std::vector<std::vector<SDL_Surface*> > * txt;
|
||||
int txtFontHeight;
|
||||
|
||||
ComponentResolved(); //c-tor
|
||||
ComponentResolved(SComponent *Comp); //c-tor
|
||||
ComponentResolved(CComponent *Comp); //c-tor
|
||||
~ComponentResolved(); //d-tor
|
||||
};
|
||||
|
||||
@ -49,7 +49,7 @@ struct ComponentsToBlit
|
||||
int w, h;
|
||||
|
||||
void blitCompsOnSur(SDL_Surface * _or, int inter, int &curh, SDL_Surface *ret);
|
||||
ComponentsToBlit(std::vector<SComponent*> & SComps, int maxw, SDL_Surface* _or); //c-tor
|
||||
ComponentsToBlit(std::vector<CComponent*> & SComps, int maxw, SDL_Surface* _or); //c-tor
|
||||
~ComponentsToBlit(); //d-tor
|
||||
};
|
||||
|
||||
|
@ -2,18 +2,17 @@
|
||||
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "BattleInterface/CBattleInterface.h"
|
||||
#include "BattleInterface/CBattleConsole.h"
|
||||
#include "BattleInterface/CBattleInterfaceClasses.h"
|
||||
#include "../CCallback.h"
|
||||
#include "CCastleInterface.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "CKingdomInterface.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CHeroWindow.h"
|
||||
#include "CMessage.h"
|
||||
#include "CPlayerInterface.h"
|
||||
//#include "SDL_Extensions.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "SDL_framerate.h"
|
||||
//#include "UIFramework/SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "BattleInterface/CCreatureAnimation.h"
|
||||
#include "Graphics.h"
|
||||
@ -187,8 +186,8 @@ void CPlayerInterface::yourTurn()
|
||||
makingTurn = true;
|
||||
std::string msg = CGI->generaltexth->allTexts[13];
|
||||
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
||||
std::vector<SComponent*> cmp;
|
||||
cmp.push_back(new SComponent(SComponent::flag, playerID, 0));
|
||||
std::vector<CComponent*> cmp;
|
||||
cmp.push_back(new CComponent(CComponent::flag, playerID, 0));
|
||||
showInfoDialog(msg, cmp);
|
||||
}
|
||||
else
|
||||
@ -756,7 +755,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
|
||||
battleInt->battleFinished(*br);
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<SBattleHex> dest, int distance)
|
||||
void CPlayerInterface::battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance)
|
||||
{
|
||||
if(LOCPLINT != this)
|
||||
{ //another local interface should do this
|
||||
@ -802,7 +801,7 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke
|
||||
tlog5 << "done!\n";
|
||||
|
||||
|
||||
std::vector<SStackAttackedInfo> arg;
|
||||
std::vector<StackAttackedInfo> arg;
|
||||
for(std::vector<BattleStackAttacked>::const_iterator i = bsa.begin(); i != bsa.end(); i++)
|
||||
{
|
||||
const CStack *defender = cb->battleGetStackByID(i->stackAttacked, false);
|
||||
@ -812,7 +811,7 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke
|
||||
if (defender && !i->isSecondary())
|
||||
battleInt->displayEffect(i->effect, defender->position);
|
||||
}
|
||||
SStackAttackedInfo to_put = {defender, i->damageAmount, i->killedAmount, attacker, LOCPLINT->curAction->actionType==7, i->killed(), i->willRebirth()};
|
||||
StackAttackedInfo to_put = {defender, i->damageAmount, i->killedAmount, attacker, LOCPLINT->curAction->actionType==7, i->killed(), i->willRebirth()};
|
||||
arg.push_back(to_put);
|
||||
|
||||
}
|
||||
@ -874,10 +873,10 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
|
||||
else
|
||||
{
|
||||
int shift = 0;
|
||||
if(ba->counter() && SBattleHex::mutualPosition(curAction->destinationTile, attacker->position) < 0)
|
||||
if(ba->counter() && BattleHex::mutualPosition(curAction->destinationTile, attacker->position) < 0)
|
||||
{
|
||||
int distp = SBattleHex::getDistance(curAction->destinationTile + 1, attacker->position);
|
||||
int distm = SBattleHex::getDistance(curAction->destinationTile - 1, attacker->position);
|
||||
int distp = BattleHex::getDistance(curAction->destinationTile + 1, attacker->position);
|
||||
int distm = BattleHex::getDistance(curAction->destinationTile - 1, attacker->position);
|
||||
|
||||
if( distp < distm )
|
||||
shift = 1;
|
||||
@ -895,7 +894,7 @@ void CPlayerInterface::yourTacticPhase(int distance)
|
||||
boost::this_thread::sleep(boost::posix_time::millisec(1));
|
||||
}
|
||||
|
||||
void CPlayerInterface::showComp(SComponent comp)
|
||||
void CPlayerInterface::showComp(CComponent comp)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
|
||||
@ -906,13 +905,13 @@ void CPlayerInterface::showComp(SComponent comp)
|
||||
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID)
|
||||
{
|
||||
std::vector<SComponent*> intComps;
|
||||
std::vector<CComponent*> intComps;
|
||||
for(int i=0;i<components.size();i++)
|
||||
intComps.push_back(new SComponent(*components[i]));
|
||||
intComps.push_back(new CComponent(*components[i]));
|
||||
showInfoDialog(text,intComps,soundID);
|
||||
}
|
||||
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<SComponent*> & components, int soundID, bool delComps)
|
||||
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<CComponent*> & components, int soundID, bool delComps)
|
||||
{
|
||||
waitWhileDialog();
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
@ -932,7 +931,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerInterface::showYesNoDialog(const std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps)
|
||||
void CPlayerInterface::showYesNoDialog(const std::string &text, const std::vector<CComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
|
||||
@ -951,9 +950,9 @@ void CPlayerInterface::showBlockingDialog( const std::string &text, const std::v
|
||||
|
||||
if(!selection && cancel) //simple yes/no dialog
|
||||
{
|
||||
std::vector<SComponent*> intComps;
|
||||
std::vector<CComponent*> intComps;
|
||||
for(int i=0;i<components.size();i++)
|
||||
intComps.push_back(new SComponent(components[i])); //will be deleted by close in window
|
||||
intComps.push_back(new CComponent(components[i])); //will be deleted by close in window
|
||||
|
||||
showYesNoDialog(text,intComps,boost::bind(&CCallback::selectionMade,cb,1,askID),boost::bind(&CCallback::selectionMade,cb,0,askID),true);
|
||||
}
|
||||
@ -1281,7 +1280,7 @@ void CPlayerInterface::showArtifactAssemblyDialog (ui32 artifactID, ui32 assembl
|
||||
const CArtifact &artifact = *CGI->arth->artifacts[artifactID];
|
||||
std::string text = artifact.Description();
|
||||
text += "\n\n";
|
||||
std::vector<SComponent*> scs;
|
||||
std::vector<CComponent*> scs;
|
||||
|
||||
if (assemble) {
|
||||
const CArtifact &assembledArtifact = *CGI->arth->artifacts[assembleTo];
|
||||
@ -1290,8 +1289,8 @@ void CPlayerInterface::showArtifactAssemblyDialog (ui32 artifactID, ui32 assembl
|
||||
text += boost::str(boost::format(CGI->generaltexth->allTexts[732]) % assembledArtifact.Name());
|
||||
|
||||
// Picture of assembled artifact at bottom.
|
||||
SComponent* sc = new SComponent;
|
||||
sc->type = SComponent::artifact;
|
||||
CComponent* sc = new CComponent;
|
||||
sc->type = CComponent::artifact;
|
||||
sc->subtype = assembledArtifact.id;
|
||||
sc->description = assembledArtifact.Description();
|
||||
sc->subtitle = assembledArtifact.Name();
|
||||
@ -1994,7 +1993,7 @@ void CPlayerInterface::gameOver(ui8 player, bool victory )
|
||||
{
|
||||
std::string txt = CGI->generaltexth->allTexts[5]; //%s has been vanquished!
|
||||
boost::algorithm::replace_first(txt, "%s", CGI->generaltexth->capColors[player]);
|
||||
showInfoDialog(txt,std::vector<SComponent*>(1, new SComponent(SComponent::flag, player, 0)));
|
||||
showInfoDialog(txt,std::vector<CComponent*>(1, new CComponent(CComponent::flag, player, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "../lib/CondSh.h"
|
||||
#include "FunctionList.h"
|
||||
#include "../lib/CGameInterface.h"
|
||||
#include "UIFramework/IUpdateable.h"
|
||||
#include "UIFramework/CIntObject.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define sprintf_s snprintf
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
class CDefEssential;
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CDefHandler;
|
||||
struct TryMoveHero;
|
||||
@ -38,7 +38,7 @@ class CAdvMapInt;
|
||||
class CCastleInterface;
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
class SComponent;
|
||||
class CComponent;
|
||||
class CCreature;
|
||||
struct SDL_Surface;
|
||||
struct CGPath;
|
||||
@ -218,7 +218,7 @@ public:
|
||||
void battleEnd(const BattleResult *br) OVERRIDE; //end of battle
|
||||
void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; used for HP regen handling
|
||||
void battleNewRound(int round) OVERRIDE; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||
void battleStackMoved(const CStack * stack, std::vector<SBattleHex> dest, int distance) OVERRIDE;
|
||||
void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) OVERRIDE;
|
||||
void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
|
||||
void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE; //called when a specific effect is set to stacks
|
||||
void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; //various one-shot effect
|
||||
@ -240,15 +240,15 @@ public:
|
||||
bool ctrlPressed() const; //determines if ctrl key is pressed (left or right or both)
|
||||
bool altPressed() const; //determines if alt key is pressed (left or right or both)
|
||||
void redrawHeroWin(const CGHeroInstance * hero);
|
||||
void showComp(SComponent comp); //TODO: comment me
|
||||
void showComp(CComponent comp); //TODO: comment me
|
||||
void openTownWindow(const CGTownInstance * town); //shows townscreen
|
||||
void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero
|
||||
SDL_Surface * infoWin(const CGObjectInstance * specific); //specific=0 => draws info about selected town/hero
|
||||
void updateInfo(const CGObjectInstance * specific);
|
||||
void init(CCallback * CB);
|
||||
int3 repairScreenPos(int3 pos); //returns position closest to pos we can center screen on
|
||||
void showInfoDialog(const std::string &text, const std::vector<SComponent*> & components = std::vector<SComponent*>(), int soundID = 0, bool delComps = false);
|
||||
void showYesNoDialog(const std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
|
||||
void showInfoDialog(const std::string &text, const std::vector<CComponent*> & components = std::vector<CComponent*>(), int soundID = 0, bool delComps = false);
|
||||
void showYesNoDialog(const std::string &text, const std::vector<CComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
|
||||
void stopMovement();
|
||||
bool moveHero(const CGHeroInstance *h, CGPath path);
|
||||
void initMovement(const TryMoveHero &details, const CGHeroInstance * ho, const int3 &hp );//initializing objects and performing first step of move
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <zlib.h>
|
||||
#include "../lib/CStopWatch.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "UIFramework/CCursorHandler.h"
|
||||
#include "CAnimation.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "../lib/CDefObjInfoHandler.h"
|
||||
@ -23,7 +23,6 @@
|
||||
#include "../lib/Connection.h"
|
||||
#include "../lib/VCMIDirs.h"
|
||||
#include "../lib/map.h"
|
||||
#include "AdventureMapButton.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "../CCallback.h"
|
||||
@ -40,6 +39,7 @@
|
||||
#include "../lib/CFileUtility.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/CGuiHandler.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
/*
|
||||
* CPreGame.cpp, part of VCMI engine
|
||||
@ -311,7 +311,7 @@ static boost::function<void()> genCommand(CMenuScreen* menu, std::vector<std::st
|
||||
}
|
||||
break; case 4://exit
|
||||
{
|
||||
return boost::bind(CInfoWindow::showYesNoDialog, boost::ref(CGI->generaltexth->allTexts[69]), (const std::vector<SComponent*>*)0, do_quit, 0, false, 1);
|
||||
return boost::bind(CInfoWindow::showYesNoDialog, boost::ref(CGI->generaltexth->allTexts[69]), (const std::vector<CComponent*>*)0, do_quit, 0, false, 1);
|
||||
}
|
||||
break; case 5://highscores
|
||||
{
|
||||
@ -324,7 +324,7 @@ static boost::function<void()> genCommand(CMenuScreen* menu, std::vector<std::st
|
||||
return boost::function<void()>();
|
||||
}
|
||||
|
||||
AdventureMapButton* CMenuEntry::createButton(CMenuScreen* parent, const JsonNode& button)
|
||||
CAdventureMapButton* CMenuEntry::createButton(CMenuScreen* parent, const JsonNode& button)
|
||||
{
|
||||
boost::function<void()> command = genCommand(parent, parent->menuNameToEntry, button["command"].String());
|
||||
|
||||
@ -332,7 +332,7 @@ AdventureMapButton* CMenuEntry::createButton(CMenuScreen* parent, const JsonNode
|
||||
if (!button["help"].isNull() && button["help"].Float() > 0)
|
||||
help = CGI->generaltexth->zelp[button["help"].Float()];
|
||||
|
||||
return new AdventureMapButton(help, command, button["x"].Float(), button["y"].Float(), button["name"].String(), button["hotkey"].Float());
|
||||
return new CAdventureMapButton(help, command, button["x"].Float(), button["y"].Float(), button["name"].String(), button["hotkey"].Float());
|
||||
}
|
||||
|
||||
CMenuEntry::CMenuEntry(CMenuScreen* parent, const JsonNode &config)
|
||||
@ -361,11 +361,11 @@ CreditsScreen::CreditsScreen()
|
||||
std::string text = bitmaph->getTextFile("CREDITS");
|
||||
size_t firstQuote = text.find('\"')+1;
|
||||
text = text.substr(firstQuote, text.find('\"', firstQuote) - firstQuote );
|
||||
credits = new CTextBox(text, SRect(450, 600, 350, 32000), 0, FONT_CREDITS, CENTER, zwykly);
|
||||
credits = new CTextBox(text, Rect(450, 600, 350, 32000), 0, FONT_CREDITS, CENTER, Colors::Cornsilk);
|
||||
credits->pos.h = credits->maxH;
|
||||
}
|
||||
|
||||
void CreditsScreen::show(SDL_Surface *to)
|
||||
void CreditsScreen::show(SDL_Surface * to)
|
||||
{
|
||||
static int count = 0;
|
||||
count++;
|
||||
@ -542,20 +542,20 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
|
||||
{
|
||||
card->difficulty->onChange = bind(&CSelectionScreen::difficultyChange, this, _1);
|
||||
card->difficulty->select(1, 0);
|
||||
AdventureMapButton *select = new AdventureMapButton(CGI->generaltexth->zelp[45], bind(&CSelectionScreen::toggleTab, this, sel), 411, 75, "GSPBUTT.DEF", SDLK_s);
|
||||
CAdventureMapButton *select = new CAdventureMapButton(CGI->generaltexth->zelp[45], bind(&CSelectionScreen::toggleTab, this, sel), 411, 75, "GSPBUTT.DEF", SDLK_s);
|
||||
select->addTextOverlay(CGI->generaltexth->allTexts[500], FONT_SMALL);
|
||||
|
||||
AdventureMapButton *opts = new AdventureMapButton(CGI->generaltexth->zelp[46], bind(&CSelectionScreen::toggleTab, this, opt), 411, 503, "GSPBUTT.DEF", SDLK_a);
|
||||
CAdventureMapButton *opts = new CAdventureMapButton(CGI->generaltexth->zelp[46], bind(&CSelectionScreen::toggleTab, this, opt), 411, 503, "GSPBUTT.DEF", SDLK_a);
|
||||
opts->addTextOverlay(CGI->generaltexth->allTexts[501], FONT_SMALL);
|
||||
|
||||
AdventureMapButton *random = new AdventureMapButton(CGI->generaltexth->zelp[47], bind(&CSelectionScreen::toggleTab, this, sel), 411, 99, "GSPBUTT.DEF", SDLK_r);
|
||||
CAdventureMapButton *random = new CAdventureMapButton(CGI->generaltexth->zelp[47], bind(&CSelectionScreen::toggleTab, this, sel), 411, 99, "GSPBUTT.DEF", SDLK_r);
|
||||
random->addTextOverlay(CGI->generaltexth->allTexts[740], FONT_SMALL);
|
||||
|
||||
start = new AdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRBEG.DEF", SDLK_b);
|
||||
start = new CAdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRBEG.DEF", SDLK_b);
|
||||
|
||||
if(network)
|
||||
{
|
||||
AdventureMapButton *hideChat = new AdventureMapButton(CGI->generaltexth->zelp[48], bind(&InfoCard::toggleChat, card), 619, 75, "GSPBUT2.DEF", SDLK_h);
|
||||
CAdventureMapButton *hideChat = new CAdventureMapButton(CGI->generaltexth->zelp[48], bind(&InfoCard::toggleChat, card), 619, 75, "GSPBUT2.DEF", SDLK_h);
|
||||
hideChat->addTextOverlay(CGI->generaltexth->allTexts[531], FONT_SMALL);
|
||||
|
||||
if(multiPlayer == CMenuScreen::MULTI_NETWORK_GUEST)
|
||||
@ -572,15 +572,15 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
|
||||
break;
|
||||
case CMenuScreen::loadGame:
|
||||
sel->recActions = 255;
|
||||
start = new AdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRLOD.DEF", SDLK_l);
|
||||
start = new CAdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRLOD.DEF", SDLK_l);
|
||||
break;
|
||||
case CMenuScreen::saveGame:
|
||||
sel->recActions = 255;
|
||||
start = new AdventureMapButton("", CGI->generaltexth->zelp[103].second, bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRSAV.DEF");
|
||||
start = new CAdventureMapButton("", CGI->generaltexth->zelp[103].second, bind(&CSelectionScreen::startGame, this), 411, 529, "SCNRSAV.DEF");
|
||||
break;
|
||||
case CMenuScreen::campaignList:
|
||||
sel->recActions = 255;
|
||||
start = new AdventureMapButton(std::pair<std::string, std::string>(), bind(&CSelectionScreen::startCampaign, this), 411, 529, "SCNRLOD.DEF", SDLK_b);
|
||||
start = new CAdventureMapButton(std::pair<std::string, std::string>(), bind(&CSelectionScreen::startCampaign, this), 411, 529, "SCNRLOD.DEF", SDLK_b);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
|
||||
backName = "SCNRBACK.DEF";
|
||||
}
|
||||
|
||||
back = new AdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 581, 529, backName, SDLK_ESCAPE);
|
||||
back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 581, 529, backName, SDLK_ESCAPE);
|
||||
|
||||
if(network)
|
||||
{
|
||||
@ -792,7 +792,7 @@ void CSelectionScreen::startGame()
|
||||
{
|
||||
std::string hlp = CGI->generaltexth->allTexts[493]; //%s exists. Overwrite?
|
||||
boost::algorithm::replace_first(hlp, "%s", sel->txt->text);
|
||||
LOCPLINT->showYesNoDialog(hlp, std::vector<SComponent*>(), overWrite, 0, false);
|
||||
LOCPLINT->showYesNoDialog(hlp, std::vector<CComponent*>(), overWrite, 0, false);
|
||||
}
|
||||
else
|
||||
overWrite();
|
||||
@ -1089,7 +1089,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
||||
positions = 16;
|
||||
}
|
||||
if(tabType == CMenuScreen::saveGame)
|
||||
txt = new CTextInput(SRect(32, 539, 350, 20), SPoint(-32, -25), "GSSTRIP.bmp", 0);
|
||||
txt = new CTextInput(Rect(32, 539, 350, 20), Point(-32, -25), "GSSTRIP.bmp", 0);
|
||||
break;
|
||||
case CMenuScreen::campaignList:
|
||||
getFiles(toParse, GameConstants::DATA_DIR + "/Maps", "h3c"); //get all campaigns
|
||||
@ -1129,7 +1129,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
||||
int sizes[] = {36, 72, 108, 144, 0};
|
||||
const char * names[] = {"SCSMBUT.DEF", "SCMDBUT.DEF", "SCLGBUT.DEF", "SCXLBUT.DEF", "SCALBUT.DEF"};
|
||||
for(int i = 0; i < 5; i++)
|
||||
new AdventureMapButton("", CGI->generaltexth->zelp[54+i].second, bind(&SelectionTab::filter, this, sizes[i], true), 158 + 47*i, 46, names[i]);
|
||||
new CAdventureMapButton("", CGI->generaltexth->zelp[54+i].second, bind(&SelectionTab::filter, this, sizes[i], true), 158 + 47*i, 46, names[i]);
|
||||
}
|
||||
|
||||
//sort buttons buttons
|
||||
@ -1137,14 +1137,14 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
|
||||
int xpos[] = {23, 55, 88, 121, 306, 339};
|
||||
const char * names[] = {"SCBUTT1.DEF", "SCBUTT2.DEF", "SCBUTCP.DEF", "SCBUTT3.DEF", "SCBUTT4.DEF", "SCBUTT5.DEF"};
|
||||
for(int i = 0; i < 6; i++)
|
||||
new AdventureMapButton("", CGI->generaltexth->zelp[107+i].second, bind(&SelectionTab::sortBy, this, i), xpos[i], 86, names[i]);
|
||||
new CAdventureMapButton("", CGI->generaltexth->zelp[107+i].second, bind(&SelectionTab::sortBy, this, i), xpos[i], 86, names[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//sort by buttons
|
||||
new AdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _numOfMaps), 23, 86, "CamCusM.DEF"); //by num of maps
|
||||
new AdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _name), 55, 86, "CamCusL.DEF"); //by name
|
||||
new CAdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _numOfMaps), 23, 86, "CamCusM.DEF"); //by num of maps
|
||||
new CAdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _name), 55, 86, "CamCusL.DEF"); //by name
|
||||
}
|
||||
|
||||
slider = new CSlider(372, 86, tabType != CMenuScreen::saveGame ? 480 : 430, bind(&SelectionTab::sliderMove, this, _1), positions, curItems.size(), 0, false, 1);
|
||||
@ -1270,9 +1270,9 @@ void SelectionTab::printMaps(SDL_Surface *to)
|
||||
CMapInfo *currentItem = curItems[elemIdx];
|
||||
|
||||
if (elemIdx == selectionPos)
|
||||
itemColor=tytulowy;
|
||||
itemColor=Colors::Jasmine;
|
||||
else
|
||||
itemColor=zwykly;
|
||||
itemColor=Colors::Cornsilk;
|
||||
|
||||
if(tabType != CMenuScreen::campaignList)
|
||||
{
|
||||
@ -1367,7 +1367,7 @@ void SelectionTab::printMaps(SDL_Surface *to)
|
||||
#undef POS
|
||||
}
|
||||
|
||||
void SelectionTab::showAll( SDL_Surface * to )
|
||||
void SelectionTab::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
printMaps(to);
|
||||
@ -1388,10 +1388,10 @@ void SelectionTab::showAll( SDL_Surface * to )
|
||||
break;
|
||||
}
|
||||
|
||||
CSDL_Ext::printAtMiddle(title, pos.x+205, pos.y+28, FONT_MEDIUM, tytulowy, to); //Select a Scenario to Play
|
||||
CSDL_Ext::printAtMiddle(title, pos.x+205, pos.y+28, FONT_MEDIUM, Colors::Jasmine, to); //Select a Scenario to Play
|
||||
if(tabType != CMenuScreen::campaignList)
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[510], pos.x+87, pos.y+62, FONT_SMALL, tytulowy, to); //Map sizes
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[510], pos.x+87, pos.y+62, FONT_SMALL, Colors::Jasmine, to); //Map sizes
|
||||
}
|
||||
}
|
||||
|
||||
@ -1447,7 +1447,7 @@ void SelectionTab::onDoubleClick()
|
||||
int SelectionTab::getLine()
|
||||
{
|
||||
int line = -1;
|
||||
SPoint clickPos(GH.current->button.x, GH.current->button.y);
|
||||
Point clickPos(GH.current->button.x, GH.current->button.y);
|
||||
clickPos = clickPos - pos.topLeft();
|
||||
|
||||
if (clickPos.y > 115 && clickPos.y < 564 && clickPos.x > 22 && clickPos.x < 371)
|
||||
@ -1475,7 +1475,7 @@ void SelectionTab::selectFName( const std::string &fname )
|
||||
|
||||
|
||||
|
||||
CChatBox::CChatBox(const SRect &rect)
|
||||
CChatBox::CChatBox(const Rect &rect)
|
||||
{
|
||||
OBJ_CONSTRUCTION;
|
||||
pos += rect;
|
||||
@ -1483,9 +1483,9 @@ CChatBox::CChatBox(const SRect &rect)
|
||||
captureAllKeys = true;
|
||||
|
||||
const int height = graphics->fonts[FONT_SMALL]->height;
|
||||
inputBox = new CTextInput(SRect(0, rect.h - height, rect.w, height));
|
||||
inputBox = new CTextInput(Rect(0, rect.h - height, rect.w, height));
|
||||
inputBox->used &= ~KEYBOARD;
|
||||
chatHistory = new CTextBox("", SRect(0, 0, rect.w, rect.h - height), 1);
|
||||
chatHistory = new CTextBox("", Rect(0, 0, rect.w, rect.h - height), 1);
|
||||
|
||||
SDL_Color green = {0,252,0};
|
||||
chatHistory->color = green;
|
||||
@ -1518,13 +1518,13 @@ InfoCard::InfoCard( bool Network )
|
||||
used = RCLICK;
|
||||
mapDescription = NULL;
|
||||
|
||||
SRect descriptionRect(26, 149, 320, 115);
|
||||
Rect descriptionRect(26, 149, 320, 115);
|
||||
mapDescription = new CTextBox("", descriptionRect, 1);
|
||||
|
||||
if(SEL->screenType == CMenuScreen::campaignList)
|
||||
{
|
||||
CSelectionScreen *ss = static_cast<CSelectionScreen*>(parent);
|
||||
CGuiHandler::moveChild(new CPicture(*ss->bg, descriptionRect + SPoint(-393, 0)), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child)
|
||||
CGuiHandler::moveChild(new CPicture(*ss->bg, descriptionRect + Point(-393, 0)), this, mapDescription, true); //move subpicture bg to our description control (by default it's our (Infocard) child)
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1571,24 +1571,24 @@ InfoCard::~InfoCard()
|
||||
delete sFlags;
|
||||
}
|
||||
|
||||
void InfoCard::showAll( SDL_Surface * to )
|
||||
void InfoCard::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
|
||||
//blit texts
|
||||
if(SEL->screenType != CMenuScreen::campaignList)
|
||||
{
|
||||
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 24, 400, FONT_SMALL, zwykly, to); //Allies
|
||||
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 190, 400, FONT_SMALL, zwykly, to); //Enemies
|
||||
printAtLoc(CGI->generaltexth->allTexts[494], 33, 430, FONT_SMALL, tytulowy, to);//"Map Diff:"
|
||||
printAtLoc(CGI->generaltexth->allTexts[492] + ":", 133,430, FONT_SMALL, tytulowy, to); //player difficulty
|
||||
printAtLoc(CGI->generaltexth->allTexts[218] + ":", 290,430, FONT_SMALL, tytulowy, to); //"Rating:"
|
||||
printAtLoc(CGI->generaltexth->allTexts[495], 26, 22, FONT_SMALL, tytulowy, to); //Scenario Name:
|
||||
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 24, 400, FONT_SMALL, Colors::Cornsilk, to); //Allies
|
||||
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 190, 400, FONT_SMALL, Colors::Cornsilk, to); //Enemies
|
||||
printAtLoc(CGI->generaltexth->allTexts[494], 33, 430, FONT_SMALL, Colors::Jasmine, to);//"Map Diff:"
|
||||
printAtLoc(CGI->generaltexth->allTexts[492] + ":", 133,430, FONT_SMALL, Colors::Jasmine, to); //player difficulty
|
||||
printAtLoc(CGI->generaltexth->allTexts[218] + ":", 290,430, FONT_SMALL, Colors::Jasmine, to); //"Rating:"
|
||||
printAtLoc(CGI->generaltexth->allTexts[495], 26, 22, FONT_SMALL, Colors::Jasmine, to); //Scenario Name:
|
||||
if(!chatOn)
|
||||
{
|
||||
printAtLoc(CGI->generaltexth->allTexts[496], 26, 132, FONT_SMALL, tytulowy, to); //Scenario Description:
|
||||
printAtLoc(CGI->generaltexth->allTexts[497], 26, 283, FONT_SMALL, tytulowy, to); //Victory Condition:
|
||||
printAtLoc(CGI->generaltexth->allTexts[498], 26, 339, FONT_SMALL, tytulowy, to); //Loss Condition:
|
||||
printAtLoc(CGI->generaltexth->allTexts[496], 26, 132, FONT_SMALL, Colors::Jasmine, to); //Scenario Description:
|
||||
printAtLoc(CGI->generaltexth->allTexts[497], 26, 283, FONT_SMALL, Colors::Jasmine, to); //Victory Condition:
|
||||
printAtLoc(CGI->generaltexth->allTexts[498], 26, 339, FONT_SMALL, Colors::Jasmine, to); //Loss Condition:
|
||||
}
|
||||
else //players list
|
||||
{
|
||||
@ -1598,7 +1598,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
{
|
||||
if(i->second.human)
|
||||
{
|
||||
printAtLoc(i->second.name, 24, 285 + playerSoFar++ * graphics->fonts[FONT_SMALL]->height, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(i->second.name, 24, 285 + playerSoFar++ * graphics->fonts[FONT_SMALL]->height, FONT_SMALL, Colors::Cornsilk, to);
|
||||
playerNames.erase(i->second.human);
|
||||
}
|
||||
}
|
||||
@ -1606,7 +1606,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
playerSoFar = 0;
|
||||
for (std::map<ui32, std::string>::const_iterator i = playerNames.begin(); i != playerNames.end(); i++)
|
||||
{
|
||||
printAtLoc(i->second, 193, 285 + playerSoFar++ * graphics->fonts[FONT_SMALL]->height, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(i->second, 193, 285 + playerSoFar++ * graphics->fonts[FONT_SMALL]->height, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1625,7 +1625,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
if (temp>20) temp=0;
|
||||
std::string sss = CGI->generaltexth->victoryConditions[temp];
|
||||
if (temp && SEL->current->mapHeader->victoryCondition.allowNormalVictory) sss+= "/" + CGI->generaltexth->victoryConditions[0];
|
||||
printAtLoc(sss, 60, 307, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(sss, 60, 307, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
temp = SEL->current->mapHeader->victoryCondition.condition;
|
||||
if (temp>12) temp=11;
|
||||
@ -1635,7 +1635,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
temp = SEL->current->mapHeader->lossCondition.typeOfLossCon+1;
|
||||
if (temp>20) temp=0;
|
||||
sss = CGI->generaltexth->lossCondtions[temp];
|
||||
printAtLoc(sss, 60, 366, FONT_SMALL, zwykly, to);
|
||||
printAtLoc(sss, 60, 366, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
temp=SEL->current->mapHeader->lossCondition.typeOfLossCon;
|
||||
if (temp>12) temp=3;
|
||||
@ -1645,7 +1645,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
//difficulty
|
||||
assert(SEL->current->mapHeader->difficulty <= 4);
|
||||
std::string &diff = CGI->generaltexth->arraytxt[142 + SEL->current->mapHeader->difficulty];
|
||||
printAtMiddleLoc(diff, 62, 472, FONT_SMALL, zwykly, to);
|
||||
printAtMiddleLoc(diff, 62, 472, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
//selecting size icon
|
||||
switch (SEL->current->mapHeader->width)
|
||||
@ -1670,7 +1670,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
|
||||
|
||||
if(SEL->screenType == CMenuScreen::loadGame)
|
||||
printToLoc((static_cast<const CMapInfo*>(SEL->current))->date,308,34, FONT_SMALL, zwykly, to);
|
||||
printToLoc((static_cast<const CMapInfo*>(SEL->current))->date,308,34, FONT_SMALL, Colors::Cornsilk, to);
|
||||
|
||||
//print flags
|
||||
int fx = 34 + graphics->fonts[FONT_SMALL]->getWidth(CGI->generaltexth->allTexts[390].c_str());
|
||||
@ -1709,7 +1709,7 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
tob="200%";
|
||||
break;
|
||||
}
|
||||
printAtMiddleLoc(tob, 311, 472, FONT_SMALL, zwykly, to);
|
||||
printAtMiddleLoc(tob, 311, 472, FONT_SMALL, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
//blit description
|
||||
@ -1726,9 +1726,9 @@ void InfoCard::showAll( SDL_Surface * to )
|
||||
|
||||
//name
|
||||
if (name.length())
|
||||
printAtLoc(name, 26, 39, FONT_BIG, tytulowy, to);
|
||||
printAtLoc(name, 26, 39, FONT_BIG, Colors::Jasmine, to);
|
||||
else
|
||||
printAtLoc("Unnamed", 26, 39, FONT_BIG, tytulowy, to);
|
||||
printAtLoc("Unnamed", 26, 39, FONT_BIG, Colors::Jasmine, to);
|
||||
|
||||
|
||||
}
|
||||
@ -1753,7 +1753,7 @@ void InfoCard::changeSelection( const CMapInfo *to )
|
||||
|
||||
void InfoCard::clickRight( tribool down, bool previousState )
|
||||
{
|
||||
static const SRect flagArea(19, 397, 335, 23);
|
||||
static const Rect flagArea(19, 397, 335, 23);
|
||||
if(down && SEL->current && isItInLoc(flagArea, GH.current->motion.x, GH.current->motion.y))
|
||||
showTeamsPopup();
|
||||
}
|
||||
@ -1761,14 +1761,14 @@ void InfoCard::clickRight( tribool down, bool previousState )
|
||||
void InfoCard::showTeamsPopup()
|
||||
{
|
||||
SDL_Surface *bmp = CMessage::drawBox1(256, 90 + 50 * SEL->current->mapHeader->howManyTeams);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[657], 128, 30, FONT_MEDIUM, tytulowy, bmp); //{Team Alignments}
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[657], 128, 30, FONT_MEDIUM, Colors::Jasmine, bmp); //{Team Alignments}
|
||||
|
||||
for(int i = 0; i < SEL->current->mapHeader->howManyTeams; i++)
|
||||
{
|
||||
std::vector<ui8> flags;
|
||||
std::string hlp = CGI->generaltexth->allTexts[656]; //Team %d
|
||||
hlp.replace(hlp.find("%d"), 2, boost::lexical_cast<std::string>(i+1));
|
||||
CSDL_Ext::printAtMiddle(hlp, 128, 65 + 50*i, FONT_SMALL, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddle(hlp, 128, 65 + 50*i, FONT_SMALL, Colors::Cornsilk, bmp);
|
||||
|
||||
for(int j = 0; j < GameConstants::PLAYER_LIMIT; j++)
|
||||
if((SEL->current->mapHeader->players[j].canHumanPlay || SEL->current->mapHeader->players[j].canComputerPlay)
|
||||
@ -1831,18 +1831,18 @@ OptionsTab::~OptionsTab()
|
||||
|
||||
}
|
||||
|
||||
void OptionsTab::showAll( SDL_Surface * to )
|
||||
void OptionsTab::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
printAtMiddleLoc(CGI->generaltexth->allTexts[515], 222, 30, FONT_BIG, tytulowy, to);
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[516], 222, 58, FONT_SMALL, 55, zwykly, to); //Select starting options, handicap, and name for each player in the game.
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[517], 107, 102, FONT_SMALL, 14, tytulowy, to); //Player Name Handicap Type
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[518], 197, 102, FONT_SMALL, 10, tytulowy, to); //Starting Town
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[519], 273, 102, FONT_SMALL, 10, tytulowy, to); //Starting Hero
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[520], 349, 102, FONT_SMALL, 10, tytulowy, to); //Starting Bonus
|
||||
printAtMiddleLoc(CGI->generaltexth->allTexts[521], 222, 538, FONT_SMALL, tytulowy, to); // Player Turn Duration
|
||||
printAtMiddleLoc(CGI->generaltexth->allTexts[515], 222, 30, FONT_BIG, Colors::Jasmine, to);
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[516], 222, 58, FONT_SMALL, 55, Colors::Cornsilk, to); //Select starting options, handicap, and name for each player in the game.
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[517], 107, 102, FONT_SMALL, 14, Colors::Jasmine, to); //Player Name Handicap Type
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[518], 197, 102, FONT_SMALL, 10, Colors::Jasmine, to); //Starting Town
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[519], 273, 102, FONT_SMALL, 10, Colors::Jasmine, to); //Starting Hero
|
||||
printAtMiddleWBLoc(CGI->generaltexth->allTexts[520], 349, 102, FONT_SMALL, 10, Colors::Jasmine, to); //Starting Bonus
|
||||
printAtMiddleLoc(CGI->generaltexth->allTexts[521], 222, 538, FONT_SMALL, Colors::Jasmine, to); // Player Turn Duration
|
||||
if (turnDuration)
|
||||
printAtMiddleLoc(CGI->generaltexth->turnDurations[turnDuration->value], 319,559, FONT_SMALL, zwykly, to);//Turn duration value
|
||||
printAtMiddleLoc(CGI->generaltexth->turnDurations[turnDuration->value], 319,559, FONT_SMALL, Colors::Cornsilk, to);//Turn duration value
|
||||
}
|
||||
|
||||
void OptionsTab::nextCastle( int player, int dir )
|
||||
@ -2129,7 +2129,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
|
||||
serial++;
|
||||
}
|
||||
|
||||
pos = parent->pos + SPoint(54, 122 + serial*50);
|
||||
pos = parent->pos + Point(54, 122 + serial*50);
|
||||
|
||||
static const char *flags[] = {"AOFLGBR.DEF", "AOFLGBB.DEF", "AOFLGBY.DEF", "AOFLGBG.DEF",
|
||||
"AOFLGBO.DEF", "AOFLGBP.DEF", "AOFLGBT.DEF", "AOFLGBS.DEF"};
|
||||
@ -2139,12 +2139,12 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
|
||||
bg = new CPicture(BitmapHandler::loadBitmap(bgs[s.color]), 0, 0, true);
|
||||
if(SEL->screenType == CMenuScreen::newGame)
|
||||
{
|
||||
btns[0] = new AdventureMapButton(CGI->generaltexth->zelp[132], bind(&OptionsTab::nextCastle, owner, s.color, -1), 107, 5, "ADOPLFA.DEF");
|
||||
btns[1] = new AdventureMapButton(CGI->generaltexth->zelp[133], bind(&OptionsTab::nextCastle, owner, s.color, +1), 168, 5, "ADOPRTA.DEF");
|
||||
btns[2] = new AdventureMapButton(CGI->generaltexth->zelp[148], bind(&OptionsTab::nextHero, owner, s.color, -1), 183, 5, "ADOPLFA.DEF");
|
||||
btns[3] = new AdventureMapButton(CGI->generaltexth->zelp[149], bind(&OptionsTab::nextHero, owner, s.color, +1), 244, 5, "ADOPRTA.DEF");
|
||||
btns[4] = new AdventureMapButton(CGI->generaltexth->zelp[164], bind(&OptionsTab::nextBonus, owner, s.color, -1), 259, 5, "ADOPLFA.DEF");
|
||||
btns[5] = new AdventureMapButton(CGI->generaltexth->zelp[165], bind(&OptionsTab::nextBonus, owner, s.color, +1), 320, 5, "ADOPRTA.DEF");
|
||||
btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[132], bind(&OptionsTab::nextCastle, owner, s.color, -1), 107, 5, "ADOPLFA.DEF");
|
||||
btns[1] = new CAdventureMapButton(CGI->generaltexth->zelp[133], bind(&OptionsTab::nextCastle, owner, s.color, +1), 168, 5, "ADOPRTA.DEF");
|
||||
btns[2] = new CAdventureMapButton(CGI->generaltexth->zelp[148], bind(&OptionsTab::nextHero, owner, s.color, -1), 183, 5, "ADOPLFA.DEF");
|
||||
btns[3] = new CAdventureMapButton(CGI->generaltexth->zelp[149], bind(&OptionsTab::nextHero, owner, s.color, +1), 244, 5, "ADOPRTA.DEF");
|
||||
btns[4] = new CAdventureMapButton(CGI->generaltexth->zelp[164], bind(&OptionsTab::nextBonus, owner, s.color, -1), 259, 5, "ADOPLFA.DEF");
|
||||
btns[5] = new CAdventureMapButton(CGI->generaltexth->zelp[165], bind(&OptionsTab::nextBonus, owner, s.color, +1), 320, 5, "ADOPRTA.DEF");
|
||||
}
|
||||
else
|
||||
for(int i = 0; i < 6; i++)
|
||||
@ -2166,7 +2166,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
|
||||
&& SEL->current->mapHeader->players[s.color].canHumanPlay
|
||||
&& SEL->multiPlayer != CMenuScreen::MULTI_NETWORK_GUEST)
|
||||
{
|
||||
flag = new AdventureMapButton(CGI->generaltexth->zelp[180], bind(&OptionsTab::flagPressed, owner, s.color), -43, 2, flags[s.color]);
|
||||
flag = new CAdventureMapButton(CGI->generaltexth->zelp[180], bind(&OptionsTab::flagPressed, owner, s.color), -43, 2, flags[s.color]);
|
||||
flag->hoverable = true;
|
||||
}
|
||||
else
|
||||
@ -2174,18 +2174,18 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
|
||||
|
||||
defActions &= ~SHARE_POS;
|
||||
town = new SelectedBox(TOWN, s.color);
|
||||
town->pos += pos + SPoint(119, 2);
|
||||
town->pos += pos + Point(119, 2);
|
||||
hero = new SelectedBox(HERO, s.color);
|
||||
hero->pos += pos + SPoint(195, 2);
|
||||
hero->pos += pos + Point(195, 2);
|
||||
bonus = new SelectedBox(BONUS, s.color);
|
||||
bonus->pos += pos + SPoint(271, 2);
|
||||
bonus->pos += pos + Point(271, 2);
|
||||
}
|
||||
|
||||
void OptionsTab::PlayerOptionsEntry::showAll( SDL_Surface * to )
|
||||
void OptionsTab::PlayerOptionsEntry::showAll(SDL_Surface * to)
|
||||
{
|
||||
CIntObject::showAll(to);
|
||||
printAtMiddleLoc(s.name, 55, 10, FONT_SMALL, zwykly, to);
|
||||
printAtMiddleWBLoc(CGI->generaltexth->arraytxt[206+whoCanPlay], 28, 34, FONT_TINY, 8, zwykly, to);
|
||||
printAtMiddleLoc(s.name, 55, 10, FONT_SMALL, Colors::Cornsilk, to);
|
||||
printAtMiddleWBLoc(CGI->generaltexth->arraytxt[206+whoCanPlay], 28, 34, FONT_TINY, 8, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
void OptionsTab::PlayerOptionsEntry::selectButtons()
|
||||
@ -2229,13 +2229,13 @@ void OptionsTab::PlayerOptionsEntry::selectButtons()
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsTab::SelectedBox::showAll( SDL_Surface * to )
|
||||
void OptionsTab::SelectedBox::showAll(SDL_Surface * to)
|
||||
{
|
||||
//PlayerSettings &s = SEL->sInfo.playerInfos[player];
|
||||
SDL_Surface *toBlit = getImg();
|
||||
const std::string *toPrint = getText();
|
||||
blitAt(toBlit, pos, to);
|
||||
printAtMiddleLoc(*toPrint, 23, 39, FONT_TINY, zwykly, to);
|
||||
printAtMiddleLoc(*toPrint, 23, 39, FONT_TINY, Colors::Cornsilk, to);
|
||||
}
|
||||
|
||||
OptionsTab::SelectedBox::SelectedBox( SelType Which, ui8 Player )
|
||||
@ -2445,7 +2445,7 @@ void OptionsTab::SelectedBox::clickRight( tribool down, bool previousState )
|
||||
}
|
||||
|
||||
if(description)
|
||||
CSDL_Ext::printAtMiddleWB(*description, 125, 145, FONT_SMALL, 37, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddleWB(*description, 125, 145, FONT_SMALL, 37, Colors::Cornsilk, bmp);
|
||||
}
|
||||
else if(val == -2)
|
||||
{
|
||||
@ -2456,7 +2456,7 @@ void OptionsTab::SelectedBox::clickRight( tribool down, bool previousState )
|
||||
bmp = CMessage::drawBox1(256, 319);
|
||||
title = &CGI->generaltexth->allTexts[80];
|
||||
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[79], 135, 137, FONT_MEDIUM, tytulowy, bmp);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[79], 135, 137, FONT_MEDIUM, Colors::Jasmine, bmp);
|
||||
|
||||
const CTown &t = CGI->townh->towns[val];
|
||||
//print creatures
|
||||
@ -2465,7 +2465,7 @@ void OptionsTab::SelectedBox::clickRight( tribool down, bool previousState )
|
||||
{
|
||||
int c = t.basicCreatures[i];
|
||||
blitAt(graphics->smallImgs[c], x, y, bmp);
|
||||
CSDL_Ext::printAtMiddleWB(CGI->creh->creatures[c]->nameSing, x + 16, y + 45, FONT_TINY, 10, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddleWB(CGI->creh->creatures[c]->nameSing, x + 16, y + 45, FONT_TINY, 10, Colors::Cornsilk, bmp);
|
||||
|
||||
if(i == 2)
|
||||
{
|
||||
@ -2485,24 +2485,24 @@ void OptionsTab::SelectedBox::clickRight( tribool down, bool previousState )
|
||||
bmp = CMessage::drawBox1(320, 255);
|
||||
title = &CGI->generaltexth->allTexts[77];
|
||||
|
||||
CSDL_Ext::printAtMiddle(*title, 167, 36, FONT_MEDIUM, tytulowy, bmp);
|
||||
CSDL_Ext::printAtMiddle(*subTitle + " - " + h->heroClass->name, 160, 99, FONT_SMALL, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddle(*title, 167, 36, FONT_MEDIUM, Colors::Jasmine, bmp);
|
||||
CSDL_Ext::printAtMiddle(*subTitle + " - " + h->heroClass->name, 160, 99, FONT_SMALL, Colors::Cornsilk, bmp);
|
||||
|
||||
blitAt(getImg(), 136, 56, bmp);
|
||||
|
||||
//print specialty
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[78], 166, 132, FONT_MEDIUM, tytulowy, bmp);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[78], 166, 132, FONT_MEDIUM, Colors::Jasmine, bmp);
|
||||
blitAt(graphics->un44->ourImages[val].bitmap, 140, 150, bmp);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->hTxts[val].bonusName, 166, 203, FONT_SMALL, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddle(CGI->generaltexth->hTxts[val].bonusName, 166, 203, FONT_SMALL, Colors::Cornsilk, bmp);
|
||||
|
||||
GH.pushInt(new CInfoPopup(bmp, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if(title)
|
||||
CSDL_Ext::printAtMiddle(*title, 135, 36, FONT_MEDIUM, tytulowy, bmp);
|
||||
CSDL_Ext::printAtMiddle(*title, 135, 36, FONT_MEDIUM, Colors::Jasmine, bmp);
|
||||
if(subTitle)
|
||||
CSDL_Ext::printAtMiddle(*subTitle, 127, 103, FONT_SMALL, zwykly, bmp);
|
||||
CSDL_Ext::printAtMiddle(*subTitle, 127, 103, FONT_SMALL, Colors::Cornsilk, bmp);
|
||||
|
||||
blitAt(getImg(), 104, 60, bmp);
|
||||
|
||||
@ -2539,7 +2539,7 @@ CScenarioInfo::CScenarioInfo(const CMapHeader *mapHeader, const StartInfo *start
|
||||
opt->recreate();
|
||||
|
||||
card->difficulty->select(startInfo->difficulty, 0);
|
||||
back = new AdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 584, 535, "SCNRBACK.DEF", SDLK_ESCAPE);
|
||||
back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 584, 535, "SCNRBACK.DEF", SDLK_ESCAPE);
|
||||
}
|
||||
|
||||
CScenarioInfo::~CScenarioInfo()
|
||||
@ -2616,14 +2616,14 @@ CMultiMode::CMultiMode()
|
||||
blitAt(CPicture("MUMAP.bmp"), 16, 77, *bg); //blit img
|
||||
pos = bg->center(); //center, window has size of bg graphic
|
||||
|
||||
bar = new CGStatusBar(new CPicture(SRect(7, 465, 440, 18), 0));//226, 472
|
||||
txt = new CTextInput(SRect(19, 436, 334, 16), *bg);
|
||||
bar = new CGStatusBar(new CPicture(Rect(7, 465, 440, 18), 0));//226, 472
|
||||
txt = new CTextInput(Rect(19, 436, 334, 16), *bg);
|
||||
txt->setText(GDefaultOptions.playerName); //Player
|
||||
|
||||
btns[0] = new AdventureMapButton(CGI->generaltexth->zelp[266], bind(&CMultiMode::openHotseat, this), 373, 78, "MUBHOT.DEF");
|
||||
btns[1] = new AdventureMapButton("Host TCP/IP game", "", bind(&CMultiMode::hostTCP, this), 373, 78 + 57*1, "MUBHOST.DEF");
|
||||
btns[2] = new AdventureMapButton("Join TCP/IP game", "", bind(&CMultiMode::joinTCP, this), 373, 78 + 57*2, "MUBJOIN.DEF");
|
||||
btns[6] = new AdventureMapButton(CGI->generaltexth->zelp[288], bind(&CGuiHandler::popIntTotally, ref(GH), this), 373, 424, "MUBCANC.DEF", SDLK_ESCAPE);
|
||||
btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[266], bind(&CMultiMode::openHotseat, this), 373, 78, "MUBHOT.DEF");
|
||||
btns[1] = new CAdventureMapButton("Host TCP/IP game", "", bind(&CMultiMode::hostTCP, this), 373, 78 + 57*1, "MUBHOST.DEF");
|
||||
btns[2] = new CAdventureMapButton("Join TCP/IP game", "", bind(&CMultiMode::joinTCP, this), 373, 78 + 57*2, "MUBJOIN.DEF");
|
||||
btns[6] = new CAdventureMapButton(CGI->generaltexth->zelp[288], bind(&CGuiHandler::popIntTotally, ref(GH), this), 373, 424, "MUBCANC.DEF", SDLK_ESCAPE);
|
||||
}
|
||||
|
||||
void CMultiMode::openHotseat()
|
||||
@ -2653,18 +2653,18 @@ CHotSeatPlayers::CHotSeatPlayers(const std::string &firstPlayer)
|
||||
|
||||
std::string text = CGI->generaltexth->allTexts[446];
|
||||
boost::replace_all(text, "\t","\n");
|
||||
SRect boxRect(25, 20, 315, 50);
|
||||
title = new CTextBox(text, boxRect, 0, FONT_BIG, CENTER, zwykly);//HOTSEAT Please enter names
|
||||
Rect boxRect(25, 20, 315, 50);
|
||||
title = new CTextBox(text, boxRect, 0, FONT_BIG, CENTER, Colors::Cornsilk);//HOTSEAT Please enter names
|
||||
|
||||
for(int i = 0; i < ARRAY_COUNT(txt); i++)
|
||||
{
|
||||
txt[i] = new CTextInput(SRect(60, 85 + i*30, 280, 16), *bg);
|
||||
txt[i] = new CTextInput(Rect(60, 85 + i*30, 280, 16), *bg);
|
||||
txt[i]->cb += boost::bind(&CHotSeatPlayers::onChange, this, _1);
|
||||
}
|
||||
|
||||
ok = new AdventureMapButton(CGI->generaltexth->zelp[560], bind(&CHotSeatPlayers::enterSelectionScreen, this), 95, 338, "MUBCHCK.DEF", SDLK_RETURN);
|
||||
cancel = new AdventureMapButton(CGI->generaltexth->zelp[561], bind(&CGuiHandler::popIntTotally, ref(GH), this), 205, 338, "MUBCANC.DEF", SDLK_ESCAPE);
|
||||
bar = new CGStatusBar(new CPicture(SRect(7, 381, 348, 18), 0));//226, 472
|
||||
ok = new CAdventureMapButton(CGI->generaltexth->zelp[560], bind(&CHotSeatPlayers::enterSelectionScreen, this), 95, 338, "MUBCHCK.DEF", SDLK_RETURN);
|
||||
cancel = new CAdventureMapButton(CGI->generaltexth->zelp[561], bind(&CGuiHandler::popIntTotally, ref(GH), this), 205, 338, "MUBCANC.DEF", SDLK_ESCAPE);
|
||||
bar = new CGStatusBar(new CPicture(Rect(7, 381, 348, 18), 0));//226, 472
|
||||
|
||||
txt[0]->setText(firstPlayer, true);
|
||||
txt[0]->giveFocus();
|
||||
@ -2711,31 +2711,31 @@ CBonusSelection::CBonusSelection( CCampaignState * _ourCampaign )
|
||||
|
||||
blitAt(panel, 456, 6, background);
|
||||
|
||||
startB = new AdventureMapButton("", "", bind(&CBonusSelection::startMap, this), 475, 536, "CBBEGIB.DEF", SDLK_RETURN);
|
||||
backB = new AdventureMapButton("", "", bind(&CBonusSelection::goBack, this), 624, 536, "CBCANCB.DEF", SDLK_ESCAPE);
|
||||
startB = new CAdventureMapButton("", "", bind(&CBonusSelection::startMap, this), 475, 536, "CBBEGIB.DEF", SDLK_RETURN);
|
||||
backB = new CAdventureMapButton("", "", bind(&CBonusSelection::goBack, this), 624, 536, "CBCANCB.DEF", SDLK_ESCAPE);
|
||||
startB->setState(CButtonBase::BLOCKED);
|
||||
|
||||
//campaign name
|
||||
if (ourCampaign->camp->header.name.length())
|
||||
printAtLoc(ourCampaign->camp->header.name, 481, 28, FONT_BIG, tytulowy, background);
|
||||
printAtLoc(ourCampaign->camp->header.name, 481, 28, FONT_BIG, Colors::Jasmine, background);
|
||||
else
|
||||
printAtLoc("Unnamed", 481, 28, FONT_BIG, tytulowy, background);
|
||||
printAtLoc("Unnamed", 481, 28, FONT_BIG, Colors::Jasmine, background);
|
||||
|
||||
//map size icon
|
||||
sizes = CDefHandler::giveDef("SCNRMPSZ.DEF");
|
||||
|
||||
|
||||
//campaign description
|
||||
printAtLoc(CGI->generaltexth->allTexts[38], 481, 63, FONT_SMALL, tytulowy, background);
|
||||
printAtLoc(CGI->generaltexth->allTexts[38], 481, 63, FONT_SMALL, Colors::Jasmine, background);
|
||||
|
||||
cmpgDesc = new CTextBox(ourCampaign->camp->header.description, SRect(480, 86, 286, 117), 1);
|
||||
cmpgDesc = new CTextBox(ourCampaign->camp->header.description, Rect(480, 86, 286, 117), 1);
|
||||
cmpgDesc->showAll(background);
|
||||
|
||||
//map description
|
||||
mapDesc = new CTextBox("", SRect(480, 280, 286, 117), 1);
|
||||
mapDesc = new CTextBox("", Rect(480, 280, 286, 117), 1);
|
||||
|
||||
//bonus choosing
|
||||
printAtLoc(CGI->generaltexth->allTexts[71], 511, 432, FONT_MEDIUM, zwykly, background); //Choose a bonus:
|
||||
printAtLoc(CGI->generaltexth->allTexts[71], 511, 432, FONT_MEDIUM, Colors::Cornsilk, background); //Choose a bonus:
|
||||
bonuses = new CHighlightableButtonsGroup(bind(&CBonusSelection::selectBonus, this, _1));
|
||||
|
||||
//set left part of window
|
||||
@ -2765,15 +2765,15 @@ CBonusSelection::CBonusSelection( CCampaignState * _ourCampaign )
|
||||
}
|
||||
|
||||
//allies / enemies
|
||||
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 486, 407, FONT_SMALL, zwykly, background); //Allies
|
||||
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 619, 407, FONT_SMALL, zwykly, background); //Enemies
|
||||
printAtLoc(CGI->generaltexth->allTexts[390] + ":", 486, 407, FONT_SMALL, Colors::Cornsilk, background); //Allies
|
||||
printAtLoc(CGI->generaltexth->allTexts[391] + ":", 619, 407, FONT_SMALL, Colors::Cornsilk, background); //Enemies
|
||||
|
||||
SDL_FreeSurface(panel);
|
||||
|
||||
//difficulty
|
||||
std::vector<std::string> difficulty;
|
||||
boost::split(difficulty, CGI->generaltexth->allTexts[492], boost::is_any_of(" "));
|
||||
printAtLoc(difficulty.back(), 689, 432, FONT_MEDIUM, zwykly, background); //Difficulty
|
||||
printAtLoc(difficulty.back(), 689, 432, FONT_MEDIUM, Colors::Cornsilk, background); //Difficulty
|
||||
|
||||
//difficulty pics
|
||||
for (int b=0; b<ARRAY_COUNT(diffPics); ++b)
|
||||
@ -2789,8 +2789,8 @@ CBonusSelection::CBonusSelection( CCampaignState * _ourCampaign )
|
||||
//difficulty selection buttons
|
||||
if (ourCampaign->camp->header.difficultyChoosenByPlayer)
|
||||
{
|
||||
diffLb = new AdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, false), 694, 508, "SCNRBLF.DEF");
|
||||
diffRb = new AdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, true), 738, 508, "SCNRBRT.DEF");
|
||||
diffLb = new CAdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, false), 694, 508, "SCNRBLF.DEF");
|
||||
diffRb = new CAdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, true), 738, 508, "SCNRBRT.DEF");
|
||||
}
|
||||
|
||||
//load miniflags
|
||||
@ -2815,7 +2815,7 @@ void CBonusSelection::goBack()
|
||||
GH.popIntTotally(this);
|
||||
}
|
||||
|
||||
void CBonusSelection::showAll( SDL_Surface * to )
|
||||
void CBonusSelection::showAll(SDL_Surface * to)
|
||||
{
|
||||
blitAt(background, pos.x, pos.y, to);
|
||||
CIntObject::showAll(to);
|
||||
@ -2879,7 +2879,7 @@ void CBonusSelection::selectMap( int whichOne )
|
||||
updateBonusSelection();
|
||||
}
|
||||
|
||||
void CBonusSelection::show( SDL_Surface * to )
|
||||
void CBonusSelection::show(SDL_Surface * to)
|
||||
{
|
||||
//blitAt(background, pos.x, pos.y, to);
|
||||
|
||||
@ -2887,12 +2887,12 @@ void CBonusSelection::show( SDL_Surface * to )
|
||||
std::string mapName = ourHeader->name;
|
||||
|
||||
if (mapName.length())
|
||||
printAtLoc(mapName, 481, 219, FONT_BIG, tytulowy, to);
|
||||
printAtLoc(mapName, 481, 219, FONT_BIG, Colors::Jasmine, to);
|
||||
else
|
||||
printAtLoc("Unnamed", 481, 219, FONT_BIG, tytulowy, to);
|
||||
printAtLoc("Unnamed", 481, 219, FONT_BIG, Colors::Jasmine, to);
|
||||
|
||||
//map description
|
||||
printAtLoc(CGI->generaltexth->allTexts[496], 481, 253, FONT_SMALL, tytulowy, to);
|
||||
printAtLoc(CGI->generaltexth->allTexts[496], 481, 253, FONT_SMALL, Colors::Jasmine, to);
|
||||
|
||||
mapDesc->showAll(to); //showAll because CTextBox has no show()
|
||||
|
||||
@ -3117,7 +3117,7 @@ void CBonusSelection::updateBonusSelection()
|
||||
CAnimation * anim = new CAnimation();
|
||||
anim->setCustom(picName, 0);
|
||||
bonusButton->setImage(anim);
|
||||
bonusButton->borderColor = Colors::Yellow; // yellow border
|
||||
bonusButton->borderColor = Colors::Maize; // yellow border
|
||||
bonuses->addButton(bonusButton);
|
||||
}
|
||||
if (active)
|
||||
@ -3240,7 +3240,7 @@ void CBonusSelection::CRegion::clickRight( tribool down, bool previousState )
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusSelection::CRegion::show( SDL_Surface * to )
|
||||
void CBonusSelection::CRegion::show(SDL_Surface * to)
|
||||
{
|
||||
//const SCampPositions::SRegionDesc & desc = owner->campDescriptions[owner->ourCampaign->camp->header.mapVersion].regions[myNumber];
|
||||
if (!accessible)
|
||||
@ -3495,7 +3495,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode &config )
|
||||
used |= LCLICK | HOVER;
|
||||
image = new CPicture(config["image"].String());
|
||||
|
||||
hoverLabel = new CLabel(pos.w / 2, pos.h + 20, FONT_MEDIUM, CENTER, tytulowy, "");
|
||||
hoverLabel = new CLabel(pos.w / 2, pos.h + 20, FONT_MEDIUM, CENTER, Colors::Jasmine, "");
|
||||
CGuiHandler::moveChild(hoverLabel, this, parent);
|
||||
}
|
||||
|
||||
@ -3524,7 +3524,7 @@ void CCampaignScreen::CCampaignButton::hover(bool on)
|
||||
hoverLabel->setTxt(" ");
|
||||
}
|
||||
|
||||
void CCampaignScreen::CCampaignButton::show(SDL_Surface *to)
|
||||
void CCampaignScreen::CCampaignButton::show(SDL_Surface * to)
|
||||
{
|
||||
if (status == CCampaignScreen::DISABLED)
|
||||
return;
|
||||
@ -3546,14 +3546,14 @@ void CCampaignScreen::CCampaignButton::show(SDL_Surface *to)
|
||||
}
|
||||
}
|
||||
|
||||
AdventureMapButton* CCampaignScreen::createExitButton(const JsonNode& button)
|
||||
CAdventureMapButton* CCampaignScreen::createExitButton(const JsonNode& button)
|
||||
{
|
||||
std::pair<std::string, std::string> help;
|
||||
if (!button["help"].isNull() && button["help"].Float() > 0)
|
||||
help = CGI->generaltexth->zelp[button["help"].Float()];
|
||||
|
||||
boost::function<void()> close = boost::bind(&CGuiHandler::popIntTotally, &GH, this);
|
||||
return new AdventureMapButton(help, close, button["x"].Float(), button["y"].Float(), button["name"].String(), button["hotkey"].Float());
|
||||
return new CAdventureMapButton(help, close, button["x"].Float(), button["y"].Float(), button["name"].String(), button["hotkey"].Float());
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "GUIClasses.h"
|
||||
#include "FunctionList.h"
|
||||
#include "../lib/CMapInfo.h"
|
||||
#include "UIFramework/IUpdateable.h"
|
||||
|
||||
/*
|
||||
* CPreGame.h, part of VCMI engine
|
||||
@ -77,9 +76,9 @@ public:
|
||||
class CMenuEntry : public CIntObject
|
||||
{
|
||||
std::vector<CPicture*> images;
|
||||
std::vector<AdventureMapButton*> buttons;
|
||||
std::vector<CAdventureMapButton*> buttons;
|
||||
|
||||
AdventureMapButton* createButton(CMenuScreen* parent, const JsonNode& button);
|
||||
CAdventureMapButton* createButton(CMenuScreen* parent, const JsonNode& button);
|
||||
public:
|
||||
CMenuEntry(CMenuScreen* parent, const JsonNode &config);
|
||||
};
|
||||
@ -90,7 +89,7 @@ class CreditsScreen : public CIntObject
|
||||
public:
|
||||
CreditsScreen();
|
||||
|
||||
void show(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
@ -103,7 +102,7 @@ public:
|
||||
CTextBox *chatHistory;
|
||||
CTextInput *inputBox;
|
||||
|
||||
CChatBox(const SRect &rect);
|
||||
CChatBox(const Rect &rect);
|
||||
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
|
||||
@ -204,8 +203,8 @@ public:
|
||||
PlayerInfo π
|
||||
PlayerSettings &s;
|
||||
CPicture *bg;
|
||||
AdventureMapButton *btns[6]; //left and right for town, hero, bonus
|
||||
AdventureMapButton *flag;
|
||||
CAdventureMapButton *btns[6]; //left and right for town, hero, bonus
|
||||
CAdventureMapButton *flag;
|
||||
SelectedBox *town;
|
||||
SelectedBox *hero;
|
||||
SelectedBox *bonus;
|
||||
@ -279,7 +278,7 @@ public:
|
||||
CPicture *bg; //general bg image
|
||||
InfoCard *card;
|
||||
OptionsTab *opt;
|
||||
AdventureMapButton *start, *back;
|
||||
CAdventureMapButton *start, *back;
|
||||
|
||||
SelectionTab *sel;
|
||||
CIntObject *curTab;
|
||||
@ -326,7 +325,7 @@ public:
|
||||
class CScenarioInfo : public CIntObject, public ISelectionScreenInfo
|
||||
{
|
||||
public:
|
||||
AdventureMapButton *back;
|
||||
CAdventureMapButton *back;
|
||||
InfoCard *card;
|
||||
OptionsTab *opt;
|
||||
|
||||
@ -340,7 +339,7 @@ class CMultiMode : public CIntObject
|
||||
public:
|
||||
CPicture *bg;
|
||||
CTextInput *txt;
|
||||
AdventureMapButton *btns[7]; //0 - hotseat, 6 - cancel
|
||||
CAdventureMapButton *btns[7]; //0 - hotseat, 6 - cancel
|
||||
CGStatusBar *bar;
|
||||
|
||||
CMultiMode();
|
||||
@ -355,7 +354,7 @@ class CHotSeatPlayers : public CIntObject
|
||||
CPicture *bg;
|
||||
CTextBox *title;
|
||||
CTextInput* txt[8];
|
||||
AdventureMapButton *ok, *cancel;
|
||||
CAdventureMapButton *ok, *cancel;
|
||||
CGStatusBar *bar;
|
||||
|
||||
void onChange(std::string newText);
|
||||
@ -369,7 +368,7 @@ public:
|
||||
class CBonusSelection : public CIntObject
|
||||
{
|
||||
SDL_Surface * background;
|
||||
AdventureMapButton * startB, * backB;
|
||||
CAdventureMapButton * startB, * backB;
|
||||
|
||||
//campaign & map descriptions:
|
||||
CTextBox * cmpgDesc, * mapDesc;
|
||||
@ -416,7 +415,7 @@ class CBonusSelection : public CIntObject
|
||||
CMapHeader *ourHeader;
|
||||
CDefHandler *sizes; //icons of map sizes
|
||||
SDL_Surface* diffPics[5]; //pictures of difficulties, user-selectable (or not if campaign locks this)
|
||||
AdventureMapButton * diffLb, * diffRb; //buttons for changing difficulty
|
||||
CAdventureMapButton * diffLb, * diffRb; //buttons for changing difficulty
|
||||
void changeDiff(bool increase); //if false, then decrease
|
||||
|
||||
//bonus selection
|
||||
@ -468,14 +467,14 @@ private:
|
||||
|
||||
public:
|
||||
CCampaignButton(const JsonNode &config );
|
||||
void show(SDL_Surface *to);
|
||||
void show(SDL_Surface * to);
|
||||
};
|
||||
|
||||
AdventureMapButton *back;
|
||||
CAdventureMapButton *back;
|
||||
std::vector<CCampaignButton*> campButtons;
|
||||
std::vector<CPicture*> images;
|
||||
|
||||
AdventureMapButton* createExitButton(const JsonNode& button);
|
||||
CAdventureMapButton* createExitButton(const JsonNode& button);
|
||||
public:
|
||||
enum CampaignSet {ROE, AB, SOD, WOG};
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "BattleInterface/CBattleInterface.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CMessage.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "../CCallback.h"
|
||||
@ -31,7 +31,6 @@
|
||||
*/
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
extern SDL_Color tytulowy, zwykly, darkTitle;
|
||||
|
||||
SpellbookInteractiveArea::SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL,
|
||||
const std::string & textR, boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt)
|
||||
@ -318,14 +317,14 @@ void CSpellWindow::fRcornerb()
|
||||
GH.breakEventHandling();
|
||||
}
|
||||
|
||||
void CSpellWindow::showAll(SDL_Surface *to)
|
||||
void CSpellWindow::showAll(SDL_Surface * to)
|
||||
{
|
||||
CSDL_Ext::blitSurface(background, NULL, to, &pos);
|
||||
blitAt(spellTab->ourImages[selectedTab].bitmap, 524 + pos.x, 88 + pos.y, to);
|
||||
|
||||
std::ostringstream mana;
|
||||
mana<<myHero->mana;
|
||||
CSDL_Ext::printAtMiddle(mana.str(), pos.x+435, pos.y +426, FONT_SMALL, tytulowy, to);
|
||||
CSDL_Ext::printAtMiddle(mana.str(), pos.x+435, pos.y +426, FONT_SMALL, Colors::Jasmine, to);
|
||||
|
||||
statusBar->showAll(to);
|
||||
|
||||
@ -611,7 +610,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
|
||||
if((sp->combatSpell && !owner->myInt->battleInt)
|
||||
|| (!sp->combatSpell && owner->myInt->battleInt))
|
||||
{
|
||||
std::vector<SComponent*> hlp(1, new SComponent(SComponent::spell, mySpell, 0));
|
||||
std::vector<CComponent*> hlp(1, new CComponent(CComponent::spell, mySpell, 0));
|
||||
LOCPLINT->showInfoDialog(sp->descriptions[schoolLevel], hlp);
|
||||
return;
|
||||
}
|
||||
@ -805,7 +804,7 @@ void CSpellWindow::SpellArea::hover(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
void CSpellWindow::SpellArea::showAll(SDL_Surface *to)
|
||||
void CSpellWindow::SpellArea::showAll(SDL_Surface * to)
|
||||
{
|
||||
if(mySpell < 0)
|
||||
return;
|
||||
@ -819,13 +818,13 @@ void CSpellWindow::SpellArea::showAll(SDL_Surface *to)
|
||||
if(spellCost > owner->myHero->mana) //hero cannot cast this spell
|
||||
{
|
||||
static const SDL_Color unavailableSpell = {239, 189, 33, 0};
|
||||
firstLineColor = zwykly;
|
||||
firstLineColor = Colors::Cornsilk;
|
||||
secondLineColor = unavailableSpell;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstLineColor = tytulowy;
|
||||
secondLineColor = zwykly;
|
||||
firstLineColor = Colors::Jasmine;
|
||||
secondLineColor = Colors::Cornsilk;
|
||||
}
|
||||
//printing spell's name
|
||||
CSDL_Ext::printAtMiddle(spell->name, pos.x + 39, pos.y + 70, FONT_TINY, firstLineColor, to);
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void hover(bool on);
|
||||
void showAll(SDL_Surface *to);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
SDL_Surface * background, * leftCorner, * rightCorner;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "CSndHandler.h"
|
||||
#include "CVideoHandler.h"
|
||||
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "CPlayerInterface.h"
|
||||
|
||||
extern SystemOptions GDefaultOptions;
|
||||
@ -568,7 +568,6 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey)
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
#include "SDL_framerate.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
|
@ -553,7 +553,7 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
def = NULL;
|
||||
|
||||
if(att || def || gs->scenarioOps->mode == StartInfo::DUEL)
|
||||
new CBattleInterface(info->belligerents[0], info->belligerents[1], info->heroes[0], info->heroes[1], SRect((conf.cc.resx - 800)/2, (conf.cc.resy - 600)/2, 800, 600), att, def);
|
||||
new CBattleInterface(info->belligerents[0], info->belligerents[1], info->heroes[0], info->heroes[1], Rect((conf.cc.resx - 800)/2, (conf.cc.resy - 600)/2, 800, 600), att, def);
|
||||
|
||||
if(vstd::contains(battleints,info->sides[0]))
|
||||
battleints[info->sides[0]]->battleStart(info->belligerents[0], info->belligerents[1], info->tile, info->heroes[0], info->heroes[1], 0);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,10 +4,8 @@
|
||||
#include "FunctionList.h"
|
||||
#include "../lib/ResourceSet.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/CSimpleWindow.h"
|
||||
#include "UIFramework/IStatusBar.h"
|
||||
#include "UIFramework/CPicture.h"
|
||||
#include "UIFramework/CKeyShortcut.h"
|
||||
#include "UIFramework/CIntObject.h"
|
||||
#include "UIFramework/CIntObjectClasses.h"
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
@ -31,7 +29,7 @@ class CStackBasicDescriptor;
|
||||
class CBonusSystemNode;
|
||||
class CArtifact;
|
||||
class CDefEssential;
|
||||
class AdventureMapButton;
|
||||
class CAdventureMapButton;
|
||||
class CHighlightableButtonsGroup;
|
||||
class CDefHandler;
|
||||
struct HeroMoveDetails;
|
||||
@ -41,7 +39,7 @@ class CAdvMapInt;
|
||||
class CCastleInterface;
|
||||
class CBattleInterface;
|
||||
class CStack;
|
||||
class SComponent;
|
||||
class CComponent;
|
||||
class CCreature;
|
||||
struct SDL_Surface;
|
||||
struct CPath;
|
||||
@ -75,8 +73,6 @@ class IBonusBearer;
|
||||
class CArtPlace;
|
||||
class CAnimImage;
|
||||
|
||||
extern SDL_Color tytulowy, tlo, zwykly ;
|
||||
|
||||
/// text + comp. + ok button
|
||||
class CInfoWindow : public CSimpleWindow
|
||||
{ //window able to delete its components when closed
|
||||
@ -84,11 +80,11 @@ class CInfoWindow : public CSimpleWindow
|
||||
|
||||
public:
|
||||
typedef std::vector<std::pair<std::string,CFunctionList<void()> > > TButtonsInfo;
|
||||
typedef std::vector<SComponent*> TCompsInfo;
|
||||
typedef std::vector<CComponent*> TCompsInfo;
|
||||
int ID; //for identification
|
||||
CTextBox *text;
|
||||
std::vector<AdventureMapButton *> buttons;
|
||||
std::vector<SComponent*> components;
|
||||
std::vector<CAdventureMapButton *> buttons;
|
||||
std::vector<CComponent*> components;
|
||||
CSlider *slider;
|
||||
|
||||
void setDelComps(bool DelComps);
|
||||
@ -102,8 +98,8 @@ public:
|
||||
CInfoWindow(); //c-tor
|
||||
~CInfoWindow(); //d-tor
|
||||
|
||||
static void showYesNoDialog( const std::string & text, const std::vector<SComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, int player = 1); //use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
|
||||
static CInfoWindow *create(const std::string &text, int playerID = 1, const std::vector<SComponent*> *components = NULL, bool DelComps = false);
|
||||
static void showYesNoDialog( const std::string & text, const std::vector<CComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, int player = 1); //use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
|
||||
static CInfoWindow *create(const std::string &text, int playerID = 1, const std::vector<CComponent*> *components = NULL, bool DelComps = false);
|
||||
};
|
||||
|
||||
/// component selection window
|
||||
@ -130,7 +126,7 @@ public:
|
||||
virtual ~CRClickPopup(); //d-tor
|
||||
|
||||
static void createAndPush(const std::string &txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo());
|
||||
static void createAndPush(const CGObjectInstance *obj, const SPoint &p, EAlignment alignment = BOTTOMRIGHT);
|
||||
static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT);
|
||||
};
|
||||
|
||||
/// popup displayed on R-click
|
||||
@ -154,7 +150,7 @@ public:
|
||||
void close();
|
||||
void show(SDL_Surface * to);
|
||||
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
|
||||
CInfoPopup(SDL_Surface * Bitmap, const SPoint &p, EAlignment alignment, bool Free=false); //c-tor
|
||||
CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
|
||||
CInfoPopup(SDL_Surface *Bitmap = NULL, bool Free = false); //default c-tor
|
||||
|
||||
void init(int x, int y);
|
||||
@ -162,7 +158,7 @@ public:
|
||||
};
|
||||
|
||||
/// common popup window component
|
||||
class SComponent : public virtual CIntObject
|
||||
class CComponent : public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
enum Etype
|
||||
@ -181,10 +177,10 @@ public:
|
||||
SDL_Surface * setSurface(std::string defName, int imgPos);
|
||||
|
||||
void init(Etype Type, int Subtype, int Val);
|
||||
SComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur=NULL, bool freeSur=false); //c-tor
|
||||
SComponent(const Component &c); //c-tor
|
||||
SComponent();; //c-tor
|
||||
virtual ~SComponent(); //d-tor
|
||||
CComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur=NULL, bool freeSur=false); //c-tor
|
||||
CComponent(const Component &c); //c-tor
|
||||
CComponent();; //c-tor
|
||||
virtual ~CComponent(); //d-tor
|
||||
|
||||
void clickRight(tribool down, bool previousState); //call-in
|
||||
SDL_Surface * getImg();
|
||||
@ -193,7 +189,7 @@ public:
|
||||
virtual void deactivate();
|
||||
};
|
||||
|
||||
class CSelectableComponent : public SComponent, public CKeyShortcut
|
||||
class CSelectableComponent : public CComponent, public CKeyShortcut
|
||||
{
|
||||
public:
|
||||
bool selected; //if true, this component is selected
|
||||
@ -212,83 +208,6 @@ public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Used as base for Tabs and List classes
|
||||
class CObjectList : public CIntObject
|
||||
{
|
||||
public:
|
||||
typedef boost::function<CIntObject* (size_t)> CreateFunc;
|
||||
typedef boost::function<void(CIntObject *)> DestroyFunc;
|
||||
|
||||
private:
|
||||
CreateFunc createObject;
|
||||
DestroyFunc destroyObject;
|
||||
|
||||
protected:
|
||||
//Internal methods for safe creation of items (Children capturing and activation/deactivation if needed)
|
||||
void deleteItem(CIntObject* item);
|
||||
CIntObject* createItem(size_t index);
|
||||
|
||||
CObjectList(CreateFunc create, DestroyFunc destroy = DestroyFunc());//Protected constructor
|
||||
};
|
||||
|
||||
/// Window element with multiple tabs
|
||||
class CTabbedInt : public CObjectList
|
||||
{
|
||||
private:
|
||||
CIntObject * activeTab;
|
||||
size_t activeID;
|
||||
|
||||
public:
|
||||
//CreateFunc, DestroyFunc - see CObjectList
|
||||
//Pos - position of object, all tabs will be moved to this position
|
||||
//ActiveID - ID of initially active tab
|
||||
CTabbedInt(CreateFunc create, DestroyFunc destroy = DestroyFunc(), SPoint position=SPoint(), size_t ActiveID=0);
|
||||
|
||||
void setActive(size_t which);
|
||||
//recreate active tab
|
||||
void reset();
|
||||
|
||||
//return currently active item
|
||||
CIntObject * getItem();
|
||||
};
|
||||
|
||||
/// List of IntObjects with optional slider
|
||||
class CListBox : public CObjectList
|
||||
{
|
||||
private:
|
||||
std::list< CIntObject* > items;
|
||||
size_t first;
|
||||
size_t totalSize;
|
||||
|
||||
SPoint itemOffset;
|
||||
CSlider * slider;
|
||||
|
||||
void updatePositions();
|
||||
public:
|
||||
//CreateFunc, DestroyFunc - see CObjectList
|
||||
//Pos - position of first item
|
||||
//ItemOffset - distance between items in the list
|
||||
//VisibleSize - maximal number of displayable at once items
|
||||
//TotalSize
|
||||
//Slider - slider style, bit field: 1 = present(disabled), 2=horisontal(vertical), 4=blue(brown)
|
||||
//SliderPos - position of slider, if present
|
||||
CListBox(CreateFunc create, DestroyFunc destroy, SPoint Pos, SPoint ItemOffset, size_t VisibleSize,
|
||||
size_t TotalSize, size_t InitialPos=0, int Slider=0, SRect SliderPos=SRect() );
|
||||
|
||||
//recreate all visible items
|
||||
void reset();
|
||||
|
||||
//return currently active items
|
||||
std::list< CIntObject * > getItems();
|
||||
|
||||
//scroll list
|
||||
void moveToPos(size_t which);
|
||||
void moveToNext();
|
||||
void moveToPrev();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class CGarrisonInt;
|
||||
|
||||
@ -321,9 +240,9 @@ class CGarrisonInt :public CIntObject
|
||||
{
|
||||
public:
|
||||
int interx; //space between slots
|
||||
SPoint garOffset; //offset between garrisons (not used if only one hero)
|
||||
Point garOffset; //offset between garrisons (not used if only one hero)
|
||||
CGarrisonSlot *highlighted; //chosen slot
|
||||
std::vector<AdventureMapButton *> splitButtons; //may be empty if no buttons
|
||||
std::vector<CAdventureMapButton *> splitButtons; //may be empty if no buttons
|
||||
|
||||
int p2, //TODO: comment me
|
||||
shiftPos;//1st slot of the second row, set shiftPoint for effect
|
||||
@ -341,7 +260,7 @@ public:
|
||||
//const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
|
||||
|
||||
void setArmy(const CArmedInstance *army, bool bottomGarrison);
|
||||
void addSplitBtn(AdventureMapButton * button);
|
||||
void addSplitBtn(CAdventureMapButton * button);
|
||||
void createSet(std::vector<CGarrisonSlot*> &ret, const CCreatureSet * set, int posX, int distance, int posY, int Upg );
|
||||
|
||||
void activate();
|
||||
@ -358,152 +277,10 @@ public:
|
||||
//removableUnits - you can take units from top;
|
||||
//smallImgs - units images size 64x58 or 32x32;
|
||||
//twoRows - display slots in 2 row (1st row = 4, 2nd = 3)
|
||||
CGarrisonInt(int x, int y, int inx, const SPoint &garsOffset, SDL_Surface *pomsur, const SPoint &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor
|
||||
CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor
|
||||
~CGarrisonInt(); //d-tor
|
||||
};
|
||||
|
||||
/// Status bar which is shown at the bottom of the in-game screens
|
||||
class CStatusBar
|
||||
: public CIntObject, public IStatusBar
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background
|
||||
int middlex, middley; //middle of statusbar
|
||||
std::string current; //text currently printed
|
||||
|
||||
CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
|
||||
~CStatusBar(); //d-tor
|
||||
void print(const std::string & text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
void show(SDL_Surface * to); //shows statusbar (with current text)
|
||||
std::string getCurrent(); //getter for current
|
||||
};
|
||||
|
||||
/// Label which shows text
|
||||
class CLabel
|
||||
: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
EAlignment alignment;
|
||||
EFonts font;
|
||||
SDL_Color color;
|
||||
std::string text;
|
||||
CPicture *bg;
|
||||
bool autoRedraw; //whether control will redraw itself on setTxt
|
||||
SPoint textOffset; //text will be blitted at pos + textOffset with appropriate alignment
|
||||
bool ignoreLeadingWhitespace;
|
||||
|
||||
virtual void setTxt(const std::string &Txt);
|
||||
void showAll(SDL_Surface * to); //shows statusbar (with current text)
|
||||
CLabel(int x=0, int y=0, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly, const std::string &Text = "");
|
||||
};
|
||||
|
||||
/// a multi-line label that tries to fit text with given available width and height; if not possible, it creates a slider for scrolling text
|
||||
class CTextBox
|
||||
: public CLabel
|
||||
{
|
||||
public:
|
||||
int maxW; //longest line of text in px
|
||||
int maxH; //total height needed to print all lines
|
||||
|
||||
int sliderStyle;
|
||||
bool redrawParentOnScrolling;
|
||||
|
||||
std::vector<std::string> lines;
|
||||
std::vector<CAnimImage* > effects;
|
||||
CSlider *slider;
|
||||
|
||||
//CTextBox( std::string Text, const SPoint &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly);
|
||||
CTextBox(std::string Text, const SRect &rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly);
|
||||
void showAll(SDL_Surface * to); //shows statusbar (with current text)
|
||||
void setTxt(const std::string &Txt);
|
||||
void setBounds(int limitW, int limitH);
|
||||
void recalculateLines(const std::string &Txt);
|
||||
|
||||
void sliderMoved(int to);
|
||||
};
|
||||
|
||||
/// Status bar which is shown at the bottom of the in-game screens
|
||||
class CGStatusBar
|
||||
: public CLabel, public IStatusBar
|
||||
{
|
||||
void init();
|
||||
public:
|
||||
IStatusBar *oldStatusBar;
|
||||
|
||||
//statusbar interface overloads
|
||||
void print(const std::string & Text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
std::string getCurrent(); //returns currently displayed text
|
||||
void show(SDL_Surface * to); //shows statusbar (with current text)
|
||||
|
||||
CGStatusBar(int x, int y, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color &Color = zwykly, const std::string &Text = "");
|
||||
CGStatusBar(CPicture *BG, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color &Color = zwykly); //given CPicture will be captured by created sbar and it's pos will be used as pos for sbar
|
||||
CGStatusBar(int x, int y, std::string name, int maxw=-1);
|
||||
|
||||
~CGStatusBar();
|
||||
void calcOffset();
|
||||
};
|
||||
|
||||
/// UIElement which can get input focus
|
||||
class CFocusable
|
||||
: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
bool focus; //only one focusable control can have focus at one moment
|
||||
|
||||
void giveFocus(); //captures focus
|
||||
void moveFocus(); //moves focus to next active control (may be used for tab switching)
|
||||
|
||||
static std::list<CFocusable*> focusables; //all existing objs
|
||||
static CFocusable *inputWithFocus; //who has focus now
|
||||
CFocusable();
|
||||
~CFocusable();
|
||||
};
|
||||
|
||||
/// Text input box where players can enter text
|
||||
class CTextInput
|
||||
: public CLabel, public CFocusable
|
||||
{
|
||||
public:
|
||||
CFunctionList<void(const std::string &)> cb;
|
||||
|
||||
void setText(const std::string &nText, bool callCb = false);
|
||||
|
||||
CTextInput(const SRect &Pos, const SPoint &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
|
||||
CTextInput(const SRect &Pos, SDL_Surface *srf = NULL);
|
||||
~CTextInput();
|
||||
void showAll(SDL_Surface * to);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
};
|
||||
|
||||
/// Listbox UI Element
|
||||
class CList : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background bitmap
|
||||
CDefHandler *arrup, *arrdo; //button arrows for scrolling list
|
||||
SDL_Surface *empty, *selection;
|
||||
SDL_Rect arrupp, arrdop; //positions of arrows
|
||||
int posw, posh; //position width/height
|
||||
int selected, //id of selected position, <0 if none
|
||||
from;
|
||||
const int SIZE; //size of list
|
||||
tribool pressed; //true=up; false=down; indeterminate=none
|
||||
|
||||
CList(int Size = 5); //c-tor
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void activate();
|
||||
void deactivate();
|
||||
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
|
||||
virtual void genList()=0;
|
||||
virtual void select(int which)=0;
|
||||
virtual void draw(SDL_Surface * to)=0;
|
||||
virtual int size() = 0; //how many elements do we have
|
||||
void fixPos(); //scrolls list, so the selection will be visible
|
||||
};
|
||||
|
||||
/// List of heroes which is shown at the right of the adventure map screen
|
||||
class CHeroList
|
||||
: public CList
|
||||
@ -584,7 +361,7 @@ public:
|
||||
std::vector<creinfo> creatures; //recruitable creatures
|
||||
boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
|
||||
CSlider *slider; //for selecting amount
|
||||
AdventureMapButton *max, *buy, *cancel;
|
||||
CAdventureMapButton *max, *buy, *cancel;
|
||||
CPicture *bitmap; //background
|
||||
CGStatusBar *bar;
|
||||
int which; //which creature is active
|
||||
@ -613,7 +390,7 @@ public:
|
||||
CGarrisonInt *gar;
|
||||
CSlider *slider;
|
||||
CCreaturePic *animLeft, *animRight; //creature's animation
|
||||
AdventureMapButton *ok, *cancel;
|
||||
CAdventureMapButton *ok, *cancel;
|
||||
SDL_Surface *bitmap; //background
|
||||
int a1, a2, c; //TODO: comment me
|
||||
bool which; //which creature is selected
|
||||
@ -638,7 +415,7 @@ public:
|
||||
int heroPortrait;
|
||||
SDL_Surface *bitmap; //background
|
||||
std::vector<CSelectableComponent *> comps; //skills to select
|
||||
AdventureMapButton *ok;
|
||||
CAdventureMapButton *ok;
|
||||
boost::function<void(ui32)> cb;
|
||||
|
||||
void close();
|
||||
@ -672,9 +449,9 @@ public:
|
||||
CPicture *bg; //background
|
||||
CSlider *slider;
|
||||
CPicture *titleImage;//title image (castle gate\town portal picture)
|
||||
AdventureMapButton *ok, *exit;
|
||||
CAdventureMapButton *ok, *exit;
|
||||
|
||||
std::vector<SRect> areas;//areas for each visible item
|
||||
std::vector<Rect> areas;//areas for each visible item
|
||||
std::vector<int> items;//id of all items present in list
|
||||
int selected;//currently selected item
|
||||
int length;//size of list (=9)
|
||||
@ -740,7 +517,7 @@ public:
|
||||
CFunctionList<void()> callback;
|
||||
bool downSelection;
|
||||
|
||||
void showAllAt(const SPoint &dstPos, const std::string &customSub, SDL_Surface * to);
|
||||
void showAllAt(const Point &dstPos, const std::string &customSub, SDL_Surface * to);
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void hover (bool on);
|
||||
@ -762,7 +539,7 @@ public:
|
||||
EType itemsType[2];
|
||||
|
||||
EMarketMode::EMarketMode mode;//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
|
||||
AdventureMapButton *ok, *max, *deal;
|
||||
CAdventureMapButton *ok, *max, *deal;
|
||||
CSlider *slider; //for choosing amount to be exchanged
|
||||
bool readyToTrade;
|
||||
|
||||
@ -774,7 +551,7 @@ public:
|
||||
void initTypes();
|
||||
void initItems(bool Left);
|
||||
std::vector<int> *getItemsIds(bool Left); //NULL if default
|
||||
void getPositionsFor(std::vector<SRect> &poss, bool Left, EType type) const;
|
||||
void getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const;
|
||||
void removeItems(const std::set<CTradeableItem *> &toRemove);
|
||||
void removeItem(CTradeableItem * t);
|
||||
void getEmptySlots(std::set<CTradeableItem *> &toRemove);
|
||||
@ -784,7 +561,7 @@ public:
|
||||
|
||||
virtual void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const = 0;
|
||||
virtual void selectionChanged(bool side) = 0; //true == left
|
||||
virtual SPoint selectionOffset(bool Left) const = 0;
|
||||
virtual Point selectionOffset(bool Left) const = 0;
|
||||
virtual std::string selectionSubtitle(bool Left) const = 0;
|
||||
virtual void garrisonChanged() = 0;
|
||||
virtual void artifactsChanged(bool left) = 0;
|
||||
@ -805,7 +582,7 @@ public:
|
||||
CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); //c-tor
|
||||
~CMarketplaceWindow(); //d-tor
|
||||
|
||||
SPoint selectionOffset(bool Left) const;
|
||||
Point selectionOffset(bool Left) const;
|
||||
std::string selectionSubtitle(bool Left) const;
|
||||
|
||||
|
||||
@ -828,7 +605,7 @@ public:
|
||||
std::vector<int> sacrificedUnits, //[slot_nr] -> how many creatures from that slot will be sacrificed
|
||||
expPerUnit;
|
||||
|
||||
AdventureMapButton *sacrificeAll, *sacrificeBackpack;
|
||||
CAdventureMapButton *sacrificeAll, *sacrificeBackpack;
|
||||
CLabel *expToLevel, *expOnAltar;
|
||||
|
||||
|
||||
@ -846,7 +623,7 @@ public:
|
||||
void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const;
|
||||
void mimicCres();
|
||||
|
||||
SPoint selectionOffset(bool Left) const;
|
||||
Point selectionOffset(bool Left) const;
|
||||
std::string selectionSubtitle(bool Left) const;
|
||||
void garrisonChanged();
|
||||
void artifactsChanged(bool left);
|
||||
@ -863,7 +640,7 @@ class CSystemOptionsWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface * background; //background of window
|
||||
AdventureMapButton *load, *save, *restart, *mainMenu, *quitGame, *backToMap; //load and restart are not used yet
|
||||
CAdventureMapButton *load, *save, *restart, *mainMenu, *quitGame, *backToMap; //load and restart are not used yet
|
||||
CHighlightableButtonsGroup * heroMoveSpeed;
|
||||
CHighlightableButtonsGroup * mapScrollSpeed;
|
||||
CHighlightableButtonsGroup * musicVolume, * effectsVolume;
|
||||
@ -909,7 +686,7 @@ public:
|
||||
int selected;//0 (left) or 1 (right)
|
||||
int oldSelected;//0 (left) or 1 (right)
|
||||
|
||||
AdventureMapButton *thiefGuild, *cancel, *recruit;
|
||||
CAdventureMapButton *thiefGuild, *cancel, *recruit;
|
||||
const CGObjectInstance *tavernObj;
|
||||
|
||||
CTavernWindow(const CGObjectInstance *TavernObj); //c-tor
|
||||
@ -945,33 +722,6 @@ public:
|
||||
CInGameConsole(); //c-tor
|
||||
};
|
||||
|
||||
/// Shows a text by moving the mouse cursor over the object
|
||||
class HoverableArea: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
std::string hoverText;
|
||||
|
||||
virtual void hover (bool on);
|
||||
|
||||
HoverableArea();
|
||||
virtual ~HoverableArea();
|
||||
};
|
||||
|
||||
/// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
|
||||
class LRClickableAreaWText: public HoverableArea
|
||||
{
|
||||
public:
|
||||
std::string text;
|
||||
|
||||
LRClickableAreaWText();
|
||||
LRClickableAreaWText(const SRect &Pos, const std::string &HoverText = "", const std::string &ClickText = "");
|
||||
virtual ~LRClickableAreaWText();
|
||||
void init();
|
||||
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
virtual void clickRight(tribool down, bool previousState);
|
||||
};
|
||||
|
||||
/// Can interact on left and right mouse clicks
|
||||
class LRClickableAreaWTextComp: public LRClickableAreaWText
|
||||
{
|
||||
@ -981,8 +731,8 @@ public:
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
virtual void clickRight(tribool down, bool previousState);
|
||||
|
||||
LRClickableAreaWTextComp(const SRect &Pos = SRect(0,0,0,0), int BaseType = -1);
|
||||
SComponent * createComponent() const;
|
||||
LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
|
||||
CComponent * createComponent() const;
|
||||
};
|
||||
|
||||
class MoraleLuckBox : public LRClickableAreaWTextComp
|
||||
@ -994,7 +744,7 @@ public:
|
||||
void set(const IBonusBearer *node);
|
||||
void showAll(SDL_Surface * to);
|
||||
|
||||
MoraleLuckBox(bool Morale, const SRect &r, bool Small=false);
|
||||
MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
|
||||
~MoraleLuckBox();
|
||||
};
|
||||
|
||||
@ -1022,37 +772,6 @@ public:
|
||||
LRClickableAreaOpenTown();
|
||||
};
|
||||
|
||||
/// Creature info window
|
||||
class CCreInfoWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
CPicture *background;
|
||||
CLabel *creatureCount;
|
||||
CLabel *creatureName;
|
||||
CLabel *abilityText;
|
||||
|
||||
CCreaturePic *animation;
|
||||
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||
std::vector<CAnimImage * > effects;
|
||||
std::map<size_t, std::pair<CLabel*, CLabel* > > infoTexts;
|
||||
|
||||
MoraleLuckBox *luck, *morale;
|
||||
|
||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||
|
||||
CCreInfoWindow(const CStackInstance &st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);
|
||||
CCreInfoWindow(const CStack &st, bool LClicked = 0);
|
||||
CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
|
||||
~CCreInfoWindow();
|
||||
|
||||
void init(const CCreature *cre, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner, int creatureCount, bool LClicked);
|
||||
void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void close();
|
||||
void show(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// Artifacts can be placed there. Gets shown at the hero window
|
||||
class CArtPlace: public LRClickableAreaWTextComp
|
||||
{
|
||||
@ -1066,7 +785,7 @@ public:
|
||||
const CArtifactInstance * ourArt;
|
||||
|
||||
CArtPlace(const CArtifactInstance * Art); //c-tor
|
||||
CArtPlace(SPoint position, const CArtifactInstance * Art = NULL); //c-tor
|
||||
CArtPlace(Point position, const CArtifactInstance * Art = NULL); //c-tor
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void clickRight(tribool down, bool previousState);
|
||||
void select ();
|
||||
@ -1114,7 +833,7 @@ public:
|
||||
|
||||
bool updateState; // Whether the commonInfo should be updated on setHero or not.
|
||||
|
||||
AdventureMapButton * leftArtRoll, * rightArtRoll;
|
||||
CAdventureMapButton * leftArtRoll, * rightArtRoll;
|
||||
bool allowedAssembling;
|
||||
std::multiset<const CArtifactInstance*> artifactsOnAltar; //artifacts id that are technically present in backpack but in GUI are moved to the altar - they'll be omitted in backpack slots
|
||||
boost::function<void(CArtPlace*)> highlightModeCallback; //if set, clicking on art place doesn't pick artifact but highlights the slot and calls this function
|
||||
@ -1141,10 +860,10 @@ public:
|
||||
void updateSlot(int i);
|
||||
void eraseSlotData (CArtPlace* artPlace, int slotID);
|
||||
|
||||
CArtifactsOfHero(const SPoint& position, bool createCommonPart = false);
|
||||
CArtifactsOfHero(const Point& position, bool createCommonPart = false);
|
||||
//Alternative constructor, used if custom artifacts positioning required (Kingdom interface)
|
||||
CArtifactsOfHero(std::vector<CArtPlace *> ArtWorn, std::vector<CArtPlace *> Backpack,
|
||||
AdventureMapButton *leftScroll, AdventureMapButton *rightScroll, bool createCommonPart = false);
|
||||
CAdventureMapButton *leftScroll, CAdventureMapButton *rightScroll, bool createCommonPart = false);
|
||||
~CArtifactsOfHero(); //d-tor
|
||||
void updateParentWindow();
|
||||
friend class CArtPlace;
|
||||
@ -1170,7 +889,7 @@ class CGarrisonWindow : public CWindowWithGarrison
|
||||
public:
|
||||
CPicture *bg; //background surface
|
||||
CLabel *title;
|
||||
AdventureMapButton *quit;
|
||||
CAdventureMapButton *quit;
|
||||
|
||||
void close();
|
||||
void showAll(SDL_Surface * to);
|
||||
@ -1183,7 +902,7 @@ class CExchangeWindow : public CWindowWithGarrison, public CWindowWithArtifacts
|
||||
CGStatusBar * ourBar; //internal statusbar
|
||||
|
||||
SDL_Surface *bg; //background
|
||||
AdventureMapButton * quit, * questlogButton[2];
|
||||
CAdventureMapButton * quit, * questlogButton[2];
|
||||
|
||||
std::vector<LRClickableAreaWTextComp *> secSkillAreas[2], primSkillAreas;
|
||||
|
||||
@ -1225,7 +944,7 @@ public:
|
||||
CLabel *woodCost, *goldCost;
|
||||
|
||||
CAnimImage *bgShip;
|
||||
AdventureMapButton *build, *quit;
|
||||
CAdventureMapButton *build, *quit;
|
||||
|
||||
CGStatusBar * statusBar;
|
||||
|
||||
@ -1237,7 +956,7 @@ class CPuzzleWindow : public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface * background;
|
||||
AdventureMapButton * quitb;
|
||||
CAdventureMapButton * quitb;
|
||||
CResDataBar * resdatabar;
|
||||
|
||||
std::vector<std::pair<SDL_Surface *, const SPuzzleInfo *> > puzzlesToPullBack;
|
||||
@ -1277,7 +996,7 @@ public:
|
||||
CPicture *bg; //background
|
||||
std::vector<CItem*> items;
|
||||
|
||||
AdventureMapButton *all, *convert, *cancel;
|
||||
CAdventureMapButton *all, *convert, *cancel;
|
||||
CGStatusBar *bar;
|
||||
void showAll(SDL_Surface * to);
|
||||
void makeDeal();
|
||||
@ -1310,7 +1029,7 @@ public:
|
||||
CPicture *bg; //background
|
||||
std::vector<CItem*> items;
|
||||
|
||||
AdventureMapButton *cancel;
|
||||
CAdventureMapButton *cancel;
|
||||
CGStatusBar *bar;
|
||||
|
||||
CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market); //c-tor
|
||||
@ -1324,7 +1043,7 @@ public:
|
||||
CUniversityWindow * parent;
|
||||
CPicture * bg;
|
||||
CGStatusBar *bar;
|
||||
AdventureMapButton *confirm, *cancel;
|
||||
CAdventureMapButton *confirm, *cancel;
|
||||
|
||||
CUnivConfirmWindow(CUniversityWindow * PARENT, int SKILL, bool available); //c-tor
|
||||
void makeDeal(int skill);
|
||||
@ -1340,7 +1059,7 @@ public:
|
||||
CDefEssential *resources;
|
||||
CPicture *bg; //background surface
|
||||
CHeroArea *heroPic;//clickable hero image
|
||||
AdventureMapButton *quit,//closes window
|
||||
CAdventureMapButton *quit,//closes window
|
||||
*upgradeAll,//upgrade all creatures
|
||||
*upgrade[7];//upgrade single creature
|
||||
|
||||
@ -1367,7 +1086,7 @@ class CThievesGuildWindow : public CIntObject
|
||||
const CGObjectInstance * owner;
|
||||
|
||||
CGStatusBar * statusBar;
|
||||
AdventureMapButton * exitb;
|
||||
CAdventureMapButton * exitb;
|
||||
SDL_Surface * background;
|
||||
CMinorResDataBar * resdatabar;
|
||||
|
||||
@ -1380,7 +1099,3 @@ public:
|
||||
CThievesGuildWindow(const CGObjectInstance * _owner);
|
||||
~CThievesGuildWindow();
|
||||
};
|
||||
|
||||
CIntObject *createCreWindow(const CStack *s);
|
||||
CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
|
||||
CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Graphics.h"
|
||||
|
||||
#include "CDefHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include <SDL_ttf.h>
|
||||
#include "../lib/CThreadHelper.h"
|
||||
#include "CGameInfo.h"
|
||||
@ -50,7 +50,7 @@ SDL_Surface * Graphics::drawHeroInfoWin(const InfoAboutHero &curh)
|
||||
SDL_Surface * ret = SDL_DisplayFormat(hInfo);
|
||||
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255));
|
||||
|
||||
printAt(curh.name,75,13,FONT_SMALL,zwykly,ret); //name
|
||||
printAt(curh.name,75,13,FONT_SMALL,Colors::Cornsilk,ret); //name
|
||||
blitAt(graphics->portraitLarge[curh.portrait],11,12,ret); //portrait
|
||||
|
||||
//army
|
||||
@ -60,11 +60,11 @@ SDL_Surface * Graphics::drawHeroInfoWin(const InfoAboutHero &curh)
|
||||
if(curh.details)
|
||||
{
|
||||
SDL_itoa((*i).second.count,buf,10);
|
||||
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,zwykly,ret);
|
||||
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,Colors::Cornsilk,ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
printAtMiddle(VLC->generaltexth->arraytxt[174 + 3*(i->second.count)],slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,zwykly,ret);
|
||||
printAtMiddle(VLC->generaltexth->arraytxt[174 + 3*(i->second.count)],slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,Colors::Cornsilk,ret);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,12 +73,12 @@ SDL_Surface * Graphics::drawHeroInfoWin(const InfoAboutHero &curh)
|
||||
for (int i = 0; i < GameConstants::PRIMARY_SKILLS; i++)
|
||||
{
|
||||
SDL_itoa(curh.details->primskills[i], buf, 10);
|
||||
printAtMiddle(buf,84+28*i,70,FONT_SMALL,zwykly,ret);
|
||||
printAtMiddle(buf,84+28*i,70,FONT_SMALL,Colors::Cornsilk,ret);
|
||||
}
|
||||
|
||||
//mana points
|
||||
SDL_itoa(curh.details->mana,buf,10);
|
||||
printAtMiddle(buf,167,108,FONT_TINY,zwykly,ret);
|
||||
printAtMiddle(buf,167,108,FONT_TINY,Colors::Cornsilk,ret);
|
||||
|
||||
blitAt(morale22->ourImages[curh.details->morale+3].bitmap,14,84,ret); //luck
|
||||
blitAt(luck22->ourImages[curh.details->morale+3].bitmap,14,101,ret); //morale
|
||||
@ -107,7 +107,7 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh )
|
||||
SDL_Surface * ret = SDL_DisplayFormat(tInfo);
|
||||
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255));
|
||||
|
||||
printAt(curh.name,75,12,FONT_SMALL,zwykly,ret); //name
|
||||
printAt(curh.name,75,12,FONT_SMALL,Colors::Cornsilk,ret); //name
|
||||
int pom = curh.fortLevel - 1; if(pom<0) pom = 3; //fort pic id
|
||||
blitAt(forts->ourImages[pom].bitmap,115,42,ret); //fort
|
||||
|
||||
@ -120,14 +120,14 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh )
|
||||
{
|
||||
// Show exact creature amount.
|
||||
SDL_itoa((*i).second.count,buf,10);
|
||||
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,zwykly,ret);
|
||||
printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,Colors::Cornsilk,ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show only a rough amount for creature stacks.
|
||||
// TODO: Deal with case when no information at all about size shold be presented.
|
||||
std::string roughAmount = curh.obj->getRoughAmount(i->first);
|
||||
printAtMiddle(roughAmount,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,zwykly,ret);
|
||||
printAtMiddle(roughAmount,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+41,FONT_TINY,Colors::Cornsilk,ret);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh )
|
||||
|
||||
if (curh.details->goldIncome >= 0) {
|
||||
SDL_itoa(curh.details->goldIncome, buf, 10); //gold income
|
||||
printAtMiddle(buf, 167, 70, FONT_TINY, zwykly, ret);
|
||||
printAtMiddle(buf, 167, 70, FONT_TINY, Colors::Cornsilk, ret);
|
||||
}
|
||||
if(curh.details->garrisonedHero) //garrisoned hero icon
|
||||
blitAt(graphics->heroInGarrison,158,87,ret);
|
||||
@ -365,7 +365,7 @@ void Graphics::loadWallPositions()
|
||||
int townID = town["id"].Float();
|
||||
|
||||
BOOST_FOREACH(const JsonNode &coords, town["pos"].Vector()) {
|
||||
SPoint pt(coords["x"].Float(), coords["y"].Float());
|
||||
Point pt(coords["x"].Float(), coords["y"].Float());
|
||||
wallPositions[townID].push_back(pt);
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,7 @@
|
||||
|
||||
#include "FontBase.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "UIFramework/SPoint.h"
|
||||
#include "UIFramework/SRect.h"
|
||||
#include "UIFramework/Geometries.h"
|
||||
|
||||
/*
|
||||
* Graphics.h, part of VCMI engine
|
||||
@ -87,7 +86,7 @@ public:
|
||||
std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle
|
||||
std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
|
||||
CDefEssential * spellEffectsPics; //bitmaps representing spells affecting a stack in battle
|
||||
std::vector< SPoint > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall <x, y>
|
||||
std::vector< Point > wallPositions[GameConstants::F_NUMBER]; //positions of different pieces of wall <x, y>
|
||||
//abilities
|
||||
CDefEssential * abils32, * abils44, * abils82;
|
||||
//spells
|
||||
|
@ -9,59 +9,26 @@ vcmiclient_LDFLAGS = -L$(top_builddir)/lib
|
||||
vcmiclient_SOURCES = \
|
||||
../CCallback.cpp \
|
||||
../CCallback.h \
|
||||
./BattleInterface/CAttackAnimation.cpp \
|
||||
./BattleInterface/CAttackAnimation.h \
|
||||
./BattleInterface/CBattleAnimation.cpp \
|
||||
./BattleInterface/CBattleAnimation.h \
|
||||
./BattleInterface/CBattleConsole.cpp \
|
||||
./BattleInterface/CBattleConsole.h \
|
||||
./BattleInterface/CBattleHero.cpp \
|
||||
./BattleInterface/CBattleHero.h \
|
||||
./BattleInterface/CBattleAnimations.cpp \
|
||||
./BattleInterface/CBattleAnimations.h \
|
||||
./BattleInterface/CBattleInterface.cpp \
|
||||
./BattleInterface/CBattleInterface.h \
|
||||
./BattleInterface/CBattleOptionsWindow.cpp \
|
||||
./BattleInterface/CBattleOptionsWindow.h \
|
||||
./BattleInterface/CBattleResultWindow.cpp \
|
||||
./BattleInterface/CBattleResultWindow.h \
|
||||
./BattleInterface/CBattleStackAnimation.cpp \
|
||||
./BattleInterface/CBattleStackAnimation.h \
|
||||
./BattleInterface/CBattleInterfaceClasses.cpp \
|
||||
./BattleInterface/CBattleInterfaceClasses.h \
|
||||
./BattleInterface/CCreatureAnimation.h \
|
||||
./BattleInterface/CCreatureAnimation.cpp \
|
||||
./BattleInterface/CDefenceAnimation.cpp \
|
||||
./BattleInterface/CDefenceAnimation.h \
|
||||
./BattleInterface/CDummyAnimation.cpp \
|
||||
./BattleInterface/CDummyAnimation.h \
|
||||
./BattleInterface/CClickableHex.cpp \
|
||||
./BattleInterface/CClickableHex.h \
|
||||
./BattleInterface/CMeleeAttackAnimation.cpp \
|
||||
./BattleInterface/CMeleeAttackAnimation.h \
|
||||
./BattleInterface/CMovementAnimation.cpp \
|
||||
./BattleInterface/CMovementAnimation.h \
|
||||
./BattleInterface/CMovementEndAnimation.cpp \
|
||||
./BattleInterface/CMovementEndAnimation.h \
|
||||
./BattleInterface/CMovementStartAnimation.cpp \
|
||||
./BattleInterface/CMovementStartAnimation.h \
|
||||
./BattleInterface/CReverseAnimation.cpp \
|
||||
./BattleInterface/CReverseAnimation.h \
|
||||
./BattleInterface/CShootingAnimation.cpp \
|
||||
./BattleInterface/CShootingAnimation.h \
|
||||
./BattleInterface/CSpellEffectAnimation.cpp \
|
||||
./BattleInterface/CSpellEffectAnimation.h \
|
||||
./BattleInterface/CStackQueue.cpp \
|
||||
./BattleInterface/CStackQueue.h \
|
||||
./BattleInterface/SStackAttackedInfo.h \
|
||||
./UIFramework/CGuiHandler.cpp \
|
||||
./UIFramework/CGuiHandler.h \
|
||||
./UIFramework/CIntObject.cpp \
|
||||
./UIFramework/CIntObject.h \
|
||||
./UIFramework/CKeyShortcut.cpp \
|
||||
./UIFramework/CKeyShortcut.h \
|
||||
./UIFramework/CPicture.cpp \
|
||||
./UIFramework/CPicture.h \
|
||||
./UIFramework/SRect.cpp \
|
||||
./UIFramework/SRect.h \
|
||||
AdventureMapButton.cpp \
|
||||
AdventureMapButton.h \
|
||||
./UIFramework/CIntObjectClasses.cpp \
|
||||
./UIFramework/CIntObjectClasses.h \
|
||||
./UIFramework/Geometries.cpp \
|
||||
./UIFramework/Geometries.h \
|
||||
./UIFramework/CCursorHandler.cpp \
|
||||
./UIFramework/CCursorHandler.h \
|
||||
./UIFramework/SDL_Extensions.cpp \
|
||||
./UIFramework/SDL_Extensions.h \
|
||||
CAdvmapInterface.cpp \
|
||||
CAdvmapInterface.h \
|
||||
CAnimation.cpp \
|
||||
@ -74,8 +41,6 @@ vcmiclient_SOURCES = \
|
||||
CConfigHandler.h \
|
||||
CCreatureWindow.cpp \
|
||||
CCreatureWindow.h \
|
||||
CCursorHandler.cpp \
|
||||
CCursorHandler.h \
|
||||
CDefHandler.cpp \
|
||||
CDefHandler.h \
|
||||
CGameInfo.cpp \
|
||||
@ -111,8 +76,4 @@ vcmiclient_SOURCES = \
|
||||
GUIClasses.h \
|
||||
mapHandler.cpp \
|
||||
mapHandler.h \
|
||||
NetPacksClient.cpp \
|
||||
SDL_Extensions.cpp \
|
||||
SDL_Extensions.h \
|
||||
SDL_framerate.cpp \
|
||||
SDL_framerate.h
|
||||
NetPacksClient.cpp
|
@ -18,7 +18,7 @@
|
||||
#include "mapHandler.h"
|
||||
#include "GUIClasses.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "UIFramework/SDL_Extensions.h"
|
||||
#include "BattleInterface/CBattleInterface.h"
|
||||
#include "../lib/CCampaignHandler.h"
|
||||
#include "../lib/CGameState.h"
|
||||
@ -766,7 +766,7 @@ void SetSelection::applyCl(CClient *cl)
|
||||
|
||||
void ShowInInfobox::applyCl(CClient *cl)
|
||||
{
|
||||
SComponent sc(c);
|
||||
CComponent sc(c);
|
||||
text.toString(sc.description);
|
||||
if(vstd::contains(cl->playerint, player) && cl->playerint[player]->human)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "StdInc.h"
|
||||
#include "CCursorHandler.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include <SDL.h>
|
||||
#include "SDL_Extensions.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "CDefHandler.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CDefHandler.h"
|
||||
|
||||
/*
|
||||
* CCursorHandler.cpp, part of VCMI engine
|
@ -1,26 +1,17 @@
|
||||
#include "StdInc.h"
|
||||
#include "CGuiHandler.h"
|
||||
|
||||
#include "IShowActivatable.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "CIntObject.h"
|
||||
#include "../CGameInfo.h"
|
||||
#include "../CCursorHandler.h"
|
||||
#include "CCursorHandler.h"
|
||||
#include "../../lib/CThreadHelper.h"
|
||||
#include "../CConfigHandler.h"
|
||||
#include "../SDL_framerate.h"
|
||||
#include "IUpdateable.h"
|
||||
|
||||
extern SDL_Surface * screenBuf, * screen2, * screen;
|
||||
extern std::queue<SDL_Event*> events;
|
||||
extern boost::mutex eventsM;
|
||||
|
||||
SDL_Color Colors::createColor(int r, int g, int b)
|
||||
{
|
||||
SDL_Color temp = {r, g, b, 0};
|
||||
return temp;
|
||||
}
|
||||
|
||||
SObjectConstruction::SObjectConstruction( CIntObject *obj )
|
||||
:myObj(obj)
|
||||
{
|
||||
@ -372,7 +363,7 @@ CGuiHandler::CGuiHandler()
|
||||
statusbar = NULL;
|
||||
|
||||
// Creates the FPS manager and sets the framerate to 48 which is doubled the value of the original Heroes 3 FPS rate
|
||||
mainFPSmng = new FPSManager(48);
|
||||
mainFPSmng = new CFramerateManager(48);
|
||||
mainFPSmng->init(); // resets internal clock, needed for FPS manager
|
||||
}
|
||||
|
||||
@ -458,4 +449,32 @@ bool CGuiHandler::isNumKey( SDLKey key, bool number )
|
||||
bool CGuiHandler::isArrowKey( SDLKey key )
|
||||
{
|
||||
return key >= SDLK_UP && key <= SDLK_LEFT;
|
||||
}
|
||||
|
||||
|
||||
CFramerateManager::CFramerateManager(int rate)
|
||||
{
|
||||
this->rate = rate;
|
||||
this->rateticks = (1000.0 / rate);
|
||||
this->fps = 0;
|
||||
}
|
||||
|
||||
void CFramerateManager::init()
|
||||
{
|
||||
this->lastticks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
void CFramerateManager::framerateDelay()
|
||||
{
|
||||
ui32 currentTicks = SDL_GetTicks();
|
||||
this->timeElapsed = currentTicks - this->lastticks;
|
||||
|
||||
// FPS is higher than it should be, then wait some time
|
||||
if (this->timeElapsed < this->rateticks)
|
||||
{
|
||||
SDL_Delay(ceil(this->rateticks) - this->timeElapsed);
|
||||
}
|
||||
|
||||
this->fps = ceil(1000.0 / this->timeElapsed);
|
||||
this->lastticks = SDL_GetTicks();
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../lib/CStopWatch.h"
|
||||
#include "SPoint.h"
|
||||
#include "Geometries.h"
|
||||
|
||||
class FPSManager;
|
||||
class CFramerateManager;
|
||||
class IStatusBar;
|
||||
class CIntObject;
|
||||
class IUpdateable;
|
||||
@ -20,11 +20,28 @@ class IShowable;
|
||||
*
|
||||
*/
|
||||
|
||||
// A fps manager which holds game updates at a constant rate
|
||||
class CFramerateManager
|
||||
{
|
||||
private:
|
||||
double rateticks;
|
||||
ui32 lastticks, timeElapsed;
|
||||
int rate;
|
||||
|
||||
public:
|
||||
int fps; // the actual fps value
|
||||
|
||||
CFramerateManager(int rate); // initializes the manager with a given fps rate
|
||||
void init(); // needs to be called directly before the main game loop to reset the internal timer
|
||||
void framerateDelay(); // needs to be called every game update cycle
|
||||
double getElapsedSeconds() const { return this->timeElapsed / 1000; }
|
||||
};
|
||||
|
||||
// Handles GUI logic and drawing
|
||||
class CGuiHandler
|
||||
{
|
||||
public:
|
||||
FPSManager * mainFPSmng; //to keep const framerate
|
||||
CFramerateManager * mainFPSmng; //to keep const framerate
|
||||
CStopWatch th;
|
||||
std::list<IShowActivatable *> listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on)
|
||||
IStatusBar * statusbar;
|
||||
@ -45,7 +62,7 @@ public:
|
||||
SDL_Event * current; //current event - can be set to NULL to stop handling event
|
||||
IUpdateable *curInt;
|
||||
|
||||
SPoint lastClick;
|
||||
Point lastClick;
|
||||
unsigned lastClickTime;
|
||||
bool terminate;
|
||||
|
||||
@ -105,10 +122,7 @@ struct SSetCaptureState
|
||||
|
||||
namespace Colors
|
||||
{
|
||||
SDL_Color createColor(int r, int g, int b);
|
||||
|
||||
const SDL_Color MetallicGold = createColor(173, 142, 66);
|
||||
const SDL_Color Yellow = createColor(242, 226, 110);
|
||||
|
||||
};
|
||||
|
||||
#define OBJ_CONSTRUCTION SObjectConstruction obj__i(this)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "CIntObject.h"
|
||||
#include "CGuiHandler.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "SDL_Extensions.h"
|
||||
|
||||
void CIntObject::activateLClick()
|
||||
{
|
||||
@ -139,7 +139,7 @@ CIntObject::CIntObject()
|
||||
parent = NULL;
|
||||
}
|
||||
|
||||
void CIntObject::show( SDL_Surface * to )
|
||||
void CIntObject::show(SDL_Surface * to)
|
||||
{
|
||||
if(defActions & UPDATE)
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
@ -147,7 +147,7 @@ void CIntObject::show( SDL_Surface * to )
|
||||
children[i]->show(to);
|
||||
}
|
||||
|
||||
void CIntObject::showAll( SDL_Surface * to )
|
||||
void CIntObject::showAll(SDL_Surface * to)
|
||||
{
|
||||
if(defActions & SHOWALL)
|
||||
{
|
||||
@ -239,17 +239,17 @@ CIntObject::~CIntObject()
|
||||
parent->children -= this;
|
||||
}
|
||||
|
||||
void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
void CIntObject::printAtLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=Colors::Cornsilk*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
CSDL_Ext::printAt(text, pos.x + x, pos.y + y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=zwykly*/, SDL_Surface * dst/*=screen*/ )
|
||||
void CIntObject::printAtMiddleLoc( const std::string & text, int x, int y, EFonts font, SDL_Color kolor/*=Colors::Cornsilk*/, SDL_Surface * dst/*=screen*/ )
|
||||
{
|
||||
CSDL_Ext::printAtMiddle(text, pos.x + x, pos.y + y, font, kolor, dst);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const SPoint &p, EFonts font, SDL_Color kolor, SDL_Surface * dst)
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst)
|
||||
{
|
||||
printAtMiddleLoc(text, p.x, p.y, font, kolor, dst);
|
||||
}
|
||||
@ -259,7 +259,7 @@ void CIntObject::blitAtLoc( SDL_Surface * src, int x, int y, SDL_Surface * dst )
|
||||
blitAt(src, pos.x + x, pos.y + y, dst);
|
||||
}
|
||||
|
||||
void CIntObject::blitAtLoc(SDL_Surface * src, const SPoint &p, SDL_Surface * dst)
|
||||
void CIntObject::blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst)
|
||||
{
|
||||
blitAtLoc(src, p.x, p.y, dst);
|
||||
}
|
||||
@ -295,7 +295,7 @@ bool CIntObject::isItInLoc( const SDL_Rect &rect, int x, int y )
|
||||
return isItIn(&rect, x - pos.x, y - pos.y);
|
||||
}
|
||||
|
||||
bool CIntObject::isItInLoc( const SDL_Rect &rect, const SPoint &p )
|
||||
bool CIntObject::isItInLoc( const SDL_Rect &rect, const Point &p )
|
||||
{
|
||||
return isItIn(&rect, p.x - pos.x, p.y - pos.y);
|
||||
}
|
||||
@ -338,7 +338,7 @@ void CIntObject::onDoubleClick()
|
||||
|
||||
void CIntObject::fitToScreen(int borderWidth, bool propagate)
|
||||
{
|
||||
SPoint newPos = pos.topLeft();
|
||||
Point newPos = pos.topLeft();
|
||||
vstd::amax(newPos.x, borderWidth);
|
||||
vstd::amax(newPos.y, borderWidth);
|
||||
vstd::amin(newPos.x, screen->w - borderWidth - pos.w);
|
||||
@ -347,7 +347,7 @@ void CIntObject::fitToScreen(int borderWidth, bool propagate)
|
||||
moveTo(newPos, propagate);
|
||||
}
|
||||
|
||||
void CIntObject::moveBy( const SPoint &p, bool propagate /*= true*/ )
|
||||
void CIntObject::moveBy( const Point &p, bool propagate /*= true*/ )
|
||||
{
|
||||
pos.x += p.x;
|
||||
pos.y += p.y;
|
||||
@ -356,9 +356,9 @@ void CIntObject::moveBy( const SPoint &p, bool propagate /*= true*/ )
|
||||
children[i]->moveBy(p, propagate);
|
||||
}
|
||||
|
||||
void CIntObject::moveTo( const SPoint &p, bool propagate /*= true*/ )
|
||||
void CIntObject::moveTo( const Point &p, bool propagate /*= true*/ )
|
||||
{
|
||||
moveBy(SPoint(p.x - pos.x, p.y - pos.y), propagate);
|
||||
moveBy(Point(p.x - pos.x, p.y - pos.y), propagate);
|
||||
}
|
||||
|
||||
void CIntObject::delChild(CIntObject *child)
|
||||
@ -403,7 +403,7 @@ void CIntObject::changeUsedEvents(ui16 what, bool enable, bool adjust /*= true*/
|
||||
}
|
||||
}
|
||||
|
||||
void CIntObject::drawBorderLoc(SDL_Surface * sur, const SRect &r, const int3 &color)
|
||||
void CIntObject::drawBorderLoc(SDL_Surface * sur, const Rect &r, const int3 &color)
|
||||
{
|
||||
CSDL_Ext::drawBorder(sur, r + pos, color);
|
||||
}
|
||||
@ -422,22 +422,40 @@ void CIntObject::redraw()
|
||||
}
|
||||
}
|
||||
|
||||
const SRect & CIntObject::center( const SRect &r, bool propagate )
|
||||
const Rect & CIntObject::center( const Rect &r, bool propagate )
|
||||
{
|
||||
pos.w = r.w;
|
||||
pos.h = r.h;
|
||||
return center(SPoint(screen->w/2, screen->h/2), propagate);
|
||||
return center(Point(screen->w/2, screen->h/2), propagate);
|
||||
}
|
||||
|
||||
const SRect & CIntObject::center( bool propagate )
|
||||
const Rect & CIntObject::center( bool propagate )
|
||||
{
|
||||
return center(pos, propagate);
|
||||
}
|
||||
|
||||
const SRect & CIntObject::center(const SPoint &p, bool propagate /*= true*/)
|
||||
const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/)
|
||||
{
|
||||
moveBy(SPoint(p.x - pos.w/2 - pos.x,
|
||||
moveBy(Point(p.x - pos.w/2 - pos.x,
|
||||
p.y - pos.h/2 - pos.y),
|
||||
propagate);
|
||||
return pos;
|
||||
}
|
||||
|
||||
void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(vstd::contains(assignedKeys,key.keysym.sym))
|
||||
{
|
||||
bool prev = pressedL;
|
||||
if(key.state == SDL_PRESSED)
|
||||
{
|
||||
pressedL = true;
|
||||
clickLeft(true, prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
pressedL = false;
|
||||
clickLeft(false, prev);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_events.h>
|
||||
#include "IShowActivatable.h"
|
||||
#include "SRect.h"
|
||||
#include "Geometries.h"
|
||||
#include "../FontBase.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
@ -19,6 +18,56 @@ struct SDL_Surface;
|
||||
|
||||
using boost::logic::tribool;
|
||||
|
||||
// Defines a activate/deactive method
|
||||
class IActivatable
|
||||
{
|
||||
public:
|
||||
virtual void activate()=0;
|
||||
virtual void deactivate()=0;
|
||||
virtual ~IActivatable(){}; //d-tor
|
||||
};
|
||||
|
||||
class IUpdateable
|
||||
{
|
||||
public:
|
||||
virtual void update()=0;
|
||||
virtual ~IUpdateable(){}; //d-tor
|
||||
};
|
||||
|
||||
// Defines a show method
|
||||
class IShowable
|
||||
{
|
||||
public:
|
||||
virtual void redraw()=0;
|
||||
virtual void show(SDL_Surface * to) = 0;
|
||||
virtual void showAll(SDL_Surface * to)
|
||||
{
|
||||
show(to);
|
||||
}
|
||||
virtual ~IShowable(){}; //d-tor
|
||||
};
|
||||
|
||||
class IShowActivatable : public IShowable, public IActivatable
|
||||
{
|
||||
public:
|
||||
//redraw parent flag - this int may be semi-transparent and require redraw of parent window
|
||||
enum {WITH_GARRISON = 1, BLOCK_ADV_HOTKEYS = 2, WITH_ARTIFACTS = 4, REDRAW_PARENT=8};
|
||||
int type; //bin flags using etype
|
||||
IShowActivatable();
|
||||
virtual ~IShowActivatable(){}; //d-tor
|
||||
};
|
||||
|
||||
// Status bar interface
|
||||
class IStatusBar
|
||||
{
|
||||
public:
|
||||
virtual ~IStatusBar(){}; //d-tor
|
||||
virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
|
||||
virtual void clear()=0;//clears statusbar and refreshes
|
||||
virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text)
|
||||
virtual std::string getCurrent()=0; //returns currently displayed text
|
||||
};
|
||||
|
||||
// Base UI element
|
||||
class CIntObject : public IShowActivatable //interface object
|
||||
{
|
||||
@ -26,7 +75,7 @@ public:
|
||||
CIntObject *parent; //parent object
|
||||
std::vector<CIntObject *> children;
|
||||
|
||||
SRect pos, //position of object on the screen
|
||||
Rect pos, //position of object on the screen
|
||||
posRelative; //position of object in the parent (not used if no parent)
|
||||
|
||||
CIntObject();
|
||||
@ -100,22 +149,22 @@ public:
|
||||
void showAll(SDL_Surface * to);
|
||||
void redraw();
|
||||
|
||||
void drawBorderLoc(SDL_Surface * sur, const SRect &r, const int3 &color);
|
||||
void drawBorderLoc(SDL_Surface * sur, const Rect &r, const int3 &color);
|
||||
void printAtLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printToLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, int x, int y, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, const SPoint &p, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst);
|
||||
void printAtMiddleWBLoc(const std::string & text, int x, int y, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst);
|
||||
void blitAtLoc(SDL_Surface * src, int x, int y, SDL_Surface * dst);
|
||||
void blitAtLoc(SDL_Surface * src, const SPoint &p, SDL_Surface * dst);
|
||||
void blitAtLoc(SDL_Surface * src, const Point &p, SDL_Surface * dst);
|
||||
bool isItInLoc(const SDL_Rect &rect, int x, int y);
|
||||
bool isItInLoc(const SDL_Rect &rect, const SPoint &p);
|
||||
const SRect & center(const SRect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position
|
||||
const SRect & center(const SPoint &p, bool propagate = true); //moves object so that point p will be in its center
|
||||
const SRect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position
|
||||
bool isItInLoc(const SDL_Rect &rect, const Point &p);
|
||||
const Rect & center(const Rect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position
|
||||
const Rect & center(const Point &p, bool propagate = true); //moves object so that point p will be in its center
|
||||
const Rect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position
|
||||
void fitToScreen(int borderWidth, bool propagate = true); //moves window to fit into screen
|
||||
void moveBy(const SPoint &p, bool propagate = true);
|
||||
void moveTo(const SPoint &p, bool propagate = true);
|
||||
void moveBy(const Point &p, bool propagate = true);
|
||||
void moveTo(const Point &p, bool propagate = true);
|
||||
void changeUsedEvents(ui16 what, bool enable, bool adjust = true);
|
||||
|
||||
void addChild(CIntObject *child, bool adjustPosition = false);
|
||||
@ -132,4 +181,16 @@ public:
|
||||
delChild(child);
|
||||
child = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
/// Class for binding keys to left mouse button clicks
|
||||
/// Classes wanting use it should have it as one of their base classes
|
||||
class CKeyShortcut : public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
std::set<int> assignedKeys;
|
||||
CKeyShortcut(){}; //c-tor
|
||||
CKeyShortcut(int key){assignedKeys.insert(key);}; //c-tor
|
||||
CKeyShortcut(std::set<int> Keys):assignedKeys(Keys){}; //c-tor
|
||||
virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in
|
||||
};
|
1490
client/UIFramework/CIntObjectClasses.cpp
Normal file
1490
client/UIFramework/CIntObjectClasses.cpp
Normal file
File diff suppressed because it is too large
Load Diff
450
client/UIFramework/CIntObjectClasses.h
Normal file
450
client/UIFramework/CIntObjectClasses.h
Normal file
@ -0,0 +1,450 @@
|
||||
#pragma once
|
||||
|
||||
#include "CIntObject.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "../FunctionList.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
struct Rect;
|
||||
class CAnimImage;
|
||||
class CLabel;
|
||||
class CAnimation;
|
||||
class CDefHandler;
|
||||
|
||||
/*
|
||||
* CPicture.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Window GUI class
|
||||
class CSimpleWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bitmap; //background
|
||||
virtual void show(SDL_Surface * to);
|
||||
CSimpleWindow():bitmap(NULL){}; //c-tor
|
||||
virtual ~CSimpleWindow(); //d-tor
|
||||
};
|
||||
|
||||
// Image class
|
||||
class CPicture : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg;
|
||||
Rect * srcRect; //if NULL then whole surface will be used
|
||||
bool freeSurf; //whether surface will be freed upon CPicture destruction
|
||||
bool needRefresh;//Surface needs to be displayed each frame
|
||||
|
||||
operator SDL_Surface*()
|
||||
{
|
||||
return bg;
|
||||
}
|
||||
|
||||
CPicture(const Rect & r, const SDL_Color & color, bool screenFormat = false); //rect filled with given color
|
||||
CPicture(const Rect & r, ui32 color, bool screenFormat = false); //rect filled with given color
|
||||
CPicture(SDL_Surface * BG, int x = 0, int y=0, bool Free = true); //wrap existing SDL_Surface
|
||||
CPicture(const std::string &bmpname, int x=0, int y=0);
|
||||
CPicture(SDL_Surface *BG, const Rect &SrcRext, int x = 0, int y = 0, bool free = false); //wrap subrect of given surface
|
||||
~CPicture();
|
||||
void init();
|
||||
|
||||
void createSimpleRect(const Rect &r, bool screenFormat, ui32 color);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void convertToScreenBPP();
|
||||
void colorizeAndConvert(int player);
|
||||
void colorize(int player);
|
||||
};
|
||||
|
||||
namespace config{struct ButtonInfo;}
|
||||
|
||||
/// Base class for buttons.
|
||||
class CButtonBase : public CKeyShortcut
|
||||
{
|
||||
public:
|
||||
enum ButtonState
|
||||
{
|
||||
NORMAL=0,
|
||||
PRESSED=1,
|
||||
BLOCKED=2,
|
||||
HIGHLIGHTED=3
|
||||
};
|
||||
private:
|
||||
int bitmapOffset; // base offset of visible bitmap from animation
|
||||
ButtonState state;//current state of button from enum
|
||||
|
||||
public:
|
||||
bool swappedImages,//fix for some buttons: normal and pressed image are swapped
|
||||
keepFrame; // don't change visual representation
|
||||
|
||||
void addTextOverlay(const std::string &Text, EFonts font, SDL_Color color = Colors::Cornsilk);
|
||||
void update();//to refresh button after image or text change
|
||||
|
||||
void setOffset(int newOffset);
|
||||
void setState(ButtonState newState);
|
||||
ButtonState getState();
|
||||
|
||||
//just to make code clearer
|
||||
void block(bool on);
|
||||
bool isBlocked();
|
||||
bool isHighlighted();
|
||||
|
||||
CAnimImage * image; //image for this button
|
||||
CLabel * text;//text overlay
|
||||
|
||||
CButtonBase(); //c-tor
|
||||
virtual ~CButtonBase(); //d-tor
|
||||
};
|
||||
|
||||
/// Typical Heroes 3 button which can be inactive or active and can
|
||||
/// hold further information if you right-click it
|
||||
class CAdventureMapButton : public CButtonBase
|
||||
{
|
||||
std::vector<std::string> imageNames;//store list of images that can be used by this button
|
||||
size_t currentImage;
|
||||
public:
|
||||
std::map<int, std::string> hoverTexts; //text for statusbar
|
||||
std::string helpBox; //for right-click help
|
||||
CFunctionList<void()> callback;
|
||||
bool actOnDown,//runs when mouse is pressed down over it, not when up
|
||||
hoverable,//if true, button will be highlighted when hovered
|
||||
borderEnabled,
|
||||
soundDisabled;
|
||||
SDL_Color borderColor;
|
||||
|
||||
void clickRight(tribool down, bool previousState);
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
void hover (bool on);
|
||||
|
||||
CAdventureMapButton(); //c-tor
|
||||
CAdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
CAdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
|
||||
CAdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key=0);//c-tor
|
||||
|
||||
void init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key );
|
||||
|
||||
void setIndex(size_t index, bool playerColoredButton=false);
|
||||
void setImage(CAnimation* anim, bool playerColoredButton=false);
|
||||
void setPlayerColor(int player);
|
||||
void showAll(SDL_Surface * to);
|
||||
};
|
||||
|
||||
/// A button which can be selected/deselected
|
||||
class CHighlightableButton
|
||||
: public CAdventureMapButton
|
||||
{
|
||||
public:
|
||||
CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key=0);
|
||||
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);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
};
|
||||
|
||||
/// A group of buttons where one button can be selected
|
||||
class CHighlightableButtonsGroup : public CIntObject
|
||||
{
|
||||
public:
|
||||
CFunctionList2<void(int)> onChange; //called when changing selected button with new button's id
|
||||
std::vector<CHighlightableButton*> buttons;
|
||||
bool musicLike; //determines the behaviour of this group
|
||||
|
||||
//void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid);
|
||||
void addButton(CHighlightableButton* bt);//add existing button, it'll be deleted by CHighlightableButtonsGroup destructor
|
||||
void addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect=0, int key=0); //creates new button
|
||||
CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons = false);
|
||||
~CHighlightableButtonsGroup();
|
||||
void select(int id, bool mode); //mode==0: id is serial; mode==1: id is unique button id
|
||||
void selectionChanged(int to);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void block(ui8 on);
|
||||
};
|
||||
|
||||
/// A typical slider which can be orientated horizontally/vertically.
|
||||
class CSlider : public CIntObject
|
||||
{
|
||||
public:
|
||||
CAdventureMapButton *left, *right, *slider; //if vertical then left=up
|
||||
int capacity,//how many elements can be active at same time
|
||||
amount, //how many elements
|
||||
positions, //number of highest position (0 if there is only one)
|
||||
value; //first active element
|
||||
bool horizontal;
|
||||
bool wheelScrolling;
|
||||
bool keyScrolling;
|
||||
|
||||
boost::function<void(int)> moved;
|
||||
|
||||
void redrawSlider();
|
||||
void sliderClicked();
|
||||
void moveLeft();
|
||||
void moveRight();
|
||||
void moveTo(int to);
|
||||
void block(bool on);
|
||||
void setAmount(int to);
|
||||
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void wheelScrolled(bool down, bool in);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
void showAll(SDL_Surface * to);
|
||||
|
||||
CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount,
|
||||
int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue
|
||||
~CSlider();
|
||||
void moveToMax();
|
||||
};
|
||||
|
||||
/// Used as base for Tabs and List classes
|
||||
class CObjectList : public CIntObject
|
||||
{
|
||||
public:
|
||||
typedef boost::function<CIntObject* (size_t)> CreateFunc;
|
||||
typedef boost::function<void(CIntObject *)> DestroyFunc;
|
||||
|
||||
private:
|
||||
CreateFunc createObject;
|
||||
DestroyFunc destroyObject;
|
||||
|
||||
protected:
|
||||
//Internal methods for safe creation of items (Children capturing and activation/deactivation if needed)
|
||||
void deleteItem(CIntObject* item);
|
||||
CIntObject* createItem(size_t index);
|
||||
|
||||
CObjectList(CreateFunc create, DestroyFunc destroy = DestroyFunc());//Protected constructor
|
||||
};
|
||||
|
||||
/// Window element with multiple tabs
|
||||
class CTabbedInt : public CObjectList
|
||||
{
|
||||
private:
|
||||
CIntObject * activeTab;
|
||||
size_t activeID;
|
||||
|
||||
public:
|
||||
//CreateFunc, DestroyFunc - see CObjectList
|
||||
//Pos - position of object, all tabs will be moved to this position
|
||||
//ActiveID - ID of initially active tab
|
||||
CTabbedInt(CreateFunc create, DestroyFunc destroy = DestroyFunc(), Point position=Point(), size_t ActiveID=0);
|
||||
|
||||
void setActive(size_t which);
|
||||
//recreate active tab
|
||||
void reset();
|
||||
|
||||
//return currently active item
|
||||
CIntObject * getItem();
|
||||
};
|
||||
|
||||
/// List of IntObjects with optional slider
|
||||
class CListBox : public CObjectList
|
||||
{
|
||||
private:
|
||||
std::list< CIntObject* > items;
|
||||
size_t first;
|
||||
size_t totalSize;
|
||||
|
||||
Point itemOffset;
|
||||
CSlider * slider;
|
||||
|
||||
void updatePositions();
|
||||
public:
|
||||
//CreateFunc, DestroyFunc - see CObjectList
|
||||
//Pos - position of first item
|
||||
//ItemOffset - distance between items in the list
|
||||
//VisibleSize - maximal number of displayable at once items
|
||||
//TotalSize
|
||||
//Slider - slider style, bit field: 1 = present(disabled), 2=horisontal(vertical), 4=blue(brown)
|
||||
//SliderPos - position of slider, if present
|
||||
CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point ItemOffset, size_t VisibleSize,
|
||||
size_t TotalSize, size_t InitialPos=0, int Slider=0, Rect SliderPos=Rect() );
|
||||
|
||||
//recreate all visible items
|
||||
void reset();
|
||||
|
||||
//return currently active items
|
||||
std::list< CIntObject * > getItems();
|
||||
|
||||
//scroll list
|
||||
void moveToPos(size_t which);
|
||||
void moveToNext();
|
||||
void moveToPrev();
|
||||
};
|
||||
|
||||
/// Status bar which is shown at the bottom of the in-game screens
|
||||
class CStatusBar
|
||||
: public CIntObject, public IStatusBar
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background
|
||||
int middlex, middley; //middle of statusbar
|
||||
std::string current; //text currently printed
|
||||
|
||||
CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
|
||||
~CStatusBar(); //d-tor
|
||||
void print(const std::string & text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
void show(SDL_Surface * to); //shows statusbar (with current text)
|
||||
std::string getCurrent(); //getter for current
|
||||
};
|
||||
|
||||
/// Label which shows text
|
||||
class CLabel
|
||||
: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
EAlignment alignment;
|
||||
EFonts font;
|
||||
SDL_Color color;
|
||||
std::string text;
|
||||
CPicture *bg;
|
||||
bool autoRedraw; //whether control will redraw itself on setTxt
|
||||
Point textOffset; //text will be blitted at pos + textOffset with appropriate alignment
|
||||
bool ignoreLeadingWhitespace;
|
||||
|
||||
virtual void setTxt(const std::string &Txt);
|
||||
void showAll(SDL_Surface * to); //shows statusbar (with current text)
|
||||
CLabel(int x=0, int y=0, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::Cornsilk, const std::string &Text = "");
|
||||
};
|
||||
|
||||
/// a multi-line label that tries to fit text with given available width and height; if not possible, it creates a slider for scrolling text
|
||||
class CTextBox
|
||||
: public CLabel
|
||||
{
|
||||
public:
|
||||
int maxW; //longest line of text in px
|
||||
int maxH; //total height needed to print all lines
|
||||
|
||||
int sliderStyle;
|
||||
bool redrawParentOnScrolling;
|
||||
|
||||
std::vector<std::string> lines;
|
||||
std::vector<CAnimImage* > effects;
|
||||
CSlider *slider;
|
||||
|
||||
//CTextBox( std::string Text, const Point &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::Cornsilk);
|
||||
CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::Cornsilk);
|
||||
void showAll(SDL_Surface * to); //shows statusbar (with current text)
|
||||
void setTxt(const std::string &Txt);
|
||||
void setBounds(int limitW, int limitH);
|
||||
void recalculateLines(const std::string &Txt);
|
||||
|
||||
void sliderMoved(int to);
|
||||
};
|
||||
|
||||
/// Status bar which is shown at the bottom of the in-game screens
|
||||
class CGStatusBar
|
||||
: public CLabel, public IStatusBar
|
||||
{
|
||||
void init();
|
||||
public:
|
||||
IStatusBar *oldStatusBar;
|
||||
|
||||
//statusbar interface overloads
|
||||
void print(const std::string & Text); //prints text and refreshes statusbar
|
||||
void clear();//clears statusbar and refreshes
|
||||
std::string getCurrent(); //returns currently displayed text
|
||||
void show(SDL_Surface * to); //shows statusbar (with current text)
|
||||
|
||||
CGStatusBar(int x, int y, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color &Color = Colors::Cornsilk, const std::string &Text = "");
|
||||
CGStatusBar(CPicture *BG, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color &Color = Colors::Cornsilk); //given CPicture will be captured by created sbar and it's pos will be used as pos for sbar
|
||||
CGStatusBar(int x, int y, std::string name, int maxw=-1);
|
||||
|
||||
~CGStatusBar();
|
||||
void calcOffset();
|
||||
};
|
||||
|
||||
/// UIElement which can get input focus
|
||||
class CFocusable
|
||||
: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
bool focus; //only one focusable control can have focus at one moment
|
||||
|
||||
void giveFocus(); //captures focus
|
||||
void moveFocus(); //moves focus to next active control (may be used for tab switching)
|
||||
|
||||
static std::list<CFocusable*> focusables; //all existing objs
|
||||
static CFocusable *inputWithFocus; //who has focus now
|
||||
CFocusable();
|
||||
~CFocusable();
|
||||
};
|
||||
|
||||
/// Text input box where players can enter text
|
||||
class CTextInput
|
||||
: public CLabel, public CFocusable
|
||||
{
|
||||
public:
|
||||
CFunctionList<void(const std::string &)> cb;
|
||||
|
||||
void setText(const std::string &nText, bool callCb = false);
|
||||
|
||||
CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
|
||||
CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
|
||||
~CTextInput();
|
||||
void showAll(SDL_Surface * to);
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
};
|
||||
|
||||
/// Listbox UI Element
|
||||
class CList : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg; //background bitmap
|
||||
CDefHandler *arrup, *arrdo; //button arrows for scrolling list
|
||||
SDL_Surface *empty, *selection;
|
||||
SDL_Rect arrupp, arrdop; //positions of arrows
|
||||
int posw, posh; //position width/height
|
||||
int selected, //id of selected position, <0 if none
|
||||
from;
|
||||
const int SIZE; //size of list
|
||||
tribool pressed; //true=up; false=down; indeterminate=none
|
||||
|
||||
CList(int Size = 5); //c-tor
|
||||
void clickLeft(tribool down, bool previousState);
|
||||
void activate();
|
||||
void deactivate();
|
||||
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
|
||||
virtual void genList()=0;
|
||||
virtual void select(int which)=0;
|
||||
virtual void draw(SDL_Surface * to)=0;
|
||||
virtual int size() = 0; //how many elements do we have
|
||||
void fixPos(); //scrolls list, so the selection will be visible
|
||||
};
|
||||
|
||||
/// Shows a text by moving the mouse cursor over the object
|
||||
class CHoverableArea: public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
std::string hoverText;
|
||||
|
||||
virtual void hover (bool on);
|
||||
|
||||
CHoverableArea();
|
||||
virtual ~CHoverableArea();
|
||||
};
|
||||
|
||||
/// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
|
||||
class LRClickableAreaWText: public CHoverableArea
|
||||
{
|
||||
public:
|
||||
std::string text;
|
||||
|
||||
LRClickableAreaWText();
|
||||
LRClickableAreaWText(const Rect &Pos, const std::string &HoverText = "", const std::string &ClickText = "");
|
||||
virtual ~LRClickableAreaWText();
|
||||
void init();
|
||||
|
||||
virtual void clickLeft(tribool down, bool previousState);
|
||||
virtual void clickRight(tribool down, bool previousState);
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CKeyShortcut.h"
|
||||
|
||||
void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(vstd::contains(assignedKeys,key.keysym.sym))
|
||||
{
|
||||
bool prev = pressedL;
|
||||
if(key.state == SDL_PRESSED)
|
||||
{
|
||||
pressedL = true;
|
||||
clickLeft(true, prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
pressedL = false;
|
||||
clickLeft(false, prev);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CIntObject.h"
|
||||
|
||||
/*
|
||||
* CKeyShortcut.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
/// Class for binding keys to left mouse button clicks
|
||||
/// Classes wanting use it should have it as one of their base classes
|
||||
class CKeyShortcut : public virtual CIntObject
|
||||
{
|
||||
public:
|
||||
std::set<int> assignedKeys;
|
||||
CKeyShortcut(){}; //c-tor
|
||||
CKeyShortcut(int key){assignedKeys.insert(key);}; //c-tor
|
||||
CKeyShortcut(std::set<int> Keys):assignedKeys(Keys){}; //c-tor
|
||||
virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in
|
||||
};
|
@ -1,133 +0,0 @@
|
||||
#include "StdInc.h"
|
||||
#include "CPicture.h"
|
||||
|
||||
#include "../CBitmapHandler.h"
|
||||
#include "../SDL_Extensions.h"
|
||||
#include "../Graphics.h"
|
||||
|
||||
|
||||
CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free )
|
||||
{
|
||||
init();
|
||||
bg = BG;
|
||||
freeSurf = Free;
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
pos.w = BG->w;
|
||||
pos.h = BG->h;
|
||||
}
|
||||
|
||||
CPicture::CPicture( const std::string &bmpname, int x, int y )
|
||||
{
|
||||
init();
|
||||
bg = BitmapHandler::loadBitmap(bmpname);
|
||||
freeSurf = true;;
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
if(bg)
|
||||
{
|
||||
pos.w = bg->w;
|
||||
pos.h = bg->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.w = pos.h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CPicture::CPicture(const SRect &r, const SDL_Color &color, bool screenFormat /*= false*/)
|
||||
{
|
||||
init();
|
||||
createSimpleRect(r, screenFormat, SDL_MapRGB(bg->format, color.r, color.g,color.b));
|
||||
}
|
||||
|
||||
CPicture::CPicture(const SRect &r, ui32 color, bool screenFormat /*= false*/)
|
||||
{
|
||||
init();
|
||||
createSimpleRect(r, screenFormat, color);
|
||||
}
|
||||
|
||||
CPicture::CPicture(SDL_Surface *BG, const SRect &SrcRect, int x /*= 0*/, int y /*= 0*/, bool free /*= false*/)
|
||||
{
|
||||
needRefresh = false;
|
||||
srcRect = new SRect(SrcRect);
|
||||
pos.x += x;
|
||||
pos.y += y;
|
||||
pos.w = srcRect->w;
|
||||
pos.h = srcRect->h;
|
||||
bg = BG;
|
||||
freeSurf = free;
|
||||
}
|
||||
|
||||
CPicture::~CPicture()
|
||||
{
|
||||
if(freeSurf)
|
||||
SDL_FreeSurface(bg);
|
||||
delete srcRect;
|
||||
}
|
||||
|
||||
void CPicture::init()
|
||||
{
|
||||
needRefresh = false;
|
||||
srcRect = NULL;
|
||||
}
|
||||
|
||||
void CPicture::show( SDL_Surface * to )
|
||||
{
|
||||
if (needRefresh)
|
||||
showAll(to);
|
||||
}
|
||||
|
||||
void CPicture::showAll( SDL_Surface * to )
|
||||
{
|
||||
if(bg)
|
||||
{
|
||||
if(srcRect)
|
||||
{
|
||||
SDL_Rect srcRectCpy = *srcRect;
|
||||
SDL_Rect dstRect = srcRectCpy;
|
||||
dstRect.x = pos.x;
|
||||
dstRect.y = pos.y;
|
||||
|
||||
CSDL_Ext::blitSurface(bg, &srcRectCpy, to, &dstRect);
|
||||
}
|
||||
else
|
||||
blitAt(bg, pos, to);
|
||||
}
|
||||
}
|
||||
|
||||
void CPicture::convertToScreenBPP()
|
||||
{
|
||||
SDL_Surface *hlp = bg;
|
||||
bg = SDL_ConvertSurface(hlp,screen->format,0);
|
||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||
SDL_FreeSurface(hlp);
|
||||
}
|
||||
|
||||
void CPicture::createSimpleRect(const SRect &r, bool screenFormat, ui32 color)
|
||||
{
|
||||
pos += r;
|
||||
pos.w = r.w;
|
||||
pos.h = r.h;
|
||||
if(screenFormat)
|
||||
bg = CSDL_Ext::newSurface(r.w, r.h);
|
||||
else
|
||||
bg = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 8, 0, 0, 0, 0);
|
||||
|
||||
SDL_FillRect(bg, NULL, color);
|
||||
freeSurf = true;
|
||||
}
|
||||
|
||||
void CPicture::colorizeAndConvert(int player)
|
||||
{
|
||||
assert(bg);
|
||||
colorize(player);
|
||||
convertToScreenBPP();
|
||||
}
|
||||
|
||||
void CPicture::colorize(int player)
|
||||
{
|
||||
assert(bg);
|
||||
assert(bg->format->BitsPerPixel == 8);
|
||||
graphics->blueToPlayersAdv(bg, player);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CIntObject.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
struct SRect;
|
||||
|
||||
/*
|
||||
* CPicture.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Image class
|
||||
class CPicture : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bg;
|
||||
SRect * srcRect; //if NULL then whole surface will be used
|
||||
bool freeSurf; //whether surface will be freed upon CPicture destruction
|
||||
bool needRefresh;//Surface needs to be displayed each frame
|
||||
|
||||
operator SDL_Surface*()
|
||||
{
|
||||
return bg;
|
||||
}
|
||||
|
||||
CPicture(const SRect & r, const SDL_Color & color, bool screenFormat = false); //rect filled with given color
|
||||
CPicture(const SRect & r, ui32 color, bool screenFormat = false); //rect filled with given color
|
||||
CPicture(SDL_Surface * BG, int x = 0, int y=0, bool Free = true); //wrap existing SDL_Surface
|
||||
CPicture(const std::string &bmpname, int x=0, int y=0);
|
||||
CPicture(SDL_Surface *BG, const SRect &SrcRext, int x = 0, int y = 0, bool free = false); //wrap subrect of given surface
|
||||
~CPicture();
|
||||
void init();
|
||||
|
||||
void createSimpleRect(const SRect &r, bool screenFormat, ui32 color);
|
||||
void show(SDL_Surface * to);
|
||||
void showAll(SDL_Surface * to);
|
||||
void convertToScreenBPP();
|
||||
void colorizeAndConvert(int player);
|
||||
void colorize(int player);
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "UIFramework/CIntObject.h"
|
||||
|
||||
/*
|
||||
* CSimpleWindow.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Window GUI class
|
||||
class CSimpleWindow : public CIntObject
|
||||
{
|
||||
public:
|
||||
SDL_Surface * bitmap; //background
|
||||
virtual void show(SDL_Surface * to);
|
||||
CSimpleWindow():bitmap(NULL){}; //c-tor
|
||||
virtual ~CSimpleWindow(); //d-tor
|
||||
};
|
19
client/UIFramework/Geometries.cpp
Normal file
19
client/UIFramework/Geometries.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "StdInc.h"
|
||||
#include "Geometries.h"
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
|
||||
Rect Rect::createCentered( int w, int h )
|
||||
{
|
||||
return Rect(screen->w/2 - w/2, screen->h/2 - h/2, w, h);
|
||||
}
|
||||
|
||||
Rect Rect::around(const Rect &r, int width /*= 1*/) /*creates rect around another */
|
||||
{
|
||||
return Rect(r.x - width, r.y - width, r.w + width * 2, r.h + width * 2);
|
||||
}
|
||||
|
||||
Rect Rect::centerIn(const Rect &r)
|
||||
{
|
||||
return Rect(r.x + (r.w - w) / 2, r.y + (r.h - h) / 2, w, h);
|
||||
}
|
262
client/UIFramework/Geometries.h
Normal file
262
client/UIFramework/Geometries.h
Normal file
@ -0,0 +1,262 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_video.h>
|
||||
#include <SDL_events.h>
|
||||
#include "../../lib/int3.h"
|
||||
|
||||
/*
|
||||
* Geometries.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
|
||||
// A point with x/y coordinate, used mostly for graphic rendering
|
||||
struct Point
|
||||
{
|
||||
int x, y;
|
||||
|
||||
//constructors
|
||||
Point()
|
||||
{
|
||||
x = y = 0;
|
||||
};
|
||||
Point(int X, int Y)
|
||||
:x(X),y(Y)
|
||||
{};
|
||||
Point(const int3 &a)
|
||||
:x(a.x),y(a.y)
|
||||
{}
|
||||
Point(const SDL_MouseMotionEvent &a)
|
||||
:x(a.x),y(a.y)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
Point operator+(const T &b) const
|
||||
{
|
||||
return Point(x+b.x,y+b.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point operator*(const T &mul) const
|
||||
{
|
||||
return Point(x*mul, y*mul);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point& operator+=(const T &b)
|
||||
{
|
||||
x += b.x;
|
||||
y += b.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point operator-(const T &b) const
|
||||
{
|
||||
return Point(x - b.x, y - b.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Point& operator-=(const T &b)
|
||||
{
|
||||
x -= b.x;
|
||||
y -= b.y;
|
||||
return *this;
|
||||
}
|
||||
bool operator<(const Point &b) const //product order
|
||||
{
|
||||
return x < b.x && y < b.y;
|
||||
}
|
||||
template<typename T> Point& operator=(const T &t)
|
||||
{
|
||||
x = t.x;
|
||||
y = t.y;
|
||||
return *this;
|
||||
}
|
||||
template<typename T> bool operator==(const T &t) const
|
||||
{
|
||||
return x == t.x && y == t.y;
|
||||
}
|
||||
template<typename T> bool operator!=(const T &t) const
|
||||
{
|
||||
return !(*this == t);
|
||||
}
|
||||
};
|
||||
|
||||
/// Rectangle class, which have a position and a size
|
||||
struct Rect : public SDL_Rect
|
||||
{
|
||||
Rect()//default c-tor
|
||||
{
|
||||
x = y = w = h = -1;
|
||||
}
|
||||
Rect(int X, int Y, int W, int H) //c-tor
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
w = W;
|
||||
h = H;
|
||||
}
|
||||
Rect(const Point & position, const Point & size) //c-tor
|
||||
{
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
w = size.x;
|
||||
h = size.y;
|
||||
}
|
||||
Rect(const SDL_Rect & r) //c-tor
|
||||
{
|
||||
x = r.x;
|
||||
y = r.y;
|
||||
w = r.w;
|
||||
h = r.h;
|
||||
}
|
||||
explicit Rect(const SDL_Surface * const &surf)
|
||||
{
|
||||
x = y = 0;
|
||||
w = surf->w;
|
||||
h = surf->h;
|
||||
}
|
||||
|
||||
Rect centerIn(const Rect &r);
|
||||
static Rect createCentered(int w, int h);
|
||||
static Rect around(const Rect &r, int width = 1); //creates rect around another
|
||||
|
||||
bool isIn(int qx, int qy) const //determines if given point lies inside rect
|
||||
{
|
||||
if (qx > x && qx<x+w && qy>y && qy<y+h)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool isIn(const Point & q) const //determines if given point lies inside rect
|
||||
{
|
||||
return isIn(q.x,q.y);
|
||||
}
|
||||
Point topLeft() const //top left corner of this rect
|
||||
{
|
||||
return Point(x,y);
|
||||
}
|
||||
Point topRight() const //top right corner of this rect
|
||||
{
|
||||
return Point(x+w,y);
|
||||
}
|
||||
Point bottomLeft() const //bottom left corner of this rect
|
||||
{
|
||||
return Point(x,y+h);
|
||||
}
|
||||
Point bottomRight() const //bottom right corner of this rect
|
||||
{
|
||||
return Point(x+w,y+h);
|
||||
}
|
||||
Rect operator+(const Rect &p) const //moves this rect by p's rect position
|
||||
{
|
||||
return Rect(x+p.x,y+p.y,w,h);
|
||||
}
|
||||
Rect operator+(const Point &p) const //moves this rect by p's point position
|
||||
{
|
||||
return Rect(x+p.x,y+p.y,w,h);
|
||||
}
|
||||
Rect& operator=(const Point &p) //assignment operator
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator=(const Rect &p) //assignment operator
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
w = p.w;
|
||||
h = p.h;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator+=(const Rect &p) //works as operator+
|
||||
{
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator+=(const Point &p) //works as operator+
|
||||
{
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator-=(const Rect &p) //works as operator+
|
||||
{
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
return *this;
|
||||
}
|
||||
Rect& operator-=(const Point &p) //works as operator+
|
||||
{
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
return *this;
|
||||
}
|
||||
template<typename T> Rect operator-(const T &t)
|
||||
{
|
||||
return Rect(x - t.x, y - t.y, w, h);
|
||||
}
|
||||
Rect operator&(const Rect &p) const //rect intersection
|
||||
{
|
||||
bool intersect = true;
|
||||
|
||||
if(p.topLeft().y < y && p.bottomLeft().y < y) //rect p is above *this
|
||||
{
|
||||
intersect = false;
|
||||
}
|
||||
else if(p.topLeft().y > y+h && p.bottomLeft().y > y+h) //rect p is below *this
|
||||
{
|
||||
intersect = false;
|
||||
}
|
||||
else if(p.topLeft().x > x+w && p.topRight().x > x+w) //rect p is on the right hand side of this
|
||||
{
|
||||
intersect = false;
|
||||
}
|
||||
else if(p.topLeft().x < x && p.topRight().x < x) //rect p is on the left hand side of this
|
||||
{
|
||||
intersect = false;
|
||||
}
|
||||
|
||||
if(intersect)
|
||||
{
|
||||
Rect ret;
|
||||
ret.x = std::max(this->x, p.x);
|
||||
ret.y = std::max(this->y, p.y);
|
||||
Point bR; //bottomRight point of returned rect
|
||||
bR.x = std::min(this->w+this->x, p.w+p.x);
|
||||
bR.y = std::min(this->h+this->y, p.h+p.y);
|
||||
ret.w = bR.x - ret.x;
|
||||
ret.h = bR.y - ret.y;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Rect();
|
||||
}
|
||||
}
|
||||
Rect operator|(const Rect &p) const //union of two rects
|
||||
{
|
||||
Rect ret;
|
||||
ret.x = std::min(p.x, this->x);
|
||||
ret.y = std::min(p.y, this->y);
|
||||
int x2 = std::max(p.x+p.w, this->x+this->w);
|
||||
int y2 = std::max(p.y+p.h, this->y+this->h);
|
||||
ret.w = x2 -ret.x;
|
||||
ret.h = y2 -ret.y;
|
||||
return ret;
|
||||
}
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* IActivatable.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Defines a activate/deactive method
|
||||
class IActivatable
|
||||
{
|
||||
public:
|
||||
virtual void activate()=0;
|
||||
virtual void deactivate()=0;
|
||||
virtual ~IActivatable(){}; //d-tor
|
||||
};
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "IShowable.h"
|
||||
#include "IActivatable.h"
|
||||
|
||||
/*
|
||||
* IShowActivatable.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
class IShowActivatable : public IShowable, public IActivatable
|
||||
{
|
||||
public:
|
||||
//redraw parent flag - this int may be semi-transparent and require redraw of parent window
|
||||
enum {WITH_GARRISON = 1, BLOCK_ADV_HOTKEYS = 2, WITH_ARTIFACTS = 4, REDRAW_PARENT=8};
|
||||
int type; //bin flags using etype
|
||||
IShowActivatable();
|
||||
virtual ~IShowActivatable(){}; //d-tor
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
/*
|
||||
* IShowable.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Defines a show method
|
||||
class IShowable
|
||||
{
|
||||
public:
|
||||
virtual void redraw()=0;
|
||||
virtual void show(SDL_Surface * to)=0;
|
||||
virtual void showAll(SDL_Surface * to)
|
||||
{
|
||||
show(to);
|
||||
}
|
||||
virtual ~IShowable(){}; //d-tor
|
||||
};
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
/*
|
||||
* IStatusBar.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
// Status bar interface
|
||||
class IStatusBar
|
||||
{
|
||||
public:
|
||||
virtual ~IStatusBar(){}; //d-tor
|
||||
virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
|
||||
virtual void clear()=0;//clears statusbar and refreshes
|
||||
virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text)
|
||||
virtual std::string getCurrent()=0; //returns currently displayed text
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user