2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
13 #include <kgamecanvas.h>
17 class BattleFieldView
;
26 class SeaView
: public KGameCanvasWidget
29 static const unsigned int GRID_SIZE
= 10;
30 static const unsigned int LABEL_SPACING
= 4;
31 static const unsigned int MARGIN
= 5;
32 static const unsigned int GAP
= 2;
34 WelcomeScreen
* m_screen
;
35 BattleFieldView
* m_fields
[2];
36 PlayerLabel
* m_labels
[2];
37 StatsWidget
* m_stats
[2];
39 KBSRenderer
* m_renderer
;
41 BattleFieldView
* otherField(BattleFieldView
* field
);
42 QPoint m_last_preview
;
45 bool setPreview(Sea::Player player
, const QPoint
& pos
);
46 bool updatePreview(const QPoint
& pos
);
47 int fieldAt(const QPoint
& p
);
49 SeaView(QWidget
* parent
);
52 void setDelegate(Delegate
* c
);
54 void add(Sea::Player p
, const Coord
& c
, Ship
* ship
);
55 void hit(Sea::Player p
, const Coord
& c
);
56 void miss(Sea::Player p
, const Coord
& c
);
57 void sink(Sea::Player p
, const Coord
& c
, Ship
* ship
);
60 void setStats(Sea::Player p
, const QString
& icon
,
61 const QString
& text
, Stats
* stats
);
62 void setNick(Sea::Player p
, const QString
& nick
);
64 WelcomeScreen
* globalScreen() const;
65 WelcomeScreen
* screen(Sea::Player player
) const;
67 void toggleLeftGrid(bool show
);
68 void toggleRightGrid(bool show
);
70 virtual void mouseMoveEvent(QMouseEvent
*);
71 virtual void mousePressEvent(QMouseEvent
*);
72 virtual void mouseReleaseEvent(QMouseEvent
*);
73 virtual void resizeEvent(QResizeEvent
*);
74 virtual void leaveEvent(QEvent
*);
78 void buttonClicked(Button
*);