Safety first (for deletions)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "gfx.h"
|
||||
#include "gfxutils.h"
|
||||
#include <power/max17050.h>
|
||||
#include "../hid/hid.h"
|
||||
|
||||
void gfx_clearscreen(){
|
||||
int battery = 0;
|
||||
@@ -18,6 +19,26 @@ void gfx_clearscreen(){
|
||||
RESETCOLOR;
|
||||
}
|
||||
|
||||
u32 FromRGBtoU32(u8 r, u8 g, u8 b){
|
||||
return 0xFF000000 | r << 16 | g << 8 | b;
|
||||
int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg){
|
||||
u32 initialX = 0, initialY = 0;
|
||||
u32 highlight = 0;
|
||||
gfx_con_getpos(&initialX, &initialY);
|
||||
|
||||
while (1){
|
||||
for (int i = 0; i < len; i++){
|
||||
(highlight == i) ? SETCOLOR(bg, entries[i].optionUnion) : SETCOLOR(entries[i].optionUnion, bg);
|
||||
gfx_puts(entries[i].name);
|
||||
gfx_con.y -= spacesBetween * 16;
|
||||
}
|
||||
gfx_con_setpos(initialX, initialY);
|
||||
Input_t *input = hidWait();
|
||||
if (input->a)
|
||||
return highlight;
|
||||
else if (input->b)
|
||||
return 0;
|
||||
else if (input->left && highlight > 0)
|
||||
highlight--;
|
||||
else if (input->right && highlight < len - 1)
|
||||
highlight++;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "gfx.h"
|
||||
#include "menu.h"
|
||||
|
||||
#define COLOR_WHITE 0xFFFFFFFF
|
||||
#define COLOR_DEFAULT 0xFF1B1B1B
|
||||
@@ -10,6 +11,7 @@
|
||||
#define SETCOLOR(fg, bg) gfx_con_setcol(fg, 1, bg)
|
||||
#define RESETCOLOR SETCOLOR(COLOR_WHITE, COLOR_DEFAULT);
|
||||
|
||||
u32 FromRGBtoU32(u8 r, u8 g, u8 b);
|
||||
#define RGBUnionToU32(optionUnion) (optionUnion | 0xFF000000)
|
||||
|
||||
void gfx_clearscreen();
|
||||
void gfx_clearscreen();
|
||||
int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg);
|
||||
@@ -19,7 +19,7 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted, u32 bg){
|
||||
if (entry.hide)
|
||||
return;
|
||||
|
||||
(highlighted) ? SETCOLOR(bg, FromRGBtoU32(entry.R, entry.G, entry.B)) : SETCOLOR(FromRGBtoU32(entry.R, entry.G, entry.B), bg);
|
||||
(highlighted) ? SETCOLOR(bg, RGBUnionToU32(entry.optionUnion)) : SETCOLOR(RGBUnionToU32(entry.optionUnion), bg);
|
||||
|
||||
if (entry.icon){
|
||||
gfx_putc(entry.icon);
|
||||
|
||||
Reference in New Issue
Block a user