Skip to content
This repository was archived by the owner on Mar 18, 2023. It is now read-only.

Commit 2b5c4ff

Browse files
committed
Add menu item type with "hamburger" icon.
1 parent 46312f9 commit 2b5c4ff

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ endif
5252
# Graphic resources
5353
OBJS += resources/background_png.o
5454
OBJS += resources/check_png.o
55+
OBJS += resources/hamburgerIcon_png.o
5556
OBJS += resources/gamepad_png.o
5657
OBJS += resources/cube_png.o
5758
OBJS += resources/savemanager_png.o
@@ -113,6 +114,8 @@ endif
113114
@# Graphics
114115
@bin2o resources/background.png resources/background_png.o _background_png
115116
@bin2o resources/check.png resources/check_png.o _check_png
117+
@bin2o resources/hamburgerIcon.png resources/hamburgerIcon_png.o _hamburgerIcon_png
118+
116119
@bin2o resources/gamepad.png resources/gamepad_png.o _gamepad_png
117120
@bin2o resources/cube.png resources/cube_png.o _cube_png
118121
@bin2o resources/savemanager.png resources/savemanager_png.o _savemanager_png

resources/hamburgerIcon.png

2.8 KB
Loading

resources/hamburgerIcon.psd

30.3 KB
Binary file not shown.

src/graphics.c

+21
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef struct menuIcon {
2020
static GSGLOBAL *gsGlobal;
2121
static GSTEXTURE bg;
2222
static GSTEXTURE check;
23+
static GSTEXTURE hamburgerIcon;
2324
static GSTEXTURE font;
2425
static GSTEXTURE gamepad;
2526
static GSTEXTURE cube;
@@ -48,6 +49,8 @@ extern u8 _background_png_start[];
4849
extern int _background_png_size;
4950
extern u8 _check_png_start[];
5051
extern int _check_png_size;
52+
extern u8 _hamburgerIcon_png_start[];
53+
extern int _hamburgerIcon_png_size;
5154
extern u8 _gamepad_png_start[];
5255
extern int _gamepad_png_size;
5356
extern u8 _cube_png_start[];
@@ -173,6 +176,7 @@ int initGraphics()
173176
graphicsLoadPNG(&check, _check_png_start, _check_png_size, 0);
174177
graphicsLoadPNG(&gamepad, _gamepad_png_start, _gamepad_png_size, 1);
175178
graphicsLoadPNG(&cube, _cube_png_start, _cube_png_size, 1);
179+
graphicsLoadPNG(&hamburgerIcon, _hamburgerIcon_png_start, _hamburgerIcon_png_size, 0);
176180
graphicsLoadPNG(&savemanager, _savemanager_png_start, _savemanager_png_size, 1);
177181
graphicsLoadPNG(&flashdrive, _flashdrive_png_start, _flashdrive_png_size, 1);
178182
graphicsLoadPNG(&memorycard1, _memorycard1_png_start, _memorycard1_png_size, 1);
@@ -705,6 +709,23 @@ void graphicsDrawPointer(float x, float y)
705709
gsKit_set_primalpha(gsGlobal, GS_BLEND_BACK2FRONT, 0);
706710
}
707711

712+
void graphicsDrawHamburger(float x, float y)
713+
{
714+
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0);
715+
gsKit_prim_sprite_texture(gsGlobal, &hamburgerIcon,
716+
x,
717+
y,
718+
0,
719+
0,
720+
x + hamburgerIcon.Width,
721+
y + hamburgerIcon.Height,
722+
hamburgerIcon.Width,
723+
hamburgerIcon.Height,
724+
1,
725+
0x80808080);
726+
gsKit_set_primalpha(gsGlobal, GS_BLEND_BACK2FRONT, 0);
727+
}
728+
708729
float graphicsGetWidthSubString(const char *str, int n)
709730
{
710731
if(!str)

src/graphics.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void graphicsDrawDeviceMenu(int activeItem);
3838
void graphicsDrawAboutPage();
3939
// Draw selection pointer at (x,y)
4040
void graphicsDrawPointer(float x, float y);
41+
// Draw hamburger icon at (x,y)
42+
void graphicsDrawHamburger(float x, float y);
4143
// Draw blue translucent rectangular box
4244
void graphicsDrawPromptBox(float width, float height);
4345
// Draw solid black rectangular box

src/menus.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static void drawMenuItems()
661661
{
662662
menuItem_t *item = activeMenu->items[idx];
663663

664-
if(item->type == MENU_ITEM_NORMAL)
664+
if(item->type == MENU_ITEM_NORMAL || item->type == MENU_ITEM_HAMBURGER_BUTTON)
665665
{
666666
if(activeMenu->identifier == MENU_CHEATS && item->extra && ((cheatsCheat_t *) item->extra)->enabled)
667667
graphicsDrawText(50, y, COLOR_YELLOW, item->text);
@@ -679,6 +679,11 @@ static void drawMenuItems()
679679
graphicsDrawText(50, y, COLOR_GREEN, item->text);
680680
}
681681

682+
if(item->type == MENU_ITEM_HAMBURGER_BUTTON)
683+
{
684+
graphicsDrawHamburger(graphicsGetDisplayWidth() - 50, y);
685+
}
686+
682687
if(idx == activeMenu->currentItem)
683688
graphicsDrawPointer(28, y+5);
684689

src/menus.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ typedef enum {
2121

2222
typedef enum {
2323
MENU_ITEM_NORMAL,
24-
MENU_ITEM_HEADER
24+
MENU_ITEM_HEADER,
25+
MENU_ITEM_HAMBURGER_BUTTON, // Normal item with hamburger button near it
2526
} menuItemType_t;
2627

2728
typedef enum {

0 commit comments

Comments
 (0)