Skip to content

Commit

Permalink
Merge pull request mrkite#99 from EtlamGit/fix-item-tool-tip-1.11
Browse files Browse the repository at this point in the history
Fix item tool-tip after "Update 1.11"
  • Loading branch information
mrkite authored Nov 20, 2016
2 parents 1ba3fa5 + a726a88 commit 438d56b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ QSharedPointer<OverlayItem> Entity::TryParse(const Tag* tag) {
entity->pos.z = pos->at(2)->toDouble();
auto id = tag->at("id");
if (id && id != &NBT::Null) {
QString type = id->toString();
QString type = id->toString().toLower().remove("minecraft:");
EntityInfo const & info = ei.getEntityInfo(type);

QMap<QString, QVariant> props = tag->getData().toMap();

// get something more descriptive if its an item
if (type == "Item") {
if (type == "item") {
auto itemId = tag->at("Item")->at("id");

QString itemtype = itemId->toString();
Expand Down
13 changes: 6 additions & 7 deletions entityidentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,19 @@ EntityIdentifier::TcatList const &EntityIdentifier::getCategoryList() const {
return categories;
}

QColor EntityIdentifier::getCategoryColor(QString name) const {
QColor EntityIdentifier::getCategoryColor(const QString name) const {
for (auto it = categories.constBegin(); it != categories.constEnd(); ++it) {
if (it->first == name)
return it->second;
}
return Qt::black; // dummy
}

EntityInfo const &EntityIdentifier::getEntityInfo(QString id) const {
// strip "minecraft:" if exists and convert lower case
id = id.replace("minecraft:","").toLower();
EntityInfo const &EntityIdentifier::getEntityInfo(const QString id) const {
for (auto it = packs.constBegin(); it != packs.constEnd(); ++it) {
if (it->enabled) {
TentityMap::const_iterator info = it->map.find(id);
// convert ID to lower case and strip "minecraft:" if exists
TentityMap::const_iterator info = it->map.find(id.toLower().remove("minecraft:"));
if (info != it->map.end()) { // found it
return info.value();
}
Expand All @@ -180,10 +179,10 @@ EntityInfo const &EntityIdentifier::getEntityInfo(QString id) const {
return entityDummy;
}

QColor EntityIdentifier::getBrushColor(QString id) const {
QColor EntityIdentifier::getBrushColor(const QString id) const {
return getEntityInfo(id).brushColor;
}

QColor EntityIdentifier::getPenColor(QString id) const {
QColor EntityIdentifier::getPenColor(const QString id) const {
return getEntityInfo(id).penColor;
}
8 changes: 4 additions & 4 deletions entityidentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class EntityIdentifier {
typedef QList<QPair<QString, QColor>> TcatList;
int getNumCategories() const;
TcatList const &getCategoryList() const;
QColor getCategoryColor(QString name) const;
QColor getCategoryColor(const QString name) const;

// interface to single EntityInfo objects
EntityInfo const &getEntityInfo(QString id) const;
QColor getBrushColor(QString id) const;
QColor getPenColor(QString id) const;
EntityInfo const &getEntityInfo(const QString id) const;
QColor getBrushColor(const QString id) const;
QColor getPenColor(const QString id) const;

private:
// singleton: prevent access to constructor and copyconstructor
Expand Down

0 comments on commit 438d56b

Please sign in to comment.