Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: simplify button prompts #128

Merged
merged 14 commits into from
Jun 28, 2023
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ jobs:
run: make createzip

- name: Build Apollo App Package
run: make
run: |
make
mv IV0000-APOL00004_00-APOLLO0000000PS4.pkg apollo-ps4-build_${{ env.sha_name }}.pkg

- name: Push package artifact
uses: actions/upload-artifact@v3
with:
name: apollo-ps4-build_${{ env.sha_name }}
path: IV0000-APOL00004_00-APOLLO0000000PS4.pkg
path: apollo-ps4-build_${{ env.sha_name }}.pkg
if-no-files-found: error
3 changes: 2 additions & 1 deletion include/orbisPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ typedef struct OrbisPadConfig
unsigned int buttonsHold;
unsigned int idle;
int padHandle;
int crossButtonOK;
}OrbisPadConfig;

int orbisPadInit();
int orbisPadInit(void);
void orbisPadFinish();
OrbisPadConfig *orbisPadGetConf();
bool orbisPadGetButtonHold(unsigned int filter);
Expand Down
1 change: 1 addition & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct
uint8_t doAni;
uint8_t update;
uint32_t user_id;
uint8_t prompt_fade;
uint64_t psid[2];
uint64_t account_id;
bucanero marked this conversation as resolved.
Show resolved Hide resolved
char save_db[256];
Expand Down
110 changes: 72 additions & 38 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ app_config_t apollo_config = {
.doAni = 1,
.update = 1,
.user_id = 0,
.prompt_fade = 1,
.psid = {0, 0},
.account_id = 0,
};
Expand All @@ -71,22 +72,6 @@ SDL_Renderer* renderer; // SDL software renderer
uint32_t* texture_mem; // Pointers to texture memory
uint32_t* free_mem; // Pointer after last texture


const char * menu_pad_help[TOTAL_MENU_IDS] = { NULL, //Main
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //Trophy list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //USB list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //HDD list
"\x10 Select \x13 Back \x11 Refresh", //Online list
"\x10 Select \x13 Back \x11 Refresh", //User backup
"\x10 Select \x13 Back", //Options
"\x13 Back", //About
"\x10 Select \x12 View Code \x13 Back", //Select Cheats
"\x13 Back", //View Cheat
"\x10 Select \x13 Back", //Cheat Option
"\x13 Back", //View Details
"\x10 Value Up \x11 Value Down \x13 Exit", //Hex Editor
};

/*
* HDD save list
*/
Expand Down Expand Up @@ -152,6 +137,73 @@ save_list_t user_backup = {
.UpdatePath = NULL,
};

static const char* get_button_prompts(int menu_id)
{
const char* prompt = NULL;

switch (menu_id)
{
case MENU_TROPHIES:
case MENU_USB_SAVES:
case MENU_HDD_SAVES:
prompt = "\x10 Select \x13 Back \x12 Details \x11 Refresh";
break;

case MENU_USER_BACKUP:
case MENU_ONLINE_DB:
prompt = "\x10 Select \x13 Back \x11 Refresh";
break;

case MENU_SETTINGS:
prompt = "\x10 Select \x13 Back";
break;

case MENU_CREDITS:
case MENU_PATCH_VIEW:
case MENU_SAVE_DETAILS:
prompt = "\x13 Back";
break;

case MENU_PATCHES:
prompt = "\x10 Select \x12 View Code \x13 Back";
break;

case MENU_CODE_OPTIONS:
prompt = "\x10 Select \x13 Back";
break;

bucanero marked this conversation as resolved.
Show resolved Hide resolved
case MENU_HEX_EDITOR:
prompt = "\x10 Value Up \x11 Value Down \x13 Exit";
break;

case MENU_MAIN_SCREEN:
default:
prompt = "";
break;
}

return prompt;
}

