From 0c509866a37ab47ff0e48d357ca55e31658c37c2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 16 Sep 2010 14:12:27 +0000 Subject: map info support, initial trade window --- src/client/Makefile.am | 4 ++-- src/client/inventorymenu.cc | 19 ++++++++++++++++ src/client/inventorymenu.h | 26 ++++++++++++++++++++++ src/client/inventorywindow.cc | 19 ---------------- src/client/inventorywindow.h | 26 ---------------------- src/client/playerview.cc | 35 ++++++++++++++++++++++++------ src/client/trademenu.cc | 50 +++++++++++++++++++++++++++++++++++++++++-- src/client/trademenu.h | 16 +++++++++++--- 8 files changed, 136 insertions(+), 59 deletions(-) create mode 100644 src/client/inventorymenu.cc create mode 100644 src/client/inventorymenu.h delete mode 100644 src/client/inventorywindow.cc delete mode 100644 src/client/inventorywindow.h (limited to 'src/client') 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/inventorymenu.cc b/src/client/inventorymenu.cc new file mode 100644 index 0000000..435c3b2 --- /dev/null +++ b/src/client/inventorymenu.cc @@ -0,0 +1,19 @@ +/* + 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/inventorymenu.h" + +namespace client { + +InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent) +{ +} + +InventoryWindow::~InventoryWindow() +{ +} + +} // namespace client diff --git a/src/client/inventorymenu.h b/src/client/inventorymenu.h new file mode 100644 index 0000000..7d4809a --- /dev/null +++ b/src/client/inventorymenu.h @@ -0,0 +1,26 @@ +/* + 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 +*/ + +#ifndef __INCLUDED_CLIENT_INVENTORYWINDOW_H__ +#define __INCLUDED_CLIENT_INVENTORYWINDOW_H__ + +#include "ui/window.h" + +namespace client { + +/** + * @brief an inventory window widget + */ +class InventoryWindow : public ui::Window +{ +public: + InventoryWindow(ui::Widget *parent = 0); + ~InventoryWindow(); + +}; // class InventoryWindow + +} +#endif // __INCLUDED_CLIENT_INVENTORYWINDOW_H__ diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc deleted file mode 100644 index b6ef82b..0000000 --- a/src/client/inventorywindow.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* - client/inventorywindow.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" - -namespace client { - -InventoryWindow::InventoryWindow(ui::Widget *parent) : ui::Window(parent) -{ -} - -InventoryWindow::~InventoryWindow() -{ -} - -} // namespace client diff --git a/src/client/inventorywindow.h b/src/client/inventorywindow.h deleted file mode 100644 index ec6ad02..0000000 --- a/src/client/inventorywindow.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - client/inventorywindow.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 -*/ - -#ifndef __INCLUDED_CLIENT_INVENTORYWINDOW_H__ -#define __INCLUDED_CLIENT_INVENTORYWINDOW_H__ - -#include "ui/window.h" - -namespace client { - -/** - * @brief an inventory window widget - */ -class InventoryWindow : public ui::Window -{ -public: - InventoryWindow(ui::Widget *parent = 0); - ~InventoryWindow(); - -}; // class InventoryWindow - -} -#endif // __INCLUDED_CLIENT_INVENTORYWINDOW_H__ 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; }; } -- cgit v1.2.3