summaryrefslogtreecommitdiffstats
path: root/knights/board_2d.h
blob: e000abd1e917781b62e763508a8b432898053503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************************
                          board_2d.h  -  description
                             -------------------
    begin                : Fri Feb 28 2003
    copyright            : (C) 2003 by The Knights Project
    email                : knights-general@lists.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef BOARD_2D_H
#define BOARD_2D_H

#include <board_base.h>
#include <tqpixmap.h>
#include <tqptrlist.h>

/**
  *@author The Knights Team
  */

typedef struct sprite
{
	bool Restore;
	int Steps;
	int POSITION_Origin;
	int POSITION_Destination;
	int POSITION_TargetTaken;
	TQPoint POINT_Origin;
	TQPoint POINT_Current;
	TQPoint POINT_LastUpdate;
	TQPoint POINT_Destination;
	TQPixmap PIXMAP_Sprite;
	TQPixmap PIXMAP_FlipFrame;
};

typedef TQPtrList<sprite> SpriteList;
class KnightsPixCache;

class board_2d : public board_base
{
	Q_OBJECT
  TQ_OBJECT
	public: 
											board_2d(TQWidget *parent=0, const char *name=0, resource *Rsrc=0, logic *Lgc=0);
											~board_2d();
		virtual void			drawMove( const ChessMove &chessMove, const bool &reverse=FALSE );
		virtual void			setPremovePositions( const int&, const int& );
		virtual void			redrawLights( void );
		void							paintEvent( TQPaintEvent *event );
		void							mouseReleaseEvent( TQMouseEvent *event );
		void							mousePressEvent( TQMouseEvent *event );
		void							mouseMoveEvent( TQMouseEvent *event );

	public slots:
		virtual void			resizeBoard( void );
		virtual void			redrawAll( void );
		virtual void			drawPosition( const int& );
		virtual void			commit( void );

	protected:
		void							drawCoords( TQPixmap *pic, const int &pos );
		TQPoint						coords( const int&, const int&);
		int								position( const TQPoint& );
		void							drawSprites( void );
		TQPixmap						getChessman( const int &pos );
		bool							isSprite( const int &pos );
		void							myBlit( const TQPoint &dp, const TQPaintDevice *src, const TQRect &sr );

	protected slots:
		void							updateSprites( void );

	private:
		SpriteList				sprites;
		sprite						*DragSprite;
		KnightsPixCache		*cache;
		TQPixmap						myself;
		TQPoint						pressPoint;
		bool							orientation;
		bool							lastMoveWasDrag;
		bool							init;

		int								updateX1;
		int								updateY1;
		int								updateX2;
		int								updateY2;

		/* Premove Positions */
		int								premoveFrom;
		int								premoveTo;
};

#endif