From 6277a95bb86a5d2f6564ecd48143e30cb9fc799f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Dec 2013 11:44:46 +0100 Subject: [PATCH] Minor gamelist polish (fix & signs, avoid double dots for zip files) --- UI/GameInfoCache.cpp | 11 ++++++----- UI/MainScreen.cpp | 14 ++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 709b01dc10..9ad6e01706 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -85,7 +85,7 @@ std::vector GameInfo::GetSaveDataDirectories() { std::vector dirs; getFilesInDir(memc.c_str(), &dirs); - + std::vector directories; for (size_t i = 0; i < dirs.size(); i++) { if (startsWith(dirs[i].name, id)) { @@ -279,8 +279,8 @@ public: { info_->fileType = FILETYPE_PSP_ISO; SequentialHandleAllocator handles; - VirtualDiscFileSystem umd(&handles,gamePath_.c_str()); - + VirtualDiscFileSystem umd(&handles, gamePath_.c_str()); + // Alright, let's fetch the PARAM.SFO. std::string paramSFOcontents; if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", ¶mSFOcontents, 0)) { @@ -339,7 +339,7 @@ public: ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info_->pic1TextureData, &info_->lock); break; } - + case FILETYPE_NORMAL_DIRECTORY: info_->title = gamePath_; break; @@ -348,7 +348,8 @@ public: { std::string fn, ext; SplitPath(gamePath_, 0, &fn, &ext); - info_->title = fn + "." + ext; + // ext includes the dot + info_->title = fn + ext; } break; } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 706476c793..32485e7386 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -23,6 +23,7 @@ #include "file/path.h" #include "gfx_es2/draw_buffer.h" #include "math/curves.h" +#include "base/stringutil.h" #include "ui/ui_context.h" #include "ui/view.h" #include "ui/viewgroup.h" @@ -78,12 +79,14 @@ public: } const std::string &GamePath() const { return gamePath_; } + virtual void Touch(const TouchInput &input) { UI::Clickable::Touch(input); if (input.flags & TOUCH_UP) { holdFrameCount_ = 0; } } + virtual void Update(const InputState &input_state) { if (down_) holdFrameCount_++; @@ -105,6 +108,7 @@ public: private: bool gridStyle_; std::string gamePath_; + std::string title_; int holdFrameCount_; }; @@ -201,9 +205,11 @@ void GameButton::Draw(UIContext &dc) { float tw, th; dc.Draw()->Flush(); dc.PushScissor(bounds_); - std::string title = ginfo->title + discNumInfo; + if (title_.empty() && !ginfo->title.empty()) { + title_ = ReplaceAll(ginfo->title + discNumInfo, "&", "&&"); + } - dc.MeasureText(dc.GetFontStyle(), title.c_str(), &tw, &th, 0); + dc.MeasureText(dc.GetFontStyle(), title_.c_str(), &tw, &th, 0); int availableWidth = bounds_.w - 150; float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f; @@ -216,7 +222,7 @@ void GameButton::Draw(UIContext &dc) { tb.w = bounds_.w - 150; dc.PushScissor(tb); } - dc.DrawText(title.c_str(), bounds_.x + tx, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); + dc.DrawText(title_.c_str(), bounds_.x + tx, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); if (availableWidth < tw) { dc.PopScissor(); } @@ -225,7 +231,7 @@ void GameButton::Draw(UIContext &dc) { } else if (!texture) { dc.Draw()->Flush(); dc.PushScissor(bounds_); - dc.DrawText((ginfo->title + discNumInfo).c_str(), bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); + dc.DrawText(title_.c_str(), bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); dc.Draw()->Flush(); dc.PopScissor(); } else {