mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +02:00
Fix GUI object initializing - Point(0,0)
This commit is contained in:
@ -517,7 +517,7 @@ std::map<int, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors(std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMinimap::CMinimap(const Rect &position):
|
CMinimap::CMinimap(const Rect &position):
|
||||||
CIntObject(LCLICK | RCLICK | HOVER | MOVE, position.topLeft()),
|
CIntObject(LCLICK | RCLICK | HOVER | MOVE, position),
|
||||||
aiShield(nullptr),
|
aiShield(nullptr),
|
||||||
minimap(nullptr),
|
minimap(nullptr),
|
||||||
level(0),
|
level(0),
|
||||||
|
@ -744,15 +744,13 @@ bool CShootingAnimation::init()
|
|||||||
spi.spin = shooterInfo->animation.projectileSpin;
|
spi.spin = shooterInfo->animation.projectileSpin;
|
||||||
|
|
||||||
Point xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
|
Point xycoord = CClickableHex::getXYUnitAnim(shooter->position, true, shooter, owner);
|
||||||
Point destcoord;
|
|
||||||
|
|
||||||
|
|
||||||
// The "master" point where all projectile positions relate to.
|
// The "master" point where all projectile positions relate to.
|
||||||
static const Point projectileOrigin(181, 252);
|
static const Point projectileOrigin(181, 252);
|
||||||
|
|
||||||
if (attackedStack)
|
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
|
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.
|
// Calculate projectile start position. Offsets are read out of the CRANIM.TXT.
|
||||||
|
@ -191,7 +191,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
|
|||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
if(!garr)
|
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],
|
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::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]);
|
boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
||||||
|
@ -535,7 +535,7 @@ CIntObject* CKingdomInterface::createOwnedObject(size_t index)
|
|||||||
{
|
{
|
||||||
OwnedObjectInfo &obj = objects[index];
|
OwnedObjectInfo &obj = objects[index];
|
||||||
std::string value = boost::lexical_cast<std::string>(obj.count);
|
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));
|
new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText));
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -907,7 +907,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
|
|||||||
artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
|
artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
|
||||||
artButtons->select(0,0);
|
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);
|
portrait = new CAnimImage("PortraitsLarge", hero->portrait, 0, 5, 6);
|
||||||
heroArea = new CHeroArea(5, 6, hero);
|
heroArea = new CHeroArea(5, 6, hero);
|
||||||
|
@ -31,9 +31,12 @@ Rect Rect::operator&(const Rect &p) const //rect intersection
|
|||||||
Rect ret;
|
Rect ret;
|
||||||
ret.x = std::max(this->x, p.x);
|
ret.x = std::max(this->x, p.x);
|
||||||
ret.y = std::max(this->y, p.y);
|
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);
|
//bottomRight point of returned rect
|
||||||
bR.y = std::min(this->h+this->y, p.h+p.y);
|
Point bR(
|
||||||
|
std::min(rightX(), p.rightX()),
|
||||||
|
std::min(bottomY(), p.bottomY())
|
||||||
|
);
|
||||||
ret.w = bR.x - ret.x;
|
ret.w = bR.x - ret.x;
|
||||||
ret.h = bR.y - ret.y;
|
ret.h = bR.y - ret.y;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -8,7 +8,7 @@ struct Point
|
|||||||
si32 x;
|
si32 x;
|
||||||
si32 y;
|
si32 y;
|
||||||
|
|
||||||
Point() {};
|
Point() : x(0), y(0) {};
|
||||||
Point(si32 _x, si32 _y) : x(_x), y(_y) {};
|
Point(si32 _x, si32 _y) : x(_x), y(_y) {};
|
||||||
|
|
||||||
bool operator==(const Point &p) const
|
bool operator==(const Point &p) const
|
||||||
@ -69,9 +69,11 @@ struct Rect : Point
|
|||||||
//bottom right corner of this rect
|
//bottom right corner of this rect
|
||||||
Point bottomRight() const { return Point(x+w, y+h); }
|
Point bottomRight() const { return Point(x+w, y+h); }
|
||||||
|
|
||||||
|
//add x,y and copy w,h from p
|
||||||
void addOffs_copySize(const Rect &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 */
|
/* Color transform matrix for: grayscale, clone, bloodlust, etc */
|
||||||
|
@ -235,7 +235,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
|||||||
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
|
||||||
{
|
{
|
||||||
if(!vstd::contains(doubleClickInterested,*i)) continue;
|
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();
|
(*i)->onDoubleClick();
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,7 @@ void CFilledTexture::showAll()
|
|||||||
//* CSDL_Ext::fillTexture(to, texture);
|
//* CSDL_Ext::fillTexture(to, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CButton::CButton() :
|
CButton::CButton() :
|
||||||
state(NORMAL),
|
state(NORMAL),
|
||||||
images(nullptr),
|
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*/,
|
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*/) :
|
const PairOfStrings * helpStr, int key/*=0*/) :
|
||||||
state(NORMAL),
|
state(NORMAL),
|
||||||
@ -193,9 +193,7 @@ CButton::CButton(const CFunctionList<void()> & flist, Point position, const std:
|
|||||||
callback(flist),
|
callback(flist),
|
||||||
text(nullptr)
|
text(nullptr)
|
||||||
{
|
{
|
||||||
pos.x = position.x;
|
pos += position;
|
||||||
pos.y = position.y;
|
|
||||||
|
|
||||||
ui16 events = LCLICK;
|
ui16 events = LCLICK;
|
||||||
|
|
||||||
if (helpStr != nullptr)
|
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 /*= ""*/)
|
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)
|
CTextContainer(Align, Font, Color), text(Text), textOffset(0, 0)
|
||||||
{
|
{
|
||||||
autoRedraw = true;
|
autoRedraw = true;
|
||||||
pos.x += x;
|
pos.x += x;
|
||||||
@ -1741,7 +1739,7 @@ void CFocusable::moveFocus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CWindowObject::CWindowObject(int options_, std::string imageName, Point centerAt):
|
CWindowObject::CWindowObject(int options_, std::string imageName, Point centerAt):
|
||||||
CIntObject(getUsedEvents(options_), Point()),
|
CIntObject(getUsedEvents(options_), Point(0, 0)),
|
||||||
shadow(nullptr),
|
shadow(nullptr),
|
||||||
options(options_),
|
options(options_),
|
||||||
background(createBg(imageName, options & PLAYER_COLORED))
|
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):
|
CWindowObject::CWindowObject(int options_, std::string imageName):
|
||||||
CIntObject(getUsedEvents(options_), Point()),
|
CIntObject(getUsedEvents(options_), Point(0, 0)),
|
||||||
shadow(nullptr),
|
shadow(nullptr),
|
||||||
options(options_),
|
options(options_),
|
||||||
background(createBg(imageName, options & PLAYER_COLORED))
|
background(createBg(imageName, options & PLAYER_COLORED))
|
||||||
|
@ -263,7 +263,7 @@ public:
|
|||||||
//CreateFunc, DestroyFunc - see CObjectList
|
//CreateFunc, DestroyFunc - see CObjectList
|
||||||
//Pos - position of object, all tabs will be moved to this position
|
//Pos - position of object, all tabs will be moved to this position
|
||||||
//ActiveID - ID of initially active tab
|
//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);
|
void setActive(size_t which);
|
||||||
//recreate active tab
|
//recreate active tab
|
||||||
|
Reference in New Issue
Block a user