1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-21 17:17:06 +02:00

Fix GUI object initializing - Point(0,0)

This commit is contained in:
paracelsus 2013-03-13 23:11:27 +00:00
parent 06e2e6ac10
commit fce4f8061c
9 changed files with 23 additions and 22 deletions

View File

@ -517,7 +517,7 @@ std::map<int, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors(std::string
}
CMinimap::CMinimap(const Rect &position):
CIntObject(LCLICK | RCLICK | HOVER | MOVE, position.topLeft()),
CIntObject(LCLICK | RCLICK | HOVER | MOVE, position),
aiShield(nullptr),
minimap(nullptr),
level(0),

View File

@ -744,15 +744,13 @@ bool CShootingAnimation::init()
spi.spin = shooterInfo->animation.projectileSpin;
Point xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
Point destcoord;
// The "master" point where all projectile positions relate to.
static const Point projectileOrigin(181, 252);
if (attackedStack)
{
destcoord = CClickableHex::getXYUnitAnim(dest, false, attackedStack, owner);
Point 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.

View File

@ -191,7 +191,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
OBJ_CONSTRUCTION_CAPTURING_ALL;
if(!garr)
{
garr = new CGarrisonInt(15, 485, 8, Point(), NULL /*background->bg*/, Point(15,485), curHero);
garr = new CGarrisonInt(15, 485, 8, Point(0, 0), NULL /*background->bg*/, Point(15,485), curHero);
split = new CAdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32],
boost::bind(&CGarrisonInt::splitClick,garr), 539, 519, "hsbtns9.def", false, NULL, false); //deleted by garrison destructor
boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);

View File

@ -535,7 +535,7 @@ CIntObject* CKingdomInterface::createOwnedObject(size_t index)
{
OwnedObjectInfo &obj = objects[index];
std::string value = boost::lexical_cast<std::string>(obj.count);
return new InfoBox(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
return new InfoBox(Point(0, 0), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText));
}
return NULL;
@ -907,7 +907,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
artButtons->select(0,0);
garr = new CGarrisonInt(6, 78, 4, Point(), NULL, Point(), hero, NULL, true, true);
garr = new CGarrisonInt(6, 78, 4, Point(0, 0), NULL, Point(0, 0), hero, NULL, true, true);
portrait = new CAnimImage("PortraitsLarge", hero->portrait, 0, 5, 6);
heroArea = new CHeroArea(5, 6, hero);

View File

@ -31,9 +31,12 @@ Rect Rect::operator&(const Rect &p) const //rect intersection
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);
//bottomRight point of returned rect
Point bR(
std::min(rightX(), p.rightX()),
std::min(bottomY(), p.bottomY())
);
ret.w = bR.x - ret.x;
ret.h = bR.y - ret.y;
return ret;

View File

@ -8,7 +8,7 @@ struct Point
si32 x;
si32 y;
Point() {};
Point() : x(0), y(0) {};
Point(si32 _x, si32 _y) : x(_x), y(_y) {};
bool operator==(const Point &p) const
@ -69,9 +69,11 @@ struct Rect : Point
//bottom right corner of this rect
Point bottomRight() const { return Point(x+w, y+h); }
//add x,y and copy w,h from p
void addOffs_copySize(const Rect &p);
Rect Rect::operator&(const Rect &p) const; //rect intersection
//rect intersection
Rect Rect::operator&(const Rect &p) const;
};
/* Color transform matrix for: grayscale, clone, bloodlust, etc */

View File

@ -235,7 +235,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
{
if(!vstd::contains(doubleClickInterested,*i)) continue;
if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y))
if (isItIn(&(*i)->pos, sEvent->motion.x, sEvent->motion.y))
{
(*i)->onDoubleClick();
}

View File

@ -177,6 +177,7 @@ void CFilledTexture::showAll()
//* CSDL_Ext::fillTexture(to, texture);
}
CButton::CButton() :
state(NORMAL),
images(nullptr),
@ -185,7 +186,6 @@ CButton::CButton() :
{
}
CButton::CButton(const CFunctionList<void()> & flist, Point position, const std::string & animName, size_t animOffs/*=0*/, size_t imagesNum/*=4*/,
const PairOfStrings * helpStr, int key/*=0*/) :
state(NORMAL),
@ -193,9 +193,7 @@ CButton::CButton(const CFunctionList<void()> & flist, Point position, const std:
callback(flist),
text(nullptr)
{
pos.x = position.x;
pos.y = position.y;
pos += position;
ui16 events = LCLICK;
if (helpStr != nullptr)
@ -1226,8 +1224,8 @@ void CLabel::showAll()
}
CLabel::CLabel(int x, int y, EFonts Font /*= FONT_SMALL*/, EAlignment Align, const SDL_Color &Color /*= Colors::WHITE*/, const std::string &Text /*= ""*/)
:CTextContainer(Align, Font, Color), text(Text)
CLabel::CLabel(int x, int y, EFonts Font /*= FONT_SMALL*/, EAlignment Align, const SDL_Color &Color /*= Colors::WHITE*/, const std::string &Text /*= ""*/) :
CTextContainer(Align, Font, Color), text(Text), textOffset(0, 0)
{
autoRedraw = true;
pos.x += x;
@ -1741,7 +1739,7 @@ void CFocusable::moveFocus()
}
CWindowObject::CWindowObject(int options_, std::string imageName, Point centerAt):
CIntObject(getUsedEvents(options_), Point()),
CIntObject(getUsedEvents(options_), Point(0, 0)),
shadow(nullptr),
options(options_),
background(createBg(imageName, options & PLAYER_COLORED))
@ -1761,7 +1759,7 @@ CWindowObject::CWindowObject(int options_, std::string imageName, Point centerAt
}
CWindowObject::CWindowObject(int options_, std::string imageName):
CIntObject(getUsedEvents(options_), Point()),
CIntObject(getUsedEvents(options_), Point(0, 0)),
shadow(nullptr),
options(options_),
background(createBg(imageName, options & PLAYER_COLORED))

View File

@ -263,7 +263,7 @@ 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);
CTabbedInt(CreateFunc create, DestroyFunc destroy = DestroyFunc(), Point position=Point(0, 0), size_t ActiveID=0);
void setActive(size_t which);
//recreate active tab