mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:26:40 +00:00 
			
		
		
		
	added region map tooltips
This commit is contained in:
		
							parent
							
								
									c808bf2b23
								
							
						
					
					
						commit
						c26a6f884f
					
				
					 2 changed files with 59 additions and 12 deletions
				
			
		| 
						 | 
					@ -12,6 +12,19 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CSMWorld::RegionMap::CellDescription::CellDescription() : mDeleted (false) {}
 | 
					CSMWorld::RegionMap::CellDescription::CellDescription() : mDeleted (false) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CSMWorld::RegionMap::CellDescription::CellDescription (const Record<Cell>& cell)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const Cell& cell2 = cell.get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!cell2.isExterior())
 | 
				
			||||||
 | 
					        throw std::logic_error ("Interior cell in region map");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mDeleted = cell.isDeleted();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mRegion = cell2.mRegion;
 | 
				
			||||||
 | 
					    mName = cell2.mName;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CSMWorld::RegionMap::CellIndex CSMWorld::RegionMap::getIndex (const QModelIndex& index) const
 | 
					CSMWorld::RegionMap::CellIndex CSMWorld::RegionMap::getIndex (const QModelIndex& index) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return CellIndex (index.column()+mMin.first, index.row()+mMin.second);
 | 
					    return CellIndex (index.column()+mMin.first, index.row()+mMin.second);
 | 
				
			||||||
| 
						 | 
					@ -53,12 +66,7 @@ void CSMWorld::RegionMap::buildMap()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (cell2.isExterior())
 | 
					        if (cell2.isExterior())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            CellDescription description;
 | 
					            CellDescription description (cell);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (cell.isDeleted())
 | 
					 | 
				
			||||||
                description.mDeleted = true;
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                description.mRegion = cell2.mRegion;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CellIndex index (cell2.mData.mX, cell2.mData.mY);
 | 
					            CellIndex index (cell2.mData.mX, cell2.mData.mY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,12 +114,7 @@ void CSMWorld::RegionMap::addCells (int start, int end)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            CellIndex index (cell2.mData.mX, cell2.mData.mY);
 | 
					            CellIndex index (cell2.mData.mX, cell2.mData.mY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CellDescription description;
 | 
					            CellDescription description (cell);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (cell.isDeleted())
 | 
					 | 
				
			||||||
                description.mDeleted = true;
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                description.mRegion = cell2.mRegion;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            addCell (index, description);
 | 
					            addCell (index, description);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -363,6 +366,44 @@ QVariant CSMWorld::RegionMap::data (const QModelIndex& index, int role) const
 | 
				
			||||||
        return QBrush (Qt::DiagCrossPattern);
 | 
					        return QBrush (Qt::DiagCrossPattern);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (role==Qt::ToolTipRole)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        CellIndex cellIndex = getIndex (index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::ostringstream stream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        stream << cellIndex.first << ", " << cellIndex.second;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::map<CellIndex, CellDescription>::const_iterator cell =
 | 
				
			||||||
 | 
					            mMap.find (cellIndex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (cell!=mMap.end())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!cell->second.mName.empty())
 | 
				
			||||||
 | 
					                stream << " " << cell->second.mName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (cell->second.mDeleted)
 | 
				
			||||||
 | 
					                stream << " (deleted)";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!cell->second.mRegion.empty())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                stream << "<br>";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                std::map<std::string, unsigned int>::const_iterator iter =
 | 
				
			||||||
 | 
					                    mColours.find (Misc::StringUtils::lowerCase (cell->second.mRegion));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (iter!=mColours.end())
 | 
				
			||||||
 | 
					                    stream << cell->second.mRegion;
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    stream << "<font color=red>" << cell->second.mRegion << "</font>";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            stream << " (no cell)";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return QString::fromUtf8 (stream.str().c_str());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return QVariant();
 | 
					    return QVariant();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QAbstractTableModel>
 | 
					#include <QAbstractTableModel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "record.hpp"
 | 
				
			||||||
 | 
					#include "cell.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace CSMWorld
 | 
					namespace CSMWorld
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    class Data;
 | 
					    class Data;
 | 
				
			||||||
| 
						 | 
					@ -28,8 +31,11 @@ namespace CSMWorld
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                bool mDeleted;
 | 
					                bool mDeleted;
 | 
				
			||||||
                std::string mRegion;
 | 
					                std::string mRegion;
 | 
				
			||||||
 | 
					                std::string mName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                CellDescription();
 | 
					                CellDescription();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                CellDescription (const Record<Cell>& cell);
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Data& mData;
 | 
					            Data& mData;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue