Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
23f8bc8a
Commit
23f8bc8a
authored
Dec 22, 2022
by
longpanda
Browse files
Add resolution_fit option in theme plugin.
parent
f2016ab8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
162 additions
and
27 deletions
+162
-27
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
+80
-19
INSTALL/grub/debug.cfg
INSTALL/grub/debug.cfg
+4
-1
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+5
-1
Plugson/src/Web/ventoy_http.c
Plugson/src/Web/ventoy_http.c
+10
-1
Plugson/src/Web/ventoy_http.h
Plugson/src/Web/ventoy_http.h
+1
-0
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
+0
-0
Plugson/vs/VentoyPlugson/x64/Release/VentoyPlugson_X64.exe
Plugson/vs/VentoyPlugson/x64/Release/VentoyPlugson_X64.exe
+0
-0
Plugson/www/buildtime
Plugson/www/buildtime
+1
-1
Plugson/www/index.html
Plugson/www/index.html
+4
-4
Plugson/www/plugson_theme.html
Plugson/www/plugson_theme.html
+57
-0
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
View file @
23f8bc8a
...
...
@@ -35,6 +35,7 @@
#include <grub/crypto.h>
#include <grub/time.h>
#include <grub/font.h>
#include <grub/video.h>
#include <grub/ventoy.h>
#include "ventoy_def.h"
...
...
@@ -59,6 +60,7 @@ static conf_replace *g_conf_replace_head = NULL;
static
VTOY_JSON
*
g_menu_lang_json
=
NULL
;
static
int
g_theme_id
=
0
;
static
int
g_theme_res_fit
=
0
;
static
int
g_theme_num
=
0
;
static
theme_list
*
g_theme_head
=
NULL
;
static
int
g_theme_random
=
vtoy_theme_random_boot_second
;
...
...
@@ -377,6 +379,18 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
if
(
g_theme_num
>
0
)
{
vtoy_json_get_int
(
json
->
pstChild
,
"default_file"
,
&
g_theme_id
);
if
(
g_theme_id
==
0
)
{
vtoy_json_get_int
(
json
->
pstChild
,
"resolution_fit"
,
&
g_theme_res_fit
);
if
(
g_theme_res_fit
!=
1
)
{
g_theme_res_fit
=
0
;
}
grub_snprintf
(
val
,
sizeof
(
val
),
"%d"
,
g_theme_res_fit
);
ventoy_env_export
(
"vtoy_res_fit"
,
val
);
}
if
(
g_theme_id
>
g_theme_num
||
g_theme_id
<
0
)
{
g_theme_id
=
0
;
...
...
@@ -3381,13 +3395,19 @@ grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, cha
return
0
;
}
extern
char
g_ventoy_theme_path
[
256
];
grub_err_t
ventoy_cmd_set_theme
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
grub_uint32_t
i
=
0
;
grub_uint32_t
mod
=
0
;
grub_uint32_t
theme_num
=
0
;
theme_list
*
node
=
g_theme_head
;
struct
grub_datetime
datetime
;
struct
grub_video_mode_info
info
;
char
buf
[
64
];
char
**
pThemePath
=
NULL
;
(
void
)
argc
;
(
void
)
args
;
(
void
)
ctxt
;
...
...
@@ -3417,41 +3437,82 @@ grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **arg
goto
end
;
}
grub_memset
(
&
datetime
,
0
,
sizeof
(
datetime
));
grub_get_datetime
(
&
datetime
);
pThemePath
=
(
char
**
)
grub_zalloc
(
sizeof
(
char
*
)
*
g_theme_num
);
if
(
!
pThemePath
)
{
goto
end
;
}
if
(
g_theme_r
andom
==
vtoy_theme_random_boot_second
)
if
(
g_theme_r
es_fit
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
second
,
(
grub_uint32_t
)
g_theme_num
,
&
mod
);
if
(
grub_video_get_info
(
&
info
)
==
GRUB_ERR_NONE
)
{
debug
(
"get video info success %ux%u
\n
"
,
info
.
width
,
info
.
height
);
grub_snprintf
(
buf
,
sizeof
(
buf
),
"%ux%u"
,
info
.
width
,
info
.
height
);
for
(
node
=
g_theme_head
;
node
;
node
=
node
->
next
)
{
if
(
grub_strstr
(
node
->
theme
.
path
,
buf
))
{
pThemePath
[
theme_num
++
]
=
node
->
theme
.
path
;
}
}
}
}
else
if
(
g_theme_random
==
vtoy_theme_random_boot_day
)
if
(
theme_num
==
0
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
day
,
(
grub_uint32_t
)
g_theme_num
,
&
mod
);
for
(
node
=
g_theme_head
;
node
;
node
=
node
->
next
)
{
pThemePath
[
theme_num
++
]
=
node
->
theme
.
path
;
}
}
else
if
(
g_theme_random
==
vtoy_theme_random_boot_month
)
if
(
theme_num
==
1
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
month
,
(
grub_uint32_t
)
g_theme_num
,
&
mod
);
mod
=
0
;
debug
(
"Only 1 theme match, no need to random.
\n
"
);
}
else
{
grub_memset
(
&
datetime
,
0
,
sizeof
(
datetime
));
grub_get_datetime
(
&
datetime
);
debug
(
"%04d/%02d/%02d %02d:%02d:%02d radom:%d mod:%d
\n
"
,
datetime
.
year
,
datetime
.
month
,
datetime
.
day
,
datetime
.
hour
,
datetime
.
minute
,
datetime
.
second
,
g_theme_random
,
mod
);
if
(
g_theme_random
==
vtoy_theme_random_boot_second
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
second
,
theme_num
,
&
mod
);
}
else
if
(
g_theme_random
==
vtoy_theme_random_boot_day
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
day
,
theme_num
,
&
mod
);
}
else
if
(
g_theme_random
==
vtoy_theme_random_boot_month
)
{
grub_divmod32
((
grub_uint32_t
)
datetime
.
month
,
theme_num
,
&
mod
);
}
for
(
i
=
0
;
i
<
mod
&&
node
;
i
++
)
{
node
=
node
->
next
;
debug
(
"%04d/%02d/%02d %02d:%02d:%02d theme_num:%d mod:%d
\n
"
,
datetime
.
year
,
datetime
.
month
,
datetime
.
day
,
datetime
.
hour
,
datetime
.
minute
,
datetime
.
second
,
theme_num
,
mod
);
}
debug
(
"random theme %s
\n
"
,
node
->
theme
.
path
);
grub_env_set
(
"theme"
,
node
->
theme
.
path
);
if
(
argc
>
0
&&
grub_strcmp
(
args
[
0
],
"switch"
)
==
0
)
{
grub_snprintf
(
g_ventoy_theme_path
,
sizeof
(
g_ventoy_theme_path
),
"%s"
,
pThemePath
[
mod
]);
}
else
{
debug
(
"random theme %s
\n
"
,
pThemePath
[
mod
]);
grub_env_set
(
"theme"
,
pThemePath
[
mod
]);
}
g_ventoy_menu_refresh
=
1
;
end:
grub_check_free
(
pThemePath
);
VENTOY_CMD_RETURN
(
GRUB_ERR_NONE
);
}
extern
char
g_ventoy_theme_path
[
256
];
grub_err_t
ventoy_cmd_set_theme_path
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
(
void
)
argc
;
...
...
INSTALL/grub/debug.cfg
View file @
23f8bc8a
...
...
@@ -24,7 +24,10 @@ submenu "$VTLANG_RESOLUTION_CFG" --class=debug_resolution --class=F5tool {
menuentry "$vtCurMode $vtActive" --class=debug_videomode --class=debug_resolution --class=F5tool VTOY_RUN_RET {
terminal_output console
set gfxmode=$1
terminal_output gfxterm
terminal_output gfxterm
if [ "$vtoy_res_fit" = "1" ]; then
vt_set_theme switch
fi
}
vt_incr vdid 1
...
...
INSTALL/grub/grub.cfg
View file @
23f8bc8a
...
...
@@ -2555,7 +2555,11 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
fi
terminal_input serial console
terminal_output serial console
else
else
if [ "$vtoy_res_fit" = "1" ]; then
terminal_output gfxterm
fi
if [ -n "$vtoy_theme" ]; then
vt_set_theme
else
...
...
Plugson/src/Web/ventoy_http.c
View file @
23f8bc8a
...
...
@@ -819,13 +819,18 @@ int ventoy_data_save_theme(data_theme *data, const char *title, char *buf, int b
{
VTOY_JSON_FMT_ITEM_PATH_LN
(
L3
,
node
->
path
);
}
VTOY_JSON_FMT_ARY_ENDEX_LN
(
L2
);
if
(
def
->
default_file
!=
data
->
default_file
)
{
VTOY_JSON_FMT_SINT_LN
(
L2
,
"default_file"
,
data
->
default_file
);
}
if
(
def
->
resolution_fit
!=
data
->
resolution_fit
)
{
VTOY_JSON_FMT_SINT_LN
(
L2
,
"resolution_fit"
,
data
->
resolution_fit
);
}
}
else
{
...
...
@@ -888,6 +893,7 @@ int ventoy_data_json_theme(data_theme *data, char *buf, int buflen)
VTOY_JSON_FMT_OBJ_BEGIN
();
VTOY_JSON_FMT_SINT
(
"default_file"
,
data
->
default_file
);
VTOY_JSON_FMT_SINT
(
"resolution_fit"
,
data
->
resolution_fit
);
VTOY_JSON_FMT_SINT
(
"display_mode"
,
data
->
display_mode
);
VTOY_JSON_FMT_STRN
(
"gfxmode"
,
data
->
gfxmode
);
...
...
@@ -939,6 +945,7 @@ static int ventoy_api_save_theme(struct mg_connection *conn, VTOY_JSON *json)
data
=
g_data_theme
+
index
;
VTOY_JSON_INT
(
"default_file"
,
data
->
default_file
);
VTOY_JSON_INT
(
"resolution_fit"
,
data
->
resolution_fit
);
VTOY_JSON_INT
(
"display_mode"
,
data
->
display_mode
);
VTOY_JSON_STR
(
"gfxmode"
,
data
->
gfxmode
);
VTOY_JSON_STR
(
"ventoy_left"
,
data
->
ventoy_left
);
...
...
@@ -4252,6 +4259,7 @@ static int ventoy_parse_theme(VTOY_JSON *json, void *p)
vtoy_json_get_string
(
child
,
"ventoy_color"
,
sizeof
(
data
->
ventoy_color
),
data
->
ventoy_color
);
vtoy_json_get_int
(
child
,
"default_file"
,
&
(
data
->
default_file
));
vtoy_json_get_int
(
child
,
"resolution_fit"
,
&
(
data
->
resolution_fit
));
vtoy_json_get_string
(
child
,
"gfxmode"
,
sizeof
(
data
->
gfxmode
),
data
->
gfxmode
);
vtoy_json_get_string
(
child
,
"serial_param"
,
sizeof
(
data
->
serial_param
),
data
->
serial_param
);
...
...
@@ -4279,6 +4287,7 @@ static int ventoy_parse_theme(VTOY_JSON *json, void *p)
if
(
node
)
{
data
->
default_file
=
0
;
data
->
resolution_fit
=
0
;
pnode
=
zalloc
(
sizeof
(
path_node
));
if
(
pnode
)
...
...
Plugson/src/Web/ventoy_http.h
View file @
23f8bc8a
...
...
@@ -100,6 +100,7 @@ typedef struct path_node
typedef
struct
data_theme
{
int
default_file
;
int
resolution_fit
;
path_node
*
filelist
;
int
display_mode
;
char
gfxmode
[
32
];
...
...
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
View file @
23f8bc8a
No preview for this file type
Plugson/vs/VentoyPlugson/x64/Release/VentoyPlugson_X64.exe
View file @
23f8bc8a
No preview for this file type
Plugson/www/buildtime
View file @
23f8bc8a
20221221 12:11:59
\ No newline at end of file
20221204 15:15:33
\ No newline at end of file
Plugson/www/index.html
View file @
23f8bc8a
...
...
@@ -757,7 +757,7 @@
<footer
class=
"main-footer"
>
<div
class=
"pull-right hidden-xs"
>
<b
id=
"plugson_build_date"
>
202212
21
1
2
:1
1:59
</b>
<b
id=
"plugson_build_date"
>
202212
04
1
5
:1
5:33
</b>
</div>
<strong><a
href=
"https://www.ventoy.net"
target=
"_blank"
>
https://www.ventoy.net
</a></strong>
</footer>
...
...
@@ -777,10 +777,10 @@
<script
src=
"/static/js/jQuery-2.1.4.min.js"
></script>
<!-- jquery validate -->
<script
src=
"/static/js/jquery.validate.min.js"
></script>
<script
src=
"/static/js/jquery.validate.vtoymethods.js?v=10
3
"
></script>
<script
src=
"/static/js/jquery.validate.vtoymethods.js?v=10
6
"
></script>
<script
src=
"/static/js/jquery.vtoy.alert.js?v=10
3
"
></script>
<script
src=
"/static/js/vtoy.js?v=10
3
"
></script>
<script
src=
"/static/js/jquery.vtoy.alert.js?v=10
6
"
></script>
<script
src=
"/static/js/vtoy.js?v=10
6
"
></script>
<script
src=
"/static/js/md5.min.js"
></script>
<!-- Bootstrap 3.3.5 -->
...
...
Plugson/www/plugson_theme.html
View file @
23f8bc8a
...
...
@@ -71,6 +71,50 @@
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
<div
class=
"box box-primary box-solid"
id=
'resolution_fit_div'
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
style=
"font-size: 14px;font-weight: bold;"
>
resolution_fit
<span
id=
"id_span_desc_cn"
>
—— 按照分辨率过滤
</span></h3>
<div
class=
"box-tools pull-right"
>
<button
class=
"btn btn-box-tool"
data-widget=
"collapse"
><i
class=
"fa fa-minus"
></i></button>
</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div
class=
"box-body no-padding"
>
<table
class=
"table table-bordered no-padding"
>
<tr
style=
"font-weight:bold;"
>
<td
class=
"td_ctrl_col"
id=
"td_title_setting"
>
选项设置
</td>
<td>
<label
class=
"radio-inline"
>
<input
type=
"radio"
id=
"id_ctrl_radio_res_fit0"
name=
"id_ctrl_radio_res_fit"
data-type=
"0"
value=
"0"
>
<span
style=
"font-weight:bold;"
>
0
</span>
</label>
<label
class=
"radio-inline"
>
<input
type=
"radio"
id=
"id_ctrl_radio_res_fit1"
name=
"id_ctrl_radio_res_fit"
data-type=
"1"
value=
"1"
>
<span
style=
"font-weight:bold;"
>
1
</span>
</label>
</td>
</tr>
<tr
id=
"tr_title_desc_cn"
>
<td
class=
"td_ctrl_col"
id=
"td_title_desc"
>
选项说明
</td>
<td>
当设置多个主题时,在随机选择时是否按照当前分辨率过滤。
<code
style=
"font-weight: bold;"
>
0
</code>
不过滤
<code
style=
"font-weight: bold;"
>
1
</code>
过滤
<br/>
注意,这个选项必须在上面设置了多个主题配置文件,同时 "默认" 设置为 “随机选择” 时才有效,其他情况下均无效。
<br/>
关于这个选项的详细解释,请参考
<a
href=
"https://www.ventoy.net/cn/plugin_theme.html#vtoy_theme_res_fit"
>
resolution_fit 选项说明
</a>
</td>
</tr>
<tr
id=
"tr_title_desc_en"
>
<td
class=
"td_ctrl_col"
>
Option Description
</td>
<td>
Filter by current resolution when you set more than one themes.
<code
style=
"font-weight: bold;"
>
0
</code>
No filter
&
nbsp
<code
style=
"font-weight: bold;"
>
1
</code>
Filter
<br/>
You can refer
<a
href=
"https://www.ventoy.net/en/plugin_theme.html#vtoy_theme_res_fit"
>
About resolution_fit
</a>
for details about this option.
</td>
</tr>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
<div
class=
"box box-primary box-solid"
>
<div
class=
"box-header with-border"
>
...
...
@@ -239,6 +283,8 @@
}
else
{
data
.
display_mode
=
0
;
}
data
.
resolution_fit
=
parseInt
(
$
(
'
input:radio[name=id_ctrl_radio_res_fit]:checked
'
).
val
());
}
function
VtoySaveCurrentPage
()
{
...
...
@@ -249,6 +295,7 @@
method
:
'
save_theme
'
,
index
:
current_tab_index
,
display_mode
:
data
.
display_mode
,
resolution_fit
:
data
.
resolution_fit
,
gfxmode
:
data
.
gfxmode
,
default_file
:
data
.
default_file
},
function
(
e
)
{
...
...
@@ -269,6 +316,12 @@
var
$tbl
=
$
(
"
#id_theme_tbl_file tbody
"
);
$tbl
.
empty
();
if
(
list
.
length
>
1
)
{
$
(
'
#resolution_fit_div
'
).
show
();
}
else
{
$
(
'
#resolution_fit_div
'
).
hide
();
}
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
var
$tr
;
td1
=
'
<td>
'
+
(
i
+
1
)
+
'
</td>
'
;
...
...
@@ -365,6 +418,8 @@
$
(
'
select[id=id_theme_sel_dismode
'
).
val
(
'
GUI
'
);
}
$
(
'
input:radio[name=id_ctrl_radio_res_fit]
'
)[
data
.
resolution_fit
].
checked
=
true
;
FillThemeFileTable
(
data
.
filelist
,
data
.
default_file
);
FillThemeFontTable
(
data
.
fontslist
);
}
...
...
@@ -515,6 +570,8 @@
$
(
'
select[id=id_theme_sel_gfxmode]
'
).
change
(
VtoySaveCurrentPage
);
$
(
'
select[id=id_theme_sel_dismode]
'
).
change
(
VtoySaveCurrentPage
);
$
(
'
#id_ctrl_radio_res_fit0
'
).
change
(
VtoySaveCurrentPage
);
$
(
'
#id_ctrl_radio_res_fit1
'
).
change
(
VtoySaveCurrentPage
);
$
(
'
#id_tab_theme a[href="#tab_0"]
'
).
click
(
OnClickMultiModeTab
);
$
(
'
#id_tab_theme a[href="#tab_1"]
'
).
click
(
OnClickMultiModeTab
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment