From 25af16fac3127523d532d4b4797eec7947ed5a72 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 1 Oct 2010 22:07:45 +0000 Subject: Initial inventory window --- src/client/playerview.cc | 64 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 11 deletions(-) (limited to 'src/client/playerview.cc') diff --git a/src/client/playerview.cc b/src/client/playerview.cc index 7791a2a..159371c 100644 --- a/src/client/playerview.cc +++ b/src/client/playerview.cc @@ -36,6 +36,7 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent) view_entitymenu = new EntityMenu(this); view_buymenu = new BuyMenu(this); view_trademenu = new TradeMenu(this); + view_inventory = new Inventory(this); //view_hud->set_focus(); //view_hud->raise(); @@ -68,11 +69,17 @@ void PlayerView::toggle_map() { if (!map()->visible()) { - if (chat()->visible() && !chat()->small_view()) + if (chat()->visible() && !chat()->small_view()) { chat()->hide(); + } - if (view_entitymenu->visible()) + if (inventory()->visible()) { + inventory()->hide(); + } + + if (view_entitymenu->visible()) { view_entitymenu->hide(); + } } map()->toggle(); @@ -83,11 +90,40 @@ void PlayerView::toggle_map() } } +void PlayerView::toggle_inventory() +{ + + if (!inventory()->visible()) { + if (chat()->visible() && !chat()->small_view()) { + chat()->hide(); + } + + if (map()->visible()) { + map()->hide(); + } + + if (view_entitymenu->visible()) { + view_entitymenu->hide(); + } + } + + inventory()->toggle(); + audio::play("ui/menu"); + + if (inventory()->visible() && chat()->visible() && chat()->small_view()) { + chat()->raise(); + } +} + void PlayerView::toggle_chat() { if (!chat()->visible()) { if (map()->visible()) map()->hide(); + + if (inventory()->visible()) { + inventory()->hide(); + } if (view_entitymenu->visible()) view_entitymenu->hide(); @@ -189,7 +225,11 @@ void PlayerView::resize() // reposition map view_map->set_size(width() - smallmargin * 2, height() - smallmargin * 4); view_map->set_location(smallmargin, smallmargin * 2); - + + // reposition inventory + view_inventory->set_size(width() - smallmargin * 2, height() - smallmargin * 4); + view_inventory->set_location(smallmargin, smallmargin * 2); + // reposition notifications view_notify->set_geometry(view_map->location(), view_map->size()); @@ -228,7 +268,7 @@ void PlayerView::draw() audio::play("ui/menu"); } else if (!view_entitymenu->visible() && !view_buymenu->visible() && !view_trademenu->visible() && - !map()->visible() && (!chat()->visible() || chat()->small_view())) { + !inventory()->visible() && !map()->visible() && (!chat()->visible() || chat()->small_view())) { // show the menu if there's no other window open view_entitymenu->show(); @@ -270,7 +310,7 @@ void PlayerView::draw() label_viewname->hide(); } - if (!map()->visible() && !chat()->visible()) { + if (!map()->visible() && !chat()->visible() && !inventory()->visible()) { view_hud->set_focus(); } @@ -278,13 +318,15 @@ void PlayerView::draw() } // reposition chat widget - if (view_chat->small_view()) { - view_chat->set_size(width() - smallmargin * 2, font()->height() * 2); - view_chat->set_location(smallmargin, height() - smallmargin *2 - view_chat->height()); - } else { - view_chat->set_geometry(view_map->location(), view_map->size()); + if (chat()->visible()) { + if (view_chat->small_view()) { + view_chat->set_size(width() - smallmargin * 2, font()->height() * 2); + view_chat->set_location(smallmargin, height() - smallmargin *2 - view_chat->height()); + } else { + view_chat->set_geometry(view_map->location(), view_map->size()); + } + view_chat->event_resize(); } - view_chat->event_resize(); } } -- cgit v1.2.3