Windows: Use system fonts in UI - no more mojibake.

No support for doing this on Android yet, still uses the atlas.
This commit is contained in:
Henrik Rydgard 2013-08-30 14:47:28 +02:00
parent 20de318acd
commit 349718a3bc
9 changed files with 38 additions and 26 deletions

View file

@ -208,10 +208,11 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams &params)
screenManager()->finishDialog(this, DR_OK);
return UI::EVENT_DONE;
}
UI::EventReturn CwCheatScreen::OnCheckBox(UI::EventParams &params) {
UI::EventReturn CwCheatScreen::OnCheckBox(UI::EventParams &params) {
return UI::EVENT_DONE;
}
void CwCheatScreen::processFileOn(std::string activatedCheat) {
for (int i = 0; i < cheatList.size(); i++) {
@ -228,10 +229,9 @@ void CwCheatScreen::processFileOn(std::string activatedCheat) {
}
}
os.close();
}
void CwCheatScreen::processFileOff(std::string deactivatedCheat) {
for (int i = 0; i < cheatList.size(); i++) {
if (cheatList[i].substr(4) == deactivatedCheat) {
cheatList[i] = "_C0 " + deactivatedCheat;
@ -260,6 +260,7 @@ void CheatCheckBox::Draw(UIContext &dc) {
if (!IsEnabled())
style = dc.theme->itemDisabledStyle;
dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.Draw()->DrawImage(image, bounds_.x2() - paddingX, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
}

View file

@ -20,10 +20,12 @@
#include "gfx_es2/glsl_program.h"
#include "gfx_es2/gl_state.h"
#include "gfx_es2/draw_text.h"
#include "gfx_es2/fbo.h"
#include "input/input_state.h"
#include "ui/ui.h"
#include "ui/ui_context.h"
#include "i18n/i18n.h"
#include "Common/KeyMap.h"
@ -497,8 +499,8 @@ void EmuScreen::render() {
if (statbuf[4095])
ERROR_LOG(HLE, "Statbuf too big");
ui_draw2d.SetFontScale(.7f, .7f);
ui_draw2d.DrawText(UBUNTU24, statbuf, 11, 11, 0xc0000000);
ui_draw2d.DrawText(UBUNTU24, statbuf, 10, 10, 0xFFFFFFFF);
ui_draw2d.DrawText(UBUNTU24, statbuf, 11, 11, 0xc0000000, FLAG_DYNAMIC_ASCII);
ui_draw2d.DrawText(UBUNTU24, statbuf, 10, 10, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
ui_draw2d.SetFontScale(1.0f, 1.0f);
}
@ -515,8 +517,8 @@ void EmuScreen::render() {
sprintf(fpsbuf, "%0.0f/%0.0f (%0.1f%%)", actual_fps, fps, vps / 60.0f * 100.0f); break;
}
ui_draw2d.SetFontScale(0.7f, 0.7f);
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT);
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT);
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII);
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII);
ui_draw2d.SetFontScale(1.0f, 1.0f);
}

View file

@ -110,7 +110,8 @@ void PopupMultiChoice::ChoiceCallback(int num) {
void PopupMultiChoice::Draw(UIContext &dc) {
Choice::Draw(dc);
int paddingX = 12;
dc.Draw()->DrawText(dc.theme->uiFont, valueText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawText(valueText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
}
class PopupSliderChoice : public Choice {
@ -160,7 +161,8 @@ void PopupSliderChoice::Draw(UIContext &dc) {
Choice::Draw(dc);
char temp[32];
sprintf(temp, "%i", *value_);
dc.Draw()->DrawText(dc.theme->uiFont, temp, bounds_.x2() - 12, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawText(temp, bounds_.x2() - 12, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
}
EventReturn PopupSliderChoiceFloat::HandleClick(EventParams &e) {
@ -173,7 +175,8 @@ void PopupSliderChoiceFloat::Draw(UIContext &dc) {
Choice::Draw(dc);
char temp[32];
sprintf(temp, "%2.2f", *value_);
dc.Draw()->DrawText(dc.theme->uiFont, temp, bounds_.x2() - 12, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawText(temp, bounds_.x2() - 12, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER);
}
}

View file

@ -180,21 +180,23 @@ void GameButton::Draw(UIContext &dc) {
dc.Draw()->Flush();
dc.RebindTexture();
dc.SetFontStyle(dc.theme->uiFont);
if (!gridStyle_) {
dc.Draw()->Flush();
dc.PushScissor(bounds_);
dc.Draw()->DrawText(0, ginfo->title.c_str(), bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.DrawText(ginfo->title.c_str(), bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.Draw()->Flush();
dc.PopScissor();
} else if (!texture) {
dc.Draw()->Flush();
dc.PushScissor(bounds_);
dc.Draw()->DrawText(0, ginfo->title.c_str(), bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.DrawText(ginfo->title.c_str(), bounds_.x + 4, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
dc.Draw()->Flush();
dc.PopScissor();
} else {
dc.Draw()->Flush();
}
dc.RebindTexture();
}
// Abstraction above path that lets you navigate easily.
@ -533,7 +535,7 @@ void MainScreen::CreateViews() {
#endif
logos->Add(new ImageView(I_LOGO, IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0))));
rightColumnItems->Add(logos);
rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))))->SetTextScale(0.5f);
rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))))->SetSmall(true);
#if defined(_WIN32) || defined(USING_QT_UI)
rightColumnItems->Add(new Choice(m->T("Load","Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile);
#endif

View file

@ -301,13 +301,13 @@ void LogoScreen::render() {
char temp[256];
sprintf(temp, "%s Henrik Rydgård", c->T("created", "Created by"));
dc.Draw()->SetFontScale(1.5f, 1.5f);
dc.Draw()->DrawImage(I_LOGO, dp_xres / 2, dp_yres / 2 - 30, 1.5f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
//dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres / 2, dp_yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.Draw()->SetFontScale(1.0f, 1.0f);
dc.Draw()->DrawTextShadow(UBUNTU24, temp, dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.Draw()->DrawTextShadow(UBUNTU24, c->T("license", "Free Software under GPL 2.0"), dp_xres / 2, dp_yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.Draw()->DrawTextShadow(UBUNTU24, "www.ppsspp.org", dp_xres / 2, dp_yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawText(temp, dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.DrawText(c->T("license", "Free Software under GPL 2.0"), dp_xres / 2, dp_yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
dc.DrawText("www.ppsspp.org", dp_xres / 2, dp_yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
if (bootFilename_.size()) {
ui_draw2d.DrawTextShadow(UBUNTU24, bootFilename_.c_str(), dp_xres / 2, dp_yres / 2 + 180, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
}

View file

@ -37,6 +37,7 @@
#include "native/ext/stb_image_write/stb_image_writer.h"
#include "native/ext/jpge/jpge.h"
#include "gfx_es2/gl_state.h"
#include "gfx_es2/draw_text.h"
#include "gfx/gl_lost_manager.h"
#include "gfx/texture.h"
#include "i18n/i18n.h"
@ -399,14 +400,16 @@ void NativeInitGraphics() {
CheckGLExtensions();
gl_lost_manager_init();
ui_draw2d.SetAtlas(&ui_atlas);
ui_draw2d_front.SetAtlas(&ui_atlas);
UIShader_Init();
// memset(&ui_theme, 0, sizeof(ui_theme));
// New style theme
ui_theme.uiFont = UBUNTU24;
ui_theme.uiFontSmall = UBUNTU24;
ui_theme.uiFontSmaller = UBUNTU24;
ui_theme.uiFont = UI::FontStyle(UBUNTU24, "Trebuchet MS", 20);
ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, "Trebuchet MS", 14);
ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, "Trebuchet MS", 11);
ui_theme.checkOn = I_CHECKEDBOX;
ui_theme.checkOff = I_SQUARE;
ui_theme.whiteImage = I_SOLIDWHITE;
@ -452,7 +455,7 @@ void NativeInitGraphics() {
uiContext = new UIContext();
uiContext->theme = &ui_theme;
uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);
uiContext->Text()->SetFont("Tahoma", 20, 0);
screenManager->setUIContext(uiContext);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
@ -548,6 +551,7 @@ void NativeRender() {
glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());
screenManager->render();
screenManager->getUIContext()->Text()->OncePerFrame();
if (g_TakeScreenshot) {
TakeScreenshot();

View file

@ -1,6 +1,6 @@
APP_STL := gnustl_static
#APP_ABI := armeabi-v7a x86
APP_ABI := armeabi-v7a armeabi x86
#APP_ABI := armeabi-v7a
#APP_ABI := armeabi-v7a armeabi x86
APP_ABI := armeabi-v7a
APP_GNUSTL_CPP_FEATURES :=
#NDK_TOOLCHAIN_VERSION := 4.8

2
lang

@ -1 +1 @@
Subproject commit 35452f047fb854d4c6326d1660be3c9d39601481
Subproject commit a9620e1768e272625433f43c171bfe653f6c4167

2
native

@ -1 +1 @@
Subproject commit b063724c9e4364613fe8af66439d56ed0fbf049c
Subproject commit 0931f784b6c231706d3dd3e499597edf7ceef25e