Planeshift

psslotmgr.h

Go to the documentation of this file.
00001 /*
00002  * psslotmgr.h
00003  *
00004  * Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation (version 2
00009  * of the License).
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  *
00019  */
00020 
00021 #ifndef PS_SLOT_MANAGER
00022 #define PS_SLOT_MANAGER
00023 
00024 #include <csutil/array.h>
00025 
00026 #include "paws/pawsnumberpromptwindow.h"
00027 
00028 //=============================================================================
00029 // Forward Declarations
00030 //=============================================================================
00031 class pawsSlot;
00032 class pawsDnDButton;
00033 class MsgHandler;
00034 struct iMeshWrapper;
00035 
00036 //=============================================================================
00037 // Classes
00038 //=============================================================================
00039 
00040 
00041 class psSlotManager : public iOnNumberEnteredAction
00042 {
00043 public:
00044     psSlotManager();
00045     virtual ~psSlotManager();
00046 
00047     bool HandleEvent( iEvent& ev );
00048 
00049     void Handle( pawsSlot* slot, bool grabOne = false, bool grabAll = false );
00050     void Handle( pawsDnDButton* target );
00051 
00052     void SetDragDetails(pawsSlot* slot, int count);
00053     void SetDragDetails(pawsDnDButton *target );
00054 
00055     bool IsDragging() { return isDragging; }
00056     bool IsPlacing() { return isPlacing; }
00057 
00059     void SetDragFlag( bool flag ) { isDragging = flag; }
00060 
00061     int HoldingContainerID() { return draggingSlot.containerID; }
00062     int HoldingSlotID() { return draggingSlot.slotID; }
00063 
00064     void CancelDrag();
00065 
00066     void OnNumberEntered(const char *name,int param,int value);
00067 
00068 
00069 private:
00070     struct DraggingSlot
00071     {
00072         int containerID;
00073         int slotID;
00074         int stackCount;
00075         pawsWidget* slot;
00076         csString meshFactName;
00077         csString materialName;
00078         csString toolTip;
00079         csString Action;
00080         int parentID;
00081         bool split; 
00082     } draggingSlot;
00083 
00084     void PlaceItem();
00085     void UpdateItem();
00086     void DropItem(bool guard);
00087 
00088 
00089     bool isDragging;
00090     bool isPlacing;
00091     bool isRotating;
00092     bool hadInventory;
00093 
00094     psPoint basePoint;
00095 
00096     csArray<pawsSlot*> slotsInUse;
00097     int last_count;
00098 
00099     csEventID MouseMove; 
00100     csEventID MouseDown; 
00101     csEventID MouseUp;   
00102     csEventID KeyDown;   
00103     csEventID KeyUp;     
00104 
00105     csString draggedMesh;
00106     iMeshWrapper* outline;
00107 };
00108 #endif