aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/widget.cpp8
-rw-r--r--gui/widget.h3
-rw-r--r--newgui.cpp22
-rw-r--r--newgui.h2
4 files changed, 22 insertions, 13 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index c72d44647c..4b8219cc08 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -52,6 +52,7 @@ void Widget::draw()
gui->box(_x, _y, _w, _h);
_x += 4;
_y += 4;
+ _w -= 8;
}
// Now perform the actual widget draw
@@ -64,6 +65,7 @@ void Widget::draw()
if (_flags & WIDGET_BORDER) {
_x -= 4;
_y -= 4;
+ _w += 8;
}
_x -= _boss->_x;
_y -= _boss->_y;
@@ -74,7 +76,7 @@ void Widget::draw()
StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text)
- : Widget (boss, x, y, w, h), _label(0)
+ : Widget (boss, x, y, w, h), _label(0), _centred(false)
{
_type = kStaticTextWidget;
setLabel(text);
@@ -104,7 +106,7 @@ void StaticTextWidget::setLabel(const char *label)
void StaticTextWidget::drawWidget(bool hilite)
{
NewGui *gui = _boss->getGui();
- gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->drawString(_label, _x, _y, _w, hilite ? gui->_textcolorhi : gui->_textcolor, _centred);
}
@@ -117,6 +119,8 @@ ButtonWidget::ButtonWidget(Dialog *boss, int x, int y, int w, int h, const char
assert(label);
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG ;
_type = kButtonWidget;
+
+ setCentred(true);
}
ButtonWidget::~ButtonWidget()
diff --git a/gui/widget.h b/gui/widget.h
index 8d2f49e164..4b72df1b42 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -112,11 +112,14 @@ protected:
class StaticTextWidget : public Widget {
protected:
char *_label;
+ bool _centred;
public:
StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text);
~StaticTextWidget();
void setLabel(const char *label);
const char *getLabel() const { return _label; }
+ void setCentred(bool centred) { _centred = centred; }
+ bool isCentred() const { return _centred; }
protected:
void drawWidget(bool hilite);
diff --git a/newgui.cpp b/newgui.cpp
index e642e0ec86..0d9de41f8b 100644
--- a/newgui.cpp
+++ b/newgui.cpp
@@ -401,23 +401,25 @@ void NewGui::drawChar(const char str, int xx, int yy)
}
-void NewGui::drawString(const char *str, int x, int y, int w, byte color)
+void NewGui::drawString(const char *str, int x, int y, int w, byte color, bool center)
{
- StringTab *st = &_s->string[5];
- st->charset = 1;
- st->center = false;
- st->color = color;
- st->xpos = x;
- st->ypos = y;
- st->right = x + w;
-
if (_s->_gameId) { /* If a game is active.. */
+ StringTab *st = &_s->string[5];
+ st->charset = 1;
+ st->center = center;
+ st->color = color;
+ st->xpos = center ? x+w/2 : x;
+ st->ypos = y;
+ st->right = x + w;
+
_s->_messagePtr = (byte *)str;
_s->drawString(5);
} else {
+ // FIXME - support center, use nicer custom font. Ultimately, we might
+ // want to *always* draw our messages this way.
uint len = strlen(str);
for (uint letter = 0; letter < len; letter++)
- drawChar(str[letter], st->xpos + (letter * 8), st->ypos);
+ drawChar(str[letter], x + (letter * 8), y);
}
}
diff --git a/newgui.h b/newgui.h
index dec7f47c5d..858e7ee7f6 100644
--- a/newgui.h
+++ b/newgui.h
@@ -133,7 +133,7 @@ public:
void frameRect(int x, int y, int w, int h, byte color);
void addDirtyRect(int x, int y, int w, int h);
void drawChar(const char c, int x, int y);
- void drawString(const char *str, int x, int y, int w, byte color);
+ void drawString(const char *str, int x, int y, int w, byte color, bool center = false);
void drawBitmap(uint32 bitmap[8], int x, int y, byte color);
void blitTo(byte buffer[320*200], int x, int y, int w, int h);