mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Smaller type icons, center text vertically
This commit is contained in:
parent
d42cc49dab
commit
06576fa16d
@ -73,7 +73,7 @@ void TrophyUI::Draw() {
|
||||
float AdjustWidth = io.DisplaySize.x / 1280;
|
||||
float AdjustHeight = io.DisplaySize.y / 720;
|
||||
const ImVec2 window_size{
|
||||
std::min(io.DisplaySize.x, (350 * AdjustWidth)),
|
||||
std::min(io.DisplaySize.x, (330 * AdjustWidth)),
|
||||
std::min(io.DisplaySize.y, (70 * AdjustHeight)),
|
||||
};
|
||||
|
||||
@ -96,18 +96,22 @@ void TrophyUI::Draw() {
|
||||
|
||||
ImGui::SameLine();
|
||||
if (trophy_type_icon) {
|
||||
SetCursorPosY((window_size.y * 0.5f) - (25 * AdjustHeight));
|
||||
SetCursorPosY((window_size.y * 0.5f) - (15 * AdjustHeight));
|
||||
Image(trophy_type_icon.GetTexture().im_id,
|
||||
ImVec2((50 * AdjustWidth), (50 * AdjustHeight)));
|
||||
ImVec2((30 * AdjustWidth), (30 * AdjustHeight)));
|
||||
} else {
|
||||
// placeholder
|
||||
const auto pos = GetCursorScreenPos();
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(pos, pos + ImVec2{50.0f * AdjustHeight},
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(pos, pos + ImVec2{30.0f * AdjustHeight},
|
||||
GetColorU32(ImVec4{0.7f}));
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
SetWindowFontScale((1.2 * AdjustHeight));
|
||||
char earned_text[] = "Trophy earned!\n%s";
|
||||
const float text_height =
|
||||
ImGui::CalcTextSize(std::strcat(earned_text, trophy_name.c_str())).y;
|
||||
SetCursorPosY((window_size.y - text_height) * 0.5f);
|
||||
TextWrapped("Trophy earned!\n%s", trophy_name.c_str());
|
||||
}
|
||||
End();
|
||||
|
@ -116,6 +116,29 @@ void TrophyViewer::PopulateTrophyWidget(QString title) {
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
||||
tableWidget->setItem(row, 1, item);
|
||||
|
||||
std::filesystem::path trophyTypePath;
|
||||
if (std::filesystem::exists(std::filesystem::current_path() / "Resources")) {
|
||||
trophyTypePath = std::filesystem::current_path() / "Resources";
|
||||
} else {
|
||||
#if defined(__linux__)
|
||||
const char* AppDir = getenv("APPDIR");
|
||||
trophyTypePath = std::filesystem::path(AppDir);
|
||||
#elif defined(__APPLE__)
|
||||
trophyTypePath = Common::GetBundleParentDirectory().parent_path() / "Resources";
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string filename = GetTrpType(trpType[row].at(0));
|
||||
const std::filesystem::path typeIconpath = trophyTypePath / filename;
|
||||
|
||||
QTableWidgetItem* typeitem = new QTableWidgetItem();
|
||||
QImage type_icon =
|
||||
QImage(QFileInfo(typeIconpath).absoluteFilePath())
|
||||
.scaled(QSize(64, 64), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
typeitem->setData(Qt::DecorationRole, type_icon);
|
||||
typeitem->setFlags(typeitem->flags() & ~Qt::ItemIsEditable);
|
||||
tableWidget->setItem(row, 6, typeitem);
|
||||
|
||||
std::string detailString = trophyDetails[row].toStdString();
|
||||
std::size_t newline_pos = 0;
|
||||
while ((newline_pos = detailString.find("\n", newline_pos)) != std::string::npos) {
|
||||
@ -129,7 +152,6 @@ void TrophyViewer::PopulateTrophyWidget(QString title) {
|
||||
SetTableItem(tableWidget, row, 3, QString::fromStdString(detailString));
|
||||
SetTableItem(tableWidget, row, 4, trpId[row]);
|
||||
SetTableItem(tableWidget, row, 5, trpHidden[row]);
|
||||
SetTableItem(tableWidget, row, 6, GetTrpType(trpType[row].at(0)));
|
||||
SetTableItem(tableWidget, row, 7, trpPid[row]);
|
||||
}
|
||||
tableWidget->verticalHeader()->resizeSection(row, icon.height());
|
||||
|
@ -32,17 +32,17 @@ private:
|
||||
QString gameTrpPath_;
|
||||
TRP trp;
|
||||
|
||||
QString GetTrpType(const QChar trp_) {
|
||||
std::string GetTrpType(const QChar trp_) {
|
||||
switch (trp_.toLatin1()) {
|
||||
case 'B':
|
||||
return "Bronze";
|
||||
return "bronze.png";
|
||||
case 'S':
|
||||
return "Silver";
|
||||
return "silver.png";
|
||||
case 'G':
|
||||
return "Gold";
|
||||
return "gold.png";
|
||||
case 'P':
|
||||
return "Platinum";
|
||||
return "platinum.png";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user