SVN_SILENT made messages (.desktop file)
[kdegames.git] / kbattleship / src / seaview.h
blob321a2de71a920515c2d0b7090c184dde6002f00e
1 /*
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.
8 */
10 #ifndef SEA_H
11 #define SEA_H
13 #include <kgamecanvas.h>
14 #include "sea.h"
15 #include "animator.h"
17 class BattleFieldView;
18 class KBSRenderer;
19 class Delegate;
20 class WelcomeScreen;
21 class Button;
22 class PlayerLabel;
23 class StatsWidget;
24 class Stats;
26 class SeaView : public KGameCanvasWidget
28 Q_OBJECT
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;
40 Delegate* m_delegate;
41 BattleFieldView* otherField(BattleFieldView* field);
42 QPoint m_last_preview;
43 int m_last_f;
45 bool setPreview(Sea::Player player, const QPoint& pos);
46 bool updatePreview(const QPoint& pos);
47 int fieldAt(const QPoint& p);
48 public:
49 SeaView(QWidget* parent);
50 ~SeaView();
52 void setDelegate(Delegate* c);
53 void cancelPreview();
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);
58 void clear();
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);
69 protected:
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*);
76 int tileSize() const;
77 public slots:
78 void buttonClicked(Button*);
79 void update();
82 #endif // SEA_H