Use some PixelPos, PixelSize.

This commit is contained in:
Joris 2012-11-13 16:37:45 +01:00
parent fc5ce4aff3
commit 777ce6b700
3 changed files with 11 additions and 15 deletions

View file

@ -465,8 +465,8 @@ public:
class CPopupContentType class CPopupContentType
{ {
public: public:
CPopupContentType() : PosX(0), PosY(0), CPopupContentType() : pos(0, 0),
MarginX(MARGIN_X), MarginY(MARGIN_Y), MinWidth(0), MinHeight(0), MarginX(MARGIN_X), MarginY(MARGIN_Y), minSize(0, 0),
Wrap(true), Condition(NULL) {} Wrap(true), Condition(NULL) {}
virtual ~CPopupContentType() { delete Condition; } virtual ~CPopupContentType() { delete Condition; }
@ -482,13 +482,11 @@ public:
static CPopupContentType *ParsePopupContent(lua_State *l); static CPopupContentType *ParsePopupContent(lua_State *l);
public: public:
int PosX; /// X position to draw. PixelPos pos; /// position to draw.
int PosY; /// Y position to draw.
int MarginX; /// Left and right margin width. int MarginX; /// Left and right margin width.
int MarginY; /// Upper and lower margin height. int MarginY; /// Upper and lower margin height.
int MinWidth; /// Minimal width covered by content type. PixelSize minSize; /// Minimal size covered by content type.
int MinHeight; /// Minimal height covered by content type.
bool Wrap; /// If true, the next content will be placed on the next "line". bool Wrap; /// If true, the next content will be placed on the next "line".
protected: protected:
std::string TextColor; /// Color used for plain text in content. std::string TextColor; /// Color used for plain text in content.

View file

@ -699,13 +699,11 @@ static void GetPopupSize(const CPopup &popup, const ButtonAction &button,
if (CanShowPopupContent(content.Condition, button, UnitTypes[button.Value])) { if (CanShowPopupContent(content.Condition, button, UnitTypes[button.Value])) {
// Automatically write the calculated coordinates. // Automatically write the calculated coordinates.
content.PosX = contentWidth + content.MarginX; content.pos.x = contentWidth + content.MarginX;
content.PosY = popupHeight + content.MarginY; content.pos.y = popupHeight + content.MarginY;
contentWidth += std::max(content.MinWidth, 2 * content.MarginX contentWidth += std::max(content.minSize.x, 2 * content.MarginX + content.GetWidth(button, Costs));
+ content.GetWidth(button, Costs)); contentHeight = std::max(content.minSize.y, 2 * content.MarginY + content.GetHeight(button, Costs));
contentHeight = std::max(content.MinHeight, 2 * content.MarginY
+ content.GetHeight(button, Costs));
maxContentHeight = std::max(contentHeight, maxContentHeight); maxContentHeight = std::max(contentHeight, maxContentHeight);
if (content.Wrap) { if (content.Wrap) {
popupWidth += contentWidth - maxContentWidth > 0 ? contentWidth - maxContentWidth : 0; popupWidth += contentWidth - maxContentWidth > 0 ? contentWidth - maxContentWidth : 0;
@ -890,7 +888,7 @@ void DrawPopup(const ButtonAction &button, const CUIButton &uibutton)
const CPopupContentType &content = **it; const CPopupContentType &content = **it;
if (CanShowPopupContent(content.Condition, button, UnitTypes[button.Value])) { if (CanShowPopupContent(content.Condition, button, UnitTypes[button.Value])) {
content.Draw(x + content.PosX, y + content.PosY, *popup, popupWidth, button, Costs); content.Draw(x + content.pos.x, y + content.pos.y, *popup, popupWidth, button, Costs);
} }
} }

View file

@ -1039,8 +1039,8 @@ static PopupConditionPanel *ParsePopupConditions(lua_State *l)
content->Wrap = wrap; content->Wrap = wrap;
content->MarginX = marginX; content->MarginX = marginX;
content->MarginY = marginY; content->MarginY = marginY;
content->MinWidth = minWidth; content->minSize.x = minWidth;
content->MinHeight = minHeight; content->minSize.y = minHeight;
content->Condition = condition; content->Condition = condition;
content->TextColor = textColor; content->TextColor = textColor;
content->HighlightColor = highColor; content->HighlightColor = highColor;