1.0.53 release

pull/1113/head v1.0.53
longpanda 3 years ago
parent 89a34bac18
commit d72bb15956

File diff suppressed because it is too large Load Diff

@ -59,11 +59,15 @@ struct grub_gui_label
grub_font_t font; grub_font_t font;
grub_video_rgba_color_t color; grub_video_rgba_color_t color;
int value; int value;
int vtoytip;
enum align_mode align; enum align_mode align;
}; };
typedef struct grub_gui_label *grub_gui_label_t; typedef struct grub_gui_label *grub_gui_label_t;
extern const char * g_ventoy_tip_msg1;
extern const char * g_ventoy_tip_msg2;
static void static void
label_destroy (void *vself) label_destroy (void *vself)
{ {
@ -90,6 +94,7 @@ label_is_instance (void *vself __attribute__((unused)), const char *type)
static void static void
label_paint (void *vself, const grub_video_rect_t *region) label_paint (void *vself, const grub_video_rect_t *region)
{ {
const char *text;
grub_gui_label_t self = vself; grub_gui_label_t self = vself;
if (! self->visible) if (! self->visible)
@ -98,16 +103,24 @@ label_paint (void *vself, const grub_video_rect_t *region)
if (!grub_video_have_common_points (region, &self->bounds)) if (!grub_video_have_common_points (region, &self->bounds))
return; return;
if (self->vtoytip == 1) {
text = g_ventoy_tip_msg1 ? g_ventoy_tip_msg1 : "";
} else if (self->vtoytip == 2) {
text = g_ventoy_tip_msg2 ? g_ventoy_tip_msg2 : "";
} else {
text = self->text;
}
/* Calculate the starting x coordinate. */ /* Calculate the starting x coordinate. */
int left_x; int left_x;
if (self->align == align_left) if (self->align == align_left)
left_x = 0; left_x = 0;
else if (self->align == align_center) else if (self->align == align_center)
left_x = (self->bounds.width left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text)) / 2; - grub_font_get_string_width (self->font, text)) / 2;
else if (self->align == align_right) else if (self->align == align_right)
left_x = (self->bounds.width left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text)); - grub_font_get_string_width (self->font, text));
else else
return; /* Invalid alignment. */ return; /* Invalid alignment. */
@ -116,7 +129,7 @@ label_paint (void *vself, const grub_video_rect_t *region)
grub_video_rect_t vpsave; grub_video_rect_t vpsave;
grub_gui_set_viewport (&self->bounds, &vpsave); grub_gui_set_viewport (&self->bounds, &vpsave);
grub_font_draw_string (self->text, grub_font_draw_string (text,
self->font, self->font,
grub_video_map_rgba_color (self->color), grub_video_map_rgba_color (self->color),
left_x, left_x,
@ -156,8 +169,8 @@ static void
label_get_minimal_size (void *vself, unsigned *width, unsigned *height) label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
{ {
grub_gui_label_t self = vself; grub_gui_label_t self = vself;
*width = grub_font_get_string_width (self->font, self->text); *width = grub_font_get_string_width (self->font, self->text);
*height = (grub_font_get_ascent (self->font) *height = (grub_font_get_ascent (self->font)
+ grub_font_get_descent (self->font)); + grub_font_get_descent (self->font));
} }
@ -255,8 +268,14 @@ label_set_property (void *vself, const char *name, const char *value)
{ {
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self); grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
grub_free (self->id); grub_free (self->id);
if (value) if (value) {
self->id = grub_strdup (value); self->id = grub_strdup (value);
if (grub_strcmp(value, "VTOY_MENU_TIP_1") == 0) {
self->vtoytip = 1;
} else if (grub_strcmp(value, "VTOY_MENU_TIP_2") == 0) {
self->vtoytip = 2;
}
}
else else
self->id = 0; self->id = 0;
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID) if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)

@ -733,6 +733,8 @@ done:
return grub_errno; return grub_errno;
} }
extern int g_menu_update_mode;
/* Set properties on the view based on settings from the specified /* Set properties on the view based on settings from the specified
theme file. */ theme file. */
grub_err_t grub_err_t
@ -752,7 +754,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
} }
p.len = grub_file_size (file); p.len = grub_file_size (file);
p.buf = grub_malloc (p.len + 4096); p.buf = grub_malloc (p.len + 8192);
p.pos = 0; p.pos = 0;
p.line_num = 1; p.line_num = 1;
p.col_num = 1; p.col_num = 1;
@ -781,6 +783,33 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
} }
} }
{
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
if (tip && tip[0] == '1')
{
char tmpmsg[512];
grub_memset(tmpmsg, 'w', 500);
tmpmsg[500] = 0;
g_menu_update_mode = 1;
p.len += grub_snprintf(p.buf + p.len, 4096,
"\n+ vbox{\n left = %s\n top = %s\n"
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"}\n",
grub_env_get("VTOY_TIP_LEFT"),
grub_env_get("VTOY_TIP_TOP"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN")
);
}
}
if (view->canvas) if (view->canvas)
view->canvas->component.ops->destroy (view->canvas); view->canvas->component.ops->destroy (view->canvas);

@ -386,21 +386,37 @@ redraw_menu_visit (grub_gui_component_t component,
} }
} }
extern int g_menu_update_mode;
static void grub_gfxmenu_update_all(grub_gfxmenu_view_t view)
{
grub_video_set_area_status(GRUB_VIDEO_AREA_DISABLED);
grub_gfxmenu_view_redraw(view, &view->screen);
}
void void
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view) grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
{ {
update_menu_components (view); update_menu_components (view);
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas, if (g_menu_update_mode)
redraw_menu_visit, view); grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
grub_video_swap_buffers (); grub_video_swap_buffers ();
if (view->double_repaint) if (view->double_repaint)
{ {
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas, if (g_menu_update_mode)
redraw_menu_visit, view); grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
} }
} }
void void
grub_gfxmenu_set_chosen_entry (int entry, void *data) grub_gfxmenu_set_chosen_entry (int entry, void *data)
{ {
@ -408,6 +424,8 @@ grub_gfxmenu_set_chosen_entry (int entry, void *data)
view->selected = entry; view->selected = entry;
grub_gfxmenu_redraw_menu (view); grub_gfxmenu_redraw_menu (view);
} }
static void static void

