mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
PPGe: Left align messages in dialogs.
It was previously left aligned, but the TextDrawer was being told to center. These are meant to just center the enclosing box of text, not the individual lines within. Makes Final Fantasy 3 look a lot better.
This commit is contained in:
parent
2d4e45d229
commit
4f586f9567
7 changed files with 94 additions and 97 deletions
|
@ -217,13 +217,13 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
|
|||
const char *text = useCaption ? safeCaption : di->T("Enter");
|
||||
PPGeDrawImage(okButtonImg, x2, 258, 11.5f, 11.5f, 0, CalcFadedColor(0x80000000));
|
||||
PPGeDrawImage(okButtonImg, x2, 256, 11.5f, 11.5f, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(text, x2 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x2 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(text, x2 + 15.5f, 254, PPGeAlign::BOX_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x2 + 14.5f, 252, PPGeAlign::BOX_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
if (flags & DS_BUTTON_CANCEL) {
|
||||
const char *text = useCaption ? safeCaption : di->T("Back");
|
||||
PPGeDrawText(text, x1 + 15.5f, 254, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x1 + 14.5f, 252, PPGE_ALIGN_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(text, x1 + 15.5f, 254, PPGeAlign::BOX_LEFT, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(text, x1 + 14.5f, 252, PPGeAlign::BOX_LEFT, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(cancelButtonImg, x1, 258, 11.5f, 11.5f, 0, CalcFadedColor(0x80000000));
|
||||
PPGeDrawImage(cancelButtonImg, x1, 256, 11.5f, 11.5f, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
|
|
@ -178,10 +178,10 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
|
|||
h2 += h + 5.0f;
|
||||
y = 135.0f - h;
|
||||
PPGeDrawRect(x - w, y2 - h, x + w, y2 + h, CalcFadedColor(0x6DCFCFCF));
|
||||
PPGeDrawText(di->T("Yes"), 204.0f, y2 + 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("Yes"), 203.0f, y2 - 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(yesColor));
|
||||
PPGeDrawText(di->T("No"), 273.0f, y2 + 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("No"), 272.0f, y2 - 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(noColor));
|
||||
PPGeDrawText(di->T("Yes"), 204.0f, y2 + 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("Yes"), 203.0f, y2 - 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(yesColor));
|
||||
PPGeDrawText(di->T("No"), 273.0f, y2 + 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("No"), 272.0f, y2 - 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(noColor));
|
||||
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
|
||||
yesnoChoice = 1;
|
||||
}
|
||||
|
@ -201,13 +201,13 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
|
|||
h2 += h + 5.0f;
|
||||
y = 135.0f - h;
|
||||
PPGeDrawRect(x - w, y2 - h, x + w, y2 + h, CalcFadedColor(0x6DCFCFCF));
|
||||
PPGeDrawText(di->T("OK"), 240.0f, y2 + 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("OK"), 239.0f, y2 - 1.0f, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("OK"), 240.0f, y2 + 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("OK"), 239.0f, y2 - 1.0f, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
ey = y2 + 25.0f;
|
||||
}
|
||||
|
||||
PPGeDrawTextWrapped(text.c_str(), 241.0f, y+2, WRAP_WIDTH, 0, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(text.c_str(), 240.0f, y, WRAP_WIDTH, 0, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawTextWrapped(text.c_str(), 241.0f, y+2, WRAP_WIDTH, 0, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(text.c_str(), 240.0f, y, WRAP_WIDTH, 0, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
sy = 125.0f - h2;
|
||||
PPGeDrawRect(40.0f, sy, 440.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawRect(40.0f, ey, 440.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
|
|
@ -68,7 +68,7 @@ void PSPNetconfDialog::DrawBanner() {
|
|||
// TODO: Draw a hexagon icon
|
||||
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
PPGeDrawText(di->T("Network Connection"), 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Network Connection"), 30, 11, PPGeAlign::BOX_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
int PSPNetconfDialog::Update(int animSpeed) {
|
||||
|
@ -88,9 +88,9 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
|||
StartDraw();
|
||||
DrawBanner();
|
||||
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
|
||||
PPGeDrawTextWrapped(err->T("PPSSPPDoesNotSupportInternet", "PPSSPP currently does not support connecting to the Internet for DLC, PSN, or game updates."), 241, 132, WRAP_WIDTH, 0, PPGE_ALIGN_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawTextWrapped(err->T("PPSSPPDoesNotSupportInternet", "PPSSPP currently does not support connecting to the Internet for DLC, PSN, or game updates."), 241, 132, WRAP_WIDTH, 0, PPGeAlign::BOX_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(confirmBtnImage, 195, 250, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("OK"), 225, 252, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("OK"), 225, 252, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
if (IsButtonPressed(confirmBtn)) {
|
||||
StartFade(false);
|
||||
|
|
|
@ -766,7 +766,7 @@ void PSPOskDialog::RenderKeyboard()
|
|||
float previewLeftSide = (480.0f - (12.0f * drawLimit)) / 2.0f;
|
||||
float title = (480.0f - (0.5f * drawLimit)) / 2.0f;
|
||||
|
||||
PPGeDrawText(oskDesc.c_str(), title , 20, PPGE_ALIGN_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(oskDesc.c_str(), title , 20, PPGeAlign::BOX_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
std::u16string result;
|
||||
|
||||
|
@ -781,7 +781,7 @@ void PSPOskDialog::RenderKeyboard()
|
|||
{
|
||||
temp[0] = result[drawIndex];
|
||||
ConvertUCS2ToUTF8(buffer, temp);
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color);
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGeAlign::BOX_HCENTER, 0.5f, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -798,21 +798,21 @@ void PSPOskDialog::RenderKeyboard()
|
|||
|
||||
ConvertUCS2ToUTF8(buffer, temp);
|
||||
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color);
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGeAlign::BOX_HCENTER, 0.5f, color);
|
||||
|
||||
// Also draw the underline for the same reason.
|
||||
color = CalcFadedColor(0xFFFFFFFF);
|
||||
PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color);
|
||||
PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGeAlign::BOX_HCENTER, 0.5f, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConvertUCS2ToUTF8(buffer, temp);
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color);
|
||||
PPGeDrawText(buffer.c_str(), previewLeftSide + (i * characterWidth), 40.0f, PPGeAlign::BOX_HCENTER, 0.5f, color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGE_ALIGN_HCENTER, 0.5f, color);
|
||||
PPGeDrawText("_", previewLeftSide + (i * characterWidth), 40.0f, PPGeAlign::BOX_HCENTER, 0.5f, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,10 +828,10 @@ void PSPOskDialog::RenderKeyboard()
|
|||
temp[0] = oskKeys[currentKeyboard][row][col];
|
||||
|
||||
ConvertUCS2ToUTF8(buffer, temp);
|
||||
PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, color);
|
||||
PPGeDrawText(buffer.c_str(), keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGeAlign::BOX_HCENTER, 0.6f, color);
|
||||
|
||||
if (selectedRow == row && col == selectedCol)
|
||||
PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGE_ALIGN_HCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("_", keyboardLeftSide + (25.0f * col) + characterWidth / 2.0, 70.0f + (25.0f * row), PPGeAlign::BOX_HCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -945,7 +945,7 @@ int PSPOskDialog::Update(int animSpeed) {
|
|||
auto di = GetI18NCategory("Dialog");
|
||||
|
||||
PPGeDrawImage(ImageID("I_SQUARE"), 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Space"), 390, 222, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
if (g_Config.iButtonPreference != PSP_SYSTEMPARAM_BUTTON_CIRCLE) {
|
||||
PPGeDrawImage(ImageID("I_CROSS"), 45, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
|
@ -955,11 +955,11 @@ int PSPOskDialog::Update(int animSpeed) {
|
|||
PPGeDrawImage(ImageID("I_CROSS"), 45, 247, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
PPGeDrawText(di->T("Select"), 75, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Delete"), 75, 247, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Select"), 75, 222, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Delete"), 75, 247, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
PPGeDrawText("Start", 135, 220, PPGE_ALIGN_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Finish"), 185, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Start", 135, 220, PPGeAlign::BOX_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Finish"), 185, 222, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
auto lookupLangName = [&](int direction) {
|
||||
// First, find the valid one...
|
||||
|
@ -983,20 +983,20 @@ int PSPOskDialog::Update(int animSpeed) {
|
|||
};
|
||||
|
||||
if (OskKeyboardNames[currentKeyboardLanguage] != "ko_KR" && IsKeyboardShiftValid(oskParams->fields[0].inputtype, currentKeyboardLanguage, currentKeyboard)) {
|
||||
PPGeDrawText("Select", 135, 245, PPGE_ALIGN_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Shift"), 185, 247, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Select", 135, 245, PPGeAlign::BOX_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("Shift"), 185, 247, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
const char *prevLang = lookupLangName(-1);
|
||||
if (prevLang) {
|
||||
PPGeDrawText("L", 235, 220, PPGE_ALIGN_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(prevLang, 255, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("L", 235, 220, PPGeAlign::BOX_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(prevLang, 255, 222, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
const char *nextLang = lookupLangName(1);
|
||||
if (nextLang) {
|
||||
PPGeDrawText("R", 235, 245, PPGE_ALIGN_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(nextLang, 255, 247, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("R", 235, 245, PPGeAlign::BOX_LEFT, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(nextLang, 255, 247, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
if (IsButtonPressed(CTRL_UP) || IsButtonHeld(CTRL_UP, upBtnFramesHeld, framesHeldThreshold, framesHeldRepeatRate)) {
|
||||
|
|
|
@ -300,7 +300,7 @@ void PSPSaveDialog::DisplayBanner(int which)
|
|||
}
|
||||
// TODO: Draw a hexagon icon
|
||||
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(title, 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(title, 30, 11, PPGeAlign::BOX_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DisplaySaveList(bool canMove) {
|
||||
|
@ -395,7 +395,7 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
|
|||
std::lock_guard<std::mutex> guard(paramLock);
|
||||
if (param.GetFileInfo(currentSelectedSave).size == 0) {
|
||||
auto di = GetI18NCategory("Dialog");
|
||||
PPGeDrawText(di->T("NEW DATA"), 180, 136, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(di->T("NEW DATA"), 180, 136, PPGeAlign::BOX_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
|
||||
} else {
|
||||
char title[512];
|
||||
char time[512];
|
||||
|
@ -452,14 +452,14 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
|
|||
std::string saveTitleTxt = saveTitle;
|
||||
std::string saveDetailTxt = saveDetail;
|
||||
|
||||
PPGeDrawText(titleTxt.c_str(), 181, 138, PPGE_ALIGN_BOTTOM, 0.6f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(titleTxt.c_str(), 180, 136, PPGE_ALIGN_BOTTOM, 0.6f, CalcFadedColor(0xFFC0C0C0));
|
||||
PPGeDrawText(timeTxt.c_str(), 181, 139, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(timeTxt.c_str(), 180, 137, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(saveTitleTxt.c_str(), 176, 162, PPGE_ALIGN_LEFT, 0.55f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(saveTitleTxt.c_str(), 175, 159, PPGE_ALIGN_LEFT, 0.55f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawTextWrapped(saveDetailTxt.c_str(), 176, 183, 480 - 175, 250 - 183, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(saveDetailTxt.c_str(), 175, 181, 480 - 175, 250 - 181, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(titleTxt.c_str(), 181, 138, PPGeAlign::BOX_BOTTOM, 0.6f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(titleTxt.c_str(), 180, 136, PPGeAlign::BOX_BOTTOM, 0.6f, CalcFadedColor(0xFFC0C0C0));
|
||||
PPGeDrawText(timeTxt.c_str(), 181, 139, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(timeTxt.c_str(), 180, 137, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(saveTitleTxt.c_str(), 176, 162, PPGeAlign::BOX_LEFT, 0.55f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(saveTitleTxt.c_str(), 175, 159, PPGeAlign::BOX_LEFT, 0.55f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawTextWrapped(saveDetailTxt.c_str(), 176, 183, 480 - 175, 250 - 183, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(saveDetailTxt.c_str(), 175, 181, 480 - 175, 250 - 181, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,8 +526,8 @@ void PSPSaveDialog::DisplaySaveDataInfo2(bool showNewData) {
|
|||
}
|
||||
|
||||
std::string saveinfoTxt = StringFromFormat("%.128s\n%s %s\n%lld KB", save_title, date, hour_time, sizeK);
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 9, 202, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 8, 200, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 9, 202, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(saveinfoTxt.c_str(), 8, 200, PPGeAlign::BOX_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
|
||||
|
@ -561,10 +561,10 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
|
|||
h2 += h + 4.0f;
|
||||
y = 132.0f - h;
|
||||
PPGeDrawRect(x - w, y2 - h, x + w, y2 + h, CalcFadedColor(0x40C0C0C0));
|
||||
PPGeDrawText(di->T("Yes"), 303.0f, y2+2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("Yes"), 302.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(yesColor));
|
||||
PPGeDrawText(di->T("No"), 367.0f, y2+2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("No"), 366.0f, y2, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(noColor));
|
||||
PPGeDrawText(di->T("Yes"), 303.0f, y2+2, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("Yes"), 302.0f, y2, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(yesColor));
|
||||
PPGeDrawText(di->T("No"), 367.0f, y2+2, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawText(di->T("No"), 366.0f, y2, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(noColor));
|
||||
if (IsButtonPressed(CTRL_LEFT) && yesnoChoice == 0) {
|
||||
yesnoChoice = 1;
|
||||
}
|
||||
|
@ -572,8 +572,8 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
|
|||
yesnoChoice = 0;
|
||||
}
|
||||
}
|
||||
PPGeDrawTextWrapped(text.c_str(), 335.0f, y+2, WRAP_WIDTH, 0, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(text.c_str(), 334.0f, y, WRAP_WIDTH, 0, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawTextWrapped(text.c_str(), 335.0f, y+2, WRAP_WIDTH, 0, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0x80000000));
|
||||
PPGeDrawTextWrapped(text.c_str(), 334.0f, y, WRAP_WIDTH, 0, PPGeAlign::BOX_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF));
|
||||
float sy = 122.0f - h2, ey = 150.0f + h2;
|
||||
PPGeDrawRect(202.0f, sy, 466.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawRect(202.0f, ey, 466.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
|
|
@ -125,7 +125,7 @@ struct PPGeTextDrawerImage {
|
|||
std::map<PPGeTextDrawerCacheKey, PPGeTextDrawerImage> textDrawerImages;
|
||||
|
||||
// Overwrite the current text lines buffer so it can be drawn later.
|
||||
void PPGePrepareText(const char *text, float x, float y, int align, float scale, float lineHeightScale,
|
||||
void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float scale, float lineHeightScale,
|
||||
int WrapType = PPGE_LINE_NONE, int wrapWidth = 0);
|
||||
|
||||
// These functions must be called between PPGeBegin and PPGeEnd.
|
||||
|
@ -455,7 +455,7 @@ static const AtlasChar *PPGeGetChar(const AtlasFont &atlasfont, unsigned int cva
|
|||
|
||||
// Break a single text string into mutiple lines.
|
||||
static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont, float x, float y,
|
||||
int align, float scale, float lineHeightScale, int wrapType, float wrapWidth, bool dryRun)
|
||||
PPGeAlign align, float scale, float lineHeightScale, int wrapType, float wrapWidth, bool dryRun)
|
||||
{
|
||||
y += atlasfont.ascend * scale;
|
||||
float sx = x, sy = y;
|
||||
|
@ -665,26 +665,22 @@ static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont,
|
|||
|
||||
const float w = maxw;
|
||||
const float h = (float)numLines * lineHeight;
|
||||
if (align)
|
||||
{
|
||||
if (!dryRun)
|
||||
{
|
||||
for (auto i = char_lines.begin(); i != char_lines.end(); ++i)
|
||||
{
|
||||
for (auto j = i->begin(); j != i->end(); ++j)
|
||||
{
|
||||
if (align & PPGE_ALIGN_HCENTER) j->x -= w / 2.0f;
|
||||
else if (align & PPGE_ALIGN_RIGHT) j->x -= w;
|
||||
if (align & PPGeAlign::ANY) {
|
||||
if (!dryRun) {
|
||||
for (auto i = char_lines.begin(); i != char_lines.end(); ++i) {
|
||||
for (auto j = i->begin(); j != i->end(); ++j) {
|
||||
if (align & PPGeAlign::BOX_HCENTER) j->x -= w / 2.0f;
|
||||
else if (align & PPGeAlign::BOX_RIGHT) j->x -= w;
|
||||
|
||||
if (align & PPGE_ALIGN_VCENTER) j->y -= h / 2.0f;
|
||||
else if (align & PPGE_ALIGN_BOTTOM) j->y -= h;
|
||||
if (align & PPGeAlign::BOX_VCENTER) j->y -= h / 2.0f;
|
||||
else if (align & PPGeAlign::BOX_BOTTOM) j->y -= h;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (align & PPGE_ALIGN_HCENTER) sx -= w / 2.0f;
|
||||
else if (align & PPGE_ALIGN_RIGHT) sx -= w;
|
||||
if (align & PPGE_ALIGN_VCENTER) sy -= h / 2.0f;
|
||||
else if (align & PPGE_ALIGN_BOTTOM) sy -= h;
|
||||
if (align & PPGeAlign::BOX_HCENTER) sx -= w / 2.0f;
|
||||
else if (align & PPGeAlign::BOX_RIGHT) sx -= w;
|
||||
if (align & PPGeAlign::BOX_VCENTER) sy -= h / 2.0f;
|
||||
else if (align & PPGeAlign::BOX_BOTTOM) sy -= h;
|
||||
}
|
||||
|
||||
AtlasTextMetrics metrics = { sx, sy, w, lineHeight, scale, numLines };
|
||||
|
@ -734,12 +730,12 @@ void PPGeMeasureText(float *w, float *h, const char *text, float scale, int Wrap
|
|||
}
|
||||
|
||||
const AtlasFont &atlasfont = g_ppge_atlas.fonts[0];
|
||||
AtlasTextMetrics metrics = BreakLines(text, atlasfont, 0, 0, 0, scale, scale, WrapType, wrapWidth, true);
|
||||
AtlasTextMetrics metrics = BreakLines(text, atlasfont, 0, 0, PPGeAlign::BOX_TOP, scale, scale, WrapType, wrapWidth, true);
|
||||
if (w) *w = metrics.maxWidth;
|
||||
if (h) *h = metrics.lineHeight * metrics.numLines;
|
||||
}
|
||||
|
||||
void PPGePrepareText(const char *text, float x, float y, int align, float scale, float lineHeightScale, int WrapType, int wrapWidth)
|
||||
void PPGePrepareText(const char *text, float x, float y, PPGeAlign align, float scale, float lineHeightScale, int WrapType, int wrapWidth)
|
||||
{
|
||||
const AtlasFont &atlasfont = g_ppge_atlas.fonts[0];
|
||||
if (!g_ppge_atlas.IsMetadataLoaded() || g_ppge_atlas.num_fonts < 1) {
|
||||
|
@ -794,8 +790,8 @@ int GetPow2(int x) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static PPGeTextDrawerImage PPGeGetTextImage(const char *text, int align, float scale, float maxWidth, bool wrap) {
|
||||
int tdalign = (align & PPGE_ALIGN_HCENTER) ? ALIGN_HCENTER : 0;
|
||||
static PPGeTextDrawerImage PPGeGetTextImage(const char *text, PPGeAlign align, float scale, float maxWidth, bool wrap) {
|
||||
int tdalign = 0;
|
||||
tdalign |= FLAG_ELLIPSIZE_TEXT;
|
||||
if (wrap) {
|
||||
tdalign |= FLAG_WRAP_TEXT;
|
||||
|
@ -847,7 +843,7 @@ static PPGeTextDrawerImage PPGeGetTextImage(const char *text, int align, float s
|
|||
return im;
|
||||
}
|
||||
|
||||
static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, int align, float scale, u32 color) {
|
||||
static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, PPGeAlign align, float scale, u32 color) {
|
||||
int bufw = ((im.entry.bmWidth + 31) / 32) * 32;
|
||||
int wp2 = GetPow2(im.entry.bmWidth);
|
||||
int hp2 = GetPow2(im.entry.bmHeight);
|
||||
|
@ -859,13 +855,13 @@ static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, int alig
|
|||
float w = im.entry.width * scale;
|
||||
float h = im.entry.height * scale;
|
||||
|
||||
if (align & PPGE_ALIGN_HCENTER)
|
||||
if (align & PPGeAlign::BOX_HCENTER)
|
||||
x -= w / 2.0f;
|
||||
else if (align & PPGE_ALIGN_RIGHT)
|
||||
else if (align & PPGeAlign::BOX_RIGHT)
|
||||
x -= w;
|
||||
if (align & PPGE_ALIGN_VCENTER)
|
||||
if (align & PPGeAlign::BOX_VCENTER)
|
||||
y -= h / 2.0f;
|
||||
else if (align & PPGE_ALIGN_BOTTOM)
|
||||
else if (align & PPGeAlign::BOX_BOTTOM)
|
||||
y -= h;
|
||||
|
||||
BeginVertexData();
|
||||
|
@ -878,7 +874,7 @@ static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, int alig
|
|||
PPGeSetDefaultTexture();
|
||||
}
|
||||
|
||||
void PPGeDrawText(const char *text, float x, float y, int align, float scale, u32 color) {
|
||||
void PPGeDrawText(const char *text, float x, float y, PPGeAlign align, float scale, u32 color) {
|
||||
if (HasTextDrawer()) {
|
||||
PPGeTextDrawerImage im = PPGeGetTextImage(text, align, scale, 480.0f - x, false);
|
||||
PPGeDrawTextImage(im, x, y, align, scale, color);
|
||||
|
@ -912,7 +908,7 @@ static std::string CropLinesToCount(const std::string &s, int numLines) {
|
|||
return s.substr(0, len);
|
||||
}
|
||||
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, int align, float scale, u32 color) {
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, PPGeAlign align, float scale, u32 color) {
|
||||
std::string s = text;
|
||||
if (wrapHeight != 0.0f) {
|
||||
s = StripTrailingWhite(s);
|
||||
|
@ -924,7 +920,7 @@ void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, fl
|
|||
if (HasTextDrawer()) {
|
||||
float actualWidth, actualHeight;
|
||||
Bounds b(0, 0, wrapWidth <= 0 ? 480.0f - x : wrapWidth, wrapHeight);
|
||||
int tdalign = (align & PPGE_ALIGN_HCENTER) ? ALIGN_HCENTER : 0;
|
||||
int tdalign = 0;
|
||||
textDrawer->SetFontScale(scale, scale);
|
||||
textDrawer->MeasureStringRect(s.c_str(), s.size(), b, &actualWidth, &actualHeight, tdalign | FLAG_WRAP_TEXT);
|
||||
if (wrapHeight != 0.0f && actualHeight > wrapHeight) {
|
||||
|
|
|
@ -45,21 +45,22 @@ void __PPGeShutdown();
|
|||
void PPGeBegin();
|
||||
void PPGeEnd();
|
||||
|
||||
enum {
|
||||
PPGE_ALIGN_LEFT = 0,
|
||||
PPGE_ALIGN_RIGHT = 16,
|
||||
PPGE_ALIGN_TOP = 0,
|
||||
PPGE_ALIGN_BOTTOM = 1,
|
||||
PPGE_ALIGN_HCENTER = 4,
|
||||
PPGE_ALIGN_VCENTER = 8,
|
||||
PPGE_ALIGN_VBASELINE = 32, // text only, possibly not yet working
|
||||
enum class PPGeAlign {
|
||||
BOX_LEFT = 0x00,
|
||||
BOX_RIGHT = 0x01,
|
||||
BOX_HCENTER = 0x02,
|
||||
|
||||
PPGE_ALIGN_CENTER = PPGE_ALIGN_HCENTER | PPGE_ALIGN_VCENTER,
|
||||
PPGE_ALIGN_TOPLEFT = PPGE_ALIGN_TOP | PPGE_ALIGN_LEFT,
|
||||
PPGE_ALIGN_TOPRIGHT = PPGE_ALIGN_TOP | PPGE_ALIGN_RIGHT,
|
||||
PPGE_ALIGN_BOTTOMLEFT = PPGE_ALIGN_BOTTOM | PPGE_ALIGN_LEFT,
|
||||
PPGE_ALIGN_BOTTOMRIGHT = PPGE_ALIGN_BOTTOM | PPGE_ALIGN_RIGHT,
|
||||
BOX_TOP = 0x00,
|
||||
BOX_BOTTOM = 0x10,
|
||||
BOX_VCENTER = 0x20,
|
||||
|
||||
BOX_CENTER = 0x22,
|
||||
|
||||
ANY = 0xFF,
|
||||
};
|
||||
inline bool operator &(const PPGeAlign &lhs, const PPGeAlign &rhs) {
|
||||
return ((int)lhs & (int)rhs) != 0;
|
||||
}
|
||||
|
||||
enum {
|
||||
PPGE_LINE_NONE = 0,
|
||||
|
@ -73,8 +74,8 @@ void PPGeMeasureText(float *w, float *h, const char *text, float scale, int Wrap
|
|||
|
||||
// Draws some text using the one font we have.
|
||||
// Clears the text buffer when done.
|
||||
void PPGeDrawText(const char *text, float x, float y, int align, float scale = 1.0f, u32 color = 0xFFFFFFFF);
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, int align, float scale = 1.0f, u32 color = 0xFFFFFFFF);
|
||||
void PPGeDrawText(const char *text, float x, float y, PPGeAlign align, float scale = 1.0f, u32 color = 0xFFFFFFFF);
|
||||
void PPGeDrawTextWrapped(const char *text, float x, float y, float wrapWidth, float wrapHeight, PPGeAlign align, float scale = 1.0f, u32 color = 0xFFFFFFFF);
|
||||
|
||||
// Draws a "4-patch" for button-like things that can be resized.
|
||||
void PPGeDraw4Patch(ImageID atlasImage, float x, float y, float w, float h, u32 color = 0xFFFFFFFF);
|
||||
|
|
Loading…
Add table
Reference in a new issue