Permalink
Browse files

Merge pull request #11784 from hrydgard/zip-install-ui-fix

Fix issue where too long filenames could wreck the Install Zip dialog layout
  • Loading branch information...
hrydgard committed Feb 10, 2019
2 parents ccfcbc7 + 259cb0f commit 429b5bf3abde1dc0b90ab5979c60200de5e9215c
Showing with 22 additions and 2 deletions.
  1. +17 −1 Common/StringUtils.cpp
  2. +2 −0 Common/StringUtils.h
  3. +3 −1 UI/InstallZipScreen.cpp
@@ -95,4 +95,20 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
*_pExtension = full_path.substr(fname_end);

return true;
}
}

std::string GetFilenameFromPath(std::string full_path) {
size_t pos;
#ifdef _WIN32
pos = full_path.rfind('\\');
if (pos != std::string::npos) {
return full_path.substr(pos + 1);
}
#endif
pos = full_path.rfind('/');
if (pos != std::string::npos) {
return full_path.substr(pos + 1);
}
// No directory components, just return the full path.
return full_path;
}
@@ -45,3 +45,5 @@ inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...)

// "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe"
bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, std::string* _pExtension);

std::string GetFilenameFromPath(std::string full_path);
@@ -23,6 +23,7 @@
#include "UI/ui_atlas.h"
#include "file/file_util.h"

#include "Common/StringUtils.h"
#include "Core/Util/GameManager.h"
#include "UI/InstallZipScreen.h"
#include "UI/MainScreen.h"
@@ -43,8 +44,9 @@ void InstallZipScreen::CreateViews() {
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
root_->Add(leftColumn);

std::string shortFilename = GetFilenameFromPath(zipPath_);
leftColumn->Add(new TextView(iz->T("Install game from ZIP file?"), ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
leftColumn->Add(new TextView(zipPath_, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
leftColumn->Add(new TextView(shortFilename, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));

doneView_ = leftColumn->Add(new TextView("", new AnchorLayoutParams(10, 120, NONE, NONE)));
progressBar_ = leftColumn->Add(new ProgressBar(new AnchorLayoutParams(10, 200, 200, NONE)));

0 comments on commit 429b5bf

Please sign in to comment.