~ubuntu-branches/ubuntu/quantal/kdegames/quantal

« back to all changes in this revision

Viewing changes to kmahjongg/boardwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac, Philip Muškovac, Felix Geyer
  • Date: 2011-12-24 17:12:20 UTC
  • mfrom: (1.3.15)
  • Revision ID: package-import@ubuntu.com-20111224171220-668s85tl3su8pejn
Tags: 4:4.7.95-0ubuntu1
[ Philip Muškovac ]
* New upstream release candidate

[ Felix Geyer ]
* Update symbol files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
848
848
                        gameOver(Game->MaxTileNum,cheatsUsed);
849
849
                    }
850
850
                    // else if no more moves are possible, display the sour grapes dialog
851
 
                    else if( ! Game->findMove( TimerPos1, TimerPos2 ) )
 
851
                    else
852
852
                    {
853
 
                        KMessageBox::information(this, i18n("Game over: You have no moves left."));
 
853
                      validMovesAvailable();
854
854
                    }
855
855
                }
856
856
                else
866
866
    }
867
867
}
868
868
 
 
869
//-----------------------------------------------------------
 
870
KGameCanvasItem* BoardWidget::itemAt(const QPoint& point) const {
 
871
    // Get the shadows...
 
872
    // theTiles.width() == The whole tile width including offset and shadow.
 
873
    // theTiles.qWidth() == Half of the width of the tile face (without the offset and the shadow).
 
874
    // theTiles.levelOffsetX() == The level of the tile (the perspective height of the tile)
 
875
    int shadowWidth = theTiles.width() - (theTiles.qWidth() * 2 + theTiles.levelOffsetX());
 
876
    int shadowHeight = theTiles.height() - (theTiles.qHeight() * 2 + theTiles.levelOffsetY());
 
877
 
 
878
    for (int i = m_items.size() - 1; i >= 0; i--) {
 
879
        KGameCanvasItem *canvasItem = m_items[i];
 
880
 
 
881
        // Cause of the shadow, that is not really a part of a tile. Correct the rect positions
 
882
        // related to the angle. Actually we just correct the rect of the canvas item cause of the
 
883
        // shadow, that is not part of the clickable tile.
 
884
        QRect oldRect = canvasItem->rect();
 
885
        QRect rectCorrection = oldRect;
 
886
 
 
887
        // Correct the positions related to the angle we had set.
 
888
        switch(m_angle) {
 
889
            case NW:
 
890
                rectCorrection.setRect(oldRect.x() + shadowWidth, oldRect.y(),
 
891
                    oldRect.width() - shadowWidth, oldRect.height() - shadowHeight);
 
892
                break;
 
893
            case NE:
 
894
                rectCorrection.setRect(oldRect.x(), oldRect.y(), oldRect.width() - shadowWidth,
 
895
                    oldRect.height() - shadowHeight);
 
896
                break;
 
897
            case SW:
 
898
                rectCorrection.setRect(oldRect.x() + shadowWidth, oldRect.y() + shadowHeight,
 
899
                    oldRect.width() - shadowWidth, oldRect.height() - shadowHeight);
 
900
                break;
 
901
            case SE:
 
902
                rectCorrection.setRect(oldRect.x(), oldRect.y() + shadowHeight,
 
903
                    oldRect.width() - shadowWidth, oldRect.height() - shadowHeight);
 
904
                break;
 
905
        }
 
906
 
 
907
        // if the canvas is visible and we click inside the corrected rect of the canvas item, we
 
908
        // can return the actual canvas item.
 
909
        if (canvasItem->visible() && rectCorrection.contains(point))
 
910
            return canvasItem;
 
911
    }
 
912
 
 
913
    return NULL;
 
914
}
869
915
 
870
916
// ----------------------------------------------------------
871
917
/*
1108
1154
  // 300 points per use
1109
1155
  cheatsUsed += 15;
1110
1156
  drawTileNumber();
 
1157
 
 
1158
  // Test if any moves are available
 
1159
  validMovesAvailable();
 
1160
}
 
1161
 
 
1162
bool BoardWidget::validMovesAvailable()
 
1163
{
 
1164
  if(!Game->findMove(TimerPos1, TimerPos2))
 
1165
  {
 
1166
    KMessageBox::information(this, i18n("Game over: You have no moves left."));
 
1167
    return false;
 
1168
  }
 
1169
 
 
1170
  return true;
1111
1171
}
1112
1172
 
1113
1173
QString  BoardWidget::getLayoutName() {