@ -33,6 +33,9 @@
#include <grub/gfxterm.h> #include <grub/gfxterm.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/env.h> #include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/ventoy.h>
#include "ventoy/ventoy_def.h"
int g_ventoy_menu_refresh = 0; int g_ventoy_menu_refresh = 0;
int g_ventoy_memdisk_mode = 0; int g_ventoy_memdisk_mode = 0;
@ -381,10 +384,28 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
static struct grub_menu_viewer *viewers; static struct grub_menu_viewer *viewers;
int g_menu_update_mode = 0;
int g_ventoy_tip_label_enable = 0;
const char * g_ventoy_tip_msg1 = NULL;
const char * g_ventoy_tip_msg2 = NULL;
static void static void
menu_set_chosen_entry (int entry) menu_set_chosen_entry (grub_menu_t menu, int entry)
{ {
struct grub_menu_viewer *cur; struct grub_menu_viewer *cur;
img_info *img;
grub_menu_entry_t e = grub_menu_get_entry (menu, entry);
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0) {
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
if (img)
{
g_ventoy_tip_msg1 = img->tip1;
g_ventoy_tip_msg2 = img->tip2;
}
}
for (cur = viewers; cur; cur = cur->next) for (cur = viewers; cur; cur = cur->next)
cur->set_chosen_entry (entry, cur->data); cur->set_chosen_entry (entry, cur->data);
} }
@ -732,13 +753,13 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_HOME: case GRUB_TERM_KEY_HOME:
case GRUB_TERM_CTRL | 'a': case GRUB_TERM_CTRL | 'a':
current_entry = 0; current_entry = 0;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case GRUB_TERM_KEY_END: case GRUB_TERM_KEY_END:
case GRUB_TERM_CTRL | 'e': case GRUB_TERM_CTRL | 'e':
current_entry = menu->size - 1; current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case GRUB_TERM_KEY_UP: case GRUB_TERM_KEY_UP:
@ -746,7 +767,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case '^': case '^':
if (current_entry > 0) if (current_entry > 0)
current_entry--; current_entry--;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case GRUB_TERM_CTRL | 'n': case GRUB_TERM_CTRL | 'n':
@ -754,7 +775,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case 'v': case 'v':
if (current_entry < menu->size - 1) if (current_entry < menu->size - 1)
current_entry++; current_entry++;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case GRUB_TERM_CTRL | 'g': case GRUB_TERM_CTRL | 'g':
@ -763,7 +784,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry = 0; current_entry = 0;
else else
current_entry -= GRUB_MENU_PAGE_SIZE; current_entry -= GRUB_MENU_PAGE_SIZE;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case GRUB_TERM_CTRL | 'c': case GRUB_TERM_CTRL | 'c':
@ -772,7 +793,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry += GRUB_MENU_PAGE_SIZE; current_entry += GRUB_MENU_PAGE_SIZE;
else else
current_entry = menu->size - 1; current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry); menu_set_chosen_entry (menu, current_entry);
break; break;
case '\n': case '\n':

