commit
81dfd21d9a
@ -0,0 +1,79 @@
|
||||
//
|
||||
// Created by koncord on 30.09.16.
|
||||
//
|
||||
|
||||
#include <stdexcept>
|
||||
#include "PlayerMarkerCollection.hpp"
|
||||
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
void PlayerMarkerCollection::addMarker(const ESM::CustomMarker &marker, bool triggerEvent)
|
||||
{
|
||||
mMarkers.insert(std::make_pair(marker.mCell, marker));
|
||||
if (triggerEvent)
|
||||
eventMarkersChanged();
|
||||
}
|
||||
|
||||
void PlayerMarkerCollection::deleteMarker(const ESM::CustomMarker &marker)
|
||||
{
|
||||
std::pair<ContainerType::iterator, ContainerType::iterator> range = mMarkers.equal_range(marker.mCell);
|
||||
|
||||
for (ContainerType::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (it->second == marker)
|
||||
{
|
||||
mMarkers.erase(it);
|
||||
eventMarkersChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("can't find marker to delete");
|
||||
}
|
||||
|
||||
void PlayerMarkerCollection::updateMarker(const ESM::CustomMarker &marker, const std::string &newNote)
|
||||
{
|
||||
std::pair<ContainerType::iterator, ContainerType::iterator> range = mMarkers.equal_range(marker.mCell);
|
||||
|
||||
for (ContainerType::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (it->second == marker)
|
||||
{
|
||||
it->second.mNote = newNote;
|
||||
eventMarkersChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("can't find marker to update");
|
||||
}
|
||||
|
||||
void PlayerMarkerCollection::clear()
|
||||
{
|
||||
mMarkers.clear();
|
||||
eventMarkersChanged();
|
||||
}
|
||||
|
||||
PlayerMarkerCollection::ContainerType::const_iterator PlayerMarkerCollection::begin() const
|
||||
{
|
||||
return mMarkers.begin();
|
||||
}
|
||||
|
||||
PlayerMarkerCollection::ContainerType::const_iterator PlayerMarkerCollection::end() const
|
||||
{
|
||||
return mMarkers.end();
|
||||
}
|
||||
|
||||
PlayerMarkerCollection::RangeType PlayerMarkerCollection::getMarkers(const ESM::CellId &cellId) const
|
||||
{
|
||||
return mMarkers.equal_range(cellId);
|
||||
}
|
||||
|
||||
size_t PlayerMarkerCollection::size() const
|
||||
{
|
||||
return mMarkers.size();
|
||||
}
|
||||
|
||||
bool PlayerMarkerCollection::isExists(const ESM::CustomMarker &marker)
|
||||
{
|
||||
return mMarkers.find(marker.mCell) != mMarkers.end();
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
//
|
||||
// Created by koncord on 30.09.16.
|
||||
//
|
||||
|
||||
// Copied from MWGui::CustomMarkerCollection
|
||||
|
||||
#ifndef OPENMW_PLAYERMARKERCOLLECTION_HPP
|
||||
#define OPENMW_PLAYERMARKERCOLLECTION_HPP
|
||||
|
||||
#include <components/esm/cellid.hpp>
|
||||
#include <components/esm/custommarkerstate.hpp>
|
||||
#include <map>
|
||||
#include <MyGUI_Common.h>
|
||||
#include <MyGUI_Colour.h>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PlayerMarkerCollection
|
||||
{
|
||||
public:
|
||||
|
||||
void addMarker(const ESM::CustomMarker &marker, bool triggerEvent = true);
|
||||
void deleteMarker(const ESM::CustomMarker &marker);
|
||||
void updateMarker(const ESM::CustomMarker &marker, const std::string &newNote);
|
||||
|
||||
void clear();
|
||||
|
||||
size_t size() const;
|
||||
|
||||
typedef std::multimap <ESM::CellId, ESM::CustomMarker> ContainerType;
|
||||
|
||||
typedef std::pair <ContainerType::const_iterator, ContainerType::const_iterator> RangeType;
|
||||
|
||||
ContainerType::const_iterator begin() const;
|
||||
ContainerType::const_iterator end() const;
|
||||
|
||||
RangeType getMarkers(const ESM::CellId &cellId) const;
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
EventHandle_Void eventMarkersChanged;
|
||||
|
||||
bool isExists(const ESM::CustomMarker &marker);
|
||||
private:
|
||||
ContainerType mMarkers;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PLAYERMARKERCOLLECTION_HPP
|
Loading…
Reference in New Issue