diff options
| author | totycro <totycro@unknown-horizons.org> | 2011-04-06 16:08:19 +0200 |
|---|---|---|
| committer | totycro <totycro@unknown-horizons.org> | 2011-04-06 16:08:19 +0200 |
| commit | ebb3d3c754a50fccdc8f780d3297361925f33a85 (patch) | |
| tree | e5c7bc18be69e322cdff28c88b1d8db5ba0c1434 /pacman-c++/mainwidget.cpp | |
| parent | 33058362d2b91082aa5b50be4ce79e9c371f9c29 (diff) | |
| download | foop-ebb3d3c754a50fccdc8f780d3297361925f33a85.tar.gz foop-ebb3d3c754a50fccdc8f780d3297361925f33a85.tar.bz2 foop-ebb3d3c754a50fccdc8f780d3297361925f33a85.zip | |
Keep track of PixmapItems in client
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
| -rw-r--r-- | pacman-c++/mainwidget.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index bf049f2..a3acc45 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp | |||
| @@ -56,6 +56,11 @@ Transmission::map_t createDummyMap() | |||
| 56 | MainWidget::MainWidget() | 56 | MainWidget::MainWidget() |
| 57 | : currentKey(0) | 57 | : currentKey(0) |
| 58 | { | 58 | { |
| 59 | visualMap.resize(Constants::map_size.width); | ||
| 60 | for (int i=0; i<visualMap.size(); ++i) { | ||
| 61 | visualMap[i].resize(Constants::map_size.height); | ||
| 62 | } | ||
| 63 | |||
| 59 | createGui(); | 64 | createGui(); |
| 60 | updateMap(createDummyMap()); | 65 | updateMap(createDummyMap()); |
| 61 | } | 66 | } |
| @@ -133,7 +138,7 @@ void MainWidget::updateMap(const Transmission::map_t& map) | |||
| 133 | Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask); | 138 | Color::Color color = static_cast<Color::Color>(cur & Transmission::color_mask); |
| 134 | qDebug() << "col=" << color; | 139 | qDebug() << "col=" << color; |
| 135 | 140 | ||
| 136 | PixmapItem *item = NULL; | 141 | PixmapItem* item = NULL; |
| 137 | if (cur & Transmission::block) | 142 | if (cur & Transmission::block) |
| 138 | { | 143 | { |
| 139 | unsigned int neighbours = Block::None; | 144 | unsigned int neighbours = Block::None; |
| @@ -194,6 +199,12 @@ void MainWidget::updateMap(const Transmission::map_t& map) | |||
| 194 | { | 199 | { |
| 195 | m_scene->addItem(item); | 200 | m_scene->addItem(item); |
| 196 | item->setPos(mapPositionToCoord(x, y)); | 201 | item->setPos(mapPositionToCoord(x, y)); |
| 202 | PixmapItem* oldItem = visualMap[x][y]; | ||
| 203 | visualMap[x][y] = item; | ||
| 204 | if (oldItem != NULL) { | ||
| 205 | m_scene->removeItem(item); | ||
| 206 | delete oldItem; | ||
| 207 | } | ||
| 197 | } | 208 | } |
| 198 | } | 209 | } |
| 199 | } | 210 | } |
