1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #if !defined(AFX_TILECTRL_H__4E768057_293D_4D27_8193_06423D1D7380__INCLUDED_)
18 #define AFX_TILECTRL_H__4E768057_293D_4D27_8193_06423D1D7380__INCLUDED_
22 #endif // _MSC_VER > 1000
23 // TileCtrl.h : header file
28 #define NB_MAX_TILE 1500
31 #define SIZE_NORMAL 64
33 #define SPACING_SMALL_X 2
34 #define SPACING_SMALL_Y 2
35 #define SPACING_NORMAL_X 4
36 #define SPACING_NORMAL_Y 4
37 #define SPACING_BIG_X 6
38 #define SPACING_BIG_Y 6
44 #define BUFFERSIZE 200 //le buffer ne peut pas contenir plus de 100 items
45 /////////////////////////////////////////////////////////////////////////////
54 HBITMAP DibSection
; BITMAPINFO BmpInfo
; void *Bits
;
56 int Loaded
; //tells if the tile was already loaded or not
57 int Selected
; //tells if the tile is selected
58 int id
; //numero du tile
59 int h
,b
,g
,d
; //index dans la liste des bordures pour le haut, le bas, la gauche et la droite du tile
62 typedef std::list
<TileInfo
*> tilelist
;
69 tilelist::iterator i
; //pointeur sur le dernier element de la liste
70 int Add(const char *path
); //ajoute un tile (bmp) dans la liste sans le charger
71 void Delete(tilelist::iterator i
,int n
);
72 void DeleteAll(); //efface provisoirement les sections DIB et les *Bits;
73 void Reload(CDC
*pDC
,tilelist::iterator iFirst
,int n
); //recharge en memoire une tranche de tiles
75 tilelist::iterator iFirst
,iLast
; // first and last index loaded in memory
79 class _Edge
//permet de stocker toutes les bordures des tiles
84 _Edge(const _Edge
& edge
);
89 void CreateH(TileInfo
*tile
);
90 void CreateB(TileInfo
*tile
);
91 void CreateG(TileInfo
*tile
);
92 void CreateD(TileInfo
*tile
);
93 int operator==(const _Edge
&ed
) const;
96 typedef list
<_Edge
> edgelist
;
98 extern int CALLBACK
CompareFunc(LPARAM lParam1
,LPARAM lParam2
,LPARAM lParamSort
);
99 extern int _LoadBitmap(const std::string
& path
,LPBITMAPINFO BitmapInfo
, std::vector
<NLMISC::CBGRA
>&Tampon
, std::vector
<NLMISC::CBGRA
>* Alpha
, int rot
);
103 class TileCtrl
: public CListCtrl
111 void DrawTile(int i
,CDC
*pDC
);
112 void UpdateBuffer(); //permet de charger et d'effacer tous les buffers inutiles des tiles invisible
113 int LoadInListCtrl(tilelist::iterator iFirst
,tilelist::iterator iLast
);
114 void DeleteTile(int i
);
115 int IsSelected(int i
);
116 void CheckTile(TileInfo
*theTile
); //check si le tile est "tilable" avec un autre et initialise h,b,g,d dans TileInfo
117 void ShadeRect( CDC
*pDC
, CRect
& rect
); //permet d'afficher un bitmap selectionne a la "windows style"
118 void InsertItemInCtrlList(tilelist::iterator iFirst
,tilelist::iterator iLast
);
119 void GetVisibility(int &First
,int &Last
);
120 int GetNbTileLine(void);
121 int GetNbTileColumn(void);
122 int GetIndex(LPPOINT pt
);
127 edgelist EdgeList
; //liste de toutes les bordures
128 int sizetile_x
,sizetile_y
;
129 int sizeicon_x
,sizeicon_y
,spacing_x
,spacing_y
,spacing_tile_text
;
131 int Sort
; //radio button state (1,2,3)
142 int iFirst
,iLast
; //indexes du premier et du dernier item du buffer
143 int iFV
,iLV
; //index du premier et du dernier item visible
153 // ClassWizard generated virtual function overrides
154 //{{AFX_VIRTUAL(TileCtrl)
156 virtual LRESULT
WindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
163 // Generated message map functions
165 //{{AFX_MSG(TileCtrl)
166 afx_msg
void OnPaint();
167 afx_msg
void OnDropFiles(HDROP hDropInfo
);
168 afx_msg
void OnRButtonDown(UINT nFlags
, CPoint point
);
169 afx_msg
void OnLButtonDown(UINT nFlags
, CPoint point
);
170 afx_msg
void OnLButtonDblClk(UINT nFlags
, CPoint point
);
171 afx_msg
void OnVScroll(UINT nSBCode
, UINT nPos
, CScrollBar
* pScrollBar
);
174 DECLARE_MESSAGE_MAP()
177 /////////////////////////////////////////////////////////////////////////////
179 //{{AFX_INSERT_LOCATION}}
180 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
182 #endif // !defined(AFX_TILECTRL_H__4E768057_293D_4D27_8193_06423D1D7380__INCLUDED_)