Skip to content

Commit

Permalink
UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 31, 2024
1 parent 3831ec1 commit 61bd011
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Core/Reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ namespace Reporting
it = crcResults.find(gamePath);
}

if (crcThread.joinable())
if (crcThread.joinable()) {
INFO_LOG(SYSTEM, "Finished CRC calculation");
crcThread.join();
}
return it->second;
}

Expand Down
3 changes: 2 additions & 1 deletion UI/GameInfoCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class GameInfo {

bool Ready(GameInfoFlags flags) {
std::unique_lock<std::mutex> guard(lock);
return (hasFlags & flags) != 0;
// Avoid the operator, we want to check all the bits.
return ((int)hasFlags & (int)flags) == (int)flags;
}

void MarkReadyNoLock(GameInfoFlags flags) {
Expand Down
16 changes: 10 additions & 6 deletions UI/GameScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ void GameScreen::CreateViews() {
tvCRC_->SetVisibility(Reporting::HasCRC(gamePath_) ? V_VISIBLE : V_GONE);
tvVerified_ = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
tvVerified_->SetVisibility(UI::V_GONE);
tvVerified_->SetSquishy(true);
if (info->badCHD) {
auto e = GetI18NCategory(I18NCat::ERRORS);
infoLayout->Add(new NoticeView(NoticeLevel::ERROR, e->T("BadCHD", "Bad CHD file.\nCompress using \"chdman createdvd\" for good performance."), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
infoLayout->Add(new NoticeView(NoticeLevel::ERROR, e->T("BadCHD", "Bad CHD file.\nCompress using \"chdman createdvd\" for good performance."), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetSquishy(true);
}
} else {
tvTitle_ = nullptr;
Expand Down Expand Up @@ -296,7 +297,7 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {
tvTitle_->SetText(info->GetTitle());
}

if (info->gameSizeOnDisk) {
if (info->Ready(GameInfoFlags::SIZE | GameInfoFlags::UNCOMPRESSED_SIZE)) {
char temp[256];
if (tvGameSize_) {
snprintf(temp, sizeof(temp), "%s: %s", ga->T("Game"), NiceSizeFormat(info->gameSizeOnDisk).c_str());
Expand Down Expand Up @@ -350,7 +351,7 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {

// Let's check the CRC in the game database, looking up the ID and also matching the crc.
std::vector<GameDBInfo> dbInfos;
if (tvVerified_ && !info->id_version.empty() && g_gameDB.GetGameInfos(info->id_version, &dbInfos)) {
if (tvVerified_ && info->Ready(GameInfoFlags::PARAM_SFO) && g_gameDB.GetGameInfos(info->id_version, &dbInfos)) {
bool found = false;
for (auto &dbInfo : dbInfos) {
if (dbInfo.crc == crcVal) {
Expand All @@ -365,21 +366,23 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {
// Like the other messages below, disabled until we have a database we have confidence in.
// tvVerified_->SetText(ga->T("CRC checksum does not match, bad or modified ISO"));
// tvVerified_->SetLevel(NoticeLevel::ERROR);
tvVerified_->SetVisibility(UI::V_GONE);
}
} else {
} else if (tvVerified_) {
// tvVerified_->SetText(ga->T("Game ID unknown - not in the Redump database"));
// tvVerified_->SetVisibility(UI::V_VISIBLE);
// tvVerified_->SetLevel(NoticeLevel::WARN);
tvVerified_->SetVisibility(UI::V_GONE);
}
} else if (!isHomebrew_) {
GameDBInfo dbInfo;
if (tvVerified_) {
std::vector<GameDBInfo> dbInfos;
if (!info->id_version.empty() && !g_gameDB.GetGameInfos(info->id_version, &dbInfos)) {
if (info->Ready(GameInfoFlags::PARAM_SFO) && !g_gameDB.GetGameInfos(info->id_version, &dbInfos)) {
// tvVerified_->SetText(ga->T("Game ID unknown - not in the ReDump database"));
// tvVerified_->SetVisibility(UI::V_VISIBLE);
// tvVerified_->SetLevel(NoticeLevel::WARN);
} else if (info->gameSizeUncompressed != 0) { // don't do this check if info still pending
} else if (info->Ready(GameInfoFlags::UNCOMPRESSED_SIZE) && info->gameSizeUncompressed != 0) { // don't do this check if info still pending
bool found = false;
for (auto &dbInfo : dbInfos) {
// TODO: Doesn't take CSO/CHD into account.
Expand All @@ -391,6 +394,7 @@ ScreenRenderFlags GameScreen::render(ScreenRenderMode mode) {
// tvVerified_->SetText(ga->T("File size incorrect, bad or modified ISO"));
// tvVerified_->SetVisibility(UI::V_VISIBLE);
// tvVerified_->SetLevel(NoticeLevel::ERROR);
// INFO_LOG(LOADER, "File size %d not matching game DB", (int)info->gameSizeUncompressed);
} else {
tvVerified_->SetText(ga->T("Click \"Calculate CRC\" to verify ISO"));
tvVerified_->SetVisibility(UI::V_VISIBLE);
Expand Down
4 changes: 3 additions & 1 deletion UI/OnScreenDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ void NoticeView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec
ApplyBoundsBySpec(bounds, horiz, vert);
MeasureNotice(dc, level_, text_, detailsText_, iconName_, 0, &w, &h, &height1_);
// Layout hack! Some weird problems with the layout that I can't figure out right now..
w = 50.0;
if (squishy_) {
w = 50.0;
}
}

void NoticeView::Draw(UIContext &dc) {
Expand Down
4 changes: 4 additions & 0 deletions UI/OnScreenDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class NoticeView : public UI::InertView {
void SetLevel(NoticeLevel level) {
level_ = level;
}
void SetSquishy(bool squishy) {
squishy_ = squishy;
}

void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override;
void Draw(UIContext &dc) override;
Expand All @@ -79,4 +82,5 @@ class NoticeView : public UI::InertView {
std::string iconName_;
NoticeLevel level_;
mutable float height1_ = 0.0f;
bool squishy_ = false;
};

0 comments on commit 61bd011

Please sign in to comment.