Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ROADMAP33
-rw-r--r--doc/TODO12
-rw-r--r--src/client/inventory.cc108
-rw-r--r--src/client/inventory.h20
-rw-r--r--src/ui/button.cc4
-rw-r--r--src/ui/iconbutton.cc9
-rw-r--r--src/ui/listitem.cc8
-rw-r--r--src/ui/listitem.h2
-rwxr-xr-xsrc/ui/modelview.cc4
9 files changed, 172 insertions, 28 deletions
diff --git a/doc/ROADMAP b/doc/ROADMAP
index 51654dd..9afaab8 100644
--- a/doc/ROADMAP
+++ b/doc/ROADMAP
@@ -66,17 +66,18 @@
Requires:
- player credits
- item info + lazy server-client exchange
- trading
- inventories
+ player credits (ok)
+ item info + lazy server-client exchange (ok)
+ trading (ok)
+ inventories (ok)
Related:
- map entity descriptions
- equipment trading
- player-to-player trading
+ map entity descriptions (ok)
eject cargo/tractor beam
+ player-to-player trading
+ player saving
+ equipment trading
model weapon slots and positioning
Optional:
@@ -84,8 +85,24 @@
fuel system
economy
tool to generate item icons from models
- dockable player ships with trade
+ dockable player ships (ok)
+ Implementation:
+
+ inventory + ship statistics window
+ base inventory depletion, per-item adjustabe depletion rate
+ dockable player ships needs owner permissions
+ eject/destroy cargo
+ handle inventory transfer on ship aquisition
+ player-to-player trading
+ player shops
+ player must be capable of setting the kind and price of items to sell
+ item 'tradeable' flag
+ shop allows multiple buyers, p2p trading just one
+ player factory ships + base factories, per-item adjustabe conversion rate and ratio
+ e.g. 2 units of niobum to 1 superconductor per 30 seconds
+
+
------------------------------------------------------------------
version 0.3.0 - Equipment
diff --git a/doc/TODO b/doc/TODO
index 37bee4f..417ccbb 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -36,14 +36,16 @@ model:
core:
BUG dedicated server does not show chat messages (to be verified)
fix game.ini load/save sequence
+ fx events: jump events, tracktor beams, weapons fire
+ pause game loop when there are no players
network:
protocol description (incomplete)
- zone/system chat
- group/clan chat (requires groups)
+ zone chat
+ group chat (requires player groups)
rcon authentication, rcon command, servers must be able to disable rcon
rconpassword: send md5sum instead of plaintext
- player authentication (player id)
+ player authentication (player id), admin rights
add server-side distance check before sending entity updates
fix lag/client interpolation
@@ -56,6 +58,7 @@ network:
reliable network messages (e.g. entity create/die)
client:
+ add map window target model
fix camera frustum clip (size issue, postponed)
tracking camera absolute speed/position
gui concept artwork
@@ -67,6 +70,7 @@ render:
ui:
modelview lighting (-> it uses current zone lighting)
+ unify evennt handlers, expand Event class ad make derived event classes
sound:
entity/event positional sounds
@@ -74,7 +78,7 @@ sound:
game:
entity health/shield/armor
- fix 'give ship' destroying inventory
+ fix 'give ship' and 'buy ship' destroying inventory
data:
update starsystem roadmap
diff --git a/src/client/inventory.cc b/src/client/inventory.cc
index 5837a17..c6e86da 100644
--- a/src/client/inventory.cc
+++ b/src/client/inventory.cc
@@ -19,6 +19,13 @@ Inventory::Inventory(ui::Widget *parent) : ui::Window(parent)
{
menu_infotimestamp = 0;
menu_inventorytimestamp = 0;
+ menu_inforecord = 0;
+ menu_amount = 0;
+
+ menu_modelview = new ui::ModelView(this);
+ menu_modelview->set_label("modelview");
+ menu_modelview->set_background(false);
+ menu_modelview->set_border(false);
menu_namelabel = new ui::Label(this);
menu_namelabel->set_label("label");
@@ -39,6 +46,13 @@ Inventory::Inventory(ui::Widget *parent) : ui::Window(parent)
menu_inventorytext->set_border(false);
menu_inventorytext->set_font(ui::root()->font_small());
+ menu_scrollpane = new ui::ScrollPane(this, menu_infotext);
+ menu_scrollpane->set_background(false);
+ menu_scrollpane->set_border(false);
+ menu_scrollpane->set_alignment(ui::AlignTop);
+
+ menu_shipbutton = new ui::IconButton(this, "bitmaps/icons/button_ship");
+
hide();
}
@@ -56,12 +70,13 @@ void Inventory::toggle()
void Inventory::update_inventory()
{
menu_listview->clear();
- menu_infotimestamp = 0;
menu_inventorytimestamp = 0;
+ menu_infotimestamp = 0;
if (!core::localcontrol() || !core::localcontrol()->inventory()) {
return;
}
+
const core::Item *selecteditem = (menu_listview->selected() ? menu_listview->selected()->item() : 0);
for (core::Inventory::Items::const_iterator it = core::localcontrol()->inventory()->items().begin(); it != core::localcontrol()->inventory()->items().end(); it++) {
@@ -97,18 +112,29 @@ void Inventory::update_inventory()
}
}
}
- menu_listview->event_resize();
+
+ // request ship info
+ if (core::localcontrol()->info()) {
+ core::game()->request_info(core::localcontrol()->info()->id());
+ if (core::localcontrol()->info()->timestamp() > menu_infotimestamp)
+ menu_infotimestamp = core::localcontrol()->info()->timestamp();
+ }
+
menu_inventorytimestamp = core::localcontrol()->inventory()->timestamp();
-}
-void Inventory::update_selection()
-{
+ if (menu_listview->selected()) {
+ set_info(menu_listview->selected()->info(), menu_listview->selected()->item()->amount());
+ } else if (menu_inforecord != core::localcontrol()->info()) {
+ set_info(0, 0);
+ }
+
+ menu_listview->event_resize();
}
bool Inventory::verify() const
{
if (!core::localcontrol() || !core::localcontrol()->inventory()) {
-
+ return true;
}
if (menu_inventorytimestamp != core::localcontrol()->inventory()->timestamp()) {
@@ -132,6 +158,7 @@ void Inventory::resize()
{
const float smallmargin = ui::UI::elementsize.height();
const float fontmargin = ui::root()->font_large()->height();
+ const float icon_size = 48.0f;
// resize label
menu_namelabel->set_size(width() - fontmargin * 2.0f, menu_namelabel->font()->height());
@@ -143,12 +170,27 @@ void Inventory::resize()
menu_inventorytext->set_size(menu_listview->width(), fontmargin * 2.0f);
menu_inventorytext->set_location(menu_listview->left(), menu_listview->bottom() + fontmargin);
+
+ menu_shipbutton->set_size(icon_size, icon_size);
+ menu_shipbutton->set_location(menu_inventorytext->left(), height() - icon_size - fontmargin);
+
+ // resize modelview
+ menu_modelview->set_size( width() - menu_listview->right() - fontmargin * 2.0f ,ui::UI::elementsize.width());
+ menu_modelview->set_location(menu_listview->right() + fontmargin, fontmargin * 3.0f);
+
+ // resize infotext
+ menu_scrollpane->set_size(menu_modelview->width(), height() - menu_modelview->bottom() - 2.0f * fontmargin);
+ menu_scrollpane->set_location(menu_modelview->left(), menu_modelview->bottom() + fontmargin);
}
void Inventory::draw()
{
if (!verify()) {
- update_inventory();
+ update_inventory();
+ }
+
+ if (menu_inforecord && (menu_inforecord->timestamp() > menu_infotimestamp)) {
+ set_info(menu_inforecord, menu_amount);
}
std::stringstream str;
@@ -167,8 +209,60 @@ void Inventory::draw()
Window::draw();
}
+void Inventory::show()
+{
+ menu_listview->deselect();
+ set_info(0, 0);
+ Window::show();
+}
+
+void Inventory::set_info(const core::Info *info, const int amount)
+{
+ menu_inforecord = info;
+ menu_infotext.clear();
+ menu_amount = amount;
+
+ if (!info) {
+ menu_modelview->set_modelname(0);
+ menu_namelabel->set_text("Inventory");
+ } else {
+ std::stringstream titlestr;
+ titlestr << info->name();
+ if (amount > 0) {
+ titlestr << " (" << amount << ")";
+ }
+ menu_namelabel->set_text(titlestr.str().c_str());
+ core::game()->request_info(info->id());
+ menu_modelview->set_modelname(info->modelname());
+
+ for (core::Info::Text::const_iterator it = menu_inforecord->text().begin(); it != menu_inforecord->text().end(); it++) {
+ menu_infotext.push_back((*it));
+ }
+ if (info->timestamp() > menu_infotimestamp) {
+ menu_infotimestamp = info->timestamp();
+ }
+ }
+
+}
+
bool Inventory::on_emit(Widget *sender, const Event event, void *data)
{
+ if (event == ui::Widget::EventButtonClicked) {
+
+ if (sender == menu_shipbutton) {
+ menu_listview->deselect();
+ set_info(core::localcontrol() ? core::localcontrol()->info() : 0, 0);
+ }
+ return true;
+
+ } else if (event == ui::Widget::EventListViewChanged) {
+
+ if (sender == menu_listview) {
+ set_info(menu_listview->selected() ? menu_listview->selected()->info() : 0, menu_listview->selected()->item()->amount());
+ }
+ return true;
+ }
+
return Window::on_emit(sender, event, data);
}
diff --git a/src/client/inventory.h b/src/client/inventory.h
index f66ec56..00b3b51 100644
--- a/src/client/inventory.h
+++ b/src/client/inventory.h
@@ -9,7 +9,10 @@
#include "core/info.h"
#include "core/inventory.h"
+#include "ui/iconbutton.h"
#include "ui/listview.h"
+#include "ui/modelview.h"
+#include "ui/scrollpane.h"
#include "ui/plaintext.h"
#include "ui/window.h"
@@ -25,6 +28,8 @@ public:
~Inventory();
void toggle();
+
+ virtual void show();
protected:
/// resize event handler
virtual void resize();
@@ -41,15 +46,26 @@ protected:
private:
void update_inventory();
- void update_selection();
+ void set_info(const core::Info *info, const int amount);
bool verify() const;
unsigned long menu_inventorytimestamp;
unsigned long menu_infotimestamp;
- ui::ListView *menu_listview;
+
+ int menu_amount;
+
+ ui::Text menu_infotext;
+
+ const core::Info *menu_inforecord;
+
+ ui::ModelView *menu_modelview;
+
ui::Label *menu_namelabel;
+ ui::ListView *menu_listview;
ui::PlainText *menu_inventorytext;
+ ui::ScrollPane *menu_scrollpane;
+ ui::IconButton *menu_shipbutton;
}; // class Inventory
diff --git a/src/ui/button.cc b/src/ui/button.cc
index ddcc72d..6cbb51e 100644
--- a/src/ui/button.cc
+++ b/src/ui/button.cc
@@ -85,7 +85,9 @@ bool Button::on_keypress(const int key, const unsigned int modifier)
{
if (key == 512 + SDL_BUTTON_LEFT) {
if (enabled()) {
- core::cmd() << button_command << std::endl;
+ if (button_command.size()) {
+ core::cmd() << button_command << std::endl;
+ }
audio::play("ui/button");
emit(EventButtonClicked);
diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 204918e..5f16e71 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -81,7 +81,7 @@ void IconButton::draw()
Paint::set_color(palette()->foreground());
}
- Paint::draw_bitmap(location(), size(), icon());
+ Paint::draw_bitmap(global_location(), size(), icon());
}
void IconButton::draw_border()
@@ -101,9 +101,12 @@ void IconButton::draw_border()
bool IconButton::on_keypress(const int key, const unsigned int modifier)
{
if (key == 512 + SDL_BUTTON_LEFT) {
- if (enabled() && iconbutton_command.size()) {
- core::cmd() << iconbutton_command << std::endl;
+ if (enabled()) {
+ if (iconbutton_command.size()) {
+ core::cmd() << iconbutton_command << std::endl;
+ }
audio::play("ui/button");
+ emit(EventButtonClicked);
}
return true;
}
diff --git a/src/ui/listitem.cc b/src/ui/listitem.cc
index ff9ad18..8702757 100644
--- a/src/ui/listitem.cc
+++ b/src/ui/listitem.cc
@@ -51,10 +51,16 @@ void ListItem::draw()
Paint::draw_label(global_location(), size(), font(), text(), alignment());
}
+void ListItem::on_mouseover(const math::Vector2f &cursor)
+{
+ if (enabled())
+ audio::play("ui/select");
+}
+
bool ListItem::on_keypress(const int key, const unsigned int modifier)
{
if (key == 512 + SDL_BUTTON_LEFT) {
- audio::play("ui/select");
+ audio::play("ui/button");
emit(EventListItemClicked);
diff --git a/src/ui/listitem.h b/src/ui/listitem.h
index 6fad3e9..3c9efea 100644
--- a/src/ui/listitem.h
+++ b/src/ui/listitem.h
@@ -52,6 +52,8 @@ protected:
/// draw the button border
virtual void draw_border();
+ virtual void on_mouseover(const math::Vector2f &cursor);
+
virtual void draw();
private:
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index b247213..9542b5f 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -69,12 +69,12 @@ void ModelView::set_zoom(const float zoom)
bool ModelView::on_keypress(const int key, const unsigned int modifier)
{
if (key == 512 + SDL_BUTTON_WHEELUP) {
- modelview_zoom -= 0.1f;
+ modelview_zoom -= 0.5f;
if (modelview_zoom < 1.0f)
modelview_zoom = 1.0f;
return true;
} else if (key == 512 + SDL_BUTTON_WHEELDOWN) {
- modelview_zoom += 0.1f;
+ modelview_zoom += 0.5f;
if (modelview_zoom > 10.0f)
modelview_zoom = 10.0f;
return true;