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-17 15:19:34 +0000
committerStijn Buys <ingar@osirion.org>2010-09-17 15:19:34 +0000
commitc62fe609a69058e2e30f757e9a06f72a98464232 (patch)
tree53f6a671bd84924ddf7d278cf10a3e527670088e /src/client/buymenu.cc
parent0c509866a37ab47ff0e48d357ca55e31658c37c2 (diff)
Bump network protocol version to 19, menudescriptions use the info infrastructure, client-side lazy info update requests.
Updated ROADMAP
Diffstat (limited to 'src/client/buymenu.cc')
-rw-r--r--src/client/buymenu.cc52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc
index c3878a8..a106659 100644
--- a/src/client/buymenu.cc
+++ b/src/client/buymenu.cc
@@ -9,7 +9,7 @@
#include "ui/paint.h"
#include "client/buymenu.h"
#include "core/info.h"
-#include "core/application.h"
+
namespace client
{
@@ -30,7 +30,7 @@ BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
menu_buywindow->set_border(true);
menu_namelabel = new ui::Label(menu_buywindow);
- menu_namelabel->set_label("infolabel");
+ menu_namelabel->set_label("label");
menu_namelabel->set_background(false);
menu_namelabel->set_border(false);
menu_namelabel->set_font(ui::root()->font_large());
@@ -60,35 +60,41 @@ BuyMenu::~BuyMenu()
}
-void BuyMenu::set_item(std::string const & itemtype, std::string const & itemname)
+void BuyMenu::set_item(core::Info *info)
{
- menu_itemtype.assign(itemtype);
- aux::to_label(menu_itemtype);
-
- menu_itemname.assign(itemname);
- aux::to_label(menu_itemname);
-
- menu_buybutton->set_command("remote buy " + menu_itemtype + ' ' + menu_itemname + "; view hide");
- menu_buybutton->set_label("buy " + menu_itemname);
-
menu_infotext.clear();
menu_namelabel->set_text(0);
menu_modelview->set_modelname(0);
- menu_inforecord = core::game()->info(menu_itemtype, menu_itemname);
+ // if the information timestamp is 0, the info is available
+ menu_inforecord = info;
- if (menu_inforecord) {
- menu_namelabel->set_text(menu_inforecord->name());
- menu_modelview->set_modelname(menu_inforecord->modelname());
-
+ if (!menu_inforecord) {
+ menu_buybutton->hide();
+ menu_modelview->hide();
+
+ menu_infotext.push_back("Information is not available");
+ menu_infotimestamp = 0;
+ } else {
for (core::Info::Text::const_iterator it = menu_inforecord->text().begin(); it != menu_inforecord->text().end(); it++) {
menu_infotext.push_back((*it));
}
+
+ menu_infotimestamp = menu_inforecord->timestamp();
+ if (menu_inforecord->type() && !menu_inforecord->timestamp()) {
+ menu_namelabel->set_text(menu_inforecord->name());
+ menu_modelview->set_modelname(menu_inforecord->modelname());
+
+ menu_buybutton->set_command("remote buy " + menu_inforecord->type()->label() + ' ' + menu_inforecord->label() + "; view hide");
+ menu_buybutton->set_label("buy " + menu_inforecord->name());
+
+ menu_buybutton->show();
+ menu_modelview->show();
+ } else {
+ menu_buybutton->hide();
+ menu_modelview->hide();
+ }
menu_infotimestamp = menu_inforecord->timestamp();
- } else {
- menu_infotext.push_back("Information is not available");
- menu_infotimestamp = 0;
- menu_inforecord = 0;
}
}
@@ -129,8 +135,8 @@ void BuyMenu::resize()
void BuyMenu::draw()
{
// update content if necessary
- if (menu_infotimestamp && menu_inforecord && (menu_infotimestamp != menu_inforecord->timestamp()))
- set_item(menu_itemtype, menu_itemname);
+ if (menu_inforecord && (menu_infotimestamp != menu_inforecord->timestamp()))
+ set_item(menu_inforecord);
}
bool BuyMenu::on_keypress(const int key, const unsigned int modifier)