MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / MiniMapDrawnFull

Method MiniMapDrawnFull

source/gamemap/MiniMapDrawnFull.cpp:330–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330MiniMapDrawnFull::MiniMapDrawnFull(CEGUI::Window* miniMapWindow) :
331 mMiniMapWindow(miniMapWindow),
332 mGameMap(*ODFrameListener::getSingleton().getClientGameMap()),
333 mCameraManager(*ODFrameListener::getSingleton().getCameraManager()),
334 mTopLeftCornerX(0),
335 mTopLeftCornerY(0),
336 mWidth(static_cast<unsigned int>(mMiniMapWindow->getPixelSize().d_width)),
337 mHeight(static_cast<unsigned int>(mMiniMapWindow->getPixelSize().d_height)),
338 mPixelBox(mWidth, mHeight, 1, Ogre::PF_R8G8B8),
339 mMiniMapOgreTexture(Ogre::TextureManager::getSingletonPtr()->createManual(
340 "miniMapOgreTexture",
341 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
342 Ogre::TEX_TYPE_2D,
343 mWidth, mHeight, 0, Ogre::PF_R8G8B8,
344 Ogre::TU_DYNAMIC_WRITE_ONLY)),
345 mPixelBuffer(mMiniMapOgreTexture->getBuffer())
346{
347 uint32_t tileXMax = mGameMap.getMapSizeX();
348 uint32_t tileYMax = mGameMap.getMapSizeY();
349 uint32_t tileX = 0;
350 uint32_t tileY = 0;
351 uint32_t mapX = 0;
352 uint32_t mapY = 0;
353
354 Ogre::Real gainX = static_cast<Ogre::Real>(mWidth) / static_cast<Ogre::Real>(tileXMax);
355 Ogre::Real gainY = static_cast<Ogre::Real>(mHeight) / static_cast<Ogre::Real>(tileYMax);
356
357 while((mapX < mWidth) && (mapY < mHeight) && (tileX < tileXMax) && (tileY < tileYMax))
358 {
359 uint32_t tileXNext = static_cast<uint32_t>(round(static_cast<Ogre::Real>(mapX + 1) / gainX));
360 uint32_t tileYNext = static_cast<uint32_t>(round(static_cast<Ogre::Real>(mapY + 1) / gainY));
361 uint32_t mapXNext = static_cast<uint32_t>(round(static_cast<Ogre::Real>(tileX + 1) * gainX));
362 uint32_t mapYNext = static_cast<uint32_t>(round(static_cast<Ogre::Real>(tileY + 1) * gainY));
363
364 if(tileXNext == tileX)
365 ++tileXNext;
366 if(tileYNext == tileY)
367 ++tileYNext;
368 if(mapXNext == mapX)
369 ++mapXNext;
370 if(mapYNext == mapY)
371 ++mapYNext;
372
373 MiniMapDrawnFullTileStateListener* listener = new MiniMapDrawnFullTileStateListener(*this,
374 mapX, mapXNext, mapY, mapYNext, tileX, tileXNext, tileY, tileYNext);
375
376 mTileStateListeners.push_back(listener);
377
378 mapX = mapXNext;
379 tileX = tileXNext;
380 if(tileXNext >= tileXMax)
381 {
382 mapY = mapYNext;
383 tileY = tileYNext;
384 mapX = 0;
385 tileX = 0;
386 }
387 }

Callers

nothing calls this directly

Calls 10

roundFunction · 0.85
getClientGameMapMethod · 0.80
getCameraManagerMethod · 0.80
getMapSizeXMethod · 0.80
getMapSizeYMethod · 0.80
addTileStateListenerMethod · 0.80
toStringFunction · 0.50
getTileMethod · 0.45
fireTileStateChangedMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected