mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-22 11:23:27 -04:00
Remove the need to cast door marker widgets
This commit is contained in:
parent
cdd2ea02b4
commit
75a04776b0
@ -38,7 +38,7 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
const int cellSize = Constants::CellSizeInUnits;
|
||||
constexpr int cellSize = Constants::CellSizeInUnits;
|
||||
constexpr float speed = 1.08f; // the zoom speed, it should be greater than 1
|
||||
|
||||
enum LocalMapWidgetDepth
|
||||
@ -57,7 +57,10 @@ namespace
|
||||
Global_ExploreOverlayLayer = 2,
|
||||
Global_MapLayer = 3
|
||||
};
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
/// @brief A widget that changes its color when hovered.
|
||||
class MarkerWidget final : public MyGUI::Widget
|
||||
{
|
||||
@ -108,10 +111,6 @@ namespace
|
||||
{
|
||||
scrollView->setCanvasSize(widgetSize * (grid.width() + 1), widgetSize * (grid.height() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
void CustomMarkerCollection::addMarker(const ESM::CustomMarker& marker, bool triggerEvent)
|
||||
{
|
||||
@ -293,7 +292,7 @@ namespace MWGui
|
||||
return MyGUI::IntCoord(position.left - halfMarkerSize, position.top - halfMarkerSize, markerSize, markerSize);
|
||||
}
|
||||
|
||||
MyGUI::Widget* LocalMapBase::createDoorMarker(const std::string& name, float x, float y) const
|
||||
MarkerWidget* LocalMapBase::createDoorMarker(const std::string& name, float x, float y) const
|
||||
{
|
||||
MarkerUserData data(mLocalMapRender);
|
||||
data.caption = name;
|
||||
@ -327,7 +326,7 @@ namespace MWGui
|
||||
return MyGUI::IntCoord(position.left - markerSize / 2, position.top - markerSize / 2, markerSize, markerSize);
|
||||
}
|
||||
|
||||
std::vector<MyGUI::Widget*>& LocalMapBase::currentDoorMarkersWidgets()
|
||||
std::vector<MarkerWidget*>& LocalMapBase::currentDoorMarkersWidgets()
|
||||
{
|
||||
return mActiveCell->isExterior() ? mExteriorDoorMarkerWidgets : mInteriorDoorMarkerWidgets;
|
||||
}
|
||||
@ -628,7 +627,7 @@ namespace MWGui
|
||||
|
||||
if (!mActiveCell->isExterior())
|
||||
{
|
||||
for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets)
|
||||
for (MarkerWidget* widget : mExteriorDoorMarkerWidgets)
|
||||
widget->setVisible(false);
|
||||
|
||||
MWWorld::CellStore& cell = worldModel->getInterior(mActiveCell->getNameId());
|
||||
@ -656,7 +655,7 @@ namespace MWGui
|
||||
++iter)
|
||||
destNotes.push_back(iter->second.mNote);
|
||||
|
||||
MyGUI::Widget* markerWidget = nullptr;
|
||||
MarkerWidget* markerWidget = nullptr;
|
||||
MarkerUserData* data;
|
||||
if (mDoorMarkersToRecycle.empty())
|
||||
{
|
||||
@ -667,7 +666,7 @@ namespace MWGui
|
||||
}
|
||||
else
|
||||
{
|
||||
markerWidget = (MarkerWidget*)mDoorMarkersToRecycle.back();
|
||||
markerWidget = mDoorMarkersToRecycle.back();
|
||||
mDoorMarkersToRecycle.pop_back();
|
||||
|
||||
data = markerWidget->getUserData<MarkerUserData>();
|
||||
|
@ -43,6 +43,7 @@ namespace SceneUtil
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class MarkerWidget;
|
||||
|
||||
class CustomMarkerCollection
|
||||
{
|
||||
@ -146,14 +147,14 @@ namespace MWGui
|
||||
std::vector<MapEntry> mMaps;
|
||||
|
||||
// Keep track of created marker widgets, just to easily remove them later.
|
||||
std::vector<MyGUI::Widget*> mExteriorDoorMarkerWidgets;
|
||||
std::map<std::pair<int, int>, std::vector<MyGUI::Widget*>> mExteriorDoorsByCell;
|
||||
std::vector<MyGUI::Widget*> mInteriorDoorMarkerWidgets;
|
||||
std::vector<MarkerWidget*> mExteriorDoorMarkerWidgets;
|
||||
std::map<std::pair<int, int>, std::vector<MarkerWidget*>> mExteriorDoorsByCell;
|
||||
std::vector<MarkerWidget*> mInteriorDoorMarkerWidgets;
|
||||
std::vector<MyGUI::Widget*> mMagicMarkerWidgets;
|
||||
std::vector<MyGUI::Widget*> mCustomMarkerWidgets;
|
||||
std::vector<MyGUI::Widget*> mDoorMarkersToRecycle;
|
||||
std::vector<MarkerWidget*> mDoorMarkersToRecycle;
|
||||
|
||||
std::vector<MyGUI::Widget*>& currentDoorMarkersWidgets();
|
||||
std::vector<MarkerWidget*>& currentDoorMarkersWidgets();
|
||||
|
||||
virtual void updateCustomMarkers();
|
||||
|
||||
@ -163,7 +164,7 @@ namespace MWGui
|
||||
MyGUI::IntPoint getMarkerPosition(float worldX, float worldY, MarkerUserData& markerPos) const;
|
||||
MyGUI::IntCoord getMarkerCoordinates(
|
||||
float worldX, float worldY, MarkerUserData& markerPos, size_t markerSize) const;
|
||||
MyGUI::Widget* createDoorMarker(const std::string& name, float x, float y) const;
|
||||
MarkerWidget* createDoorMarker(const std::string& name, float x, float y) const;
|
||||
MyGUI::IntCoord getMarkerCoordinates(MyGUI::Widget* widget, size_t markerSize) const;
|
||||
|
||||
virtual void notifyPlayerUpdate() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user