Skip to content

Commit

Permalink
nyx: add no box and 5 entries per line support
Browse files Browse the repository at this point in the history
Icons that have `_nobox.bmp` in their name will make the grey background disappear.

Additionally a new option was added in Nyx Options called `Extended Boot Entries` that allows user to have a total of 10 entries showing up in Launch and More configs menus.
  • Loading branch information
CTCaer committed May 13, 2022
1 parent b9cdf5d commit c2ff5db
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 47 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ If the main .ini is not found, it is created on the first hekate boot and only h
| Config option | Description |
| ------------------ | ---------------------------------------------------------- |
| themecolor=167 | Sets Nyx color of text highlights. |
| entries5col=0 | 1: Sets Launch entry columns from 4 to 5 per line. For a total of 10 entries. |
| timeoff=100 | Sets time offset in HEX. Must be in HOS epoch format |
| homescreen=0 | Sets home screen. 0: Home menu, 1: All configs (merges Launch and More configs), 2: Launch, 3: More Configs. |
| verification=1 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and mostly reliable), 2: Full (sha256 based, slow and 100% reliable). |
| ------------------ | ------- The following options can only be edited in nyx.ini ------- |
| umsemmcrw=0 | 1: eMMC/emuMMC UMS will be mounted as writable by default. |
| jcdisable=0 | 1: Disables Joycon driver completely. |
| jcforceright=0 | 1: Forces right joycon to be used as main mouse control. |
Expand Down
6 changes: 4 additions & 2 deletions README_BOOTLOGO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ The bootlogo can be any size with a maximum of 720 x 1280.

When it's smaller than 720 x 1280, it is automatically centered and the background takes the color of the first pixel.

When saving a landscape bootlogo, it should be rotated 90 degrees counterclockwise.
The process is to create a landscape bootlogo and then rotate it 90 degrees counterclockwise.

Lastly, the supported format is 32-bit (ARGB) BMP. Classic 24-bit (RGB) BMPs are not supported for performance reasons.


## How to configure

If a boot entry specifies a custom logo path (`logopath=`), this is one will be loaded.
If a boot entry specifies a custom logo path (`logopath=`), this one will be loaded.

If the above is not found or the format is not correct, it will try to load `bootloader/bootlogo.bmp`.
If this is not found, the default hekate logo will be used.

(`bootloader/bootlogo.bmp` is basically like a global bootlogo.)
6 changes: 4 additions & 2 deletions nyx/README_RES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

The background for Nyx, must be a 1280 x 720 32-bit BMP. Alpha blending is taken into account. For that reason, if a solid background is required, that value must be 0xFF. There are sites that can produce the correct bmp.

The icons supported are 192 x 192 32-bit BMP. You can utilize transparency at will and make nice mixes with the button background.
The icons supported are 192 x 192 32-bit BMP. You can utilize transparency at will and make nice mixes with the button background.

Additionally, using the `icon={sd path}`, the icon will get colorized if the name ends in `_hue.bmp`. That only works nicely if the icon is a white layout with transparency.

If `_nobox.bmp` is used then the button background is removed. Useful for icon themes that aim for a specific style.

The default system icons (`icon_switch.bmp` and `icon_payload.bmp`) can be replaced with white layouts that have transparency. They can also be replaced with normal icons if the following exist: `icon_switch_custom.bmp` or/and `icon_payload_custom.bmp`


## How to configure

The background must go to /bootloader/res/background.bmp

The icons can be utilized either via `[boot entries names]` -> `boot entries names.bmp` or by using `icon={sd path}`, which should point at a bmp.
The icons can be utilized either via `[boot entries names]` -> `boot entries names.bmp` or by using `icon={sd path}` (preferred method), which should point at a bmp.
8 changes: 6 additions & 2 deletions nyx/nyx_gui/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void set_default_configuration()

void set_nyx_default_configuration()
{
n_cfg.themecolor = 167;
n_cfg.theme_color = 167;
n_cfg.entries_5_columns = 0;
n_cfg.timeoff = 0;
n_cfg.home_screen = 0;
n_cfg.verification = 1;
Expand Down Expand Up @@ -194,7 +195,10 @@ int create_nyx_config_entry(bool force_unmount)

// Add config entry.
f_puts("[config]\nthemecolor=", &fp);
itoa(n_cfg.themecolor, lbuf, 10);
itoa(n_cfg.theme_color, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nentries5col=", &fp);
itoa(n_cfg.entries_5_columns, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\ntimeoff=", &fp);
itoa(n_cfg.timeoff, lbuf, 16);
Expand Down
3 changes: 2 additions & 1 deletion nyx/nyx_gui/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ typedef struct _hekate_config

typedef struct _nyx_config
{
u32 themecolor;
u32 theme_color;
u32 entries_5_columns;
u32 timeoff;
u32 home_screen;
u32 verification;
Expand Down
90 changes: 65 additions & 25 deletions nyx/nyx_gui/frontend/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ lv_style_t mbox_darken;

char *text_color;

typedef struct _gui_status_bar_ctx
{
lv_obj_t *mid;
lv_obj_t *time_temp;
lv_obj_t *temp_symbol;
lv_obj_t *temp_degrees;
lv_obj_t *battery;
lv_obj_t *battery_more;
} gui_status_bar_ctx;

typedef struct _jc_lv_driver_t
{
lv_indev_t *indev;
Expand All @@ -92,7 +82,7 @@ typedef struct _jc_lv_driver_t

static jc_lv_driver_t jc_drv_ctx;

static gui_status_bar_ctx status_bar;
gui_status_bar_ctx status_bar;

static void _nyx_disp_init()
{
Expand Down Expand Up @@ -1411,8 +1401,8 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
}
typedef struct _launch_menu_entries_t
{
lv_obj_t *btn[16];
lv_obj_t *label[16];
lv_obj_t *btn[20];
lv_obj_t *label[20];
} launch_menu_entries_t;

static launch_menu_entries_t launch_ctxt;
Expand Down Expand Up @@ -1543,24 +1533,49 @@ typedef struct _launch_button_pos_t
u16 btn_y;
u16 lbl_x;
u16 lbl_y;

} launch_button_pos_t;

static const launch_button_pos_t launch_button_pos[8] = {
static const launch_button_pos_t launch_button_pos8[8] = {
// First row.
{ 19, 36, 0, 245 },
{ 340, 36, 321, 245 },
{ 661, 36, 642, 245 },
{ 982, 36, 963, 245 },
// Second row.
{ 19, 313, 0, 522 },
{ 340, 313, 321, 522 },
{ 661, 313, 642, 522 },
{ 982, 313, 963, 522 }
};

static const launch_button_pos_t launch_button_pos10[10] = {
// First row.
{ 19, 36, 0, 245},
{260, 36, 241, 245},
{501, 36, 482, 245},
{742, 36, 723, 245},
{983, 36, 964, 245},
// Second row.
{ 19, 313, 0, 522},
{260, 313, 241, 522},
{501, 313, 482, 522},
{742, 313, 723, 522},
{983, 313, 964, 522}
};

static lv_res_t _create_window_home_launch(lv_obj_t *btn)
{
const u32 max_entries = n_cfg.entries_5_columns ? 10 : 8;
const launch_button_pos_t *launch_button_pos = n_cfg.entries_5_columns ? launch_button_pos10 : launch_button_pos8;

char *icon_path;

static lv_style_t btn_home_noborder_rel;
lv_style_copy(&btn_home_noborder_rel, lv_theme_get_current()->btn.rel);
btn_home_noborder_rel.body.opa = LV_OPA_0;
btn_home_noborder_rel.body.border.width = 4;
btn_home_noborder_rel.body.border.opa = LV_OPA_0;

static lv_style_t btn_home_transp_rel;
lv_style_copy(&btn_home_transp_rel, lv_theme_get_current()->btn.rel);
btn_home_transp_rel.body.opa = LV_OPA_0;
Expand Down Expand Up @@ -1611,14 +1626,12 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
lv_cont_set_fit(lv_page_get_scrl(lv_win_get_content(win)), false, false);
lv_page_set_scrl_height(lv_win_get_content(win), 572);

lv_btn_ext_t * ext;
lv_obj_t *btn_boot_entry;
lv_obj_t *boot_entry_lbl_cont;
lv_obj_t *boot_entry_label;
bool no_boot_entries = false;

u32 max_entries = 8;
lv_btn_ext_t * ext;

// Create CFW buttons.
// Buttons are 200 x 200 with 4 pixel borders.
// Icons must be <= 192 x 192.
Expand All @@ -1644,7 +1657,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
lv_obj_set_style(boot_entry_lbl_cont, &btn_label_home_transp);

// Create the rest of the buttons.
for (u32 btn_idx = 1; btn_idx < 8; btn_idx++)
for (u32 btn_idx = 1; btn_idx < (n_cfg.entries_5_columns ? 10 : 8); btn_idx++)
{
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt.btn[btn_idx] = btn_boot_entry;
Expand All @@ -1659,7 +1672,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
// Create colorized icon style based on its parrent style.
static lv_style_t img_style;
lv_style_copy(&img_style, &lv_style_plain);
img_style.image.color = lv_color_hsv_to_rgb(n_cfg.themecolor, 100, 100);
img_style.image.color = lv_color_hsv_to_rgb(n_cfg.theme_color, 100, 100);
img_style.image.intense = LV_OPA_COVER;

// Parse ini boot entries and set buttons/icons.
Expand Down Expand Up @@ -1704,6 +1717,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
icon_path = NULL;
bool payload = false;
bool img_colorize = false;
bool img_noborder = false;
lv_img_dsc_t *bmp = NULL;
lv_obj_t *img = NULL;

Expand All @@ -1728,6 +1742,10 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
bmp = bmp_to_lvimg_obj(tmp_path);
if (bmp)
img_colorize = true;
s_printf(tmp_path, "bootloader/res/%s_nobox.bmp", ini_sec->name);
bmp = bmp_to_lvimg_obj(tmp_path);
if (bmp)
img_noborder = true;
}

if (!bmp && payload)
Expand All @@ -1745,6 +1763,10 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
// Check if colorization is enabled.
if (bmp && strlen(icon_path) > 8 && !memcmp(icon_path + strlen(icon_path) - 8, "_hue", 4))
img_colorize = true;

// Check if no border is enabled.
if (bmp && strlen(icon_path) > 8 && !memcmp(icon_path + strlen(icon_path) - 10, "_nobox", 4))
img_noborder = true;
}

// Enable button.
Expand Down Expand Up @@ -1772,11 +1794,28 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)

// Add button mask/radius and align icon.
lv_obj_t *btn = lv_btn_create(launch_ctxt.btn[curr_btn_idx], NULL);
lv_obj_set_size(btn, 200, 200);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel);
u32 btn_width = 200;
u32 btn_height = 200;
if (img_noborder)
{
btn_width = bmp->header.w + 4;
btn_height = bmp->header.h + 4;

if (btn_width > 200)
btn_width = 200;
if (btn_height > 200)
btn_height = 200;

lv_btn_set_style(launch_ctxt.btn[curr_btn_idx], LV_BTN_STYLE_REL, &btn_home_noborder_rel);
lv_btn_set_style(launch_ctxt.btn[curr_btn_idx], LV_BTN_STYLE_PR, &btn_home_noborder_rel);
}
lv_obj_set_size(btn, btn_width, btn_height);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, img_noborder ? &btn_home_noborder_rel : &btn_home_transp_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr);
if (img)
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
if (img_noborder)
lv_obj_align(btn, NULL, LV_ALIGN_CENTER, 0, 0);

// Set autoboot index.
ext = lv_obj_get_ext_attr(btn);
Expand Down Expand Up @@ -1808,7 +1847,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)

ini_parse_failed:
// Reiterate the loop with more cfgs if combined.
if (combined_cfg && (curr_btn_idx < 8) && !more_cfg)
if (combined_cfg && (curr_btn_idx < (n_cfg.entries_5_columns ? 10 : 8)) && !more_cfg)
goto ini_parsing;

failed_sd_mount:
Expand Down Expand Up @@ -2094,6 +2133,7 @@ static lv_res_t _show_hide_save_button(lv_obj_t *tv, uint16_t tab_idx)
{
if (tab_idx == 4) // Options.
{
lv_btn_set_action(status_bar.mid, LV_BTN_ACTION_CLICK, _save_options_action);
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_COVER);
lv_obj_set_click(status_bar.mid, true);
}
Expand Down Expand Up @@ -2174,7 +2214,7 @@ static void _nyx_set_default_styles(lv_theme_t * th)
tabview_btn_tgl_pr.body.grad_color = tabview_btn_tgl_pr.body.main_color;
tabview_btn_tgl_pr.body.opa = 35;

lv_color_t tmp_color = lv_color_hsv_to_rgb(n_cfg.themecolor, 100, 100);
lv_color_t tmp_color = lv_color_hsv_to_rgb(n_cfg.theme_color, 100, 100);
text_color = malloc(32);
s_printf(text_color, "#%06X", (u32)(tmp_color.full & 0xFFFFFF));
}
Expand Down Expand Up @@ -2351,7 +2391,7 @@ void nyx_load_and_run()
tmp451_init();

