00001 /* 00002 * The Mana World 00003 * Copyright (C) 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef INVENTORYWINDOW_H 00023 #define INVENTORYWINDOW_H 00024 00025 #include "gui/widgets/window.h" 00026 00027 #include "inventory.h" 00028 00029 #include <guichan/actionlistener.hpp> 00030 #include <guichan/keylistener.hpp> 00031 #include <guichan/selectionlistener.hpp> 00032 00033 class Item; 00034 class ItemContainer; 00035 class ProgressBar; 00036 class TextBox; 00037 00043 class InventoryWindow : public Window, 00044 public gcn::ActionListener, 00045 public gcn::KeyListener, 00046 public gcn::SelectionListener 00047 { 00048 public: 00052 #ifdef TMWSERV_SUPPORT 00053 InventoryWindow(int invSize = (INVENTORY_SIZE)); 00054 #else 00055 InventoryWindow(int invSize = (INVENTORY_SIZE - 2)); 00056 #endif 00057 00061 ~InventoryWindow(); 00062 00066 void logic(); 00067 00071 void action(const gcn::ActionEvent &event); 00072 00076 Item* getSelectedItem() const; 00077 00081 void mouseClicked(gcn::MouseEvent &event); 00082 00083 #ifdef TMWSERV_SUPPORT 00084 00087 void keyPressed(gcn::KeyEvent &event); 00088 00092 void keyReleased(gcn::KeyEvent &event); 00093 #endif 00094 00098 void valueChanged(const gcn::SelectionEvent &event); 00099 00100 private: 00101 void updateButtons(); 00103 ItemContainer *mItems; 00104 00105 std::string mWeight; 00106 std::string mSlots; 00107 int mUsedSlots; 00108 int mTotalWeight; 00109 int mMaxWeight; 00110 gcn::Button *mUseButton; 00111 gcn::Button *mDropButton; 00112 #ifdef TMWSERV_SUPPORT 00113 gcn::Button *mSplitButton; 00114 #endif 00115 gcn::Label *mWeightLabel; 00116 gcn::Label *mSlotsLabel; 00117 00118 ProgressBar *mWeightBar; 00119 ProgressBar *mSlotsBar; 00120 00121 int mMaxSlots; 00122 00123 bool mSplit; 00124 bool mItemDesc; 00125 }; 00126 00127 extern InventoryWindow *inventoryWindow; 00128 00129 #endif