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-16 14:12:27 +0000
committerStijn Buys <ingar@osirion.org>2010-09-16 14:12:27 +0000
commit0c509866a37ab47ff0e48d357ca55e31658c37c2 (patch)
tree57f69397ac1b30ce42a3e3fcd19c2fd8ed67d4e0 /src/client
parent3392cb739f212aea561eceb1781cd2e10e55c932 (diff)
map info support, initial trade window
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am4
-rw-r--r--src/client/inventorymenu.cc (renamed from src/client/inventorywindow.cc)4
-rw-r--r--src/client/inventorymenu.h (renamed from src/client/inventorywindow.h)2
-rw-r--r--src/client/playerview.cc35
-rw-r--r--src/client/trademenu.cc50
-rw-r--r--src/client/trademenu.h16
6 files changed, 94 insertions, 17 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 3169525..741f5a3 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -8,7 +8,7 @@ noinst_LTLIBRARIES = libclient.la
endif
libclient_la_SOURCES = action.cc buymenu.cc chat.cc client.cc clientext.cc \
- entitymenu.cc hud.cc infowidget.cc input.cc inventorywindow.cc joystick.cc key.cc \
+ entitymenu.cc hud.cc infowidget.cc input.cc inventorymenu.cc joystick.cc key.cc \
keyboard.cc map.cc notifications.cc playerview.cc soundext.cc targeticonbutton.cc \
targets.cc trademenu.cc video.cc worldview.cc
@@ -17,7 +17,7 @@ libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_HEADERS = action.h chat.h client.h clientext.h hud.h entitymenu.h \
- input.h inventorywindow.h joystick.h key.h keyboard.h map.h notifications.h soundext.h \
+ input.h inventorymenu.h joystick.h key.h keyboard.h map.h notifications.h soundext.h \
targets.h video.h infowidget.h playerview.h worldview.h trademenu.h buymenu.h \
targeticonbutton.h
diff --git a/src/client/inventorywindow.cc b/src/client/inventorymenu.cc
index b6ef82b..435c3b2 100644
--- a/src/client/inventorywindow.cc
+++ b/src/client/inventorymenu.cc
@@ -1,10 +1,10 @@
/*
- client/inventorywindow.cc
+ client/inventorymenu.cc
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
-#include "client/inventorywindow.h"
+#include "client/inventorymenu.h"
namespace client {
diff --git a/src/client/inventorywindow.h b/src/client/inventorymenu.h
index ec6ad02..7d4809a 100644
--- a/src/client/inventorywindow.h
+++ b/src/client/inventorymenu.h
@@ -1,5 +1,5 @@
/*
- client/inventorywindow.h
+ client/inventorymenu.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
index 578e97f..de4c704 100644
--- a/src/client/playerview.cc
+++ b/src/client/playerview.cc
@@ -33,7 +33,8 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent)
view_map = new Map(this);
view_entitymenu = new EntityMenu(this);
view_buymenu = new BuyMenu(this);
-
+ view_trademenu = new TradeMenu(this);
+
//view_hud->set_focus();
//view_hud->raise();
//view_entitymenu->raise();
@@ -51,6 +52,8 @@ void PlayerView::clear()
view_chat->hide();
view_map->hide();
view_entitymenu->hide();
+ view_buymenu->hide();
+ view_trademenu->hide();
}
void PlayerView::event_text(const std::string & text)
@@ -120,24 +123,36 @@ void PlayerView::show_menu(const std::string & args)
std::string itemname;
if ((argstr >> itemtype) && (argstr >> itemname)) {
+ // hide other menus
+ view_entitymenu->hide();
+ view_trademenu->hide();
+ // show buy menu
view_buymenu->set_item(itemtype, itemname);
view_buymenu->show();
- view_entitymenu->hide();
+
} else {
con_print << "usage: view buy [string] [string] buy menu for item type and name" << std::endl;
}
} else if (label.compare("trade") == 0) {
- // trade menu, multiple items
-
+ // hide other menus
+ view_buymenu->hide();
+ view_entitymenu->hide();
+ // show trade menu
+ view_trademenu->show();
+
} else if (label.compare("hide") == 0) {
+ // hide all menus
view_buymenu->hide();
view_entitymenu->hide();
-
+ view_trademenu->hide();
} else {
+ // hide other menus
+ view_buymenu->hide();
+ view_trademenu->hide();
+ // show other menus
view_entitymenu->generate(core::localplayer()->view(), label.c_str());
view_entitymenu->show();
- view_buymenu->hide();
}
if (chat()->visible() && chat()->small_view())
@@ -152,6 +167,8 @@ void PlayerView::resize()
// reposition buy menu
view_buymenu->event_resize();
+ // reposition trade menu
+ view_trademenu->event_resize();
// set hud geometry
view_hud->set_geometry(0, 0, width(), height());
@@ -198,7 +215,7 @@ void PlayerView::draw()
chat()->hide();
audio::play("ui/menu");
- } else if (!view_entitymenu->visible() && !view_buymenu->visible() &&
+ } else if (!view_entitymenu->visible() && !view_buymenu->visible() && !view_trademenu->visible() &&
!map()->visible() && (!chat()->visible() || chat()->small_view())) {
// show the menu if there's no other window open
@@ -230,6 +247,10 @@ void PlayerView::draw()
view_buymenu->hide();
}
+ if (view_trademenu->visible()) {
+ view_trademenu->hide();
+ }
+
if (map()->visible()) {
label_viewname->set_text(core::localplayer()->zone()->name());
label_viewname->show();
diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc
index c60791f..75b9d67 100644
--- a/src/client/trademenu.cc
+++ b/src/client/trademenu.cc
@@ -4,15 +4,15 @@
the terms of the GNU General Public License version 2
*/
-#include "ui/ui.h"
#include "ui/button.h"
#include "ui/paint.h"
+#include "ui/ui.h"
#include "client/trademenu.h"
namespace client
{
-TradeMenu::TradeMenu(ui::Window *parent, const char * label) : ui::Window(parent)
+TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
{
set_border(false);
set_background(false);
@@ -24,7 +24,19 @@ TradeMenu::TradeMenu(ui::Window *parent, const char * label) : ui::Window(parent
menu_tradewindow = new ui::Window(this);
menu_tradewindow->set_label("tradewindow");
menu_tradewindow->set_border(true);
+
+ menu_listview = new ui::ListView(menu_tradewindow);
+ menu_listview->set_label("listview");
+ menu_listview->set_background(false);
+ menu_listview->set_border(true);
+
+ menu_scrollpane = new ui::ScrollPane(menu_tradewindow, menu_infotext);
+ menu_scrollpane->set_background(false);
+ menu_scrollpane->set_border(true);
+ menu_scrollpane->set_alignment(ui::AlignTop);
+ menu_closebutton = new ui::Button(menu_tradewindow, "Return", "view hide");
+
hide();
}
@@ -33,4 +45,38 @@ TradeMenu::~TradeMenu()
}
+void TradeMenu::resize()
+{
+ const float smallmargin = ui::UI::elementsize.height();
+ const float fontmargin = ui::root()->font_large()->height();
+
+ // this menu takes the entire screen
+ set_size(parent()->size());
+
+ // resize the subwindow
+ menu_tradewindow->set_size(width() - smallmargin * 2.0f, height()- smallmargin * 4.0f);
+ menu_tradewindow->set_location(smallmargin, smallmargin * 2.0f);
+
+ // resize label
+ //menu_namelabel->set_size(menu_tradewindow->width() - fontmargin * 2.0f, menu_namelabel->font()->height());
+ //menu_namelabel->set_location(fontmargin, fontmargin);
+
+ // resize listview
+ menu_listview->set_size(ui::UI::elementsize.width() * 1.5f, menu_tradewindow->height() - smallmargin * 2.0f - fontmargin * 3.0f);
+ menu_listview->set_location(fontmargin, fontmargin * 3.0f);
+
+ // resize infotext pane
+ menu_scrollpane->set_size(menu_tradewindow->width() - ui::UI::elementsize.width() * 1.5f - fontmargin * 3.0f,
+ menu_tradewindow->height() - smallmargin * 2.0f - fontmargin * 3.0f);
+ menu_scrollpane->set_location(ui::UI::elementsize.width() * 1.5f + fontmargin * 2.0f, fontmargin * 3.0f);
+
+ // resize buttons
+ //menu_buybutton->set_size(ui::UI::elementsize);
+ //menu_buybutton->set_location(menu_tradewindow->width() * 0.5f - ui::UI::elementsize.width() - smallmargin * 2.0f, menu_tradewindow->height() - smallmargin * 1.5f);
+
+ menu_closebutton->set_size(ui::UI::elementsize);
+ //menu_closebutton->set_location(menu_tradewindow->width() * 0.5f + smallmargin * 2.0f, menu_tradewindow->height() - smallmargin * 1.5f);
+ menu_closebutton->set_location(0.5f * (menu_tradewindow->width() - ui::UI::elementsize.width()), menu_tradewindow->height() - smallmargin * 1.5f );
+}
+
}
diff --git a/src/client/trademenu.h b/src/client/trademenu.h
index 03b5077..98cf71d 100644
--- a/src/client/trademenu.h
+++ b/src/client/trademenu.h
@@ -7,9 +7,11 @@
#ifndef __INCLUDED_CLIENT_TRADEMENU_H__
#define __INCLUDED_CLIENT_TRADEMENU_H__
+#include "core/info.h"
#include "ui/container.h"
#include "ui/label.h"
-#include "ui/window.h"
+#include "ui/listview.h"
+#include "ui/widget.h"
namespace client
{
@@ -18,8 +20,8 @@ namespace client
class TradeMenu : public ui::Window
{
public:
- /// create a new menu
- TradeMenu(ui::Window *parent, const char * label = 0);
+ /// create a new trade menu
+ TradeMenu(ui::Widget *parent, const char * label = 0);
~TradeMenu();
protected:
@@ -28,6 +30,14 @@ protected:
private:
ui::Window *menu_tradewindow;
+ ui::ListView *menu_listview;
+ ui::ScrollPane *menu_scrollpane;
+ ui::Button *menu_closebutton;
+
+ core::Info *menu_inforecord;
+ ui::Text menu_infotext;
+
+ unsigned long menu_infotimestamp;
};
}