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

Favourites Mode #1366

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ endif

FRONTEND_OBJS = pad.o xparam.o fntsys.o renderman.o menusys.o OSDHistory.o system.o lang.o lang_internal.o config.o hdd.o dialogs.o \
dia.o ioman.o texcache.o themes.o supportbase.o bdmsupport.o ethsupport.o hddsupport.o zso.o lz4.o \
appsupport.o gui.o guigame.o textures.o opl.o atlas.o nbns.o httpclient.o gsm.o cheatman.o sound.o ps2cnf.o
appsupport.o favsupport.o gui.o guigame.o textures.o opl.o atlas.o nbns.o httpclient.o gsm.o cheatman.o sound.o ps2cnf.o

IOP_OBJS = iomanx.o filexio.o ps2fs.o usbd.o bdmevent.o \
bdm.o bdmfs_fatfs.o usbmass_bd.o iLinkman.o IEEE1394_bd.o mx4sio_bd.o \
Expand All @@ -92,14 +92,14 @@ EECORE_OBJS = ee_core.o ioprp.o util.o \
ingame_smstcpip.o smap_ingame.o smbman.o smbinit.o

PNG_ASSETS = load0 load1 load2 load3 load4 load5 load6 load7 usb usb_bd ilk_bd \
m4s_bd hdd_bd hdd eth app cross triangle circle square select start left right \
m4s_bd hdd_bd hdd eth app fav fav_mark cross triangle circle square select start left right \
background info cover disc screen ELF HDL ISO ZSO UL APPS CD DVD Aspect_s Aspect_w Aspect_w1 \
Aspect_w2 Device_1 Device_2 Device_3 Device_4 Device_5 Device_6 Device_all Rating_0 \
Rating_1 Rating_2 Rating_3 Rating_4 Rating_5 Scan_240p Scan_240p1 Scan_480i Scan_480p \
Scan_480p1 Scan_480p2 Scan_480p3 Scan_480p4 Scan_480p5 Scan_576i Scan_576p Scan_720p \
Scan_1080i Scan_1080i2 Scan_1080p Vmode_multi Vmode_ntsc Vmode_pal logo case apps_case\
Index_0 Index_1 Index_2 Index_3 Index_4
# unused icons - up down l1 l2 l3 r1 r2 r3
Index_0 Index_1 Index_2 Index_3 Index_4 R3
# unused icons - up down l1 l2 l3 r1 r2

GFX_OBJS = $(PNG_ASSETS:%=%_png.o) poeveticanew.o icon_sys.o icon_icn.o

Expand Down
Binary file modified gfx/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/eth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/fav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/fav_mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/hdd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/hdd_bd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/ilk_bd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/m4s_bd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/udp_bd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/usb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/usb_bd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum CONFIG_INDEX {
#define CONFIG_OPL_HDD_MODE "hdd_mode"
#define CONFIG_OPL_ETH_MODE "eth_mode"
#define CONFIG_OPL_APP_MODE "app_mode"
#define CONFIG_OPL_FAV_MODE "fav_mode"
#define CONFIG_OPL_BDM_CACHE "bdm_cache"
#define CONFIG_OPL_HDD_CACHE "hdd_cache"
#define CONFIG_OPL_SMB_CACHE "smb_cache"
Expand Down
1 change: 1 addition & 0 deletions include/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum UI_ITEMS {
CFG_HDDMODE,
CFG_ETHMODE,
CFG_APPMODE,
CFG_FAVMODE,
CFG_BDMCACHE,
CFG_HDDCACHE,
CFG_SMBCACHE,
Expand Down
16 changes: 16 additions & 0 deletions include/favsupport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __FAV_SUPPORT_H
#define __FAV_SUPPORT_H

#include "include/iosupport.h"

#define FAV_MODE_UPDATE_DELAY 240

item_list_t *favGetObject(int initOnly);
unsigned char favGetFlags(item_list_t *itemList);

void writeFavouritesFile(submenu_item_t *items, int size);
submenu_item_t *readFavouritesFile(int *out_size);
void addFavouriteItem(const submenu_item_t *item);
void removeFavouriteByIdAndText(int id, const char *text);

#endif
1 change: 1 addition & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct gui_update_t
int id;
int text_id;
int selected;
void *owner;
} submenu;

struct
Expand Down
1 change: 1 addition & 0 deletions include/iosupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum IO_MODES {
ETH_MODE,
HDD_MODE,
APP_MODE,
FAV_MODE,

MODE_COUNT
};
Expand Down
10 changes: 9 additions & 1 deletion include/menusys.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ typedef struct submenu_item

int *cache_id;
int *cache_uid;

/// item_list_t that owns the submenu_item (for favourites)
void *owner;

int favourited;
} submenu_item_t;

typedef struct submenu_list
Expand Down Expand Up @@ -70,6 +75,8 @@ typedef struct menu_item

void (*execSquare)(struct menu_item *curMenu);

void (*fav)(struct menu_item *curMenu);

/// hint list
struct menu_hint_item *hints;
} menu_item_t;
Expand All @@ -90,7 +97,8 @@ void menuInitAppMenu(void);
void menuAppendItem(menu_item_t *item);

