From f35c18a0c22935d88f3993470bed9cd691f4d32c Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 27 Apr 2020 09:13:22 +0300 Subject: [PATCH] nyx: Refresh emuMMC status after a creation --- nyx/nyx_gui/frontend/gui.c | 18 ++++++++++++++++++ nyx/nyx_gui/frontend/gui_emummc_tools.c | 24 ++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index b0a9e67..de49ee2 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -418,6 +418,24 @@ lv_obj_t *nyx_create_standard_window(const char *win_title) return win; } +lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action) +{ + static lv_style_t win_bg_style; + + lv_style_copy(&win_bg_style, &lv_style_plain); + win_bg_style.body.main_color = LV_COLOR_HEX(0x2D2D2D);// TODO: COLOR_HOS_BG + win_bg_style.body.grad_color = win_bg_style.body.main_color; + + lv_obj_t *win = lv_win_create(lv_scr_act(), NULL); + lv_win_set_title(win, win_title); + lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style); + lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES); + + lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", rel_action); + + return win; +} + static bool launch_logs_enable = false; static void _launch_hos(u8 autoboot, u8 autoboot_list) diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index e9164d0..36747f9 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -45,15 +45,28 @@ typedef struct _mbr_ctxt_t static mbr_ctxt_t mbr_ctx; +static lv_obj_t *emummc_manage_window; +static lv_res_t (*emummc_tools)(lv_obj_t *btn); + +static lv_res_t _action_emummc_window_close(lv_obj_t *btn) +{ + lv_win_close_action(btn); + lv_obj_del(emummc_manage_window); + + (*emummc_tools)(NULL); + + return LV_RES_INV; +} + static void _create_window_emummc() { emmc_tool_gui_t emmc_tool_gui_ctxt; lv_obj_t *win; if (!mbr_ctx.part_idx) - win = nyx_create_standard_window(SYMBOL_DRIVE" Create SD File emuMMC"); + win = nyx_create_window_custom_close_btn(SYMBOL_DRIVE" Create SD File emuMMC", _action_emummc_window_close); else - win = nyx_create_standard_window(SYMBOL_DRIVE" Create SD Partition emuMMC"); + win = nyx_create_window_custom_close_btn(SYMBOL_DRIVE" Create SD Partition emuMMC", _action_emummc_window_close); //Disable buttons. nyx_window_toggle_buttons(win, true); @@ -710,10 +723,6 @@ typedef struct _emummc_images_t static emummc_images_t *emummc_img; -static lv_obj_t *emummc_manage_window; - -static lv_res_t (*emummc_tools)(lv_obj_t *btn); - static lv_res_t _save_emummc_cfg_mbox_action(lv_obj_t *btns, const char *txt) { free(emummc_img->dirlist); @@ -789,7 +798,7 @@ static lv_res_t _save_file_emummc_cfg_action(lv_obj_t *btn) return LV_RES_INV; } -static lv_res_t _create_change_emummc_window() +static lv_res_t _create_change_emummc_window(lv_obj_t *btn_caller) { lv_obj_t *win = nyx_create_standard_window(SYMBOL_SETTINGS" Change emuMMC"); lv_win_add_btn(win, NULL, SYMBOL_POWER" Disable", _save_disable_emummc_cfg_action); @@ -1035,7 +1044,6 @@ lv_res_t create_win_emummc_tools(lv_obj_t *btn) emu_info.path = NULL; emu_info.nintendo_path = NULL; - //! TODO: Always update that info when something was changed. // Parse emuMMC configuration. LIST_INIT(ini_sections); if (ini_parse(&ini_sections, "emuMMC/emummc.ini", false))