// Set hekate theme based on chosen hue.
lv_theme_t *th = lv_theme_hekate_init(n_cfg.themecolor, NULL);
lv_theme_t *th = lv_theme_hekate_init(n_cfg.theme_color, NULL);
lv_theme_set_current(th);

// Create main menu
Expand Down
13 changes: 13 additions & 0 deletions nyx/nyx_gui/frontend/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ typedef struct _emmc_tool_gui_t
bool raw_emummc;
} emmc_tool_gui_t;

typedef struct _gui_status_bar_ctx
{
lv_obj_t *mid;
lv_obj_t *time_temp;
lv_obj_t *temp_symbol;
lv_obj_t *temp_degrees;
lv_obj_t *battery;
lv_obj_t *battery_more;
lv_obj_t *monitor;
} gui_status_bar_ctx;

extern lv_style_t hint_small_style;
extern lv_style_t hint_small_style_white;
extern lv_style_t monospace_text;
Expand All @@ -56,6 +67,8 @@ extern lv_style_t mbox_darken;

extern char *text_color;

extern gui_status_bar_ctx status_bar;

void reload_nyx();
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path);
lv_res_t mbox_action(lv_obj_t * btns, const char * txt);
Expand Down
Loading

0 comments on commit c2ff5db

Please sign in to comment.