void submenuRebuildCache(submenu_list_t *submenu);
submenu_list_t *submenuAppendItem(submenu_list_t **submenu, int icon_id, char *text, int id, int text_id);
submenu_list_t *submenuAppendItem(submenu_list_t **submenu, int icon_id, char *text, int id, int text_id, void *owner);
submenu_list_t *submenuFindItemByIdAndText(submenu_list_t *submenu, int id, const char *text);
void submenuRemoveItem(submenu_list_t **submenu, int id);
void submenuDestroy(submenu_list_t **submenu);
void submenuSort(submenu_list_t **submenu);
Expand Down
4 changes: 4 additions & 0 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ extern int gBDMStartMode;
extern int gHDDStartMode;
extern int gETHStartMode;
extern int gAPPStartMode;
extern int gFAVStartMode;
extern int bdmCacheSize;
extern int hddCacheSize;
extern int smbCacheSize;
Expand Down Expand Up @@ -218,6 +219,9 @@ void initSupport(item_list_t *itemList, int mode, int force_reinit);

void setDefaultColors(void);

item_list_t *getFavouritesOwnerPointer(short int mode);
void loadFavourites(void);

#define MENU_ITEM_HEIGHT 19

#include "include/menusys.h"
Expand Down
6 changes: 4 additions & 2 deletions include/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ enum INTERNAL_TEXTURE {
HDD_ICON,
ETH_ICON,
APP_ICON,
FAV_ICON,
FAV_MARK,
INDEX_0,
INDEX_1,
INDEX_2,
INDEX_3,
INDEX_4,
R3_ICON,
LEFT_ICON,
RIGHT_ICON,
CROSS_ICON,
Expand All @@ -38,8 +41,7 @@ enum INTERNAL_TEXTURE {
L2_ICON,
L3_ICON,
R1_ICON,
R2_ICON,
R3_ICON, */
R2_ICON, */
MAIN_BG,
INFO_BG,
COVER_DEFAULT,
Expand Down
10 changes: 9 additions & 1 deletion lng_tmpl/_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gui_strings:
- label: NET_GAMES
string: ETH Games
- label: APPS
string: Apps
string: Applications
- label: THEME
string: Theme
- label: LANGUAGE
Expand Down Expand Up @@ -692,3 +692,11 @@ gui_strings:
string: 'Files found: %i'
- label: CHEAT_SELECTION
string: Cheat Selection
- label: FAV
string: Favourites
- label: FAVMODE
string: Favourites Start Mode
- label: FAV_HINT
string: Favourite
- label: FAV_MSG
string: "%s not allowed through Favourites Menu."
28 changes: 25 additions & 3 deletions src/dia.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ static void diaRenderItem(int x, int y, struct UIItem *item, int selected, int h
}
}

static int maxScrollOffset = 0;
static int scrollOffset = 0;

/// renders whole ui screen (for given dialog setup)
void diaRenderUI(struct UIItem *ui, short inMenu, struct UIItem *cur, int haveFocus)
{
Expand All @@ -573,7 +576,8 @@ void diaRenderUI(struct UIItem *ui, short inMenu, struct UIItem *cur, int haveFo

// render all items
struct UIItem *rc = ui;
int x = x0, y = y0, hmax = 0;
int x = x0, hmax = 0;
int y = y0 - scrollOffset; // adjust y position based on scroll offset

while (rc->type != UI_TERMINATOR) {
int w = 0, h = 0;
Expand Down Expand Up @@ -877,6 +881,18 @@ int diaExecuteDialog(struct UIItem *ui, int uiId, short inMenu, int (*updater)(i
setButtonDelay(KEY_UP, DIA_SCROLL_SPEED);
setButtonDelay(KEY_DOWN, DIA_SCROLL_SPEED);

// calculate content height and maximum scroll offset
scrollOffset = 0;
int lineCount = 0;
struct UIItem *item = ui;
while (item && item->type != UI_TERMINATOR) {
if ((item->type == UI_BREAK) || (item->type == UI_SPLITTER))
lineCount++;
item++;
}
int contentHeight = lineCount * 25;
maxScrollOffset = (contentHeight > screenHeight) ? (contentHeight - screenHeight) : 0;

// okay, we have the first selectable item
// we can proceed with rendering etc. etc.
while (1) {
Expand Down Expand Up @@ -911,15 +927,21 @@ int diaExecuteDialog(struct UIItem *ui, int uiId, short inMenu, int (*updater)(i
}

if (getKey(KEY_UP)) {
scrollOffset = max(0, scrollOffset - 12); // prevent negative scroll offset
newf = diaGetPrevLine(cur, ui);
if (newf == cur)
if (newf == cur) {
newf = diaGetLastControl(ui);
scrollOffset = maxScrollOffset;
}
}

if (getKey(KEY_DOWN)) {
scrollOffset = min(maxScrollOffset, scrollOffset + 12); // prevent exceeding max scroll offset
newf = diaGetNextLine(cur, ui);
if (newf == cur)
if (newf == cur) {
newf = diaGetFirstControl(ui);
scrollOffset = 0;
}
}

if (newf != cur) {
Expand Down
5 changes: 5 additions & 0 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ struct UIItem diaConfig[] = {
{UI_ENUM, CFG_APPMODE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_FAVMODE}}},
{UI_SPACER},
{UI_ENUM, CFG_FAVMODE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_DEFDEVICE}}},
{UI_SPACER},
{UI_ENUM, CFG_DEFDEVICE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}},
Expand Down
Loading