[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src/client TilePresentation.h TilePresen...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src/client TilePresentation.h TilePresen... |
Date: |
Thu, 27 Feb 2003 12:54:22 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/27 12:54:22
Modified files:
src/client : TilePresentation.h TilePresentation.cpp
Game.cpp
Log message:
The info contained in the TileButton is now the full tile object. This
allow
to handle rotation.
Patches:
Index: camino/src/client/Game.cpp
diff -u camino/src/client/Game.cpp:1.19 camino/src/client/Game.cpp:1.20
--- camino/src/client/Game.cpp:1.19 Thu Feb 27 12:26:25 2003
+++ camino/src/client/Game.cpp Thu Feb 27 12:54:22 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Game.cpp,v 1.19 2003/02/27 17:26:25 pfremy Exp $
+** Version : $Id: Game.cpp,v 1.20 2003/02/27 17:54:22 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
@@ -148,7 +148,7 @@
{
qDebug("Game::tileClickedInBoard - %dx%d", row, col );
// check if we have one tile selected in tile presentation
- if (_presentation->getSelected() == Tile::TILE_UNKNOWN) {
+ if (_presentation->getSelected() == 0L) {
return;
}
@@ -159,8 +159,10 @@
// check if there is no tile at this place: ask board to do that
// check if the rule allow to play here: ask board to do that
-
+
// if all the check pass, send the tile to the server
+ sendPlayerPlaysAMove( _presentation->getSelected() );
+
// if the server accepts the move, he will send us a message to add the
// tile to the board.
}
@@ -242,7 +244,7 @@
void Game::recvTilesForYou( Tile::TileType tile )
{
// qDebug( "Game::recvTile - %d", ( int )tile );
- _presentation->addTile( tile );
+ _presentation->addTile( new Tile( tile ) );
}
void Game::slot_undo()
Index: camino/src/client/TilePresentation.cpp
diff -u camino/src/client/TilePresentation.cpp:1.7
camino/src/client/TilePresentation.cpp:1.8
--- camino/src/client/TilePresentation.cpp:1.7 Thu Feb 27 12:26:25 2003
+++ camino/src/client/TilePresentation.cpp Thu Feb 27 12:54:22 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: TilePresentation.cpp,v 1.7 2003/02/27 17:26:25 pfremy Exp $
+** Version : $Id: TilePresentation.cpp,v 1.8 2003/02/27 17:54:22 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 28/01/2003
@@ -62,9 +62,9 @@
vbox->setSpacing( 10 );
new QLabel( "Selected tile :", vbox );
_rotateButton = new QPushButton( "rotate", vbox );
- _selectedTile = new TileButton( hbox );
- _selectedTile->setFlat( true );
- _selectedTile->setAlwaysShow( true );
+ _selectedTileButton = new TileButton( hbox );
+ _selectedTileButton->setFlat( true );
+ _selectedTileButton->setAlwaysShow( true );
connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_selectTile( int )
) );
}
@@ -79,15 +79,16 @@
void TilePresentation::slot_selectTile( int num )
{
- _selectedTile->setTile( _buttonList.at(num)->getTileType() );
+ _selectedTileButton->setTile( _buttonList.at(num)->getTile() );
_selectedIndex = num;
}
-void TilePresentation::addTile( Tile::TileType tile )
+void TilePresentation::addTile( Tile * tile )
{
QPtrListIterator<TileButton> it( _buttonList );
for( ; it.current(); ++it ) {
- if (it.current()->_type == Tile::TILE_UNKNOWN) {
+ if (it.current()->getTile() == 0L
+ || it.current()->getTile()->getType() ==
Tile::TILE_UNKNOWN) {
it.current()->setTile( tile );
return;
}
@@ -97,26 +98,26 @@
_buttonList.first()->setTile( tile );
}
-void TilePresentation::removeTile( Tile::TileType tile )
+void TilePresentation::removeTile( Tile * tile )
{
QPtrListIterator<TileButton> it( _buttonList );
for( ; it.current(); ++it ) {
- if (it.current()->_type == tile) {
- it.current()->setTile( Tile::TILE_UNKNOWN);
+ if (it.current()->getTile() == tile ) {
+ it.current()->setTile( 0L );
return;
}
}
- qDebug("TilePresentation::removeTile() - Could not find tile %d !",
tile);
+ qDebug("TilePresentation::removeTile() - Could not find tile %d !",
tile->getType());
}
void TilePresentation::removeSelectedTile()
{
- removeTile( _selectedTile->_type );
+ removeTile( _selectedTileButton->getTile() );
}
-Tile::TileType TilePresentation::getSelected()
+Tile * TilePresentation::getSelected()
{
- return _selectedTile->_type;
+ return _selectedTileButton->getTile();
}
//
@@ -127,36 +128,41 @@
: QPushButton( parent, name )
{
_alwaysShow = false;
- setTile( Tile::TILE_UNKNOWN );
+ setTile( 0L );
// setFlat( true );
reinit();
}
-void TileButton::setTile( Tile::TileType type )
+void TileButton::setTile( Tile * tile )
{
- _type = type;
- //int size = theme.getZoomSize();
-// setPixmap( theme.getTilePixmap( (int)type, 0 ) );
- setPixmap( Theme::getTheme()->pixmapForTile( type ) );
+ _tile = tile;
+
+ if (tile != 0L) {
+ //int size = theme.getZoomSize();
+ // setPixmap( theme.getTilePixmap( (int)type, 0 ) );
+ setPixmap( Theme::getTheme()->pixmapForTile( tile->getType() )
);
+ } else {
+ setPixmap( Theme::getTheme()->pixmapForTile( Tile::TILE_UNKNOWN
) );
+ }
setFixedSize( pixmap()->width() + 2, pixmap()->height() + 2 );
- if ( _alwaysShow == false) {
- if ( type == Tile::TILE_UNKNOWN ) {
+ if ( _alwaysShow == true) {
+ show();
+ } else {
+ if ( _tile == 0L || _tile->getType() == Tile::TILE_UNKNOWN ) {
hide();
} else {
show();
}
- } else {
- show();
}
}
void TileButton::reinit()
{
- setTile( _type );
+ setTile( _tile );
}
void TileButton::setAlwaysShow( bool as )
{
_alwaysShow = as;
- setTile( _type );
+ setTile( _tile );
}
Index: camino/src/client/TilePresentation.h
diff -u camino/src/client/TilePresentation.h:1.7
camino/src/client/TilePresentation.h:1.8
--- camino/src/client/TilePresentation.h:1.7 Thu Feb 27 12:26:25 2003
+++ camino/src/client/TilePresentation.h Thu Feb 27 12:54:22 2003
@@ -5,7 +5,7 @@
** TilePresentation.h
** Displays tiles of the player
**
-** Version : $Id: TilePresentation.h,v 1.7 2003/02/27 17:26:25 pfremy Exp $
+** Version : $Id: TilePresentation.h,v 1.8 2003/02/27 17:54:22 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 28/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -54,10 +54,10 @@
/** Constructor */
TilePresentation( QWidget * parent = 0, const char * name = 0 );
void reupdate();
- void addTile( Tile::TileType tile );
- void removeTile( Tile::TileType tile );
+ void addTile( Tile * tile );
+ void removeTile( Tile * tile );
void removeSelectedTile();
- Tile::TileType getSelected();
+ Tile * getSelected();
public slots:
void slot_selectTile( int num );
@@ -67,7 +67,7 @@
protected:
QPtrList< TileButton > _buttonList;
- TileButton * _selectedTile;
+ TileButton * _selectedTileButton;
QPushButton * _rotateButton;
int _selectedIndex;
};
@@ -78,14 +78,14 @@
TileButton( QWidget * parent = 0, const char * name = 0 );
void setAlwaysShow( bool as );
- void setTile( Tile::TileType type );
- Tile::TileType getTileType() { return _type; }
+ void setTile( Tile * tile );
+ Tile * getTile() { return _tile; }
void reinit();
protected:
bool _alwaysShow;
- Tile::TileType _type;
+ Tile* _tile;
friend class TilePresentation;
};