mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Remove lots of now-unnecessary ".c_str()"
This commit is contained in:
parent
ccbcf1369b
commit
306c28c2cc
@ -96,8 +96,8 @@ void AsyncImageFileView::Draw(UIContext &dc) {
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX() + 1, bounds_.centerY() + 1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_, bounds_.centerX() + 1, bounds_.centerY() + 1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_, bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
} else {
|
||||
if (!texture_ || texture_->Failed()) {
|
||||
@ -110,7 +110,7 @@ void AsyncImageFileView::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_, bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,8 +234,8 @@ void UIContext::MeasureTextRect(const UI::FontStyle &style, float scaleX, float
|
||||
}
|
||||
}
|
||||
|
||||
void UIContext::DrawText(const char *str, float x, float y, uint32_t color, int align) {
|
||||
_dbg_assert_(str != nullptr);
|
||||
void UIContext::DrawText(std::string_view str, float x, float y, uint32_t color, int align) {
|
||||
_dbg_assert_(str.data() != nullptr);
|
||||
if (!textDrawer_ || (align & FLAG_DYNAMIC_ASCII)) {
|
||||
// Use the font texture if this font is in that texture instead.
|
||||
bool useFontTexture = Draw()->GetFontAtlas()->getFont(fontStyle_->atlasFont) != nullptr;
|
||||
@ -255,13 +255,13 @@ void UIContext::DrawText(const char *str, float x, float y, uint32_t color, int
|
||||
RebindTexture();
|
||||
}
|
||||
|
||||
void UIContext::DrawTextShadow(const char *str, float x, float y, uint32_t color, int align) {
|
||||
void UIContext::DrawTextShadow(std::string_view str, float x, float y, uint32_t color, int align) {
|
||||
uint32_t alpha = (color >> 1) & 0xFF000000;
|
||||
DrawText(str, x + 2, y + 2, alpha, align);
|
||||
DrawText(str, x, y, color, align);
|
||||
}
|
||||
|
||||
void UIContext::DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align) {
|
||||
void UIContext::DrawTextRect(std::string_view str, const Bounds &bounds, uint32_t color, int align) {
|
||||
if (!textDrawer_ || (align & FLAG_DYNAMIC_ASCII)) {
|
||||
// Use the font texture if this font is in that texture instead.
|
||||
bool useFontTexture = Draw()->GetFontAtlas()->getFont(fontStyle_->atlasFont) != nullptr;
|
||||
@ -296,7 +296,7 @@ float UIContext::CalculateTextScale(std::string_view str, float availWidth, floa
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void UIContext::DrawTextRectSqueeze(const char *str, const Bounds &bounds, uint32_t color, int align) {
|
||||
void UIContext::DrawTextRectSqueeze(std::string_view str, const Bounds &bounds, uint32_t color, int align) {
|
||||
float origScaleX = fontScaleX_;
|
||||
float origScaleY = fontScaleY_;
|
||||
float scale = CalculateTextScale(str, bounds.w / origScaleX, bounds.h / origScaleY);
|
||||
@ -306,7 +306,7 @@ void UIContext::DrawTextRectSqueeze(const char *str, const Bounds &bounds, uint3
|
||||
SetFontScale(origScaleX, origScaleY);
|
||||
}
|
||||
|
||||
void UIContext::DrawTextShadowRect(const char *str, const Bounds &bounds, uint32_t color, int align) {
|
||||
void UIContext::DrawTextShadowRect(std::string_view str, const Bounds &bounds, uint32_t color, int align) {
|
||||
uint32_t alpha = (color >> 1) & 0xFF000000;
|
||||
Bounds shadowBounds(bounds.x+2, bounds.y+2, bounds.w, bounds.h);
|
||||
DrawTextRect(str, shadowBounds, alpha, align);
|
||||
|
@ -84,12 +84,12 @@ public:
|
||||
void SetFontScale(float scaleX, float scaleY);
|
||||
void MeasureText(const UI::FontStyle &style, float scaleX, float scaleY, std::string_view str, float *x, float *y, int align = 0) const;
|
||||
void MeasureTextRect(const UI::FontStyle &style, float scaleX, float scaleY, std::string_view str, const Bounds &bounds, float *x, float *y, int align = 0) const;
|
||||
void DrawText(const char *str, float x, float y, uint32_t color, int align = 0);
|
||||
void DrawTextShadow(const char *str, float x, float y, uint32_t color, int align = 0);
|
||||
void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
void DrawTextShadowRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
void DrawText(std::string_view str, float x, float y, uint32_t color, int align = 0);
|
||||
void DrawTextShadow(std::string_view str, float x, float y, uint32_t color, int align = 0);
|
||||
void DrawTextRect(std::string_view str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
void DrawTextShadowRect(std::string_view str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
// Will squeeze the text into the bounds if needed.
|
||||
void DrawTextRectSqueeze(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
void DrawTextRectSqueeze(std::string_view str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
|
||||
float CalculateTextScale(std::string_view str, float availWidth, float availHeight) const;
|
||||
|
||||
|
@ -651,13 +651,13 @@ void AbstractChoiceWithValueDisplay::Draw(UIContext &dc) {
|
||||
}
|
||||
dc.SetFontScale(scale, scale);
|
||||
Bounds valueBounds(bounds_.x2() - textPadding_.right - imagePadding, bounds_.y, w, bounds_.h);
|
||||
dc.DrawTextRect(valueText.c_str(), valueBounds, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRect(valueText, valueBounds, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
} else {
|
||||
Choice::Draw(dc);
|
||||
float scale = CalculateValueScale(dc, valueText, bounds_.w);
|
||||
dc.SetFontScale(scale, scale);
|
||||
dc.DrawTextRect(valueText.c_str(), bounds_.Expand(-paddingX, 0.0f), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRect(valueText, bounds_.Expand(-paddingX, 0.0f), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
@ -524,14 +524,14 @@ void Choice::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
if (centered_) {
|
||||
dc.DrawTextRectSqueeze(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
dc.DrawTextRectSqueeze(text_, bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
} else {
|
||||
if (rightIconImage_.isValid()) {
|
||||
uint32_t col = rightIconKeepColor_ ? 0xffffffff : style.fgColor; // Don't apply theme to gold icon
|
||||
dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, col, rightIconFlipH_);
|
||||
}
|
||||
Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h);
|
||||
dc.DrawTextRectSqueeze(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
dc.DrawTextRectSqueeze(text_, textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT | drawTextFlags_);
|
||||
}
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
@ -583,10 +583,10 @@ void InfoItem::Draw(UIContext &dc) {
|
||||
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_, padBounds, &leftWidth, &leftHeight, ALIGN_VCENTER);
|
||||
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.DrawTextRect(text_.c_str(), padBounds, style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawTextRect(text_, padBounds, style.fgColor, ALIGN_VCENTER);
|
||||
|
||||
Bounds rightBounds(padBounds.x + leftWidth, padBounds.y, padBounds.w - leftWidth, padBounds.h);
|
||||
dc.DrawTextRect(rightText_.c_str(), rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRect(rightText_, rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
|
||||
}
|
||||
|
||||
std::string InfoItem::DescribeText() const {
|
||||
@ -602,7 +602,7 @@ ItemHeader::ItemHeader(std::string_view text, LayoutParams *layoutParams)
|
||||
|
||||
void ItemHeader::Draw(UIContext &dc) {
|
||||
dc.SetFontStyle(large_ ? dc.theme->uiFont : dc.theme->uiFontSmall);
|
||||
dc.DrawText(text_.c_str(), bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.DrawText(text_, bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ void CollapsibleHeader::Draw(UIContext &dc) {
|
||||
float xoff = 37.0f;
|
||||
|
||||
dc.SetFontStyle(dc.theme->uiFontSmall);
|
||||
dc.DrawText(text_.c_str(), bounds_.x + 4 + xoff, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.DrawText(text_, bounds_.x + 4 + xoff, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2() - 2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
||||
if (hasSubItems_) {
|
||||
dc.Draw()->DrawImageRotated(ImageID("I_ARROW"), bounds_.x + 20.0f, bounds_.y + 20.0f, 1.0f, *toggle_ ? -M_PI / 2 : M_PI);
|
||||
@ -703,7 +703,7 @@ void PopupHeader::Draw(UIContext &dc) {
|
||||
|
||||
float tw, th;
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text_.c_str(), &tw, &th, 0);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text_, &tw, &th, 0);
|
||||
|
||||
float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f;
|
||||
|
||||
@ -717,7 +717,7 @@ void PopupHeader::Draw(UIContext &dc) {
|
||||
dc.PushScissor(tb);
|
||||
}
|
||||
|
||||
dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->itemStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.DrawText(text_, bounds_.x + tx, bounds_.centerY(), dc.theme->itemStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->itemStyle.fgColor);
|
||||
|
||||
if (availableWidth < tw) {
|
||||
@ -798,7 +798,7 @@ void CheckBox::Draw(UIContext &dc) {
|
||||
|
||||
if (!text_.empty()) {
|
||||
Bounds textBounds(bounds_.x + paddingX, bounds_.y, availWidth, bounds_.h);
|
||||
dc.DrawTextRectSqueeze(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextRectSqueeze(text_, textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
|
||||
}
|
||||
dc.Draw()->DrawImage(image, bounds_.x2() - paddingX, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
@ -885,7 +885,7 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
|
||||
if (!text_.empty() && !ignoreText_) {
|
||||
float width = 0.0f;
|
||||
float height = 0.0f;
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &width, &height);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &width, &height);
|
||||
|
||||
w += width;
|
||||
if (imageID_.isValid()) {
|
||||
@ -922,7 +922,7 @@ void Button::Draw(UIContext &dc) {
|
||||
// dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor);
|
||||
DrawBG(dc, style);
|
||||
float tw, th;
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &tw, &th);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &tw, &th);
|
||||
tw *= scale_;
|
||||
th *= scale_;
|
||||
|
||||
@ -942,7 +942,7 @@ void Button::Draw(UIContext &dc) {
|
||||
textX += img->w / 2.0f;
|
||||
}
|
||||
}
|
||||
dc.DrawText(text_.c_str(), textX, bounds_.centerY(), style.fgColor, ALIGN_CENTER);
|
||||
dc.DrawText(text_, textX, bounds_.centerY(), style.fgColor, ALIGN_CENTER);
|
||||
}
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
|
||||
@ -956,7 +956,7 @@ void RadioButton::GetContentDimensions(const UIContext &dc, float &w, float &h)
|
||||
h = 0.0f;
|
||||
|
||||
if (!text_.empty()) {
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &w, &h);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &w, &h);
|
||||
}
|
||||
|
||||
// Add some internal padding to not look totally ugly
|
||||
@ -996,7 +996,7 @@ void RadioButton::Draw(UIContext &dc) {
|
||||
dc.Begin();
|
||||
|
||||
float tw, th;
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &tw, &th);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &tw, &th);
|
||||
|
||||
if (tw > bounds_.w) {
|
||||
dc.PushScissor(bounds_);
|
||||
@ -1006,7 +1006,7 @@ void RadioButton::Draw(UIContext &dc) {
|
||||
|
||||
if (!text_.empty()) {
|
||||
float textX = bounds_.x + paddingW_ * 2.0f + radioRadius_ * 2.0f;
|
||||
dc.DrawText(text_.c_str(), textX, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.DrawText(text_, textX, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
if (tw > bounds_.w) {
|
||||
@ -1091,9 +1091,9 @@ void TextView::Draw(UIContext &dc) {
|
||||
|
||||
if (shadow_) {
|
||||
uint32_t shadowColor = 0x80000000;
|
||||
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
|
||||
dc.DrawTextRect(text_, textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
|
||||
}
|
||||
dc.DrawTextRect(text_.c_str(), textBounds.Offset(pad_, pad_), textColor, textAlign_);
|
||||
dc.DrawTextRect(text_, textBounds.Offset(pad_, pad_), textColor, textAlign_);
|
||||
if (small_) {
|
||||
// If we changed font style, reset it.
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
@ -1133,10 +1133,10 @@ void TextEdit::Draw(UIContext &dc) {
|
||||
if (text_.empty()) {
|
||||
if (placeholderText_.size()) {
|
||||
uint32_t c = textColor & 0x50FFFFFF;
|
||||
dc.DrawTextRect(placeholderText_.c_str(), bounds_, c, ALIGN_CENTER);
|
||||
dc.DrawTextRect(placeholderText_, bounds_, c, ALIGN_CENTER);
|
||||
}
|
||||
} else {
|
||||
dc.DrawTextRect(text_.c_str(), textBounds, textColor, ALIGN_VCENTER | ALIGN_LEFT | align_);
|
||||
dc.DrawTextRect(text_, textBounds, textColor, ALIGN_VCENTER | ALIGN_LEFT | align_);
|
||||
}
|
||||
|
||||
if (HasFocus()) {
|
||||
@ -1156,7 +1156,7 @@ void TextEdit::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
void TextEdit::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, !text_.empty() ? text_.c_str() : "Wj", &w, &h, align_);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, !text_.empty() ? text_ : "Wj", &w, &h, align_);
|
||||
w += 2;
|
||||
h += 2;
|
||||
}
|
||||
|
@ -473,9 +473,9 @@ void GPUDriverTestScreen::DiscardTest(UIContext &dc) {
|
||||
std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME);
|
||||
std::string vendor = screenManager()->getDrawContext()->GetInfoString(InfoField::VENDORSTRING);
|
||||
std::string driver = screenManager()->getDrawContext()->GetInfoString(InfoField::DRIVER);
|
||||
dc.DrawText(apiName.c_str(), layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(vendor.c_str(), layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(driver.c_str(), layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(apiName, layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(vendor, layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(driver, layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.Flush();
|
||||
|
||||
float testW = 170.f;
|
||||
@ -579,9 +579,9 @@ void GPUDriverTestScreen::ShaderTest(UIContext &dc) {
|
||||
std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME);
|
||||
std::string vendor = screenManager()->getDrawContext()->GetInfoString(InfoField::VENDORSTRING);
|
||||
std::string driver = screenManager()->getDrawContext()->GetInfoString(InfoField::DRIVER);
|
||||
dc.DrawText(apiName.c_str(), layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(vendor.c_str(), layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(driver.c_str(), layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(apiName, layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(vendor, layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.DrawText(driver, layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
dc.Flush();
|
||||
|
||||
float y = layoutBounds.y + 150;
|
||||
|
@ -15,7 +15,7 @@ void JoystickHistoryView::Draw(UIContext &dc) {
|
||||
float minRadius = std::min(bounds_.w, bounds_.h) * 0.5f - image->w;
|
||||
dc.Begin();
|
||||
Bounds textBounds(bounds_.x, bounds_.centerY() + minRadius + 5.0, bounds_.w, bounds_.h / 2 - minRadius - 5.0);
|
||||
dc.DrawTextShadowRect(title_.c_str(), textBounds, 0xFFFFFFFF, ALIGN_TOP | ALIGN_HCENTER | FLAG_WRAP_TEXT);
|
||||
dc.DrawTextShadowRect(title_, textBounds, 0xFFFFFFFF, ALIGN_TOP | ALIGN_HCENTER | FLAG_WRAP_TEXT);
|
||||
dc.Flush();
|
||||
dc.BeginNoTex();
|
||||
dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2.0f, minRadius * 2.0f, 0x80FFFFFF);
|
||||
|
@ -333,7 +333,7 @@ void GameButton::Draw(UIContext &dc) {
|
||||
dc.PushScissor(bounds_);
|
||||
const std::string currentTitle = ginfo->GetTitle();
|
||||
dc.SetFontScale(0.6f, 0.6f);
|
||||
dc.DrawText(title_.c_str(), bounds_.x + 4.0f, bounds_.centerY(), style.fgColor, ALIGN_VCENTER | ALIGN_LEFT);
|
||||
dc.DrawText(title_, bounds_.x + 4.0f, bounds_.centerY(), style.fgColor, ALIGN_VCENTER | ALIGN_LEFT);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
title_ = currentTitle;
|
||||
dc.Draw()->Flush();
|
||||
@ -348,15 +348,15 @@ void GameButton::Draw(UIContext &dc) {
|
||||
title_ = ReplaceAll(title_, "\n", " ");
|
||||
}
|
||||
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, title_.c_str(), &tw, &th, 0);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, title_, &tw, &th, 0);
|
||||
|
||||
int availableWidth = bounds_.w - 150;
|
||||
if (g_Config.bShowIDOnGameIcon) {
|
||||
float vw, vh;
|
||||
dc.MeasureText(dc.GetFontStyle(), 0.7f, 0.7f, ginfo->id_version.c_str(), &vw, &vh, 0);
|
||||
dc.MeasureText(dc.GetFontStyle(), 0.7f, 0.7f, ginfo->id_version, &vw, &vh, 0);
|
||||
availableWidth -= vw + 20;
|
||||
dc.SetFontScale(0.7f, 0.7f);
|
||||
dc.DrawText(ginfo->id_version.c_str(), bounds_.x + availableWidth + 160, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(ginfo->id_version, bounds_.x + availableWidth + 160, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f;
|
||||
@ -369,7 +369,7 @@ void GameButton::Draw(UIContext &dc) {
|
||||
tb.w = availableWidth;
|
||||
dc.PushScissor(tb);
|
||||
}
|
||||
dc.DrawText(title_.c_str(), bounds_.x + tx, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(title_, bounds_.x + tx, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
if (availableWidth < tw) {
|
||||
dc.PopScissor();
|
||||
}
|
||||
@ -378,7 +378,7 @@ void GameButton::Draw(UIContext &dc) {
|
||||
} else if (!texture) {
|
||||
dc.Draw()->Flush();
|
||||
dc.PushScissor(bounds_);
|
||||
dc.DrawText(title_.c_str(), bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(title_, bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.Draw()->Flush();
|
||||
dc.PopScissor();
|
||||
} else {
|
||||
@ -416,8 +416,8 @@ void GameButton::Draw(UIContext &dc) {
|
||||
}
|
||||
if (gridStyle_ && g_Config.bShowIDOnGameIcon) {
|
||||
dc.SetFontScale(0.5f*g_Config.fGameGridScale, 0.5f*g_Config.fGameGridScale);
|
||||
dc.DrawText(ginfo->id_version.c_str(), x+5, y+1, 0xFF000000, ALIGN_TOPLEFT);
|
||||
dc.DrawText(ginfo->id_version.c_str(), x+4, y, dc.theme->infoStyle.fgColor, ALIGN_TOPLEFT);
|
||||
dc.DrawText(ginfo->id_version, x+5, y+1, 0xFF000000, ALIGN_TOPLEFT);
|
||||
dc.DrawText(ginfo->id_version, x+4, y, dc.theme->infoStyle.fgColor, ALIGN_TOPLEFT);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
if (overlayColor) {
|
||||
@ -467,7 +467,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
|
||||
dc.FillRect(style.background, bounds_);
|
||||
|
||||
std::string text(GetText());
|
||||
std::string_view text(GetText());
|
||||
|
||||
ImageID image = ImageID("I_FOLDER");
|
||||
if (text == "..") {
|
||||
@ -475,7 +475,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
float tw, th;
|
||||
dc.MeasureText(dc.GetFontStyle(), gridStyle_ ? g_Config.fGameGridScale : 1.0, gridStyle_ ? g_Config.fGameGridScale : 1.0, text.c_str(), &tw, &th, 0);
|
||||
dc.MeasureText(dc.GetFontStyle(), gridStyle_ ? g_Config.fGameGridScale : 1.0, gridStyle_ ? g_Config.fGameGridScale : 1.0, text, &tw, &th, 0);
|
||||
|
||||
bool compact = bounds_.w < 180 * (gridStyle_ ? g_Config.fGameGridScale : 1.0);
|
||||
|
||||
@ -486,7 +486,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
// No icon, except "up"
|
||||
dc.PushScissor(bounds_);
|
||||
if (image == ImageID("I_FOLDER")) {
|
||||
dc.DrawText(text.c_str(), bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(text, bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
} else {
|
||||
dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, style.fgColor, ALIGN_CENTER);
|
||||
}
|
||||
@ -498,7 +498,7 @@ void DirButton::Draw(UIContext &dc) {
|
||||
scissor = true;
|
||||
}
|
||||
dc.Draw()->DrawImage(image, bounds_.x + 72, bounds_.centerY(), 0.88f*(gridStyle_ ? g_Config.fGameGridScale : 1.0), style.fgColor, ALIGN_CENTER);
|
||||
dc.DrawText(text.c_str(), bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(text, bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
|
||||
if (scissor) {
|
||||
dc.PopScissor();
|
||||
|
@ -164,7 +164,7 @@ static void RenderNotice(UIContext &dc, Bounds bounds, float height1, NoticeLeve
|
||||
UI::Drawable backgroundDark = UI::Drawable(colorAlpha(darkenColor(GetNoticeBackgroundColor(level)), alpha));
|
||||
dc.FillRect(backgroundDark, bottomTextBounds);
|
||||
dc.SetFontScale(extraTextScale, extraTextScale);
|
||||
dc.DrawTextRect(details.c_str(), bottomTextBounds, foreGround, (align & FLAG_DYNAMIC_ASCII) | ALIGN_LEFT);
|
||||
dc.DrawTextRect(details, bottomTextBounds, foreGround, (align & FLAG_DYNAMIC_ASCII) | ALIGN_LEFT);
|
||||
}
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "UI/BackgroundAudio.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
|
||||
static inline const char *DeNull(const char *ptr) {
|
||||
return ptr ? ptr : "";
|
||||
static inline std::string_view DeNull(const char *ptr) {
|
||||
return ptr ? std::string_view(ptr) : "";
|
||||
}
|
||||
|
||||
// Compound view, creating a FileChooserChoice inside.
|
||||
|
Loading…
Reference in New Issue
Block a user