forked from mirror/openmw-tes3mp
transparent overlay
This commit is contained in:
parent
a04df37f83
commit
38828acac9
8 changed files with 68 additions and 2 deletions
|
@ -266,13 +266,17 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager, const std::string&
|
||||||
mGlobalMapRender = new MWRender::GlobalMap(cacheDir);
|
mGlobalMapRender = new MWRender::GlobalMap(cacheDir);
|
||||||
mGlobalMapRender->render();
|
mGlobalMapRender->render();
|
||||||
|
|
||||||
|
mGlobalMapRender->exploreCell(0,0);
|
||||||
|
|
||||||
getWidget(mLocalMap, "LocalMap");
|
getWidget(mLocalMap, "LocalMap");
|
||||||
getWidget(mGlobalMap, "GlobalMap");
|
getWidget(mGlobalMap, "GlobalMap");
|
||||||
getWidget(mGlobalMapImage, "GlobalMapImage");
|
getWidget(mGlobalMapImage, "GlobalMapImage");
|
||||||
|
getWidget(mGlobalMapOverlay, "GlobalMapOverlay");
|
||||||
getWidget(mPlayerArrowLocal, "CompassLocal");
|
getWidget(mPlayerArrowLocal, "CompassLocal");
|
||||||
getWidget(mPlayerArrowGlobal, "CompassGlobal");
|
getWidget(mPlayerArrowGlobal, "CompassGlobal");
|
||||||
|
|
||||||
mGlobalMapImage->setImageTexture("GlobalMap.png");
|
mGlobalMapImage->setImageTexture("GlobalMap.png");
|
||||||
|
mGlobalMapOverlay->setImageTexture("GlobalMapOverlay");
|
||||||
|
|
||||||
mGlobalMap->setVisible (false);
|
mGlobalMap->setVisible (false);
|
||||||
|
|
||||||
|
@ -328,6 +332,11 @@ void MapWindow::addVisitedLocation(const std::string& name, int x, int y)
|
||||||
markerWidget->setUserString("Caption_Text", name);
|
markerWidget->setUserString("Caption_Text", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapWindow::cellExplored(int x, int y)
|
||||||
|
{
|
||||||
|
mGlobalMapRender->exploreCell(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||||
{
|
{
|
||||||
if (_id!=MyGUI::MouseButton::Left) return;
|
if (_id!=MyGUI::MouseButton::Left) return;
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace MWGui
|
||||||
void setCellName(const std::string& cellName);
|
void setCellName(const std::string& cellName);
|
||||||
|
|
||||||
void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map
|
void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map
|
||||||
|
void cellExplored(int x, int y);
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
|
@ -82,6 +83,7 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::ScrollView* mGlobalMap;
|
MyGUI::ScrollView* mGlobalMap;
|
||||||
MyGUI::ImageBox* mGlobalMapImage;
|
MyGUI::ImageBox* mGlobalMapImage;
|
||||||
|
MyGUI::ImageBox* mGlobalMapOverlay;
|
||||||
MyGUI::ImageBox* mPlayerArrowLocal;
|
MyGUI::ImageBox* mPlayerArrowLocal;
|
||||||
MyGUI::ImageBox* mPlayerArrowGlobal;
|
MyGUI::ImageBox* mPlayerArrowGlobal;
|
||||||
MyGUI::Button* mButton;
|
MyGUI::Button* mButton;
|
||||||
|
|
|
@ -621,6 +621,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
|
||||||
name = getGameSettingString("sDefaultCellname", "Wilderness");
|
name = getGameSettingString("sDefaultCellname", "Wilderness");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mMap->cellExplored(cell->cell->getGridX(), cell->cell->getGridY());
|
||||||
|
|
||||||
mMap->setCellName( name );
|
mMap->setCellName( name );
|
||||||
mHud->setCellName( name );
|
mHud->setCellName( name );
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <OgreColourValue.h>
|
#include <OgreColourValue.h>
|
||||||
#include <OgreHardwareVertexBuffer.h>
|
#include <OgreHardwareVertexBuffer.h>
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
#include <OgreHardwarePixelBuffer.h>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -47,6 +48,7 @@ namespace MWRender
|
||||||
mWidth = cellSize*(mMaxX-mMinX+1);
|
mWidth = cellSize*(mMaxX-mMinX+1);
|
||||||
mHeight = cellSize*(mMaxY-mMinY+1);
|
mHeight = cellSize*(mMaxY-mMinY+1);
|
||||||
|
|
||||||
|
mExploredBuffer.resize((mMaxX-mMinX+1) * (mMaxY-mMinY+1) * 4);
|
||||||
|
|
||||||
//if (!boost::filesystem::exists(mCacheDir + "/GlobalMap.png"))
|
//if (!boost::filesystem::exists(mCacheDir + "/GlobalMap.png"))
|
||||||
if (1)
|
if (1)
|
||||||
|
@ -179,5 +181,46 @@ namespace MWRender
|
||||||
imageY = 1.f-float(y - mMinY + 1) / (mMaxY - mMinY + 1);
|
imageY = 1.f-float(y - mMinY + 1) / (mMaxY - mMinY + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobalMap::exploreCell(int cellX, int cellY)
|
||||||
|
{
|
||||||
|
mExploredCells.push_back(std::make_pair(cellX, cellY));
|
||||||
|
int width = mMaxX-mMinX+1;
|
||||||
|
int height = mMaxY-mMinY+1;
|
||||||
|
|
||||||
|
if (mOverlayTexture.isNull())
|
||||||
|
{
|
||||||
|
mOverlayTexture = Ogre::TextureManager::getSingleton().createManual("GlobalMapOverlay", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||||
|
Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8B8G8R8, Ogre::TU_DYNAMIC_WRITE_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = mMinX; x <= mMaxX; ++x)
|
||||||
|
{
|
||||||
|
for (int y = mMinY; y <= mMaxY; ++y)
|
||||||
|
{
|
||||||
|
unsigned char r,g,b,a;
|
||||||
|
r = 0;
|
||||||
|
g = 0;
|
||||||
|
b = 0;
|
||||||
|
if (std::find(mExploredCells.begin(), mExploredCells.end(), std::make_pair(x, y)) != mExploredCells.end())
|
||||||
|
a = 0;
|
||||||
|
else
|
||||||
|
a = 128;
|
||||||
|
int texelX = (x-mMinX);
|
||||||
|
int texelY = (height-1) - (y-mMinY);
|
||||||
|
|
||||||
|
assert( static_cast<unsigned int>(texelY * width * 4 + texelX * 4+3) < mExploredBuffer.size());
|
||||||
|
mExploredBuffer[texelY * width * 4 + texelX * 4] = r;
|
||||||
|
mExploredBuffer[texelY * width * 4 + texelX * 4+1] = g;
|
||||||
|
mExploredBuffer[texelY * width * 4 + texelX * 4+2] = b;
|
||||||
|
mExploredBuffer[texelY * width * 4 + texelX * 4+3] = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ogre::Image image;
|
||||||
|
image.loadDynamicImage(&mExploredBuffer[0], width, height, Ogre::PF_A8B8G8R8);
|
||||||
|
|
||||||
|
memcpy(mOverlayTexture->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD),
|
||||||
|
&mExploredBuffer[0], width*height*4);
|
||||||
|
mOverlayTexture->getBuffer()->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <OgreTexture.h>
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -22,9 +24,16 @@ namespace MWRender
|
||||||
|
|
||||||
void cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY);
|
void cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY);
|
||||||
|
|
||||||
|
void exploreCell (int cellX, int cellY);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mCacheDir;
|
std::string mCacheDir;
|
||||||
|
|
||||||
|
std::vector< std::pair<int,int> > mExploredCells;
|
||||||
|
|
||||||
|
Ogre::TexturePtr mOverlayTexture;
|
||||||
|
std::vector<Ogre::uchar> mExploredBuffer;
|
||||||
|
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ namespace MWRender
|
||||||
*/
|
*/
|
||||||
void saveFogOfWar(MWWorld::CellStore* cell);
|
void saveFogOfWar(MWWorld::CellStore* cell);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the interior map texture index and normalized position
|
* Get the interior map texture index and normalized position
|
||||||
* on this texture, given a world position (in ogre coordinates)
|
* on this texture, given a world position (in ogre coordinates)
|
||||||
|
|
|
@ -23,7 +23,8 @@ namespace MWRender
|
||||||
mFreeLook(true),
|
mFreeLook(true),
|
||||||
mHeight(128.f),
|
mHeight(128.f),
|
||||||
mCameraDistance(300.f),
|
mCameraDistance(300.f),
|
||||||
mDistanceAdjusted(false)
|
mDistanceAdjusted(false),
|
||||||
|
mAnimation(NULL)
|
||||||
{
|
{
|
||||||
mVanity.enabled = false;
|
mVanity.enabled = false;
|
||||||
mVanity.allowed = true;
|
mVanity.allowed = true;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<Property key="CanvasSize" value="1536 1536"/>
|
<Property key="CanvasSize" value="1536 1536"/>
|
||||||
|
|
||||||
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage">
|
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage">
|
||||||
|
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapOverlay"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassGlobal">
|
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassGlobal">
|
||||||
|
|
Loading…
Reference in a new issue