2012-11-01 16:19:01 +01:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 23:58:25 +01:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/display.h"
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/colorutil.h"
|
|
|
|
#include "base/timeutil.h"
|
|
|
|
#include "base/NativeApp.h"
|
|
|
|
#include "gfx_es2/glsl_program.h"
|
2013-02-22 22:14:17 +01:00
|
|
|
#include "gfx_es2/gl_state.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
#include "input/input_state.h"
|
|
|
|
#include "math/curves.h"
|
|
|
|
#include "ui/ui.h"
|
|
|
|
#include "ui_atlas.h"
|
|
|
|
#include "util/random/rng.h"
|
2013-01-02 21:00:10 +01:00
|
|
|
#include "util/text/utf8.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
#include "UIShader.h"
|
|
|
|
|
2012-12-27 00:18:45 +01:00
|
|
|
#include "../../GPU/ge_constants.h"
|
|
|
|
#include "../../GPU/GPUState.h"
|
|
|
|
#include "../../GPU/GPUInterface.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
#include "../../Core/Config.h"
|
2012-11-23 12:42:35 +01:00
|
|
|
#include "../../Core/CoreParameter.h"
|
2013-01-02 21:00:10 +01:00
|
|
|
#include "../../Core/SaveState.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
#include "MenuScreens.h"
|
|
|
|
#include "EmuScreen.h"
|
2013-03-07 00:10:53 +01:00
|
|
|
#include "TestRunner.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-01-11 19:43:42 +10:00
|
|
|
#ifdef USING_QT_UI
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDir>
|
|
|
|
#endif
|
|
|
|
|
2013-01-02 21:00:10 +01:00
|
|
|
|
|
|
|
// Ugly communication with NativeApp
|
|
|
|
extern std::string game_title;
|
|
|
|
|
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
static const int symbols[4] = {
|
|
|
|
I_CROSS,
|
|
|
|
I_CIRCLE,
|
|
|
|
I_SQUARE,
|
|
|
|
I_TRIANGLE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const uint32_t colors[4] = {
|
|
|
|
/*
|
|
|
|
0xFF6666FF, // blue
|
|
|
|
0xFFFF6666, // red
|
|
|
|
0xFFFF66FF, // pink
|
|
|
|
0xFF66FF66, // green
|
|
|
|
*/
|
|
|
|
0xC0FFFFFF,
|
|
|
|
0xC0FFFFFF,
|
|
|
|
0xC0FFFFFF,
|
|
|
|
0xC0FFFFFF,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void DrawBackground(float alpha) {
|
|
|
|
static float xbase[100] = {0};
|
|
|
|
static float ybase[100] = {0};
|
|
|
|
if (xbase[0] == 0.0f) {
|
|
|
|
GMRng rng;
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
xbase[i] = rng.F() * dp_xres;
|
|
|
|
ybase[i] = rng.F() * dp_yres;
|
|
|
|
}
|
|
|
|
}
|
2013-02-22 22:14:17 +01:00
|
|
|
glstate.depthWrite.set(GL_TRUE);
|
|
|
|
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
2012-11-01 16:19:01 +01:00
|
|
|
glClearColor(0.1f,0.2f,0.43f,1.0f);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
|
|
ui_draw2d.DrawImageStretch(I_BG, 0, 0, dp_xres, dp_yres);
|
|
|
|
float t = time_now();
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
float x = xbase[i];
|
|
|
|
float y = ybase[i] + 40*cos(i * 7.2 + t * 1.3);
|
|
|
|
float angle = sin(i + t);
|
|
|
|
int n = i & 3;
|
|
|
|
ui_draw2d.DrawImageRotated(symbols[n], x, y, 1.0f, angle, colorAlpha(colors[n], alpha * 0.1f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// For private alphas, etc.
|
|
|
|
void DrawWatermark() {
|
|
|
|
// ui_draw2d.DrawTextShadow(UBUNTU24, "PRIVATE BUILD", dp_xres / 2, 10, 0xFF0000FF, ALIGN_HCENTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogoScreen::update(InputState &input_state) {
|
|
|
|
frames_++;
|
|
|
|
if (frames_ > 180 || input_state.pointer_down[0]) {
|
|
|
|
if (bootFilename_.size()) {
|
|
|
|
screenManager()->switchScreen(new EmuScreen(bootFilename_));
|
|
|
|
} else {
|
|
|
|
screenManager()->switchScreen(new MenuScreen());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogoScreen::render() {
|
|
|
|
float t = (float)frames_ / 60.0f;
|
|
|
|
|
|
|
|
float alpha = t;
|
|
|
|
if (t > 1.0f) alpha = 1.0f;
|
|
|
|
float alphaText = alpha;
|
|
|
|
if (t > 2.0f) alphaText = 3.0f - t;
|
|
|
|
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(alpha);
|
|
|
|
|
2012-12-27 00:18:45 +01:00
|
|
|
ui_draw2d.SetFontScale(1.5f, 1.5f);
|
2012-11-01 16:19:01 +01:00
|
|
|
ui_draw2d.DrawText(UBUNTU48, "PPSSPP", dp_xres / 2, dp_yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
|
2012-12-27 00:18:45 +01:00
|
|
|
ui_draw2d.SetFontScale(1.0f, 1.0f);
|
2012-11-01 16:19:01 +01:00
|
|
|
ui_draw2d.DrawText(UBUNTU24, "Created by Henrik Rydgard", dp_xres / 2, dp_yres / 2 + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
|
|
|
|
ui_draw2d.DrawText(UBUNTU24, "Free Software under GPL 2.0", dp_xres / 2, dp_yres / 2 + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
|
|
|
|
ui_draw2d.DrawText(UBUNTU24, "www.ppsspp.org", dp_xres / 2, dp_yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
|
|
|
|
if (bootFilename_.size()) {
|
|
|
|
ui_draw2d.DrawText(UBUNTU24, bootFilename_.c_str(), dp_xres / 2, dp_yres / 2 + 180, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawWatermark();
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ==================
|
|
|
|
// Menu Screen
|
|
|
|
// ==================
|
|
|
|
|
|
|
|
void MenuScreen::update(InputState &input_state) {
|
|
|
|
frames_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuScreen::render() {
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
|
|
|
double xoff = 150 - frames_ * frames_ * 0.4f;
|
|
|
|
if (xoff < -20)
|
|
|
|
xoff = -20;
|
2013-01-26 23:46:02 +01:00
|
|
|
if (frames_ > 200) // seems the above goes nuts after a while...
|
|
|
|
xoff = -20;
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
int w = LARGE_BUTTON_WIDTH + 40;
|
|
|
|
|
2013-03-11 19:27:58 +01:00
|
|
|
ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 75, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM);
|
2012-11-01 16:19:01 +01:00
|
|
|
ui_draw2d.SetFontScale(0.7f, 0.7f);
|
2013-03-11 19:27:58 +01:00
|
|
|
ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_GIT_VERSION, dp_xres + xoff, 85, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM);
|
2012-11-01 16:19:01 +01:00
|
|
|
ui_draw2d.SetFontScale(1.0f, 1.0f);
|
2013-03-11 19:27:58 +01:00
|
|
|
VLinear vlinear(dp_xres + xoff, 100, 20);
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
if (UIButton(GEN_ID, vlinear, w, "Load...", ALIGN_RIGHT)) {
|
2013-02-12 14:39:18 +10:00
|
|
|
#if defined(USING_QT_UI)
|
2013-01-11 19:43:42 +10:00
|
|
|
QString fileName = QFileDialog::getOpenFileName(NULL, "Load ROM", g_Config.currentDirectory.c_str(), "PSP ROMs (*.iso *.cso *.pbp *.elf)");
|
|
|
|
if (QFile::exists(fileName)) {
|
|
|
|
QDir newPath;
|
|
|
|
g_Config.currentDirectory = newPath.filePath(fileName).toStdString();
|
|
|
|
g_Config.Save();
|
|
|
|
screenManager()->switchScreen(new EmuScreen(fileName.toStdString()));
|
|
|
|
}
|
|
|
|
#else
|
2012-11-01 16:19:01 +01:00
|
|
|
FileSelectScreenOptions options;
|
|
|
|
options.allowChooseDirectory = true;
|
2012-11-10 10:15:11 +01:00
|
|
|
options.filter = "iso:cso:pbp:elf:prx:";
|
2012-11-01 16:19:01 +01:00
|
|
|
options.folderIcon = I_ICON_FOLDER;
|
|
|
|
options.iconMapping["iso"] = I_ICON_UMD;
|
|
|
|
options.iconMapping["cso"] = I_ICON_UMD;
|
|
|
|
options.iconMapping["pbp"] = I_ICON_EXE;
|
|
|
|
options.iconMapping["elf"] = I_ICON_EXE;
|
|
|
|
screenManager()->switchScreen(new FileSelectScreen(options));
|
2013-01-11 19:43:42 +10:00
|
|
|
#endif
|
2012-11-01 16:19:01 +01:00
|
|
|
UIReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, vlinear, w, "Settings", ALIGN_RIGHT)) {
|
2013-03-02 17:47:37 +01:00
|
|
|
screenManager()->push(new SettingsScreen(), 0);
|
2012-11-01 16:19:01 +01:00
|
|
|
UIReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, vlinear, w, "Credits", ALIGN_RIGHT)) {
|
|
|
|
screenManager()->switchScreen(new CreditsScreen());
|
|
|
|
UIReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, vlinear, w, "Exit", ALIGN_RIGHT)) {
|
2013-01-13 20:11:46 +10:00
|
|
|
// TODO: Save when setting changes, rather than when we quit
|
|
|
|
NativeShutdown();
|
2012-11-01 16:19:01 +01:00
|
|
|
// TODO: Need a more elegant way to quit
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, vlinear, w, "www.ppsspp.org", ALIGN_RIGHT)) {
|
|
|
|
LaunchBrowser("http://www.ppsspp.org/");
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawWatermark();
|
|
|
|
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InGameMenuScreen::update(InputState &input) {
|
|
|
|
if (input.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
screenManager()->finishDialog(this, DR_CANCEL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InGameMenuScreen::render() {
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
2013-01-02 21:00:10 +01:00
|
|
|
const char *title;
|
2013-03-11 21:32:14 +01:00
|
|
|
// Try to ignore (tm) etc.
|
|
|
|
if (UTF8StringNonASCIICount(game_title.c_str()) > 2) {
|
2013-01-02 21:00:10 +01:00
|
|
|
title = "(can't display japanese title)";
|
|
|
|
} else {
|
|
|
|
title = game_title.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_draw2d.DrawText(UBUNTU48, title, dp_xres / 2, 30, 0xFFFFFFFF, ALIGN_HCENTER);
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2012-12-26 21:08:41 +01:00
|
|
|
int x = 30;
|
|
|
|
int y = 50;
|
2013-01-02 21:00:10 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Show Debug Statistics", ALIGN_TOPLEFT, &g_Config.bShowDebugStats);
|
2013-02-12 00:34:15 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Show FPS", ALIGN_TOPLEFT, &g_Config.bShowFPSCounter);
|
2013-02-13 18:21:21 +01:00
|
|
|
|
|
|
|
// TODO: Maybe shouldn't show this if the screen ratios are very close...
|
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Stretch to display", ALIGN_TOPLEFT, &g_Config.bStretchToDisplay);
|
|
|
|
|
2013-01-02 21:00:10 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Hardware Transform", ALIGN_TOPLEFT, &g_Config.bHardwareTransform);
|
2013-03-11 19:27:58 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Buffered Rendering", ALIGN_TOPLEFT, &g_Config.bBufferedRendering);
|
2013-02-19 00:44:22 +01:00
|
|
|
bool fs = g_Config.iFrameSkip == 1;
|
|
|
|
UICheckBox(GEN_ID, x, y += 50, "Frameskip", ALIGN_TOPLEFT, &fs);
|
|
|
|
g_Config.iFrameSkip = fs ? 1 : 0;
|
2013-01-02 21:00:10 +01:00
|
|
|
|
|
|
|
// TODO: Add UI for more than one slot.
|
2013-02-20 00:22:58 +01:00
|
|
|
HLinear hlinear1(x, y + 80, 20);
|
|
|
|
if (UIButton(GEN_ID, hlinear1, LARGE_BUTTON_WIDTH, "Save State", ALIGN_LEFT)) {
|
2013-01-02 21:00:10 +01:00
|
|
|
SaveState::SaveSlot(0, 0, 0);
|
|
|
|
screenManager()->finishDialog(this, DR_CANCEL);
|
|
|
|
}
|
2013-02-20 00:22:58 +01:00
|
|
|
if (UIButton(GEN_ID, hlinear1, LARGE_BUTTON_WIDTH, "Load State", ALIGN_LEFT)) {
|
2013-01-02 21:00:10 +01:00
|
|
|
SaveState::LoadSlot(0, 0, 0);
|
|
|
|
screenManager()->finishDialog(this, DR_CANCEL);
|
|
|
|
}
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
VLinear vlinear(dp_xres - 10, 160, 20);
|
|
|
|
if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Continue", ALIGN_RIGHT)) {
|
|
|
|
screenManager()->finishDialog(this, DR_CANCEL);
|
|
|
|
}
|
2013-03-02 17:47:37 +01:00
|
|
|
if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Settings", ALIGN_RIGHT)) {
|
|
|
|
screenManager()->push(new SettingsScreen(), 0);
|
|
|
|
}
|
2012-11-01 16:19:01 +01:00
|
|
|
if (UIButton(GEN_ID, vlinear, LARGE_BUTTON_WIDTH, "Return to Menu", ALIGN_RIGHT)) {
|
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
|
|
|
}
|
2013-03-02 17:47:37 +01:00
|
|
|
|
|
|
|
/*
|
2013-01-04 14:33:24 +01:00
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres - 10), LARGE_BUTTON_WIDTH*2, "Debug: Dump Next Frame", ALIGN_BOTTOMRIGHT)) {
|
2012-12-27 00:18:45 +01:00
|
|
|
gpu->DumpNextFrame();
|
|
|
|
}
|
2013-03-02 17:47:37 +01:00
|
|
|
*/
|
2012-12-27 00:18:45 +01:00
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
DrawWatermark();
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsScreen::update(InputState &input) {
|
|
|
|
if (input.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
g_Config.Save();
|
2013-03-02 17:47:37 +01:00
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsScreen::render() {
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
2013-01-26 17:26:07 +01:00
|
|
|
ui_draw2d.DrawText(UBUNTU48, "Settings", dp_xres / 2, 20, 0xFFFFFFFF, ALIGN_HCENTER);
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-01-10 12:51:18 +01:00
|
|
|
// TODO: Need to add tabs soon...
|
2012-11-01 16:19:01 +01:00
|
|
|
// VLinear vlinear(10, 80, 10);
|
2013-01-10 12:51:18 +01:00
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
int x = 30;
|
2013-01-26 17:26:07 +01:00
|
|
|
int y = 30;
|
2013-01-10 12:51:18 +01:00
|
|
|
int stride = 40;
|
2013-03-11 19:27:58 +01:00
|
|
|
int columnw = 420;
|
2013-01-10 12:51:18 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += stride, "Sound Emulation", ALIGN_TOPLEFT, &g_Config.bEnableSound);
|
2013-03-03 13:00:21 +01:00
|
|
|
if (UICheckBox(GEN_ID, x, y += stride, "Buffered Rendering", ALIGN_TOPLEFT, &g_Config.bBufferedRendering)) {
|
2013-03-03 13:30:29 +01:00
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
2013-03-03 13:00:21 +01:00
|
|
|
}
|
2013-01-03 12:04:00 +01:00
|
|
|
if (g_Config.bBufferedRendering) {
|
|
|
|
bool doubleRes = g_Config.iWindowZoom == 2;
|
2013-03-11 19:27:58 +01:00
|
|
|
if (UICheckBox(GEN_ID, x + columnw, y, "2x Render Resolution", ALIGN_TOPLEFT, &doubleRes)) {
|
2013-03-03 13:30:29 +01:00
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
2013-03-03 13:00:21 +01:00
|
|
|
}
|
2013-01-03 12:04:00 +01:00
|
|
|
g_Config.iWindowZoom = doubleRes ? 2 : 1;
|
|
|
|
}
|
2013-03-10 22:41:34 +10:00
|
|
|
#ifndef __SYMBIAN32__
|
2013-01-10 12:51:18 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += stride, "Hardware Transform", ALIGN_TOPLEFT, &g_Config.bHardwareTransform);
|
2013-03-11 19:27:58 +01:00
|
|
|
UICheckBox(GEN_ID, x + columnw, y, "Draw using Stream VBO", ALIGN_TOPLEFT, &g_Config.bUseVBO);
|
2013-03-10 22:41:34 +10:00
|
|
|
#endif
|
2013-03-11 11:52:56 +10:00
|
|
|
UICheckBox(GEN_ID, x, y += stride, "Vertex Cache", ALIGN_TOPLEFT, &g_Config.bVertexCache);
|
2012-12-01 23:20:08 +01:00
|
|
|
|
2013-02-16 09:49:33 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += stride, "JIT (Dynarec)", ALIGN_TOPLEFT, &g_Config.bJit);
|
|
|
|
if (g_Config.bJit)
|
2013-03-11 19:27:58 +01:00
|
|
|
UICheckBox(GEN_ID, x + columnw, y, "Fastmem (may be unstable)", ALIGN_TOPLEFT, &g_Config.bFastMemory);
|
2013-03-10 22:41:34 +10:00
|
|
|
|
2013-01-10 12:51:18 +01:00
|
|
|
UICheckBox(GEN_ID, x, y += stride, "On-screen Touch Controls", ALIGN_TOPLEFT, &g_Config.bShowTouchControls);
|
2013-01-26 17:26:07 +01:00
|
|
|
if (g_Config.bShowTouchControls) {
|
2013-03-11 19:27:58 +01:00
|
|
|
UICheckBox(GEN_ID, x + columnw, y, "Large Controls", ALIGN_TOPLEFT, &g_Config.bLargeControls);
|
|
|
|
UICheckBox(GEN_ID, x + columnw, y += stride, "Show Analog Stick", ALIGN_TOPLEFT, &g_Config.bShowAnalogStick);
|
|
|
|
} else {
|
|
|
|
y += stride;
|
2013-01-26 17:26:07 +01:00
|
|
|
}
|
2013-03-11 19:27:58 +01:00
|
|
|
UICheckBox(GEN_ID, x, y, "Tilt to Analog (horizontal)", ALIGN_TOPLEFT, &g_Config.bAccelerometerToAnalogHoriz);
|
2013-01-10 12:57:45 +01:00
|
|
|
// UICheckBox(GEN_ID, x, y += stride, "Draw raw framebuffer (for some homebrew)", ALIGN_TOPLEFT, &g_Config.bDisplayFramebuffer);
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres-10), LARGE_BUTTON_WIDTH, "Back", ALIGN_RIGHT | ALIGN_BOTTOM)) {
|
2013-03-02 17:47:37 +01:00
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|
2013-03-07 00:10:53 +01:00
|
|
|
if (UIButton(GEN_ID, Pos(10, dp_yres-10), LARGE_BUTTON_WIDTH, "Developer Menu", ALIGN_BOTTOMLEFT)) {
|
|
|
|
screenManager()->push(new DeveloperScreen());
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeveloperScreen::update(InputState &input) {
|
|
|
|
if (input.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
g_Config.Save();
|
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeveloperScreen::render() {
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
|
|
|
ui_draw2d.DrawText(UBUNTU48, "Developer Tools", dp_xres / 2, 20, 0xFFFFFFFF, ALIGN_HCENTER);
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres-10), LARGE_BUTTON_WIDTH, "Back", ALIGN_RIGHT | ALIGN_BOTTOM)) {
|
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres / 2, 100), LARGE_BUTTON_WIDTH, "Run CPU tests", ALIGN_CENTER | ALIGN_TOP)) {
|
|
|
|
// TODO: Run tests
|
|
|
|
RunTests();
|
|
|
|
// screenManager()->push(new EmuScreen())
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(10, dp_yres-10), LARGE_BUTTON_WIDTH, "Dump frame to log", ALIGN_BOTTOMLEFT)) {
|
|
|
|
gpu->DumpNextFrame();
|
|
|
|
}
|
2012-12-01 23:20:08 +01:00
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class FileListAdapter : public UIListAdapter {
|
|
|
|
public:
|
|
|
|
FileListAdapter(const FileSelectScreenOptions &options, const std::vector<FileInfo> *items) : options_(options), items_(items) {}
|
|
|
|
virtual size_t getCount() const { return items_->size(); }
|
|
|
|
virtual void drawItem(int item, int x, int y, int w, int h, bool active) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const FileSelectScreenOptions &options_;
|
|
|
|
const std::vector<FileInfo> *items_;
|
|
|
|
};
|
|
|
|
|
|
|
|
void FileListAdapter::drawItem(int item, int x, int y, int w, int h, bool selected) const
|
|
|
|
{
|
|
|
|
int icon = -1;
|
|
|
|
if ((*items_)[item].isDirectory) {
|
|
|
|
icon = options_.folderIcon;
|
|
|
|
} else {
|
|
|
|
std::string extension = getFileExtension((*items_)[item].name);
|
|
|
|
auto iter = options_.iconMapping.find(extension);
|
|
|
|
if (iter != options_.iconMapping.end())
|
|
|
|
icon = iter->second;
|
|
|
|
}
|
|
|
|
int iconSpace = this->itemHeight(item);
|
|
|
|
ui_draw2d.DrawImage2GridH(selected ? I_BUTTON_SELECTED: I_BUTTON, x, y, x + w);
|
|
|
|
ui_draw2d.DrawTextShadow(UBUNTU24, (*items_)[item].name.c_str(), x + UI_SPACE + iconSpace, y + 25, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
|
|
|
|
if (icon != -1)
|
|
|
|
ui_draw2d.DrawImage(icon, x + UI_SPACE, y + 25, 1.0f, 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FileSelectScreen::FileSelectScreen(const FileSelectScreenOptions &options) : options_(options) {
|
|
|
|
currentDirectory_ = g_Config.currentDirectory;
|
|
|
|
updateListing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSelectScreen::updateListing() {
|
|
|
|
listing_.clear();
|
2012-11-14 02:20:01 +10:00
|
|
|
getFilesInDir(currentDirectory_.c_str(), &listing_, options_.filter);
|
2012-11-01 16:19:01 +01:00
|
|
|
g_Config.currentDirectory = currentDirectory_;
|
|
|
|
list_.contentChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSelectScreen::update(InputState &input_state) {
|
|
|
|
if (input_state.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
g_Config.Save();
|
|
|
|
screenManager()->switchScreen(new MenuScreen());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSelectScreen::render() {
|
|
|
|
FileListAdapter adapter(options_, &listing_);
|
|
|
|
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
|
|
|
if (list_.Do(GEN_ID, 10, BUTTON_HEIGHT + 20, dp_xres-20, dp_yres - BUTTON_HEIGHT - 30, &adapter)) {
|
|
|
|
if (listing_[list_.selected].isDirectory) {
|
|
|
|
currentDirectory_ = listing_[list_.selected].fullName;
|
|
|
|
ILOG("%s", currentDirectory_.c_str());
|
|
|
|
updateListing();
|
|
|
|
list_.selected = -1;
|
|
|
|
} else {
|
|
|
|
std::string boot_filename = listing_[list_.selected].fullName;
|
|
|
|
ILOG("Selected: %i : %s", list_.selected, boot_filename.c_str());
|
|
|
|
list_.selected = -1;
|
|
|
|
g_Config.Save();
|
|
|
|
|
|
|
|
screenManager()->switchScreen(new EmuScreen(boot_filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_draw2d.DrawImageStretch(I_BUTTON, 0, 0, dp_xres, 70);
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(10,10), SMALL_BUTTON_WIDTH, "Up", ALIGN_TOPLEFT)) {
|
|
|
|
currentDirectory_ = getDir(currentDirectory_);
|
|
|
|
updateListing();
|
|
|
|
}
|
|
|
|
ui_draw2d.DrawTextShadow(UBUNTU24, currentDirectory_.c_str(), 20 + SMALL_BUTTON_WIDTH, 10 + 25, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, 10), SMALL_BUTTON_WIDTH, "Back", ALIGN_RIGHT)) {
|
|
|
|
g_Config.Save();
|
|
|
|
screenManager()->switchScreen(new MenuScreen());
|
|
|
|
}*/
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreditsScreen::update(InputState &input_state) {
|
|
|
|
if (input_state.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
screenManager()->switchScreen(new MenuScreen());
|
|
|
|
}
|
|
|
|
frames_++;
|
|
|
|
}
|
|
|
|
|
2013-03-03 13:00:21 +01:00
|
|
|
static const char * credits[] = {
|
2013-03-02 12:31:11 -08:00
|
|
|
"PPSSPP",
|
2012-11-01 16:19:01 +01:00
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"A fast and portable PSP emulator",
|
|
|
|
"",
|
|
|
|
"Created by Henrik Rydgard",
|
|
|
|
"",
|
2012-12-01 10:44:37 +01:00
|
|
|
"Contributors:",
|
|
|
|
"unknownbrackets",
|
2012-11-20 11:54:51 +01:00
|
|
|
"orphis",
|
2013-01-26 17:26:07 +01:00
|
|
|
"xsacha",
|
2012-11-20 11:54:51 +01:00
|
|
|
"artart78",
|
2013-01-26 17:26:07 +01:00
|
|
|
"tmaul",
|
2012-11-20 11:54:51 +01:00
|
|
|
"ced2911",
|
|
|
|
"soywiz",
|
|
|
|
"kovensky",
|
2013-01-26 17:26:07 +01:00
|
|
|
"raven02",
|
2013-02-05 22:22:14 +01:00
|
|
|
"xele",
|
2012-11-01 16:19:01 +01:00
|
|
|
"",
|
|
|
|
"Written in C++ for speed and portability",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"Free tools used:",
|
2012-12-02 14:48:00 +10:00
|
|
|
#ifdef ANDROID
|
2012-11-01 16:19:01 +01:00
|
|
|
"Android SDK + NDK",
|
2012-12-13 13:15:20 +10:00
|
|
|
#elif defined(BLACKBERRY)
|
2012-12-02 14:48:00 +10:00
|
|
|
"Blackberry NDK",
|
2013-02-12 14:39:18 +10:00
|
|
|
#endif
|
|
|
|
#if defined(USING_QT_UI)
|
2012-12-13 13:15:20 +10:00
|
|
|
"Qt",
|
2012-12-02 14:48:00 +10:00
|
|
|
#else
|
|
|
|
"SDL",
|
|
|
|
#endif
|
2012-11-01 16:19:01 +01:00
|
|
|
"CMake",
|
|
|
|
"freetype2",
|
|
|
|
"zlib",
|
2012-12-02 14:48:00 +10:00
|
|
|
"PSP SDK",
|
2012-11-01 16:19:01 +01:00
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"Check out the website:",
|
|
|
|
"www.ppsspp.org",
|
|
|
|
"compatibility lists, forums, and development info",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"Also check out Dolphin, the best Wii/GC emu around:",
|
2012-11-02 17:52:51 +01:00
|
|
|
"http://www.dolphin-emu.org",
|
2012-11-01 16:19:01 +01:00
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"PPSSPP is intended for educational purposes only.",
|
|
|
|
"",
|
|
|
|
"Please make sure that you own the rights to any games",
|
|
|
|
"you play by owning the UMD or buying the digital",
|
|
|
|
"download from the PSN store on your real PSP.",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"PSP is a trademark by Sony, Inc.",
|
|
|
|
};
|
|
|
|
|
|
|
|
void CreditsScreen::render() {
|
2013-03-02 12:31:11 -08:00
|
|
|
// TODO: This is kinda ugly, done on every frame...
|
|
|
|
char temp[256];
|
2013-03-02 13:18:43 -08:00
|
|
|
snprintf(temp, 256, "PPSSPP %s", PPSSPP_GIT_VERSION);
|
2013-03-02 13:50:38 -08:00
|
|
|
credits[0] = (const char *)temp;
|
2013-03-02 12:31:11 -08:00
|
|
|
|
2012-11-01 16:19:01 +01:00
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
|
|
|
const int numItems = ARRAY_SIZE(credits);
|
|
|
|
int itemHeight = 36;
|
|
|
|
int totalHeight = numItems * itemHeight + dp_yres + 200;
|
|
|
|
int y = dp_yres - (frames_ % totalHeight);
|
|
|
|
for (int i = 0; i < numItems; i++) {
|
|
|
|
float alpha = linearInOut(y+32, 64, dp_yres - 192, 64);
|
|
|
|
if (alpha > 0.0f) {
|
|
|
|
UIText(dp_xres/2, y, credits[i], whiteAlpha(alpha), ease(alpha), ALIGN_HCENTER);
|
|
|
|
}
|
|
|
|
y += itemHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres - 10), 200, "Back", ALIGN_BOTTOMRIGHT)) {
|
|
|
|
screenManager()->switchScreen(new MenuScreen());
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ErrorScreen::update(InputState &input_state) {
|
|
|
|
if (input_state.pad_buttons_down & PAD_BUTTON_BACK) {
|
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ErrorScreen::render()
|
|
|
|
{
|
|
|
|
UIShader_Prepare();
|
|
|
|
UIBegin();
|
|
|
|
DrawBackground(1.0f);
|
|
|
|
|
|
|
|
ui_draw2d.DrawText(UBUNTU48, errorTitle_.c_str(), dp_xres / 2, 30, 0xFFFFFFFF, ALIGN_HCENTER);
|
|
|
|
ui_draw2d.DrawText(UBUNTU24, errorMessage_.c_str(), 40, 120, 0xFFFFFFFF, ALIGN_LEFT);
|
|
|
|
|
|
|
|
if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres - 10), 200, "Back", ALIGN_BOTTOMRIGHT)) {
|
|
|
|
screenManager()->finishDialog(this, DR_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
UIEnd();
|
|
|
|
|
|
|
|
glsl_bind(UIShader_Get());
|
|
|
|
ui_draw2d.Flush(UIShader_Get());
|
|
|
|
}
|