/* * glyph.h - Author: Anders Reggestad * * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org) * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef PAWS_GLYPH_WINDOW #define PAWS_GLYPH_WINDOW // CS INCLUDES #include #include #include "paws/pawswidget.h" #include "paws/pawsbutton.h" #include "paws/pawstextbox.h" #include "pawsslot.h" #include "inventorywindow.h" #include "util/psconst.h" #include "net/messages.h" #define FLOATING_SLOT GLYPH_LIST_MAX_SLOTS struct iEngine; class pawsGlyphSlot : public pawsSlot { public: pawsGlyphSlot() { dragDrop = false; emptyOnZeroCount = false; Clear(); } int GetStatID() { return statID; } void SetStatID(int statID) { this->statID = statID; } void Clear() { statID = 0; pawsSlot::Clear(); } protected: int statID; }; CREATE_PAWS_FACTORY( pawsGlyphSlot ); class pawsGlyphWindow : public pawsWidget, public psClientNetSubscriber { public: pawsGlyphWindow(); virtual ~pawsGlyphWindow(); /** For the iNetSubsciber interface. */ void HandleMessage( MsgEntry* message ); bool PostSetup(); void Show(); void Hide(); bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ); protected: void HandleAssemble( MsgEntry* me ); void HandleGlyphList( MsgEntry* me ); /** Clear glyph slots that are not used (used glyphs are in the 'usedSlots' array) */ void ClearUnusedGlyphs(const csArray & usedSlots); /** Create new row in listbox of glyph slots */ void NewGlyphSlotRow(int wayNum); /** Counts number of glyph of given type in assembler */ int CountTypeInAssembler(int statID); /** Removes a glyph of given type from assembler */ void RemoveTypeFromAssembler(int statID); pawsGlyphSlot * FindFreeAssemblerSlot(); /** Finds free glyph slot (may create new slots when all are occupied) */ pawsGlyphSlot * FindFreeSlot(int wayNum); /** Finds a good location for 'glyph', 'recvGlyphs' is array of glyphs received from the server It tries to find slot of same type and purification status. If there is not such a slot, it tries to find a slot that kept glyphs with same type, but is no longer occupied now. If there is none, it just returns a free slot. */ pawsGlyphSlot * FindAppropriateSlotForGlyph(const csArray & recvGlyphs, const psRequestGlyphsMessage::NetworkGlyph & glyph); /** Finds slot that keeps glyphs of given type and given purification status */ pawsGlyphSlot * GetGlyphTypeSlot(int statID, int purifyStatus); /** Creates floating slot (that replaces mouse cursor) from given slot */ void CreateFloatingSlot(pawsGlyphSlot * sourceSlot); /** Sends content of assembler to server */ void SendAssembler(); /*** Clears the Spell name and Description fields. ***/ void ClearSpell(); csRef msgHandler; pawsMessageTextBox * description; pawsTextBox * spellName; csArray ways; pawsGlyphSlot * assembler[GLYPH_ASSEMBLER_SLOTS]; }; CREATE_PAWS_FACTORY( pawsGlyphWindow ); #endif