forked from Ports/perfect_dark
Implement a simple colored box menu item type and use that for the preview.
This commit is contained in:
1 parent
519bd95a75
commit
79fb976bcf
5 files changed
+45
-4
No files matched your search
@@ -971,7 +971,6 @@ static MenuItemHandlerResult menuhandlerCrosshairColorPreview(s32 operation, str
|
||||
{
|
||||
if (operation == MENUOP_GETCOLOUR) {
|
||||
data->label.colour1 = g_PlayerExtCfg[g_ExtMenuPlayer].crosshaircolour;
|
||||
data->label.colour2 = g_PlayerExtCfg[g_ExtMenuPlayer].crosshaircolour;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1019,10 +1018,10 @@ struct menuitem g_ExtendedGameCrosshairColourMenuItems[] = {
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_LABEL,
|
||||
MENUITEMTYPE_COLORBOX,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_LABEL_CUSTOMCOLOUR | MENUITEMFLAG_SELECTABLE_CENTRE,
|
||||
(uintptr_t)"PREVIEW\n",
|
||||
0,
|
||||
menuhandlerCrosshairColorPreview,
|
||||
},
|
||||
|
||||
@@ -1178,6 +1178,9 @@ bool menuIsItemFocusable(struct menuitem *item, struct menudialog *dialog, s32 a
|
||||
case MENUITEMTYPE_METER:
|
||||
case MENUITEMTYPE_MARQUEE:
|
||||
case MENUITEMTYPE_CONTROLLER:
|
||||
#ifndef PLATFORM_N64
|
||||
case MENUITEMTYPE_COLORBOX:
|
||||
#endif
|
||||
return false;
|
||||
case MENUITEMTYPE_10:
|
||||
case MENUITEMTYPE_14:
|
||||
|
||||
@@ -2109,6 +2109,36 @@ Gfx *menuitemMeterRender(Gfx *gdl, struct menurendercontext *context)
|
||||
return gdl;
|
||||
}
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
|
||||
// Draws a colored box which fills the background of the menu item.
|
||||
Gfx* menuitemColorBoxRender(Gfx *gdl, struct menurendercontext *context)
|
||||
{
|
||||
u32 width = context->width;
|
||||
u32 height = context->height;
|
||||
u32 colour1;
|
||||
s32 x1;
|
||||
s32 x2;
|
||||
|
||||
x1 = context->x;
|
||||
x2 = x1 + width;
|
||||
|
||||
union handlerdata data;
|
||||
if (context->item->handlervoid) {
|
||||
context->item->handlervoid(MENUOP_GETCOLOUR, context->item, &data);
|
||||
}
|
||||
|
||||
colour1 = data.label.colour1;
|
||||
|
||||
gdl = textSetPrimColour(gdl, colour1);
|
||||
gDPFillRectangleScaled(gdl++, x1, context->y, x2, context->y + height);
|
||||
gdl = text0f153838(gdl);
|
||||
|
||||
return gdl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Gfx *menuitemSelectableRender(Gfx *gdl, struct menurendercontext *context)
|
||||
{
|
||||
u32 leftcolour;
|
||||
@@ -4349,6 +4379,7 @@ Gfx *menuitemRender(Gfx *gdl, struct menurendercontext *context)
|
||||
case MENUITEMTYPE_CAROUSEL: return menuitemCarouselRender(gdl, context);
|
||||
case MENUITEMTYPE_MODEL: return menuitemModelRender(gdl, context);
|
||||
case MENUITEMTYPE_CONTROLLER: return menuitemControllerRender(gdl, context);
|
||||
case MENUITEMTYPE_COLORBOX: return menuitemColorBoxRender(gdl, context);
|
||||
}
|
||||
|
||||
return gdl;
|
||||
|
||||
@@ -1692,6 +1692,10 @@
|
||||
#define MENUITEMTYPE_CONTROLLER 0x19
|
||||
#define MENUITEMTYPE_END 0x1a
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
#define MENUITEMTYPE_COLORBOX 0x1b
|
||||
#endif
|
||||
|
||||
#define MENUMODELFLAG_HASSCALE 0x01
|
||||
#define MENUMODELFLAG_HASPOSITION 0x02
|
||||
#define MENUMODELFLAG_HASROTATION 0x04
|
||||
|
||||
@@ -32,6 +32,10 @@ Gfx *menuitemLabelRender(Gfx *gdl, struct menurendercontext *context);
|
||||
|
||||
Gfx *menuitemMeterRender(Gfx *gdl, struct menurendercontext *context);
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
Gfx *menuitemColorBoxRender(Gfx *gdl, struct menurendercontext *context);
|
||||
#endif
|
||||
|
||||
Gfx *menuitemSelectableRender(Gfx *gdl, struct menurendercontext *context);
|
||||
bool menuitemSelectableTick(struct menuitem *item, struct menuinputs *inputs, u32 tickflags);
|
||||
|
||||
|
||||
Reference in new issue
Block a user