Skip to content

Commit

Permalink
"Thin Borders" touch button style, ability to choose.
Browse files Browse the repository at this point in the history
Also a Gold color scheme. Not sure whether to use or not.
  • Loading branch information
hrydgard committed Dec 10, 2013
1 parent d394282 commit 7271367
Show file tree
Hide file tree
Showing 24 changed files with 34,190 additions and 34,048 deletions.
3 changes: 2 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {

#endif
control->Get("DisableDpadDiagonals", &bDisableDpadDiagonals, false);
control->Get("TouchButtonStyle", &iTouchButtonStyle, 0);
control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
//set these to -1 if not initialized. initializing these
//requires pixel coordinates which is not known right now.
Expand Down Expand Up @@ -523,7 +524,7 @@ void Config::Save() {
control->Set("DeadzoneRadius", fDeadzoneRadius);
#endif
control->Set("DisableDpadDiagonals", bDisableDpadDiagonals);

control->Set("TouchButtonStyle", iTouchButtonStyle);
control->Set("TouchButtonOpacity", iTouchButtonOpacity);
control->Set("ActionButtonScale", fActionButtonScale);
control->Set("ActionButtonSpacing2", fActionButtonSpacing);
Expand Down
2 changes: 2 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ struct Config {

// Disable diagonals
bool bDisableDpadDiagonals;
// Control Style
int iTouchButtonStyle;
// Control Positions
int iTouchButtonOpacity;
//space between PSP buttons
Expand Down
26 changes: 15 additions & 11 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ void GameSettingsScreen::CreateViews() {
CheckBox *disableDiags = controlsSettings->Add(new CheckBox(&g_Config.bDisableDpadDiagonals, c->T("Disable D-Pad diagonals (4-way touch)")));
disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);
controlsSettings->Add(new PopupSliderChoice(&g_Config.iTouchButtonOpacity, 0, 100, c->T("Button Opacity"), screenManager()));
static const char *touchControlStyles[] = {"Classic", "Thin borders"};
View *style = controlsSettings->Add(new PopupMultiChoice(&g_Config.iTouchButtonStyle, c->T("Button style"), touchControlStyles, 0, ARRAY_SIZE(touchControlStyles), c, screenManager()));
disableDiags->SetEnabledPtr(&g_Config.bShowTouchControls);

// System
ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
Expand All @@ -261,25 +264,17 @@ void GameSettingsScreen::CreateViews() {

systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)")))->SetEnabled(!PSP_IsInited());
systemSettings->Add(new CheckBox(&g_Config.bSeparateIOThread, s->T("I/O on thread (experimental)")))->SetEnabled(!PSP_IsInited());
systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default)"), screenManager()));
systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, s->T("Change CPU Clock", "Change CPU Clock (0 = default) (unstable)"), screenManager()));
#ifndef USING_GLES2
systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, s->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (0 = off, mem hog)"), screenManager()));
#endif

systemSettings->Add(new CheckBox(&g_Config.bAtomicAudioLocks, s->T("Atomic Audio locks (experimental)")))->SetEnabled(!PSP_IsInited());

systemSettings->Add(new ItemHeader(s->T("Networking")));
systemSettings->Add(new CheckBox(&g_Config.bEnableWlan, s->T("Enable networking", "Enable networking/wlan (beta)")));

//#ifndef ANDROID
systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
systemSettings->SetSpacing(0);
systemSettings->Add(new ItemHeader(s->T("Developer Tools")));
systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);

