kblackbox
kbbscalablegraphicwidget.cpp
Go to the documentation of this file.
67 KBBScalableGraphicWidget::KBBScalableGraphicWidget(KBBGameDoc* gameDoc, KBBThemeManager* themeManager, QAction* done)
122 m_score->setWhatsThis(i18n("<qt><p>This is <b>your score</b>. You should try to get the lowest possible.</p><p>The score increases:<ul><li>with time: <b>1 point</b> per second.</li><li>with the use of lasers:<ul><li><b>3 points</b> if the laser beam hits a ball or exits at the entry point,</li><li><b>9 points</b> if it exits at another entry point.</li></ul></li></ul></p><p>Your score is set to <b>999</b> at the end of the game if you make a mistake.</p></qt>"));
125 setWhatsThis(i18n("<qt><p>This is the <b>main game area</b>.</p><ul><li>The <b>black box</b> is in the center.</li><li>On the left, there are the <b>balls</b> you have to place over the black box.</li><li>Around the black box, there are <b>lasers</b> that are replaced with <b>interaction information</b> if you use them.</li></ul></qt>"));
158 if (!m_pause && m_inputAccepted && (!m_balls->containsVisible(boxPosition))&& (!m_ballsUnsure->containsVisible(boxPosition))) {
160 m_balls->insert(new KBBGraphicsItemBall(playerBall, this, m_themeManager, boxPosition, m_columns, m_rows));
183 m_markersNothing->insert(new KBBGraphicsItemOnBox(markerNothing, this, m_themeManager, boxPosition, m_columns, m_rows));
225 if (!m_pause && m_inputAccepted && (!m_balls->containsVisible(boxPositionTo)) && (!m_ballsUnsure->containsVisible(boxPositionTo))) {
241 int KBBScalableGraphicWidget::moveMarkerNothing(const int boxPositionFrom, const int boxPositionTo)
272 // same amount of lasers: We "recycle" them. (Just destroying them and re-creating them is not working fine: some lasers remain hidden until the next resize... Strange bug with QGraphicsView...)
285 m_scene->setSceneRect(m_ballRepository->x() - RATIO, 0, m_columns*RATIO + 2*BORDER_SIZE - m_ballRepository->x() + RATIO, m_rows*RATIO + 2*BORDER_SIZE);
303 int KBBScalableGraphicWidget::positionAfterMovingBall(const int boxPositionFrom, const int boxPositionTo) const
305 if (!m_pause && m_inputAccepted && (!m_balls->containsVisible(boxPositionTo)) && (!m_ballsUnsure->containsVisible(boxPositionTo))) {
335 m_rectBackground.setRect((sW-w)/2-offset+m_ballRepository->x()-RATIO, -offset, w + 2*offset, sH + 2*offset);
339 m_rectBackground.setRect(-offset+m_ballRepository->x()-RATIO, (sH-h)/2-offset, sW + 2*offset, h + 2*offset);
343 fitInView(m_ballRepository->x()-RATIO, 0, m_columns*RATIO + 2*BORDER_SIZE - m_ballRepository->x() + RATIO, m_rows*RATIO + 2*BORDER_SIZE, Qt::KeepAspectRatio);
347 m_score->move(OFFSET_DONE_BUTTON, height() - m_score->height() - m_doneButton->height() - 3*OFFSET_DONE_BUTTON);
400 if ((m_balls->containsVisible(i) || m_ballsUnsure->containsVisible(i)) && m_boardBalls->contains(i)) {
402 m_ballsSolution->insert(new KBBGraphicsItemBall(rightPlayerBall, this, m_themeManager, i, m_columns, m_rows));
404 if ((m_balls->containsVisible(i) || m_ballsUnsure->containsVisible(i)) && !m_boardBalls->contains(i))
405 m_ballsSolution->insert(new KBBGraphicsItemOnBox(wrongPlayerBall, this, m_themeManager, i, m_columns, m_rows));
406 if (!m_balls->containsVisible(i) && !m_ballsUnsure->containsVisible(i) && m_boardBalls->contains(i))
407 m_ballsSolution->insert(new KBBGraphicsItemBall(solutionBall, this, m_themeManager, i, m_columns, m_rows));
495 m_themeManager->svgRenderer()->render(painter, m_themeManager->elementId(background), m_rectBackground);
517 m_ballsUnsure->insert(new KBBGraphicsItemBall(unsureBall, this, m_themeManager, boxPosition, m_columns, m_rows));
520 m_balls->insert(new KBBGraphicsItemBall(playerBall, this, m_themeManager, boxPosition, m_columns, m_rows));
543 if ((m_balls->containsVisible(m_cursor->boxPosition())) || (m_ballsUnsure->containsVisible(m_cursor->boxPosition())))
572 if (!m_pause && m_gameDoc->mayShootRay(incomingPosition) && m_inputAccepted && m_lasers->containsVisible(incomingPosition)) {
584 m_rayResults->insert(outRay = new KBBGraphicsItemRayResult(this, m_themeManager, m_scene, outgoingPosition, m_columns, m_rows, m_rayNumber));
587 m_rayResults->insert(inRay = new KBBGraphicsItemRayResult(this, m_themeManager, m_scene, incomingPosition, m_columns, m_rows, rayNumberOrReflection));
text
void mouseBorderClick(const int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:202
void setPointSize(int pointSize)
void addMarkerNothing(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:180
Item on the box on the scalable graphic widget.
Definition: kbbgraphicsitemonbox.h:50
void drawBackground(QPainter *painter, const QRectF &)
Definition: kbbscalablegraphicwidget.cpp:493
bool containsVisible(int position)
If an element is not visible, it is not contained.
Definition: kbbgraphicsitemset.cpp:92
int moveBall(const int boxPositionFrom, const int boxPositionTo)
Definition: kbbscalablegraphicwidget.cpp:221
void render(QPainter *painter)
void keyboardMoveUp()
Definition: kbbscalablegraphicwidget.cpp:470
Laser element of the scalable graphic widget.
Definition: kbbgraphicsitemlaser.h:51
void setFocusPolicy(Qt::FocusPolicy policy)
int ballToTake() const
Definition: kbbgraphicsitemballrepository.cpp:69
void keyboardMoveDown()
Definition: kbbscalablegraphicwidget.cpp:446
icon
void setSceneRect(const QRectF &rect)
void resizeEvent(QResizeEvent *)
Definition: kbbscalablegraphicwidget.cpp:324
void cursorAtNewPosition(int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:417
void hide()
The black box in the scalable graphic widget.
Definition: kbbgraphicsitemblackbox.h:52
void addBallUnsure(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:173
void setFrameStyle(int style)
qreal height() const
void setBoardSize(const int columns, const int rows)
Definition: kbbgraphicsitemcursor.cpp:151
void setScore(int score)
Definition: kbbscalablegraphicwidget.cpp:385
toolTip
int moveMarkerNothing(const int boxPositionFrom, const int boxPositionTo)
Definition: kbbscalablegraphicwidget.cpp:241
int width() const
void setBold(bool enable)
KBBItemWithPosition * item(int position)
Return the item at the given position.
Definition: kbbgraphicsitemset.cpp:116
void setMinimumSize(const QSize &)
virtual void setPause(bool state)
Should the element changes if the game is paused? Do nothing.
Definition: kbbitemwithposition.cpp:61
void drawRay(const int borderPosition)
Definition: kbbscalablegraphicwidget.cpp:191
void draw(KBBBallsOnBoard *ballsOnBoard, const int borderPosition)
Definition: kbbgraphicsitemray.cpp:72
Ray on the scalable graphic widget of KBlackBox.
Definition: kbbgraphicsitemray.h:52
void fillBallsOutside(int placed)
Definition: kbbgraphicsitemballrepository.cpp:75
void setFocus()
void insert(KBBItemWithPosition *item)
Insert an item in the list.
Definition: kbbgraphicsitemset.cpp:106
KBBScalableGraphicWidget(KBBGameDoc *gameDoc, KBBThemeManager *themeManager, QAction *done)
Constructor.
Definition: kbbscalablegraphicwidget.cpp:67
void setVisible(const int position, const bool visible)
Change the visibility of an element.
Definition: kbbgraphicsitemset.cpp:139
virtual void highlightBoth(bool)
Definition: kbbitemwithposition.cpp:56
bool isEmpty() const
void move(int x, int y)
static const int HIT_POSITION
When a laser ray enter the black box, it exits on a defined border position, except if the laser ray ...
Definition: kbbgamedoc.h:65
void setScene(QGraphicsScene *scene)
static int const BORDER_SIZE
Distance between the black box and the widget border.
Definition: kbbscalablegraphicwidget.h:74
void keyboardMoveLeft()
Definition: kbbscalablegraphicwidget.cpp:454
void setKBBScalableGraphicWidget(KBBScalableGraphicWidget *w)
Set the KBBScalableGraphicWidget.
Definition: kbbgraphicsitemblackbox.cpp:110
void setCacheMode(QFlags< QGraphicsView::CacheModeFlag > mode)
void setPause(bool state)
Definition: kbbscalablegraphicwidget.cpp:312
void popupText(const QString &text, int time=5000)
Message to display.
Definition: kbbscalablegraphicwidget.cpp:292
int positionAfterMovingBall(const int boxPositionFrom, const int boxPositionTo) const
Definition: kbbscalablegraphicwidget.cpp:303
whatsThis
void mouseBoxClick(const Qt::MouseButton button, int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:210
const QFont & font() const
Result of a laser ray shoot in the black box.
Definition: kbbgraphicsitemrayresult.h:55
bool contains(int boxPosition)
Check if there is a ball at the given position in the black box.
Definition: kbbballsonboard.cpp:112
bool mayShootRay(const int incomingPosition) const
Definition: kbbgamedoc.cpp:88
bool isVisible() const
void removeAllBalls()
Definition: kbbscalablegraphicwidget.cpp:351
void clearFocus()
void setWhatsThis(const QString &)
void setMaximumWidth(int maxw)
QString elementId(const KBBScalableGraphicWidget::itemType itemType)
Get the XML "id" value of the item.
Definition: kbbthememanager.cpp:81
void setOpposite(KBBGraphicsItemRayResult *opposite)
Define the opposite "ray result" item.
Definition: kbbgraphicsitemrayresult.cpp:136
void setFixedHeight(int h)
void keyboardEnter()
Definition: kbbscalablegraphicwidget.cpp:434
static int const RATIO
Width and height of a single square on the black box.
Definition: kbbscalablegraphicwidget.h:81
void setBorderPosition(const int borderPosition)
Definition: kbbgraphicsitemcursor.cpp:164
void update(qreal x, qreal y, qreal w, qreal h)
void newGame(int columns, int rows, int balls)
Definition: kbbgraphicsitemballrepository.cpp:89
void keyboardSpace()
Definition: kbbscalablegraphicwidget.cpp:478
void display(const QString &s)
~KBBScalableGraphicWidget()
Definition: kbbscalablegraphicwidget.cpp:130
void keyboardMoveRight()
Definition: kbbscalablegraphicwidget.cpp:462
void addBall(int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:150
void setBoxPosition(const int boxPosition)
Definition: kbbgraphicsitemcursor.cpp:193
The balls the player has to place.
Definition: kbbgraphicsitemballrepository.h:45
void setRect(qreal x, qreal y, qreal width, qreal height)
void removeBall(int outsidePosition)
Definition: kbbgraphicsitemballrepository.cpp:115
void setToolTip(const QString &)
void show()
void solve(const bool continueGame)
display the solution
Definition: kbbscalablegraphicwidget.cpp:391
void addItem(QGraphicsItem *item)
void newGame(int columns, int rows, int ballNumber)
Definition: kbbscalablegraphicwidget.cpp:251
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool isEnabled() const
int height() const
qreal width() const
void removeBall(const int boxPosition)
Definition: kbbscalablegraphicwidget.cpp:359
void setSize(const int columns, const int rows)
Define the (new) size of the black box.
Definition: kbbgraphicsitemblackbox.cpp:74
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.