Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
committerStijn Buys <ingar@osirion.org>2010-09-19 19:44:13 +0000
commitcc18095cded14f5e7e3f049e47fca2224134b647 (patch)
tree2a057f4836925083a19988d571dc0664925c9e48 /src/client
parentbadfb31888a6bd62e0a019b3f3dec517df4121ec (diff)
text rendering cleanups, inventory capacity & cargo volume
Diffstat (limited to 'src/client')
-rw-r--r--src/client/buymenu.cc10
-rw-r--r--src/client/hud.cc28
-rw-r--r--src/client/infowidget.cc26
-rw-r--r--src/client/inventorylistview.cc2
-rw-r--r--src/client/trademenu.cc67
-rw-r--r--src/client/trademenu.h7
-rw-r--r--src/client/video.cc2
-rw-r--r--src/client/worldview.cc10
8 files changed, 77 insertions, 75 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc
index a106659..ba93f42 100644
--- a/src/client/buymenu.cc
+++ b/src/client/buymenu.cc
@@ -29,6 +29,11 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
menu_buywindow->set_background(true);
menu_buywindow->set_border(true);
+ menu_modelview = new ui::ModelView(menu_buywindow);
+ menu_modelview->set_label("modelview");
+ menu_modelview->set_background(false);
+ menu_modelview->set_border(false);
+
menu_namelabel = new ui::Label(menu_buywindow);
menu_namelabel->set_label("label");
menu_namelabel->set_background(false);
@@ -36,11 +41,6 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
menu_namelabel->set_font(ui::root()->font_large());
menu_namelabel->set_alignment(ui::AlignCenter);
- menu_modelview = new ui::ModelView(menu_buywindow);
- menu_modelview->set_label("modelview");
- menu_modelview->set_background(false);
- menu_modelview->set_border(false);
-
menu_scrollpane = new ui::ScrollPane(menu_buywindow, menu_infotext);
menu_scrollpane->set_background(false);
menu_scrollpane->set_border(false);
diff --git a/src/client/hud.cc b/src/client/hud.cc
index 3a7601b..d712987 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -28,7 +28,7 @@ HUD::HUD(ui::Widget *parent) : Widget(parent)
hud_toolbar->add_button("", "Chat", "ui_chat");
hud_toolbar->add_button("", "Map", "ui_map");
*/
- hud_center = new ui::Bitmap(this, "pointers/center");
+ hud_center = new ui::Bitmap(this, "bitmaps/pointers/center");
hud_center->set_color(palette()->pointer());
}
@@ -180,7 +180,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
if (is_active_target) {
// entity name and distance
- std::stringstream strdistance;
+ std::ostringstream strdistance;
float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius();
if (d > 0) {
if (d > 100.0f) {
@@ -213,7 +213,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
cy - r - 4 - render::Text::fontheight(), entity->name());
render::Text::draw(cx - aux::text_length(strdistance.str()) * render::Text::fontwidth() * 0.5f,
- cy + r + 4, strdistance);
+ cy + r + 4, strdistance.str());
}
}
@@ -235,7 +235,6 @@ bool HUD::on_keypress(const int key, const unsigned int modifier)
void HUD::draw()
{
using namespace render;
- std::stringstream status;
if (core::localcontrol() && (input::mouse_control || input::joystick_control) &&
(render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
@@ -248,7 +247,6 @@ void HUD::draw()
Text::setfont("gui", 12, 18);
Text::setcolor('N'); //set normal color
-
core::Zone *zone = core::localcontrol()->zone();
// draw HUD targets
@@ -269,7 +267,7 @@ void HUD::draw()
/*
unsigned int state = core::localcontrol()->state();
if (state) {
- std::stringstream statestr;
+ std::ostringstream statestr;
statestr.clear();
if (state == core::Entity::ImpulseInitiate) {
statestr << "^FInitializing kinetic impulse drive " << core::localcontrol()->timer();
@@ -281,15 +279,13 @@ void HUD::draw()
statestr << "^FJumping...";
}
- Text::draw(4, render::State::height() - Text::fontheight()*3 - 4, statestr);
+ Text::draw(4, render::State::height() - Text::fontheight()*3 - 4, statestr.str());
}
*/
const core::Entity *target = targets::current();
- std::stringstream strdistance;
-
if (target) {
- std::stringstream strtarget;
+ std::ostringstream strtarget;
strtarget << "^B" << target->name() << "\n^B";
float d = math::distance(core::localcontrol()->location(), target->location())
@@ -316,15 +312,15 @@ void HUD::draw()
} else {
strtarget << " --";
}
- strtarget << '\n';
- Text::draw(width() - 4 - Text::fontwidth()*30, height() - Text::fontheight()*2 - 4, strtarget);
+ Text::draw(width() - 4 - Text::fontwidth()*30, height() - Text::fontheight()*2 - 4, strtarget.str());
}
// draw player info
- std::stringstream playerinfostr;
+ std::ostringstream playerinfostr;
playerinfostr << "^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
- Text::draw(width() - 4 - Text::fontwidth()*52, height() - Text::fontheight()*2 - 4, playerinfostr);
+ Text::draw(width() - 4 - Text::fontwidth()*52, height() - Text::fontheight()*2 - 4, playerinfostr.str());
+ // draw thruster indicator
Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
gl::color(1, 1, 1, 1);
gl::begin(gl::Quads);
@@ -388,9 +384,9 @@ void HUD::draw()
Text::setfont("gui", 14, 24);
Text::setcolor('B'); //set normal color
- std::stringstream speedstr;
+ std::ostringstream speedstr;
speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
- Text::draw(316 + 4 + 10, height() - 6 - 16 - render::Text::fontwidth() / 2, speedstr);
+ Text::draw(316 + 4 + 10, height() - 6 - 16 - render::Text::fontwidth() / 2, speedstr.str());
Text::setfont("gui", 12, 18);
Text::setcolor('N'); //set normal color
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);
+ }
}
}
diff --git a/src/client/inventorylistview.cc b/src/client/inventorylistview.cc
index d2752d6..0126ff4 100644
--- a/src/client/inventorylistview.cc
+++ b/src/client/inventorylistview.cc
@@ -64,7 +64,7 @@ void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType
void InventoryListView::draw()
{
- if (listview_timestamp != listview_inventory->timestamp()) {
+ if (listview_inventory && (listview_timestamp != listview_inventory->timestamp())) {
set_inventory(listview_inventory, listview_infotype);
}
diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc
index d93864d..7ac3e7c 100644
--- a/src/client/trademenu.cc
+++ b/src/client/trademenu.cc
@@ -4,6 +4,8 @@
the terms of the GNU General Public License version 2
*/
+#include <iomanip>
+
#include "core/application.h"
#include "core/info.h"
#include "core/inventory.h"
@@ -13,8 +15,7 @@
#include "ui/listitem.h"
#include "client/trademenu.h"
-namespace client
-{
+namespace client {
TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
{
@@ -28,7 +29,12 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent
menu_tradewindow = new ui::Window(this);
menu_tradewindow->set_label("tradewindow");
menu_tradewindow->set_border(true);
-
+
+ menu_modelview = new ui::ModelView(menu_tradewindow);
+ menu_modelview->set_label("modelview");
+ menu_modelview->set_background(false);
+ menu_modelview->set_border(false);
+
menu_namelabel = new ui::Label(menu_tradewindow);
menu_namelabel->set_label("label");
menu_namelabel->set_background(false);
@@ -42,20 +48,12 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent
menu_inventorylistview->set_background(false);
menu_inventorylistview->set_border(true);
- menu_inventorylabel = new ui::Label(menu_tradewindow);
- menu_inventorylabel->set_label("label");
- menu_inventorylabel->set_background(false);
- menu_inventorylabel->set_border(false);
- menu_inventorylabel->set_font(ui::root()->font_small());
- menu_inventorylabel->set_alignment(ui::AlignLeft);
-
+ menu_inventorytext = new ui::PlainText(menu_tradewindow);
+ menu_inventorytext->set_label("inventorytext");
+ menu_inventorytext->set_background(false);
+ menu_inventorytext->set_border(false);
+ menu_inventorytext->set_font(ui::root()->font_small());
-
- menu_modelview = new ui::ModelView(menu_tradewindow);
- menu_modelview->set_label("modelview");
- menu_modelview->set_background(false);
- menu_modelview->set_border(false);
-
menu_scrollpane = new ui::ScrollPane(menu_tradewindow, menu_infotext);
menu_scrollpane->set_background(false);
menu_scrollpane->set_border(false);
@@ -66,12 +64,11 @@ TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent
menu_traderlistview->set_background(false);
menu_traderlistview->set_border(true);
- menu_traderlabel = new ui::Label(menu_tradewindow);
- menu_traderlabel->set_label("label");
- menu_traderlabel->set_background(false);
- menu_traderlabel->set_border(false);
- menu_traderlabel->set_font(ui::root()->font_small());
- menu_traderlabel->set_alignment(ui::AlignLeft);
+ menu_tradertext = new ui::PlainText(menu_tradewindow);
+ menu_tradertext->set_label("tradertext");
+ menu_tradertext->set_background(false);
+ menu_tradertext->set_border(false);
+ menu_tradertext->set_font(ui::root()->font_small());
menu_closebutton = new ui::Button(menu_tradewindow, "Return", "view hide");
@@ -116,7 +113,7 @@ void TradeMenu::set_item(ui::ListItem *item)
{
menu_infotext.clear();
menu_namelabel->set_text("Trade");
- menu_traderlabel->clear();
+ menu_tradertext->clear();
if (!item || !item->info()) {
menu_traderlistview->deselect();
@@ -153,8 +150,8 @@ void TradeMenu::set_item(ui::ListItem *item)
menu_buybutton->set_command("remote buy " + item->info()->type()->label() + " " + item->info()->label() + " 1; ");
std::ostringstream str;
- str << "Price: " << item->item()->price();
- menu_traderlabel->set_text(str.str());
+ str << "Price: " << std::setw(8) << item->item()->price() << '\n' << "Volume: " << std::setw(7) << std::setprecision(2) << item->info()->volume();
+ menu_tradertext->set_text(str.str());
menu_sellallbutton->hide();
menu_sellbutton->hide();
@@ -201,8 +198,8 @@ void TradeMenu::resize()
menu_inventorylistview->set_size(ui::UI::elementsize.width(), menu_tradewindow->height() - smallmargin * 2.0f - fontmargin * 6.0f);
menu_inventorylistview->set_location(fontmargin, fontmargin * 3.0f);
- menu_inventorylabel->set_size(menu_inventorylistview->width(), fontmargin);
- menu_inventorylabel->set_location(menu_inventorylistview->left(), menu_inventorylistview->bottom() + fontmargin);
+ menu_inventorytext->set_size(menu_inventorylistview->width(), fontmargin);
+ menu_inventorytext->set_location(menu_inventorylistview->left(), menu_inventorylistview->bottom() + fontmargin);
// resize modelview
menu_modelview->set_size(menu_tradewindow->width() - 2.0f * ui::UI::elementsize.width() - fontmargin * 4.0f, ui::UI::elementsize.width());
@@ -229,8 +226,8 @@ void TradeMenu::resize()
menu_traderlistview->set_size(ui::UI::elementsize.width(), menu_tradewindow->height() - smallmargin * 2.0f - fontmargin * 6.0f);
menu_traderlistview->set_location(menu_tradewindow->width() - menu_traderlistview->width() - fontmargin, fontmargin * 3.0f);
- menu_traderlabel->set_size(menu_traderlistview->width(), fontmargin);
- menu_traderlabel->set_location(menu_traderlistview->left(), menu_traderlistview->bottom() + fontmargin);
+ menu_tradertext->set_size(menu_traderlistview->width(), fontmargin);
+ menu_tradertext->set_location(menu_traderlistview->left(), menu_traderlistview->bottom() + fontmargin);
// resize close button
menu_closebutton->set_size(ui::UI::elementsize);
@@ -250,10 +247,16 @@ bool TradeMenu::on_emit(Widget *sender, const Event event, void *data)
void TradeMenu::draw()
{
std::stringstream str;
- str << "Credits: " << core::localplayer()->credits();
- menu_inventorylabel->set_text(str.str());
+ str << "Credit: " << std::setw(8) << core::localplayer()->credits();
+
+ if (core::localcontrol() && core::localcontrol()->inventory()) {
+ core::Inventory *inventory = core::localcontrol()->inventory();
+ str << '\n';
+ str << "Cargo: " << std::setprecision(2) << std::setw(6) << inventory->capacity_used() << " of " << inventory->capacity();
+ }
+ menu_inventorytext->set_text(str.str());
Window::draw();
}
-}
+} // namespace client
diff --git a/src/client/trademenu.h b/src/client/trademenu.h
index 5f56a08..6ee53b5 100644
--- a/src/client/trademenu.h
+++ b/src/client/trademenu.h
@@ -11,8 +11,9 @@
#include "ui/container.h"
#include "ui/label.h"
#include "ui/listitem.h"
-#include "ui/scrollpane.h"
#include "ui/modelview.h"
+#include "ui/plaintext.h"
+#include "ui/scrollpane.h"
#include "ui/widget.h"
#include "client/inventorylistview.h"
@@ -45,8 +46,8 @@ private:
ui::Window *menu_tradewindow;
ui::Button *menu_closebutton;
ui::Label *menu_namelabel;
- ui::Label *menu_inventorylabel;
- ui::Label *menu_traderlabel;
+ ui::PlainText *menu_inventorytext;
+ ui::PlainText *menu_tradertext;
ui::ModelView *menu_modelview;
ui::ScrollPane *menu_scrollpane;
diff --git a/src/client/video.cc b/src/client/video.cc
index 9e9d553..6eee36b 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -320,7 +320,7 @@ void draw_loader()
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
math::Vector2f pos;
math::Vector2f size(render::State::width(), render::State::height());
- ui::paint::bitmap(pos, size, "loader");
+ ui::Paint::draw_bitmap(pos, size, "bitmaps/loader");
if (loader_message.size()) {
using render::Text;
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
index c4f932b..684e08e 100644
--- a/src/client/worldview.cc
+++ b/src/client/worldview.cc
@@ -29,13 +29,13 @@ WorldView::WorldView(ui::Widget *parent) : ui::Widget(parent)
view_playerview->hide();
// icon buttons
- view_menubutton = new ui::IconButton(this, "icons/button_menu", "ui_menu");
+ view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu");
- view_launchbutton = new ui::IconButton(this, "icons/button_launch", "launch");
- view_dockbutton = new TargetIconButton(this, "icons/button_dock", "dock", core::Entity::Dockable);
+ view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch");
+ view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable);
- view_chatbutton = new ui::IconButton(this, "icons/button_chat", "ui_chat");
- view_mapbutton = new ui::IconButton(this, "icons/button_map", "ui_map");
+ view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat");
+ view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map");
}
WorldView::~WorldView()