diff --git a/src/MetaData.cpp b/src/MetaData.cpp index 4a782f5bc..575ea65b2 100644 --- a/src/MetaData.cpp +++ b/src/MetaData.cpp @@ -8,14 +8,18 @@ MetaDataDecl gameDecls[] = { - {"name", MD_STRING, "", false}, - {"desc", MD_MULTILINE_STRING, "", false}, - {"image", MD_IMAGE_PATH, "", false}, - {"thumbnail", MD_IMAGE_PATH, "", false}, - {"rating", MD_RATING, "0", false}, - {"releasedate", MD_DATE, "0", false}, - {"playcount", MD_INT, "0", true}, - {"lastplayed", MD_TIME, "0", true} + {"name", MD_STRING, "", false}, + {"desc", MD_MULTILINE_STRING, "", false}, + {"image", MD_IMAGE_PATH, "", false}, + {"thumbnail", MD_IMAGE_PATH, "", false}, + {"rating", MD_RATING, "0", false}, + {"releasedate", MD_DATE, "0", false}, + {"developer", MD_STRING, "unknown", false}, + {"publisher", MD_STRING, "unknown", false}, + {"genre", MD_STRING, "unknown", false}, + {"players", MD_INT, "1", false}, + {"playcount", MD_INT, "0", true}, + {"lastplayed", MD_TIME, "0", true} }; const std::vector gameMDD(gameDecls, gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0])); diff --git a/src/components/DateTimeComponent.cpp b/src/components/DateTimeComponent.cpp index 8c8d81492..41d299dd8 100644 --- a/src/components/DateTimeComponent.cpp +++ b/src/components/DateTimeComponent.cpp @@ -245,6 +245,7 @@ void DateTimeComponent::updateTextCache() const std::string dispString = getDisplayString(mode); std::shared_ptr font = getFont(); mTextCache = std::unique_ptr(font->buildTextCache(dispString, 0, 0, mColor)); + setSize(mTextCache->metrics.size); //set up cursor positions mCursorBoxes.clear(); diff --git a/src/components/TextComponent.cpp b/src/components/TextComponent.cpp index 090b6281f..4b0b00073 100644 --- a/src/components/TextComponent.cpp +++ b/src/components/TextComponent.cpp @@ -80,8 +80,6 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans) if(font && !mText.empty()) { - Renderer::setMatrix(trans); - if(mCentered) { const Eigen::Vector2f& textSize = mTextCache->metrics.size; @@ -90,6 +88,8 @@ void TextComponent::render(const Eigen::Affine3f& parentTrans) Eigen::Affine3f centeredTrans = trans; centeredTrans = centeredTrans.translate(Eigen::Vector3f(pos.x(), pos.y(), 0)); Renderer::setMatrix(centeredTrans); + }else{ + Renderer::setMatrix(trans); } font->renderTextCache(mTextCache.get()); @@ -118,7 +118,27 @@ void TextComponent::onTextChanged() calculateExtent(); std::shared_ptr f = getFont(); - mTextCache = std::shared_ptr(f->buildTextCache(f->wrapText(mText, mSize.x()), 0, 0, (mColor >> 8 << 8) | mOpacity)); + const bool wrap = (mSize.y() == 0 || (int)mSize.y() > f->getHeight()); + Eigen::Vector2f size = f->sizeText(mText); + if(!wrap && mSize.x() && mText.size() && size.x() > mSize.x()) + { + // abbreviate text + const std::string abbrev = ".."; + Eigen::Vector2f abbrevSize = f->sizeText(abbrev); + + std::string text = mText; + while(text.size() && size.x() + abbrevSize.x() > mSize.x()) + { + text.erase(text.size() - 1, 1); + size = f->sizeText(text); + } + + text.append(abbrev); + + mTextCache = std::shared_ptr(f->buildTextCache(text, 0, 0, (mColor >> 8 << 8) | mOpacity)); + }else{ + mTextCache = std::shared_ptr(f->buildTextCache(f->wrapText(mText, mSize.x()), 0, 0, (mColor >> 8 << 8) | mOpacity)); + } } void TextComponent::onColorChanged() diff --git a/src/scrapers/GamesDBScraper.cpp b/src/scrapers/GamesDBScraper.cpp index 16d40a571..6367a64b2 100644 --- a/src/scrapers/GamesDBScraper.cpp +++ b/src/scrapers/GamesDBScraper.cpp @@ -106,6 +106,11 @@ std::vector GamesDBScraper::parseReq(ScraperSearchParams params, s boost::posix_time::ptime rd = string_to_ptime(game.child("ReleaseDate").text().get(), "%m/%d/%Y"); mdl.back().setTime("releasedate", rd); + mdl.back().set("developer", game.child("Developer").text().get()); + mdl.back().set("publisher", game.child("Publisher").text().get()); + mdl.back().set("genre", game.child("Genres").first_child().text().get()); + mdl.back().set("players", game.child("Players").text().get()); + if(Settings::getInstance()->getBool("ScrapeRatings") && game.child("Rating")) { float ratingVal = (game.child("Rating").text().as_int() / 10.0f); diff --git a/src/views/gamelist/DetailedGameListView.cpp b/src/views/gamelist/DetailedGameListView.cpp index ddd29d117..8b2da5a68 100644 --- a/src/views/gamelist/DetailedGameListView.cpp +++ b/src/views/gamelist/DetailedGameListView.cpp @@ -7,8 +7,11 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : mDescContainer(window), mDescription(window), mImage(window), - mLblRating(window), mLblReleaseDate(window), mLblLastPlayed(window), mLblPlayCount(window), - mRating(window), mReleaseDate(window), mLastPlayed(window), mPlayCount(window) + mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), + mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window), + + mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window), + mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window) { //mHeaderImage.setPosition(mSize.x() * 0.25f, 0); @@ -32,6 +35,18 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : mLblReleaseDate.setText("Released: "); addChild(&mLblReleaseDate); addChild(&mReleaseDate); + mLblDeveloper.setText("Developer: "); + addChild(&mLblDeveloper); + addChild(&mDeveloper); + mLblPublisher.setText("Publisher: "); + addChild(&mLblPublisher); + addChild(&mPublisher); + mLblGenre.setText("Genre: "); + addChild(&mLblGenre); + addChild(&mGenre); + mLblPlayers.setText("Players: "); + addChild(&mLblPlayers); + addChild(&mPlayers); mLblLastPlayed.setText("Last played: "); addChild(&mLblLastPlayed); mLastPlayed.setDisplayMode(DateTimeComponent::DISP_RELATIVE_TO_NOW); @@ -64,9 +79,10 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them initMDLabels(); std::vector labels = getMDLabels(); - assert(labels.size() == 4); - const char* lblElements[4] = { - "md_lbl_rating", "md_lbl_releasedate", "md_lbl_lastplayed", "md_lbl_playcount" + assert(labels.size() == 8); + const char* lblElements[8] = { + "md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher", + "md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount" }; for(unsigned int i = 0; i < labels.size(); i++) @@ -77,9 +93,10 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them initMDValues(); std::vector values = getMDValues(); - assert(values.size() == 4); - const char* valElements[4] = { - "md_rating", "md_releasedate", "md_lastplayed", "md_playcount" + assert(values.size() == 8); + const char* valElements[8] = { + "md_rating", "md_releasedate", "md_developer", "md_publisher", + "md_genre", "md_players", "md_lastplayed", "md_playcount" }; for(unsigned int i = 0; i < values.size(); i++) @@ -134,14 +151,21 @@ void DetailedGameListView::initMDValues() std::shared_ptr defaultFont = Font::get(FONT_SIZE_SMALL); mRating.setSize(defaultFont->getHeight() * 5.0f, (float)defaultFont->getHeight()); mReleaseDate.setFont(defaultFont); + mDeveloper.setFont(defaultFont); + mPublisher.setFont(defaultFont); + mGenre.setFont(defaultFont); + mPlayers.setFont(defaultFont); mLastPlayed.setFont(defaultFont); mPlayCount.setFont(defaultFont); float bottom = 0.0f; + + const float colSize = (mSize.x() * 0.48f) / 2; for(unsigned int i = 0; i < labels.size(); i++) { const float heightDiff = (labels[i]->getSize().y() - values[i]->getSize().y()) / 2; values[i]->setPosition(labels[i]->getPosition() + Vector3f(labels[i]->getSize().x(), heightDiff, 0)); + values[i]->setSize(colSize - labels[i]->getSize().x(), values[i]->getSize().y()); float testBot = values[i]->getPosition().y() + values[i]->getSize().y(); if(testBot > bottom) @@ -164,6 +188,10 @@ void DetailedGameListView::updateInfoPanel() mImage.setImage(file->metadata.get("image")); mRating.setValue(file->metadata.get("rating")); mReleaseDate.setValue(file->metadata.get("releasedate")); + mDeveloper.setValue(file->metadata.get("developer")); + mPublisher.setValue(file->metadata.get("publisher")); + mGenre.setValue(file->metadata.get("genre")); + mPlayers.setValue(file->metadata.get("players")); mLastPlayed.setValue(file->metadata.get("lastplayed")); mPlayCount.setValue(file->metadata.get("playcount")); @@ -187,6 +215,10 @@ std::vector DetailedGameListView::getMDLabels() std::vector ret; ret.push_back(&mLblRating); ret.push_back(&mLblReleaseDate); + ret.push_back(&mLblDeveloper); + ret.push_back(&mLblPublisher); + ret.push_back(&mLblGenre); + ret.push_back(&mLblPlayers); ret.push_back(&mLblLastPlayed); ret.push_back(&mLblPlayCount); return ret; @@ -197,6 +229,10 @@ std::vector DetailedGameListView::getMDValues() std::vector ret; ret.push_back(&mRating); ret.push_back(&mReleaseDate); + ret.push_back(&mDeveloper); + ret.push_back(&mPublisher); + ret.push_back(&mGenre); + ret.push_back(&mPlayers); ret.push_back(&mLastPlayed); ret.push_back(&mPlayCount); return ret; diff --git a/src/views/gamelist/DetailedGameListView.h b/src/views/gamelist/DetailedGameListView.h index 7ba89dfca..28756e698 100644 --- a/src/views/gamelist/DetailedGameListView.h +++ b/src/views/gamelist/DetailedGameListView.h @@ -25,10 +25,14 @@ private: ImageComponent mImage; - TextComponent mLblRating, mLblReleaseDate, mLblLastPlayed, mLblPlayCount; + TextComponent mLblRating, mLblReleaseDate, mLblDeveloper, mLblPublisher, mLblGenre, mLblPlayers, mLblLastPlayed, mLblPlayCount; RatingComponent mRating; DateTimeComponent mReleaseDate; + TextComponent mDeveloper; + TextComponent mPublisher; + TextComponent mGenre; + TextComponent mPlayers; DateTimeComponent mLastPlayed; TextComponent mPlayCount;