static void helpFooter(void)
{
// Draw help
u8 alpha = 0xFF;
if (apollo_config.prompt_fade && orbisPadGetConf()->idle > 0x100)
illusion0001 marked this conversation as resolved.
Show resolved Hide resolved
{
int dec = (orbisPadGetConf()->idle - 0x100) * 2;
if (dec > alpha)
dec = alpha;
alpha -= dec;
}

SetFontSize(APP_FONT_SIZE_DESCRIPTION);
SetCurrentFont(font_adonais_regular);
SetFontAlign(FONT_ALIGN_SCREEN_CENTER);
SetFontColor(APP_FONT_COLOR | alpha, 0);
DrawString(0, SCREEN_HEIGHT - 94, get_button_prompts(menu_id));
SetFontAlign(FONT_ALIGN_LEFT);
bucanero marked this conversation as resolved.
Show resolved Hide resolved
}

static int initPad()
{
Expand Down Expand Up @@ -355,7 +407,7 @@ void update_db_path(char* path)
strcpy(path, apollo_config.save_db);
}

static void registerSpecialChars()
static void registerSpecialChars(void)
{
// Register save tags
RegisterSpecialCharacter(CHAR_TAG_PS1, 2, 1.5, &menu_textures[tag_ps1_png_index]);
Expand All @@ -374,10 +426,10 @@ static void registerSpecialChars()
RegisterSpecialCharacter(CHAR_TAG_TRANSFER, 0, 1.0, &menu_textures[tag_transfer_png_index]);

// Register button icons
RegisterSpecialCharacter(CHAR_BTN_X, 0, 1.2, &menu_textures[footer_ico_cross_png_index]);
RegisterSpecialCharacter(orbisPadGetConf()->crossButtonOK ? CHAR_BTN_X : CHAR_BTN_O, 0, 1.2, &menu_textures[footer_ico_cross_png_index]);
RegisterSpecialCharacter(CHAR_BTN_S, 0, 1.2, &menu_textures[footer_ico_square_png_index]);
RegisterSpecialCharacter(CHAR_BTN_T, 0, 1.2, &menu_textures[footer_ico_triangle_png_index]);
RegisterSpecialCharacter(CHAR_BTN_O, 0, 1.2, &menu_textures[footer_ico_circle_png_index]);
RegisterSpecialCharacter(orbisPadGetConf()->crossButtonOK ? CHAR_BTN_O : CHAR_BTN_X, 0, 1.2, &menu_textures[footer_ico_circle_png_index]);

// Register trophy icons
RegisterSpecialCharacter(CHAR_TRP_BRONZE, 2, 0.9f, &menu_textures[trp_bronze_png_index]);
Expand Down Expand Up @@ -583,25 +635,7 @@ s32 main(s32 argc, const char* argv[])
orbisPadUpdate();
drawScene();

//Draw help
if (menu_pad_help[menu_id])
{
u8 alpha = 0xFF;
if (orbisPadGetConf()->idle > 0x100)
{
int dec = (orbisPadGetConf()->idle - 0x100) * 2;
if (dec > alpha)
dec = alpha;
alpha -= dec;
}

SetFontSize(APP_FONT_SIZE_DESCRIPTION);
SetCurrentFont(font_adonais_regular);
SetFontAlign(FONT_ALIGN_SCREEN_CENTER);
SetFontColor(APP_FONT_COLOR | alpha, 0);
DrawString(0, SCREEN_HEIGHT - 94, (char *)menu_pad_help[menu_id]);
SetFontAlign(FONT_ALIGN_LEFT);
}
helpFooter();

#ifdef APOLLO_ENABLE_LOGGING
// Calculate FPS and ms/frame
Expand Down
3 changes: 2 additions & 1 deletion source/menu_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "menu.h"
#include "menu_gui.h"
#include "libfont.h"
#include "orbisPad.h"

static void _draw_OptionsMenu(u8 alpha)
{
Expand All @@ -32,7 +33,7 @@ static void _draw_OptionsMenu(u8 alpha)
DrawTexture(&menu_textures[c], OPTION_ITEM_OFF - 29, y_off, 0, menu_textures[c].width, menu_textures[c].height, 0xFFFFFF00 | alpha);
break;
case APP_OPTION_CALL:
DrawTexture(&menu_textures[footer_ico_cross_png_index], OPTION_ITEM_OFF - 29, y_off+2, 0, menu_textures[footer_ico_cross_png_index].width, menu_textures[footer_ico_cross_png_index].height, 0xFFFFFF00 | alpha);
DrawTexture(&menu_textures[orbisPadGetConf()->crossButtonOK ? footer_ico_cross_png_index : footer_ico_circle_png_index], OPTION_ITEM_OFF - 29, y_off+2, 0, menu_textures[footer_ico_cross_png_index].width/2, menu_textures[footer_ico_cross_png_index].height/2, 0xFFFFFF00 | alpha);
bucanero marked this conversation as resolved.
Show resolved Hide resolved
break;
case APP_OPTION_LIST:
SetFontAlign(FONT_ALIGN_CENTER);
Expand Down
14 changes: 13 additions & 1 deletion source/orbisPad.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <stdint.h>
#include <sys/time.h>
#include <dbglogger.h>
#include <orbis/SystemService.h>
#include "orbisPad.h"

#define LOG dbglogger_log
Expand Down Expand Up @@ -103,6 +104,9 @@ bool orbisPadGetButtonHold(unsigned int filter)

bool orbisPadGetButtonPressed(unsigned int filter)
{
if (!orbisPadConf.crossButtonOK && (filter & (ORBIS_PAD_BUTTON_CROSS|ORBIS_PAD_BUTTON_CIRCLE)))
filter ^= (ORBIS_PAD_BUTTON_CROSS|ORBIS_PAD_BUTTON_CIRCLE);

if((orbisPadConf.buttonsPressed&filter)==filter)
{
orbisPadConf.buttonsPressed ^= filter;
Expand Down Expand Up @@ -173,7 +177,7 @@ int orbisPadUpdate()
return -1;
}

int orbisPadInit()
int orbisPadInit(void)
{
int ret;
OrbisUserServiceInitializeParams param;
Expand Down Expand Up @@ -214,6 +218,14 @@ int orbisPadInit()
return -1;
}

ret = sceSystemServiceParamGetInt(ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN, &orbisPadConf.crossButtonOK);
if (ret < 0)
{
LOG("sceSystemServiceParamGetInt error 0x%08X", ret);
LOG("Failed to obtain ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN info!, assigning X as main button.");
orbisPadConf.crossButtonOK = 1;
}

orbispad_initialized=1;
g_time = timeInMilliseconds();
LOG("ORBISPAD initialized: scePadOpen return handle 0x%X", orbisPadConf.padHandle);
Expand Down
12 changes: 12 additions & 0 deletions source/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static char * sort_opt[] = {"Disabled", "by Name", "by Title ID", NULL};
static void log_callback(int sel);
static void sort_callback(int sel);
static void ani_callback(int sel);
static void btn_fade_callback(int sel);
static void db_url_callback(int sel);
static void clearcache_callback(int sel);
static void upd_appdata_callback(int sel);
Expand All @@ -36,6 +37,12 @@ menu_option_t menu_options[] = {
.value = &apollo_config.doAni,
.callback = ani_callback
},
{ .name = "Button Prompts Fade Out",
.options = NULL,
.type = APP_OPTION_BOOL,
.value = &apollo_config.prompt_fade,
.callback = btn_fade_callback
},
{ .name = "Sort Saves",
.options = sort_opt,
.type = APP_OPTION_LIST,
Expand Down Expand Up @@ -91,6 +98,11 @@ static void ani_callback(int sel)
apollo_config.doAni = !sel;
}

static void btn_fade_callback(int sel)
bucanero marked this conversation as resolved.
Show resolved Hide resolved
{
apollo_config.prompt_fade = !sel;
}

static void db_url_callback(int sel)
{
if (osk_dialog_get_text("Enter the URL of the online database", apollo_config.save_db, sizeof(apollo_config.save_db)))
Expand Down