mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
automatically zoom in on the player while moving
This commit is contained in:
parent
cf3515a898
commit
2dd329938a
@ -84,6 +84,15 @@ namespace MWGui
|
||||
eventbox->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||
}
|
||||
|
||||
void setVisible(bool b)
|
||||
{
|
||||
mMainWidget->setVisible(b);
|
||||
if (b)
|
||||
mVisible = true;
|
||||
else
|
||||
mVisible = false;
|
||||
}
|
||||
|
||||
void setCellName(const std::string& cellName)
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(cellName);
|
||||
@ -110,8 +119,13 @@ namespace MWGui
|
||||
|
||||
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)
|
||||
setImage(name, image);
|
||||
else
|
||||
setImage(name, "black.png");
|
||||
|
||||
if (MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0)
|
||||
setImage(name+"_fog", image+"_fog");
|
||||
else
|
||||
setImage(name+"_fog", "black.png");
|
||||
}
|
||||
}
|
||||
mInterior = interior;
|
||||
@ -119,6 +133,17 @@ namespace MWGui
|
||||
mCurY = y;
|
||||
}
|
||||
|
||||
void setPlayerPos(const float x, const float y)
|
||||
{
|
||||
if (mVisible) return;
|
||||
MyGUI::IntSize size = mMap->getCanvasSize();
|
||||
MyGUI::IntPoint middle = MyGUI::IntPoint(x*size.width,y*size.height);
|
||||
MyGUI::IntCoord viewsize = mMap->getCoord();
|
||||
MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top);
|
||||
std::cout << pos.left << " top " << pos.top << std::endl;
|
||||
mMap->setViewOffset(pos);
|
||||
}
|
||||
|
||||
void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
@ -146,6 +171,7 @@ namespace MWGui
|
||||
MyGUI::IntPoint mLastDragPos;
|
||||
int mCurX, mCurY;
|
||||
bool mInterior;
|
||||
bool mVisible;
|
||||
};
|
||||
|
||||
class MainMenu : public OEngine::GUI::Layout
|
||||
|
@ -424,3 +424,8 @@ void WindowManager::setInteriorMapTexture(const int x, const int y)
|
||||
{
|
||||
map->setActiveCell(x,y, true);
|
||||
}
|
||||
|
||||
void WindowManager::setPlayerPos(const float x, const float y)
|
||||
{
|
||||
map->setPlayerPos(x,y);
|
||||
}
|
||||
|
@ -154,6 +154,7 @@ namespace MWGui
|
||||
void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty
|
||||
|
||||
void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell
|
||||
void setPlayerPos(const float x, const float y); ///< set player position in map space
|
||||
|
||||
void setInteriorMapTexture(const int x, const int y);
|
||||
///< set the index of the map texture that should be used (for interiors)
|
||||
|
@ -263,6 +263,7 @@ void LocalMap::setPlayerPosition (const Ogre::Vector3& position)
|
||||
u = std::abs((pos.x - (sSize*x))/sSize);
|
||||
v = 1-std::abs((pos.y + (sSize*y))/sSize);
|
||||
texName = "Cell_"+coordStr(x,y);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -274,6 +275,7 @@ void LocalMap::setPlayerPosition (const Ogre::Vector3& position)
|
||||
|
||||
texName = mInteriorName + "_" + coordStr(x,y);
|
||||
}
|
||||
mEnvironment->mWindowManager->setPlayerPos(1/3.f + u/3.f, 1/3.f + v/3.f);
|
||||
|
||||
// explore radius (squared)
|
||||
const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;
|
||||
|
Loading…
x
Reference in New Issue
Block a user