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-10-09 22:05:46 +0000
committerStijn Buys <ingar@osirion.org>2010-10-09 22:05:46 +0000
commit43927cc52bdd7e44d62b0e6309612558f565b70f (patch)
treea3e9ccf69d6ab03c8444b78ac53d49529a52e675 /src/client
parent0ecdd8bc98ba583bbee801b838d785c6f881d7df (diff)
fix crash introduced with inventory transfer, buywindow credits indicator,
removed impulse drive initialization delay.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/buymenu.cc56
-rw-r--r--src/client/buymenu.h3
-rw-r--r--src/client/soundext.cc2
-rw-r--r--src/client/trademenu.cc6
4 files changed, 58 insertions, 9 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc
index 91f3dba..61198d3 100644
--- a/src/client/buymenu.cc
+++ b/src/client/buymenu.cc
@@ -9,6 +9,7 @@
#include "ui/paint.h"
#include "client/buymenu.h"
#include "core/info.h"
+#include "core/application.h"
namespace client
{
@@ -40,6 +41,18 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Widget(parent)
menu_namelabel->set_border(false);
menu_namelabel->set_font(ui::root()->font_large());
menu_namelabel->set_alignment(ui::AlignCenter);
+
+ menu_msgtext = new ui::Label(menu_buywindow);
+ menu_msgtext->set_label("label");
+ menu_msgtext->set_background(false);
+ menu_msgtext->set_border(false);
+ menu_msgtext->set_alignment(ui::AlignCenter);
+
+ menu_pricetext = new ui::PlainText(menu_buywindow);
+ menu_pricetext->set_label("pricetext");
+ menu_pricetext->set_background(false);
+ menu_pricetext->set_border(false);
+ menu_pricetext->set_font(ui::root()->font_small());
menu_scrollpane = new ui::ScrollPane(menu_buywindow, menu_infotext);
menu_scrollpane->set_background(false);
@@ -67,6 +80,7 @@ void BuyMenu::set_item(core::Info *info)
menu_modelview->set_modelname(0);
menu_buybutton->hide();
menu_modelview->hide();
+ menu_msgtext->hide();
// if the information timestamp is 0, the info is available
menu_inforecord = info;
@@ -81,18 +95,24 @@ void BuyMenu::set_item(core::Info *info)
for (core::Info::Text::const_iterator it = menu_inforecord->text().begin(); it != menu_inforecord->text().end(); it++) {
menu_infotext.push_back((*it));
}
- if (menu_inforecord->type()) {
+
+ if (menu_inforecord->type() && menu_inforecord->label().size()) {
menu_namelabel->set_text(menu_inforecord->name());
menu_modelview->set_modelname(menu_inforecord->modelname());
- if (menu_inforecord->label().size()) {
- menu_buybutton->set_command("remote buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label() + "; view hide");
- menu_buybutton->set_label("buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label());
+ menu_buybutton->set_command("remote buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label() + "; view hide");
+ menu_buybutton->set_label("buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label());
+ menu_modelview->show();
+
+ if (core::localplayer()->credits() < menu_inforecord->price()) {
+ menu_msgtext->set_text("^1Not enough credits");
+ menu_msgtext->show();
+ } else {
menu_buybutton->show();
- menu_modelview->show();
}
}
+
menu_infotimestamp = menu_inforecord->timestamp();
}
}
@@ -114,9 +134,14 @@ void BuyMenu::resize()
menu_namelabel->set_location(fontmargin, fontmargin);
// resize model view
- menu_modelview->set_size(ui::UI::elementsize.width() * 1.5f,
- menu_buywindow->height() - smallmargin * 2.0f - fontmargin * 3.0f);
+ menu_modelview->set_size(ui::UI::elementsize.width() * 1.5f, menu_buywindow->height() - smallmargin * 2.0f - fontmargin * 3.0f);
menu_modelview->set_location(fontmargin, fontmargin * 3.0f);
+
+ menu_msgtext->set_size(menu_modelview->width(), fontmargin);
+ menu_msgtext->set_location(menu_modelview->left(), menu_modelview->top());
+
+ menu_pricetext->set_size(menu_modelview->width(), fontmargin * 2.0f);
+ menu_pricetext->set_location(menu_modelview->left(), menu_modelview->bottom() - menu_pricetext->height());
// resize infotext pane
menu_scrollpane->set_size(menu_buywindow->width() - ui::UI::elementsize.width() * 1.5f - fontmargin * 3.0f,
@@ -136,6 +161,23 @@ void BuyMenu::draw()
// update content if necessary
if (menu_inforecord && (menu_infotimestamp != menu_inforecord->timestamp()))
set_item(menu_inforecord);
+
+ if (menu_inforecord) {
+ std::stringstream creditstr;
+ creditstr << core::localplayer()->credits();
+
+ std::stringstream pricestr;
+ pricestr << menu_inforecord->price();
+
+ std::stringstream str;
+ str << " Price: " << aux::pad_left(pricestr.str(),12);
+ str << '\n';
+ str << " Credits: " << aux::pad_left(creditstr.str(),12);
+
+ menu_pricetext->set_text(str.str());
+ } else {
+ menu_pricetext->clear();
+ }
}
bool BuyMenu::on_keypress(const int key, const unsigned int modifier)
diff --git a/src/client/buymenu.h b/src/client/buymenu.h
index 91ed10e..7f19ebf 100644
--- a/src/client/buymenu.h
+++ b/src/client/buymenu.h
@@ -12,6 +12,7 @@
#include "ui/button.h"
#include "ui/label.h"
#include "ui/modelview.h"
+#include "ui/plaintext.h"
#include "ui/widget.h"
#include "ui/scrollpane.h"
@@ -43,6 +44,8 @@ private:
ui::Label *menu_namelabel;
ui::ScrollPane *menu_scrollpane;
ui::ModelView *menu_modelview;
+ ui::Label *menu_msgtext;
+ ui::PlainText *menu_pricetext;
ui::Button *menu_closebutton;
ui::Button *menu_buybutton;
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index d05d20e..117c62d 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -227,7 +227,7 @@ void SoundExt::frame(float elapsed)
pitch = 1.0f;
} else {
- if (state_engineeventbuffer == state_impulseloopbuffer) {
+ if ((state_engineeventbuffer == state_impulsestartbuffer) || (state_engineeventbuffer == state_impulseloopbuffer)) {
audio::update_source(state_engineeventsource,
entity->location() - entity->axis().forward() * r ,
entity->axis().forward() * speed);
diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc
index f0030f5..3c0847a 100644
--- a/src/client/trademenu.cc
+++ b/src/client/trademenu.cc
@@ -348,8 +348,12 @@ void TradeMenu::draw()
set_itemtype(menu_itemtype);
}
+
+ std::stringstream creditstr;
+ creditstr << core::localplayer()->credits();
+
std::stringstream str;
- str << "Credits: " << std::setw(12) << core::localplayer()->credits();
+ str << "Credits: " << aux::pad_left(creditstr.str(),12);
if (core::localcontrol() && core::localcontrol()->inventory()) {
core::Inventory *inventory = core::localcontrol()->inventory();