@ -1562,6 +1562,7 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
grub_size_t len; grub_size_t len;
img_info *img; img_info *img;
img_info *tail; img_info *tail;
const menu_tip *tip;
img_iterator_node *tmp; img_iterator_node *tmp;
img_iterator_node *new_node; img_iterator_node *new_node;
img_iterator_node *node = (img_iterator_node *)data; img_iterator_node *node = (img_iterator_node *)data;
@ -1779,6 +1780,14 @@ static int ventoy_collect_img_files(const char *filename, const struct grub_dirh
g_ventoy_img_count++; g_ventoy_img_count++;
img->alias = ventoy_plugin_get_menu_alias(vtoy_alias_image_file, img->path); img->alias = ventoy_plugin_get_menu_alias(vtoy_alias_image_file, img->path);
tip = ventoy_plugin_get_menu_tip(img->path);
if (tip)
{
img->tip1 = tip->tip1;
img->tip2 = tip->tip2;
}
img->class = ventoy_plugin_get_menu_class(vtoy_class_image_file, img->name, img->path); img->class = ventoy_plugin_get_menu_class(vtoy_class_image_file, img->name, img->path);
if (!img->class) if (!img->class)
{ {
@ -2073,23 +2082,23 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
if (g_tree_view_menu_style == 0) if (g_tree_view_menu_style == 0)
{ {
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%d\" {\n" "menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
" %s_%s \n" " %s_%s \n"
"}\n", "}\n",
grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT), grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
img->unsupport ? "[***********] " : "", img->unsupport ? "[***********] " : "",
img->alias ? img->alias : img->name, img->class, img->id, img->alias ? img->alias : img->name, img->class, img,
img->menu_prefix, img->menu_prefix,
img->unsupport ? "unsupport_menuentry" : "common_menuentry"); img->unsupport ? "unsupport_menuentry" : "common_menuentry");
} }
else else
{ {
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%d\" {\n" "menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
" %s_%s \n" " %s_%s \n"
"}\n", "}\n",
img->unsupport ? "[***********] " : "", img->unsupport ? "[***********] " : "",
img->alias ? img->alias : img->name, img->class, img->id, img->alias ? img->alias : img->name, img->class, img,
img->menu_prefix, img->menu_prefix,
img->unsupport ? "unsupport_menuentry" : "common_menuentry"); img->unsupport ? "unsupport_menuentry" : "common_menuentry");
} }
@ -2136,7 +2145,7 @@ static int ventoy_set_default_menu(void)
if (0 == g_default_menu_mode) if (0 == g_default_menu_mode)
{ {
vtoy_ssprintf(g_list_script_buf, g_list_script_pos, "set default='VID_%d'\n", default_node->id); vtoy_ssprintf(g_list_script_buf, g_list_script_pos, "set default='VID_%p'\n", default_node);
} }
else else
{ {
@ -2169,7 +2178,7 @@ static int ventoy_set_default_menu(void)
pos = end + 1; pos = end + 1;
} }
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "VID_%d'\n", default_node->id); vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "VID_%p'\n", default_node);
grub_free(def); grub_free(def);
} }
} }
@ -2266,7 +2275,7 @@ static grub_err_t ventoy_cmd_ext_select_img_path(grub_extcmd_context_t ctxt, int
return grub_error(GRUB_ERR_BAD_ARGUMENT, "No such image"); return grub_error(GRUB_ERR_BAD_ARGUMENT, "No such image");
} }
grub_snprintf(id, sizeof(id), "VID_%d", cur->id); grub_snprintf(id, sizeof(id), "VID_%p", cur);
grub_env_set("chosen", id); grub_env_set("chosen", id);
grub_env_export("chosen"); grub_env_export("chosen");
@ -2275,11 +2284,10 @@ static grub_err_t ventoy_cmd_ext_select_img_path(grub_extcmd_context_t ctxt, int
static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args) static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args)
{ {
int img_id = 0;
char value[32]; char value[32];
char *pos = NULL; char *pos = NULL;
const char *id = NULL; const char *id = NULL;
img_info *cur = g_ventoy_img_list; img_info *cur = NULL;
(void)ctxt; (void)ctxt;
@ -2293,20 +2301,11 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
pos = grub_strstr(id, "VID_"); pos = grub_strstr(id, "VID_");
if (pos) if (pos)
{ {
img_id = (int)grub_strtoul(pos + 4, NULL, 10); cur = (img_info *)(void *)grub_strtoul(pos + 4, NULL, 16);
} }
else else
{ {
img_id = (int)grub_strtoul(id, NULL, 10); cur = g_ventoy_img_list;
}
while (cur)
{
if (img_id == cur->id)
{
break;
}
cur = cur->next;
} }
if (!cur) if (!cur)
@ -2335,12 +2334,14 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
grub_device_t dev = NULL; grub_device_t dev = NULL;
img_info *cur = NULL; img_info *cur = NULL;
img_info *tail = NULL; img_info *tail = NULL;
img_info *min = NULL;
img_info *head = NULL;
const char *strdata = NULL; const char *strdata = NULL;
char *device_name = NULL; char *device_name = NULL;
char buf[32]; char buf[32];
img_iterator_node *node = NULL; img_iterator_node *node = NULL;
img_iterator_node *tmp = NULL; img_iterator_node *tmp = NULL;
(void)ctxt; (void)ctxt;
if (argc != 2) if (argc != 2)
@ -2470,17 +2471,49 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
} }
/* sort image list by image name */ /* sort image list by image name */
for (cur = g_ventoy_img_list; cur; cur = cur->next) while (g_ventoy_img_list)
{ {
for (tail = cur->next; tail; tail = tail->next) min = g_ventoy_img_list;
for (cur = g_ventoy_img_list->next; cur; cur = cur->next)
{ {
if (ventoy_cmp_img(cur, tail) > 0) if (ventoy_cmp_img(min, cur) > 0)
{ {
ventoy_swap_img(cur, tail); min = cur;
} }
} }
if (min->prev)
{
min->prev->next = min->next;
}
if (min->next)
{
min->next->prev = min->prev;
}
if (min == g_ventoy_img_list)
{
g_ventoy_img_list = min->next;
}
if (head == NULL)
{
head = tail = min;
min->prev = NULL;
min->next = NULL;
}
else
{
tail->next = min;
min->prev = tail;
min->next = NULL;
tail = min;
}
} }
g_ventoy_img_list = head;
if (g_default_menu_mode == 1) if (g_default_menu_mode == 1)
{ {
vtoy_ssprintf(g_list_script_buf, g_list_script_pos, vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
@ -2492,11 +2525,11 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
for (cur = g_ventoy_img_list; cur; cur = cur->next) for (cur = g_ventoy_img_list; cur; cur = cur->next)
{ {
vtoy_ssprintf(g_list_script_buf, g_list_script_pos, vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
"menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%d\" {\n" "menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%p\" {\n"
" %s_%s \n" " %s_%s \n"
"}\n", "}\n",
cur->unsupport ? "[***********] " : "", cur->unsupport ? "[***********] " : "",
cur->alias ? cur->alias : cur->name, cur->class, cur->id, cur->alias ? cur->alias : cur->name, cur->class, cur,
cur->menu_prefix, cur->menu_prefix,
cur->unsupport ? "unsupport_menuentry" : "common_menuentry"); cur->unsupport ? "unsupport_menuentry" : "common_menuentry");
} }
@ -4851,6 +4884,27 @@ static grub_err_t grub_cmd_gptpriority(grub_extcmd_context_t ctxt, int argc, cha
} }
/* <BEGIN>: Deleted by longpanda, 20210916 PN:XX LABEL:XX */
#if 0
void ventoy_tip_set_menu_label(const char *vid)
{
img_info *node;
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (vid)
{
node = (img_info *)(void *)grub_strtoul(vid + 4, NULL, 16);
if (node)
{
g_ventoy_tip_msg1 = node->tip1;
g_ventoy_tip_msg2 = node->tip2;
}
}
}
#endif /* #if 0 */
/* <END> : Deleted by longpanda, 20210916 PN:XX LABEL:XX */
int ventoy_env_init(void) int ventoy_env_init(void)
{ {
char buf[64]; char buf[64];

@ -215,6 +215,8 @@ typedef struct img_info
char name[256]; char name[256];
const char *alias; const char *alias;
const char *tip1;
const char *tip2;
const char *class; const char *class;
const char *menu_prefix; const char *menu_prefix;
@ -865,6 +867,17 @@ typedef struct menu_alias
struct menu_alias *next; struct menu_alias *next;
}menu_alias; }menu_alias;
typedef struct menu_tip
{
int pathlen;
char isopath[256];
char tip1[1024];
char tip2[1024];
struct menu_tip *next;
}menu_tip;
#define vtoy_class_image_file 0 #define vtoy_class_image_file 0
#define vtoy_class_directory 1 #define vtoy_class_directory 1
@ -1017,6 +1030,7 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath);
int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list); int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
const char * ventoy_plugin_get_injection(const char *isopath); const char * ventoy_plugin_get_injection(const char *isopath);
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath); const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
const menu_tip * ventoy_plugin_get_menu_tip(const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path); const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path);
int ventoy_plugin_check_memdisk(const char *isopath); int ventoy_plugin_check_memdisk(const char *isopath);
int ventoy_plugin_get_image_list_index(int type, const char *name); int ventoy_plugin_get_image_list_index(int type, const char *name);