systemSettings->Add(new ItemHeader(s->T("General")));
systemSettings->Add(new Choice(s->T("Developer Tools")))->OnClick.Handle(this, &GameSettingsScreen::OnDeveloperTools);
systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents);
systemSettings->Add(new Choice(s->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings);
systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, s->T("Auto Load Newest Savestate")));
Expand All @@ -289,6 +284,15 @@ void GameSettingsScreen::CreateViews() {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
systemSettings->Add(enableReportsCheckbox_);

systemSettings->Add(new ItemHeader(s->T("Networking")));
systemSettings->Add(new CheckBox(&g_Config.bEnableWlan, s->T("Enable networking", "Enable networking/wlan (beta)")));

//#ifndef ANDROID
systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
systemSettings->SetSpacing(0);

systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
// TODO: Come up with a way to display a keyboard for mobile users,
Expand Down
41 changes: 26 additions & 15 deletions UI/GamepadEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#define USE_PAUSE_BUTTON 0
#endif

static u32 GetButtonColor() {
return g_Config.iTouchButtonStyle == 1 ? 0xFFFFFF : 0xc0b080;
}

void MultiTouchButton::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
const AtlasImage &image = dc.Draw()->GetAtlas()->images[bgImg_];
w = image.w * scale_;
Expand Down Expand Up @@ -63,7 +67,7 @@ void MultiTouchButton::Draw(UIContext &dc) {
scale *= 2.0f;
opacity *= 1.15f;
}
uint32_t colorBg = colorAlpha(0xc0b080, opacity);
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t color = colorAlpha(0xFFFFFF, opacity);

dc.Draw()->DrawImageRotated(bgImg_, bounds_.centerX(), bounds_.centerY(), scale, angle_ * (M_PI * 2 / 360.0f), colorBg, flipImageH_);
Expand Down Expand Up @@ -191,7 +195,7 @@ void PSPDpad::ProcessTouch(float x, float y, bool down) {
void PSPDpad::Draw(UIContext &dc) {
float opacity = g_Config.iTouchButtonOpacity / 100.0f;

uint32_t colorBg = colorAlpha(0xc0b080, opacity);
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t color = colorAlpha(0xFFFFFF, opacity);

static const float xoff[4] = {1, 0, -1, 0};
Expand Down Expand Up @@ -223,7 +227,7 @@ void PSPStick::GetContentDimensions(const UIContext &dc, float &w, float &h) con
void PSPStick::Draw(UIContext &dc) {
float opacity = g_Config.iTouchButtonOpacity / 100.0f;

uint32_t colorBg = colorAlpha(0xc0b080, opacity);
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t color = colorAlpha(0x808080, opacity);

float stickX = bounds_.centerX();
Expand Down Expand Up @@ -447,41 +451,48 @@ UI::ViewGroup *CreatePadLayout(bool *pause) {
const int halfW = dp_xres / 2;

if (g_Config.bShowTouchControls) {
int roundImage = g_Config.iTouchButtonStyle ? I_ROUND_LINE : I_ROUND;
int rectImage = g_Config.iTouchButtonStyle ? I_RECT_LINE : I_RECT;
int shoulderImage = g_Config.iTouchButtonStyle ? I_SHOULDER_LINE : I_SHOULDER;
int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR;
int stickImage = g_Config.iTouchButtonStyle ? I_STICK_LINE : I_STICK;
int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG;

#if USE_PAUSE_BUTTON
root->Add(new BoolButton(pause, I_ROUND, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
root->Add(new BoolButton(pause, roundImage, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90);
#endif
if (g_Config.bShowTouchCircle)
root->Add(new PSPButton(CTRL_CIRCLE, I_ROUND, I_CIRCLE, Action_button_scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_CIRCLE, roundImage, I_CIRCLE, Action_button_scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true)));

if (g_Config.bShowTouchCross)
root->Add(new PSPButton(CTRL_CROSS, I_ROUND, I_CROSS, Action_button_scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_CROSS, roundImage, I_CROSS, Action_button_scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true)));

if (g_Config.bShowTouchTriangle)
root->Add(new PSPButton(CTRL_TRIANGLE, I_ROUND, I_TRIANGLE, Action_button_scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_TRIANGLE, roundImage, I_TRIANGLE, Action_button_scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true)));

if (g_Config.bShowTouchSquare)
root->Add(new PSPButton(CTRL_SQUARE, I_ROUND, I_SQUARE, Action_button_scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_SQUARE, roundImage, I_SQUARE, Action_button_scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true)));

if (g_Config.bShowTouchStart)
root->Add(new PSPButton(CTRL_START, I_RECT, I_START, start_key_scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_START, rectImage, I_START, start_key_scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true)));

if (g_Config.bShowTouchSelect)
root->Add(new PSPButton(CTRL_SELECT, I_RECT, I_SELECT, select_key_scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_SELECT, rectImage, I_SELECT, select_key_scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true)));

if (g_Config.bShowTouchUnthrottle)
root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, I_RECT, I_ARROW, unthrottle_key_scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180);
root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, rectImage, I_ARROW, unthrottle_key_scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180);

if (g_Config.bShowTouchLTrigger)
root->Add(new PSPButton(CTRL_LTRIGGER, I_SHOULDER, I_L, l_key_scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true)));
root->Add(new PSPButton(CTRL_LTRIGGER, shoulderImage, I_L, l_key_scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true)));

