-
Notifications
You must be signed in to change notification settings - Fork 9
вопрос #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KloopRE
wants to merge
8
commits into
hBuzzy:master
Choose a base branch
from
KloopRE:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
вопрос #5
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
07e9843
вопрос
KloopRE eed1304
Помогите
KloopRE d494c3c
Еще вопрос
KloopRE 6f7e4bd
redactor
KloopRE 4747e86
pacman
KloopRE c858500
Исправление замечаний
KloopRE bdb0d05
Исправление ошибок
KloopRE 1a8bf8c
Замечания
KloopRE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #include "customgraphicsview.h" | ||
|
|
||
| #include <QMouseEvent> | ||
| #include <QDebug> | ||
|
|
||
| CustomGraphicsView::CustomGraphicsView(QGraphicsScene *scene, QWidget *parent, int gridSize) | ||
| : QGraphicsView(scene, parent), cellSize_(gridSize) | ||
| { | ||
| setMouseTracking(true); | ||
| } | ||
|
|
||
| void CustomGraphicsView::mouseMoveEvent(QMouseEvent *event) | ||
| { | ||
| if (isDrawing_) | ||
| { | ||
| int halfGridSize = cellSize_ / 2; | ||
| QPoint localMousePos = event->pos(); | ||
| center_ = this->mapToScene(localMousePos); | ||
| center_.setX(this->center_.x() - halfGridSize); | ||
| center_.setY(this->center_.y() - halfGridSize); | ||
| update(); | ||
| qDebug() << "cursor Coordinates: (" << center_.x() << ", " << center_.y() << ")"; | ||
| } | ||
| } | ||
|
|
||
| void CustomGraphicsView::mouseReleaseEvent(QMouseEvent *event) | ||
| { | ||
| if (event->button() == Qt::LeftButton && isDrawing_) | ||
| { | ||
| isDrawing_ = false; | ||
| setCursorStyle(); | ||
| emit customMouseRelease(); | ||
| } | ||
| } | ||
|
|
||
| void CustomGraphicsView::setCursorStyle() | ||
| { | ||
| if (isDrawing_) | ||
| { | ||
| setCursor(Qt::CrossCursor); | ||
| } | ||
| else | ||
| { | ||
| setCursor(Qt::ArrowCursor); | ||
| } | ||
| } | ||
|
|
||
| int CustomGraphicsView::getCenterX() const | ||
| { | ||
| return center_.x(); | ||
| } | ||
|
|
||
| int CustomGraphicsView::getCenterY() const | ||
| { | ||
| return center_.y(); | ||
| } | ||
|
|
||
| void CustomGraphicsView::setCenterX(int newX) | ||
| { | ||
| center_.setX(newX); | ||
| } | ||
|
|
||
| void CustomGraphicsView::setCenterY(int newY) | ||
| { | ||
| center_.setY(newY); | ||
| } | ||
|
|
||
| void CustomGraphicsView::setCenter(QPointF newCenter) | ||
| { | ||
| center_ = newCenter; | ||
| } | ||
|
|
||
| void CustomGraphicsView::setDrawing(bool isDrawing) | ||
| { | ||
| isDrawing_ = isDrawing; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #ifndef CUSTOMGRAPHICSVIEW_H | ||
| #define CUSTOMGRAPHICSVIEW_H | ||
|
|
||
| #include <QGraphicsView> | ||
| #include <QMouseEvent> | ||
|
|
||
| class CustomGraphicsView : public QGraphicsView | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| CustomGraphicsView(QGraphicsScene *scene, QWidget *parent = nullptr, int gridSize = 64); | ||
|
|
||
| void setCursorStyle(); | ||
| int getCenterX() const; | ||
| int getCenterY() const; | ||
| void setCenterX(int newX); | ||
| void setCenterY(int newY); | ||
| void setCenter(QPointF isDrawing); | ||
| void setDrawing(bool newDrawing); | ||
|
|
||
| protected: | ||
| void mouseMoveEvent(QMouseEvent *event) override; | ||
| void mouseReleaseEvent(QMouseEvent *event) override; | ||
|
|
||
| private: | ||
| int cellSize_; | ||
| QPointF center_; | ||
| bool isDrawing_ = false; | ||
|
|
||
| signals: | ||
| void customMouseRelease(); | ||
| }; | ||
|
|
||
| #endif // CUSTOMGRAPHICSVIEW_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "directions.h" | ||
|
|
||
| const std::string Directions::Left = "Left"; | ||
| const std::string Directions::Right = "Right"; | ||
| const std::string Directions::Up = "Up"; | ||
| const std::string Directions::Down = "Down"; | ||
|
|
||
| Directions::Directions(const std::string& type) : directionsType_(type) {} | ||
|
|
||
| std::string Directions::getType() const | ||
| { | ||
| return directionsType_; | ||
| } | ||
|
|
||
| std::ostream& operator<<(std::ostream& os, const Directions& direction) | ||
| { | ||
| os << direction.getType(); | ||
| return os; | ||
| } | ||
|
|
||
| bool operator==(const Directions& left, const Directions& right) | ||
| { | ||
| return left.getType() == right.getType(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #ifndef DIRECTIONS_H | ||
| #define DIRECTIONS_H | ||
|
|
||
| #include <string> | ||
|
|
||
| class Directions { | ||
| public: | ||
| static const std::string Left; | ||
| static const std::string Right; | ||
| static const std::string Up; | ||
| static const std::string Down; | ||
|
|
||
| Directions(const std::string& type); | ||
|
|
||
| std::string getType() const; | ||
|
|
||
| friend std::ostream& operator<<(std::ostream& os, const Directions& direction); | ||
| friend bool operator==(const Directions& left, const Directions& right); | ||
|
|
||
| private: | ||
| std::string directionsType_; | ||
| }; | ||
|
|
||
| #endif // DIRECTIONS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #include "gameelement.h" | ||
|
|
||
| GameElement::GameElement(ElementType type) : elementType_(type) {} | ||
|
|
||
| GameElement::ElementType GameElement::getType() const | ||
| { | ||
| return elementType_; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #ifndef GAMEELEMENT_H | ||
| #define GAMEELEMENT_H | ||
|
|
||
| class GameElement { | ||
| public: | ||
| enum ElementType { | ||
| Empty = 0, | ||
| Wall = 1, | ||
| Puckman = 2, | ||
| Hostile = 3, | ||
| Coin = 4 | ||
| }; | ||
|
|
||
| GameElement(ElementType type); | ||
|
|
||
| ElementType getType() const; | ||
|
|
||
| private: | ||
| ElementType elementType_; | ||
| }; | ||
|
|
||
| #endif // GAMEELEMENT_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Раз начали не переносить скобки в части проекта, то не переносите их везде. Касается всего проекта. + Комментарий.