@ -48,6 +48,7 @@ static install_template *g_install_template_head = NULL;
static dud *g_dud_head = NULL; static dud *g_dud_head = NULL;
static menu_password *g_pwd_head = NULL; static menu_password *g_pwd_head = NULL;
static persistence_config *g_persistence_head = NULL; static persistence_config *g_persistence_head = NULL;
static menu_tip *g_menu_tip_head = NULL;
static menu_alias *g_menu_alias_head = NULL; static menu_alias *g_menu_alias_head = NULL;
static menu_class *g_menu_class_head = NULL; static menu_class *g_menu_class_head = NULL;
static custom_boot *g_custom_boot_head = NULL; static custom_boot *g_custom_boot_head = NULL;
@ -1417,6 +1418,176 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
return 0; return 0;
} }
static int ventoy_plugin_menutip_check(VTOY_JSON *json, const char *isodisk)
{
const char *path = NULL;
const char *tip = NULL;
VTOY_JSON *pNode = NULL;
(void)isodisk;
if (json->enDataType != JSON_TYPE_OBJECT)
{
grub_printf("Not object %d\n", json->enDataType);
return 1;
}
tip = vtoy_json_get_string_ex(json->pstChild, "left");
if (tip)
{
grub_printf("left: <%s>\n", tip);
}
tip = vtoy_json_get_string_ex(json->pstChild, "top");
if (tip)
{
grub_printf("top: <%s>\n", tip);
}
tip = vtoy_json_get_string_ex(json->pstChild, "color");
if (tip)
{
grub_printf("color: <%s>\n", tip);
}
pNode = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "tips");
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (path && path[0] == '/')
{
if (grub_strchr(path, '*'))
{
grub_printf("image: <%s> [ * ]\n", path);
}
else if (ventoy_check_file_exist("%s%s", isodisk, path))
{
grub_printf("image: <%s> [ OK ]\n", path);
}
else
{
grub_printf("image: <%s> [ NOT EXIST ]\n", path);
}
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
if (tip)
{
grub_printf("tip: <%s>\n", tip);
}
else
{
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip1");
if (tip)
grub_printf("tip1: <%s>\n", tip);
else
grub_printf("tip1: <NULL>\n");
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip2");
if (tip)
grub_printf("tip2: <%s>\n", tip);
else
grub_printf("tip2: <NULL>\n");
}
}
else
{
grub_printf("image: <%s> [ INVALID ]\n", path);
}
}
return 0;
}
static int ventoy_plugin_menutip_entry(VTOY_JSON *json, const char *isodisk)
{
const char *path = NULL;
const char *tip = NULL;
VTOY_JSON *pNode = NULL;
menu_tip *node = NULL;
menu_tip *next = NULL;
(void)isodisk;
if (json->enDataType != JSON_TYPE_OBJECT)
{
debug("Not object %d\n", json->enDataType);
return 0;
}
pNode = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "tips");
if (pNode == NULL)
{
debug("Not tips found\n");
return 0;
}
if (g_menu_tip_head)
{
for (node = g_menu_tip_head; node; node = next)
{
next = node->next;
grub_free(node);
}
g_menu_tip_head = NULL;
}
tip = vtoy_json_get_string_ex(json->pstChild, "left");
if (tip)
{
grub_env_set("VTOY_TIP_LEFT", tip);
}
tip = vtoy_json_get_string_ex(json->pstChild, "top");
if (tip)
{
grub_env_set("VTOY_TIP_TOP", tip);
}
tip = vtoy_json_get_string_ex(json->pstChild, "color");
if (tip)
{
grub_env_set("VTOY_TIP_COLOR", tip);
}
for (pNode = pNode->pstChild; pNode; pNode = pNode->pstNext)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (path && path[0] == '/')
{
node = grub_zalloc(sizeof(menu_tip));
if (node)
{
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip");
if (tip)
{
grub_snprintf(node->tip1, 1000, "%s", tip);
}
else
{
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip1");
if (tip)
grub_snprintf(node->tip1, 1000, "%s", tip);
tip = vtoy_json_get_string_ex(pNode->pstChild, "tip2");
if (tip)
grub_snprintf(node->tip2, 1000, "%s", tip);
}
if (g_menu_tip_head)
{
node->next = g_menu_tip_head;
}
g_menu_tip_head = node;
}
}
}
return 0;
}
static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk) static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
{ {
@ -2101,6 +2272,7 @@ static plugin_entry g_plugin_entries[] =
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check }, { "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check }, { "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check }, { "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check }, { "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check }, { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check }, { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check },
@ -2149,6 +2321,11 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
(void)ctxt; (void)ctxt;
(void)argc; (void)argc;
grub_env_set("VTOY_TIP_LEFT", "10%");
grub_env_set("VTOY_TIP_TOP", "80%+5");
grub_env_set("VTOY_TIP_COLOR", "blue");
grub_env_set("VTOY_TIP_ALIGN", "left");
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "%s/ventoy/ventoy.json", args[0]); file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "%s/ventoy/ventoy.json", args[0]);
if (!file) if (!file)
{ {
@ -2205,6 +2382,15 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
} }
} }
if (g_menu_tip_head)
{
grub_env_set("VTOY_MENU_TIP_ENABLE", "1");
}
else
{
grub_env_unset("VTOY_MENU_TIP_ENABLE");
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE); VENTOY_CMD_RETURN(GRUB_ERR_NONE);
} }
@ -2465,6 +2651,28 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
return NULL; return NULL;
} }
const menu_tip * ventoy_plugin_get_menu_tip(const char *isopath)
{
int len;
menu_tip *node = NULL;
if (!g_menu_tip_head)
{
return NULL;
}
len = (int)grub_strlen(isopath);
for (node = g_menu_tip_head; node; node = node->next)
{
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
{
return node;
}
}
return NULL;
}
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path) const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
{ {
int namelen; int namelen;

@ -185,7 +185,7 @@ ventoy_unpack_injection() {
if [ -e $VTOY_PATH/ventoy_injection ]; then if [ -e $VTOY_PATH/ventoy_injection ]; then
echo "### decompress injection ... ###" >>$VTLOG echo "### decompress injection ... ###" >>$VTLOG
ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1 ventoy_unpack_injection > $VTOY_PATH/injection.log 2>&1
fi fi

@ -350,7 +350,17 @@ fi
#################################################################### ####################################################################
# # # #
# Step 3 : Check for debug break # # Step 3 : Run LiveInjection Hook #
# #
####################################################################
if [ -f "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" ]; then
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS
fi
####################################################################
# #
# Step 4 : Check for debug break #
# # # #
#################################################################### ####################################################################
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
@ -367,7 +377,7 @@ fi
#################################################################### ####################################################################
# # # #
# Step 4 : Hand over to real init # # Step 5 : Hand over to real init #
# # # #
#################################################################### ####################################################################
$BUSYBOX_PATH/umount /proc $BUSYBOX_PATH/umount /proc

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -112,6 +112,15 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json --cla
unset pager unset pager
} }
menuentry 'Check menu tip plugin configuration' --class=debug_menutip --class=debug_json --class=F5tool {
set pager=1
vt_check_plugin_json $vt_plugin_path menu_tip $vtoy_iso_part
echo -e "\npress ENTER to exit ..."
read vtInputKey
unset pager
}
menuentry 'Check menu class plugin configuration' --class=debug_menuclass --class=debug_json --class=F5tool { menuentry 'Check menu class plugin configuration' --class=debug_menuclass --class=debug_json --class=F5tool {
set pager=1 set pager=1
vt_check_plugin_json $vt_plugin_path menu_class $vtoy_iso_part vt_check_plugin_json $vt_plugin_path menu_class $vtoy_iso_part

@ -1075,7 +1075,7 @@ function legacy_linux_menu_func {
ventoy_gui_console ventoy_gui_console
else else
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size} linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot boot
fi fi
else else
@ -1963,7 +1963,7 @@ function img_unsupport_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.52" set VENTOY_VERSION="1.0.53"
#ACPI not compatible with Window7/8, so disable by default #ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1 set VTOY_PARAM_NO_ACPI=1
@ -2032,7 +2032,10 @@ else
set vtoydev=$vtoy_dev set vtoydev=$vtoy_dev
set vtoy_iso_part=($vtoy_dev,1) set vtoy_iso_part=($vtoy_dev,1)
set vtoy_efi_part=($vtoy_dev,2) set vtoy_efi_part=($vtoy_dev,2)
loadfont unicode
vt_load_file_to_mem "auto" $prefix/fonts/unicode.pf2 vtoy_font_mem
loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size}
set vt_plugin_path=$vtoy_iso_part set vt_plugin_path=$vtoy_iso_part
fi fi

Binary file not shown.

@ -30,13 +30,15 @@ terminal-box: "terminal_box_*.png"
scrollbar_thumb = "slider_*.png" scrollbar_thumb = "slider_*.png"
} }
+ progress_bar { + progress_bar {
id = "__timeout__" id = "__timeout__"
text = "@TIMEOUT_NOTIFICATION_SHORT@" text = "@TIMEOUT_NOTIFICATION_SHORT@"
left = 20% left = 90%
width = 60% width = 10%
top = 85% top = 90%
text_color = "red" text_color = "red"
bar_style = "*" bar_style = "*"
@ -93,4 +95,3 @@ terminal-box: "terminal_box_*.png"
height = 25 height = 25
+ label {text = "@VTOY_ISO_UEFI_DRV@" color = "red" align = "left"} + label {text = "@VTOY_ISO_UEFI_DRV@" color = "red" align = "left"}
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save