From cc18095cded14f5e7e3f049e47fca2224134b647 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 19 Sep 2010 19:44:13 +0000 Subject: text rendering cleanups, inventory capacity & cargo volume --- src/client/infowidget.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/client/infowidget.cc') diff --git a/src/client/infowidget.cc b/src/client/infowidget.cc index 3081b8d..c4c85a1 100644 --- a/src/client/infowidget.cc +++ b/src/client/infowidget.cc @@ -25,7 +25,8 @@ namespace client { -void time_to_stream(std::stringstream &str, float time) +// helper function +void time_to_stream(std::ostringstream &str, float time) { int minutes = (int) floorf(time / 60.0f); int seconds = (int) floorf(time - (float) minutes * 60.0f); @@ -43,7 +44,7 @@ DevInfoWidget::DevInfoWidget(ui::Widget *parent) : ui::Widget(parent) void DevInfoWidget::draw() { - std::stringstream textstream; + std::ostringstream textstream; const core::Entity *target = targets::current(); float d = 0; @@ -71,8 +72,8 @@ void DevInfoWidget::draw() } } - ui::paint::color(palette()->foreground()); - ui::paint::text(global_location(), size(), font(), textstream); + ui::Paint::set_color(palette()->foreground()); + ui::Paint::draw_text(global_location(), font(), textstream.str()); } /* -- StatsInfoWidget ---------------------------------------------- */ @@ -109,7 +110,7 @@ void StatsInfoWidget::draw() fps = roundf(((float) fps_counter_size ) / t); } - std::stringstream textstream; + std::ostringstream textstream; if (core::game()) { textstream << "^Ntime ^B"; @@ -140,8 +141,8 @@ void StatsInfoWidget::draw() } } - ui::paint::color(palette()->foreground()); - ui::paint::text(global_location(), size(), font(), textstream); + ui::Paint::set_color(palette()->foreground()); + ui::Paint::draw_text(global_location(), font(), textstream.str()); } /* -- KeyInfoWidget ------------------------------------------------ */ @@ -155,10 +156,9 @@ KeyInfoWidget::KeyInfoWidget(ui::Widget *parent) : Widget(parent) void KeyInfoWidget::draw() { - std::string label; - ui::paint::color(palette()->highlight()); - Key::Modifier mod = input::modifier(); + std::string label; + if (mod != Key::None) { if (mod == Key::Shift) label.assign("shift+"); @@ -172,8 +172,10 @@ void KeyInfoWidget::draw() label.append(input::last_key_pressed()->name()); } - if (label.size()) - ui::paint::label(global_location(), size(), font(), label , ui::AlignCenter); + if (label.size()) { + ui::Paint::set_color(palette()->highlight()); + ui::Paint::draw_label(global_location(), size(), font(), label , ui::AlignCenter); + } } } -- cgit v1.2.3