Use ref for CPopup instead of pointer.

This commit is contained in:
Joris 2012-11-13 15:05:45 +01:00
parent bb0b8acc06
commit 74868505e9
2 changed files with 21 additions and 19 deletions

View file

@ -471,7 +471,7 @@ public:
virtual ~CPopupContentType() { delete Condition; }
/// Tell how show the variable Index.
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const = 0;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const = 0;
/// Get the content's width
virtual int GetWidth(const ButtonAction &button, int *Costs) const = 0;
/// Get the content's height
@ -503,7 +503,7 @@ public:
CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(NULL) {}
virtual ~CPopupContentTypeButtonInfo() {}
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual int GetWidth(const ButtonAction &button, int *Costs) const;
virtual int GetHeight(const ButtonAction &button, int *Costs) const;
@ -519,7 +519,7 @@ public:
CPopupContentTypeText() : MaxWidth(0), Font(NULL) {}
virtual ~CPopupContentTypeText() {}
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual int GetWidth(const ButtonAction &button, int *Costs) const;
virtual int GetHeight(const ButtonAction &button, int *Costs) const;
@ -535,7 +535,7 @@ public:
CPopupContentTypeCosts() : Font(NULL), Centered(0) {}
virtual ~CPopupContentTypeCosts() {}
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual int GetWidth(const ButtonAction &button, int *Costs) const;
virtual int GetHeight(const ButtonAction &button, int *Costs) const;
@ -550,7 +550,7 @@ public:
CPopupContentTypeLine();
virtual ~CPopupContentTypeLine() {}
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual int GetWidth(const ButtonAction &button, int *Costs) const;
virtual int GetHeight(const ButtonAction &button, int *Costs) const;
@ -569,7 +569,7 @@ public:
delete Text;
}
virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
virtual int GetWidth(const ButtonAction &button, int *Costs) const;
virtual int GetHeight(const ButtonAction &button, int *Costs) const;
@ -688,7 +688,7 @@ public:
CInfoPanel InfoPanel; /// Info panel
std::vector<CUnitInfoPanel *> InfoPanelContents;/// Info panel contents
std::vector<CPopup *> ButtonPopups; /// Popup windows for buttons
std::vector<CPopup *> ButtonPopups; /// Popup windows for buttons
CUIButton *SingleSelectedButton; /// Button for single selected unit

View file

@ -377,7 +377,7 @@ static int GetButtonStatus(const ButtonAction &button, int UnderCursor)
return height;
}
/* virtual */ void CPopupContentTypeButtonInfo::Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *) const
/* virtual */ void CPopupContentTypeButtonInfo::Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *) const
{
const CFont &font = this->Font ? *this->Font : GetSmallFont();
CLabel label(font, this->TextColor, this->HighlightColor);
@ -398,7 +398,7 @@ static int GetButtonStatus(const ButtonAction &button, int UnderCursor)
int i = 0;
int y_off = y;
unsigned int width = this->MaxWidth
? std::min(this->MaxWidth, popupWidth - 2 * popup->MarginX)
? std::min(this->MaxWidth, popupWidth - 2 * popup.MarginX)
: 0;
while ((sub = GetLineFont(++i, draw, width, &font)).length()) {
label.Draw(x, y_off, sub);
@ -435,7 +435,7 @@ static int GetButtonStatus(const ButtonAction &button, int UnderCursor)
return height;
}
/* virtual */ void CPopupContentTypeText::Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *) const
/* virtual */ void CPopupContentTypeText::Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *) const
{
const CFont &font = this->Font ? *this->Font : GetSmallFont();
CLabel label(font, this->TextColor, this->HighlightColor);
@ -443,7 +443,7 @@ static int GetButtonStatus(const ButtonAction &button, int UnderCursor)
int i = 0;
int y_off = y;
unsigned int width = this->MaxWidth
? std::min(this->MaxWidth, popupWidth - 2 * popup->MarginX)
? std::min(this->MaxWidth, popupWidth - 2 * popup.MarginX)
: 0;
while ((sub = GetLineFont(++i, this->Text, width, &font)).length()) {
label.Draw(x, y_off, sub);
@ -505,7 +505,7 @@ static int GetButtonStatus(const ButtonAction &button, int UnderCursor)
return std::max(popupHeight, font.Height());
}
/* virtual */ void CPopupContentTypeCosts::Draw(int x, int y, const CPopup *, const unsigned int, const ButtonAction &button, int *Costs) const
/* virtual */ void CPopupContentTypeCosts::Draw(int x, int y, const CPopup &, const unsigned int, const ButtonAction &button, int *Costs) const
{
const CFont &font = this->Font ? *this->Font : GetSmallFont();
CLabel label(font, this->TextColor, this->HighlightColor);
@ -560,9 +560,9 @@ CPopupContentTypeLine::CPopupContentTypeLine() : Color(ColorWhite), Width(0), He
return this->Height;
}
/* virtual */ void CPopupContentTypeLine::Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
/* virtual */ void CPopupContentTypeLine::Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
{
Video.FillRectangle(this->Color, x - popup->MarginX - this->MarginX + 1,
Video.FillRectangle(this->Color, x - popup.MarginX - this->MarginX + 1,
y, this->Width && Width < popupWidth ? Width : popupWidth - 2, Height);
}
@ -581,7 +581,7 @@ CPopupContentTypeLine::CPopupContentTypeLine() : Color(ColorWhite), Width(0), He
return font.Height();
}
/* virtual */ void CPopupContentTypeVariable::Draw(int x, int y, const CPopup *, const unsigned int, const ButtonAction &button, int *) const
/* virtual */ void CPopupContentTypeVariable::Draw(int x, int y, const CPopup &, const unsigned int, const ButtonAction &button, int *) const
{
std::string text; // Optional text to display.
CFont &font = this->Font ? *this->Font : GetSmallFont(); // Font to use.
@ -885,10 +885,12 @@ void DrawPopup(const ButtonAction &button, const CUIButton &uibutton)
Video.DrawRectangle(popup->BorderColor, x, y, popupWidth, popupHeight);
// Contents
for (std::vector<CPopupContentType *>::const_iterator content = popup->Contents.begin();
content != popup->Contents.end(); ++content) {
if (CanShowPopupContent((*content)->Condition, button, UnitTypes[button.Value])) {
(*content)->Draw(x + (*content)->PosX, y + (*content)->PosY, popup, popupWidth, button, Costs);
for (std::vector<CPopupContentType *>::const_iterator it = popup->Contents.begin();
it != popup->Contents.end(); ++it) {
const CPopupContentType &content = **it;
if (CanShowPopupContent(content.Condition, button, UnitTypes[button.Value])) {
content.Draw(x + content.PosX, y + content.PosY, *popup, popupWidth, button, Costs);
}
}