Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio/audio.cc12
-rw-r--r--src/audio/audio.h4
-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
-rw-r--r--src/game/base/ship.cc6
-rw-r--r--src/game/base/shipmodel.cc17
8 files changed, 87 insertions, 19 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index b7a79d7..46d3a67 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -212,4 +212,16 @@ void update_source(size_t source_index, math::Vector3f const & location, math::V
alSourcef(source, AL_GAIN, gain);
}
+bool is_playing(const size_t source_index)
+{
+ if (!audio_context)
+ return false;
+
+ ALuint source = Sources::source(source_index);
+ ALint srcstate = 0;
+ alGetSourcei(source , AL_SOURCE_STATE , &srcstate);
+
+ return (srcstate == AL_PLAYING);
+}
+
}
diff --git a/src/audio/audio.h b/src/audio/audio.h
index ecfdf3e..ad9a024 100644
--- a/src/audio/audio.h
+++ b/src/audio/audio.h
@@ -58,6 +58,10 @@ void update_source(size_t source_index, math::Vector3f const & location, math::V
/// update listener parameters
void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity, float gain = 1.0f);
+
+/// return true is a source is playing
+bool is_playing(const size_t source_index);
+
}
#endif // __INCLUDED_AUDIO_AUDIO_H__
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();
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 696033c..a588122 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -416,11 +416,13 @@ void Ship::frame(float seconds)
// clamp input values
target_thrust = 0.0f;
+ target_afterburner = 0.0f;
math::clamp(target_pitch, -1.0f, 1.0f);
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
- math::clamp(target_afterburner, -1.0f, 1.0f);
-
+
+ actual_maxspeed = Game::g_impulsespeed->value();
+ actual_acceleration = Game::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
}
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index 9133d28..077fd3e 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -235,13 +235,6 @@ void ShipModel::buy(core::EntityControlable *buyer, core::Entity *seller)
player->send("^WCan not afford transaction!");
return;
}
-
- player->add_credits(-price());
-
- // player has only ship for now
- if (player->control()) {
- player->remove_asset(player->control());
- }
Ship * ship = new Ship(player, this);
ship->set_zone(seller->zone());
@@ -257,9 +250,17 @@ void ShipModel::buy(core::EntityControlable *buyer, core::Entity *seller)
}
ship->inventory()->set_dirty();
+ // remove old ship
+ if (player->control()) {
+ player->remove_asset(player->control());
+ }
+
+ // set control to new ship
player->set_control(ship);
player->set_view(seller);
-
+
+ player->add_credits(-price());
+
// send the ship purchased message
std::stringstream msgstr;
msgstr << "^BPurchased " << aux::article(name()) << " for " << price() << " credits";