if (g_Config.bShowTouchRTrigger)
root->Add(new PSPButton(CTRL_RTRIGGER, I_SHOULDER, I_R, r_key_scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true);
root->Add(new PSPButton(CTRL_RTRIGGER, shoulderImage, I_R, r_key_scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true);

if (g_Config.bShowTouchDpad)
root->Add(new PSPDpad(I_DIR, I_ARROW, D_pad_scale, D_pad_spacing, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true)));
root->Add(new PSPDpad(dirImage, I_ARROW, D_pad_scale, D_pad_spacing, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true)));

if (g_Config.bShowTouchAnalogStick)
root->Add(new PSPStick(I_STICKBG, I_STICK, 0, analog_stick_scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true)));
root->Add(new PSPStick(stickBg, stickImage, 0, analog_stick_scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true)));
}

return root;
Expand Down
6 changes: 5 additions & 1 deletion UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ void DrawBackground(float alpha) {
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
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);
int img = I_BG;
#ifdef GOLD
img = I_BG_GOLD;
#endif
ui_draw2d.DrawImageStretch(img, 0, 0, dp_xres, dp_yres);
float t = time_now();
for (int i = 0; i < 100; i++) {
float x = xbase[i];
Expand Down
10 changes: 10 additions & 0 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,16 @@ void NativeInitGraphics() {
ui_theme.buttonHighlightedStyle = ui_theme.itemHighlightedStyle;

ui_theme.popupTitle.fgColor = 0xFFE3BE59;

#ifdef GOLD
ui_theme.itemFocusedStyle.background = UI::Drawable(0xFF4cc2ed);
ui_theme.itemDownStyle.background = UI::Drawable(0xFF39a9ee);
ui_theme.itemDisabledStyle.background = UI::Drawable(0x55AFD4E0);
ui_theme.itemHighlightedStyle.background = UI::Drawable(0x5539BBbd);

ui_theme.popupTitle.fgColor = 0xFF59BEE3;
#endif

ui_draw2d.Init();
ui_draw2d_front.Init();

Expand Down
32 changes: 22 additions & 10 deletions UI/TouchControlLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

static const int leftColumnWidth = 140;

static u32 GetButtonColor() {
return g_Config.iTouchButtonStyle == 1 ? 0xFFFFFF : 0xc0b080;
}

// convert from screen coordinates (leftColumnWidth to dp_xres) to actual fullscreen coordinates (0 to 1.0)
static inline float toFullscreenCoord(int screenx) {
return (float)(screenx - leftColumnWidth) / (dp_xres - leftColumnWidth);
Expand Down Expand Up @@ -76,7 +80,7 @@ class PSPActionButtons : public DragDropButton {
PSPActionButtons(float &x, float &y, float &scale, float &spacing)
: DragDropButton(x, y, -1, -1, scale), spacing_(spacing) {
using namespace UI;
roundId_ = I_ROUND;
roundId_ = g_Config.iTouchButtonStyle ? I_ROUND_LINE : I_ROUND;

circleId_ = I_CIRCLE;
crossId_ = I_CROSS;
Expand Down Expand Up @@ -105,7 +109,7 @@ class PSPActionButtons : public DragDropButton {
void Draw(UIContext &dc) {
float opacity = g_Config.iTouchButtonOpacity / 100.0f;

uint32_t colorBg = colorAlpha(0xc0b080, opacity);
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t color = colorAlpha(0xFFFFFF, opacity);

int centerX = bounds_.centerX();
Expand Down Expand Up @@ -165,18 +169,20 @@ class PSPDPadButtons : public DragDropButton {
void Draw(UIContext &dc) {
float opacity = g_Config.iTouchButtonOpacity / 100.0f;

uint32_t colorBg = colorAlpha(0xc0b080, opacity);
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t color = colorAlpha(0xFFFFFF, opacity);

static const float xoff[4] = {1, 0, -1, 0};
static const float yoff[4] = {0, 1, 0, -1};

int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR;

for (int i = 0; i < 4; i++) {
float x = bounds_.centerX() + xoff[i] * D_pad_Radius * spacing_;
float y = bounds_.centerY() + yoff[i] * D_pad_Radius * spacing_;
float angle = i * M_PI / 2;

dc.Draw()->DrawImageRotated(I_DIR, x, y, scale_, angle + PI, colorBg, false);
dc.Draw()->DrawImageRotated(dirImage, x, y, scale_, angle + PI, colorBg, false);
dc.Draw()->DrawImageRotated(I_ARROW, x, y, scale_, angle + PI, color);
}
}
Expand Down Expand Up @@ -363,36 +369,42 @@ void TouchControlLayoutScreen::CreateViews() {

controls_.push_back(actionButtons);

int rectImage = g_Config.iTouchButtonStyle ? I_RECT_LINE : I_RECT;
int shoulderImage = g_Config.iTouchButtonStyle ? I_SHOULDER_LINE : I_SHOULDER;
int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR;
int stickImage = g_Config.iTouchButtonStyle ? I_STICK_LINE : I_STICK;
int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG;

if (g_Config.bShowTouchDpad) {
controls_.push_back(new PSPDPadButtons(g_Config.fDpadX, g_Config.fDpadY, g_Config.fDpadScale, g_Config.fDpadSpacing));
}

if (g_Config.bShowTouchSelect) {
controls_.push_back(new DragDropButton(g_Config.fSelectKeyX, g_Config.fSelectKeyY, I_RECT, I_SELECT, g_Config.fSelectKeyScale));
controls_.push_back(new DragDropButton(g_Config.fSelectKeyX, g_Config.fSelectKeyY, rectImage, I_SELECT, g_Config.fSelectKeyScale));
}

if (g_Config.bShowTouchStart) {
controls_.push_back(new DragDropButton(g_Config.fStartKeyX, g_Config.fStartKeyY, I_RECT, I_START, g_Config.fStartKeyScale));
controls_.push_back(new DragDropButton(g_Config.fStartKeyX, g_Config.fStartKeyY, rectImage, I_START, g_Config.fStartKeyScale));
}

if (g_Config.bShowTouchUnthrottle) {
DragDropButton *unthrottle = new DragDropButton(g_Config.fUnthrottleKeyX, g_Config.fUnthrottleKeyY, I_RECT, I_ARROW, g_Config.fUnthrottleKeyScale);
DragDropButton *unthrottle = new DragDropButton(g_Config.fUnthrottleKeyX, g_Config.fUnthrottleKeyY, rectImage, I_ARROW, g_Config.fUnthrottleKeyScale);
unthrottle->SetAngle(180.0f);
controls_.push_back(unthrottle);
}

if (g_Config.bShowTouchLTrigger) {
controls_.push_back(new DragDropButton(g_Config.fLKeyX, g_Config.fLKeyY, I_SHOULDER, I_L, g_Config.fLKeyScale));
controls_.push_back(new DragDropButton(g_Config.fLKeyX, g_Config.fLKeyY, shoulderImage, I_L, g_Config.fLKeyScale));
}

if (g_Config.bShowTouchRTrigger) {
DragDropButton *rbutton = new DragDropButton(g_Config.fRKeyX, g_Config.fRKeyY, I_SHOULDER, I_R, g_Config.fRKeyScale);
DragDropButton *rbutton = new DragDropButton(g_Config.fRKeyX, g_Config.fRKeyY, shoulderImage, I_R, g_Config.fRKeyScale);
rbutton->FlipImageH(true);
controls_.push_back(rbutton);
}

if (g_Config.bShowTouchAnalogStick) {
controls_.push_back(new DragDropButton(g_Config.fAnalogStickX, g_Config.fAnalogStickY, I_STICKBG, I_STICK, g_Config.fAnalogStickScale));
controls_.push_back(new DragDropButton(g_Config.fAnalogStickX, g_Config.fAnalogStickY, stickBg, stickImage, g_Config.fAnalogStickScale));
};

for (size_t i = 0; i < controls_.size(); i++) {
Expand Down
Loading

0 comments on commit 7271367

Please sign in to comment.