Skip to content

Commit 30a53d6

Browse files
committed
Prevent wallpaper from being copied if transparency is not enabled
Only copies the wallpaper in either one of those instances: 1) the user starts the program with the Fluent theme AND transparency enabled; 2) the user enables the Fluent theme having transparency enabled; 3) the user enables transparency having the Fluent theme enabled. This prevents the wallpaper from being copied unnecessarily for users with transparency disabled, avoiding potential issues and allowing users to disable it in case of any problems (i.e. they can manually set acrylic=0 in settings.ini). It also has the added bonus of updating the wallpaper without needing to restart the program.
1 parent 7139814 commit 30a53d6

File tree

7 files changed

+48
-22
lines changed

7 files changed

+48
-22
lines changed

Minecraft Note Block Studio.yyp

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/change_theme/change_theme.gml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function change_theme() {
33

44
window_set_color(window_background)
55

6-
6+
if (theme == 3 && acrylic && !wpaperexist) {
7+
wallpaper_init()
8+
}
79

810
}

scripts/control_create/control_create.gml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,13 @@ function control_create() {
4848
mouseover = 0
4949
display_width = display_get_width()
5050
display_height = display_get_height()
51+
52+
// Wallpaper
5153
wpaper = 0
54+
wpaperexist = 0
5255
wpaperside = 0
53-
ExecuteShell("\"" + data_directory + "wallpaper.bat", true, true)
54-
wpaperexist = file_exists(data_directory + "Wallpaper.jpg")
55-
if (wpaperexist) {
56-
wpaper = sprite_add(data_directory + "Wallpaper.jpg", 1, 0, 0, 0, 0)
57-
if (display_width / display_height < sprite_get_width(wpaper) / sprite_get_height(wpaper)) wpaperside = 1
58-
wpaperwidth = (sprite_get_width(wpaper) / sprite_get_height(wpaper)) * 720
59-
tempsurf = surface_create(wpaperwidth, 720)
60-
surface_set_target(tempsurf)
61-
draw_sprite_ext(wpaper, 0, 0, 0, 720 / sprite_get_height(wpaper), 720 / sprite_get_height(wpaper), 0, -1, 1)
62-
surface_reset_target()
63-
sprite_delete(wpaper)
64-
wpaper = sprite_create_from_surface(tempsurf, 0, 0, wpaperwidth, 720, 0, 1, 0, 0)
65-
surface_free(tempsurf)
66-
wpaperblur = sprite_create_blur_alt(wpaper, 0.25, sprite_get_width(wpaper), sprite_get_height(wpaper), 300, 8, 16)
67-
}
56+
wpaperwidth = 0
57+
wpaperblur = 0
6858

6959
// Audio
7060
channels = 256
@@ -493,6 +483,9 @@ function control_create() {
493483
if (file_exists_lib(update_file)) {
494484
files_delete_lib(update_file)
495485
}
486+
487+
// Init wallpaper
488+
change_theme()
496489

497490
// Auto-recovery
498491
// DISABLED DUE TO https://github.com/HielkeMinecraft/OpenNoteBlockStudio/issues/196

scripts/draw_window_preferences/draw_window_preferences.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ function draw_window_preferences() {
318318
if (!isplayer) if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 20 + 25, blackout, "Blackout mode", "Makes the workspace background solid black, so you can\nremove in your video editor when recording the screen.", false, true)) blackout = !blackout
319319
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 25, windowsound, "Navigation sound", "Whether to play sound effects when navigating the interface.\n(Only applies to the Fluent theme.)", (theme != 3), true)) windowsound = !windowsound
320320
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 25, fdark, "Dark mode", "Whether to use darker colors on the interface.\n(Only applies to the Fluent theme.)", (theme != 3), true)) fdark = !fdark
321-
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 25, acrylic, "Transparency effects", "Whether to show transparency effects on the interface.\n(Only applies to the Fluent theme.)", (theme != 3), true)) acrylic = !acrylic
321+
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 25, acrylic, "Transparency effects", "Whether to show transparency effects on the interface.\n(Only applies to the Fluent theme.)", (theme != 3), true)) {acrylic = !acrylic change_theme()}
322322
} else {
323323
if (!isplayer) if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 20 + 25, blackout, "全黑模式", "使背景变为纯黑色,可以用于剪辑时扣掉。", false, true)) blackout = !blackout
324324
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 25, windowsound, "界面音效", "是否在浏览时播放音效。\n(仅限Fluent主题)", (theme != 3), true)) windowsound = !windowsound
325325
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 25, fdark, "暗色模式", "是否在界面上使用暗色调。\n(仅限Fluent主题)", (theme != 3), true)) fdark = !fdark
326-
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 25, acrylic, "透明效果", "是否在界面上显示透明效果。\n(仅限Fluent主题)", (theme != 3), true)) acrylic = !acrylic
326+
if (draw_checkbox(x1 + 40, y1 + (theme = 3) * 22 + 74 + 16 + 20 + 20 + 20 + 25, acrylic, "透明效果", "是否在界面上显示透明效果。\n(仅限Fluent主题)", (theme != 3), true)) {acrylic = !acrylic change_theme()}
327327
}
328328

329329
// Accent color picker

scripts/menu_click/menu_click.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ function menu_click(argument0) {
282282
break
283283
}
284284
case "theme": {
285-
if (sel = 0) theme = 0
286-
else if (sel = 2) theme = 1
287-
else if (sel = 1) theme = 2
288-
else if (sel = 3) theme = 3
285+
if (sel = 0) {theme = 0 change_theme()}
286+
else if (sel = 2) {theme = 1 change_theme()}
287+
else if (sel = 1) {theme = 2 change_theme()}
288+
else if (sel = 3) {theme = 3 change_theme()}
289289
break
290290
}
291291
case "filep": {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function wallpaper_init() {
2+
var tempsurf, wpaperwidth;
3+
ExecuteShell("\"" + data_directory + "wallpaper.bat", true, true)
4+
wpaperexist = file_exists(data_directory + "Wallpaper.jpg")
5+
if (wpaperexist) {
6+
wpaper = sprite_add(data_directory + "Wallpaper.jpg", 1, 0, 0, 0, 0)
7+
if (display_width / display_height < sprite_get_width(wpaper) / sprite_get_height(wpaper)) wpaperside = 1
8+
wpaperwidth = (sprite_get_width(wpaper) / sprite_get_height(wpaper)) * 720
9+
tempsurf = surface_create(wpaperwidth, 720)
10+
surface_set_target(tempsurf)
11+
draw_sprite_ext(wpaper, 0, 0, 0, 720 / sprite_get_height(wpaper), 720 / sprite_get_height(wpaper), 0, -1, 1)
12+
surface_reset_target()
13+
sprite_delete(wpaper)
14+
wpaper = sprite_create_from_surface(tempsurf, 0, 0, wpaperwidth, 720, 0, 1, 0, 0)
15+
surface_free(tempsurf)
16+
wpaperblur = sprite_create_blur_alt(wpaper, 0.25, sprite_get_width(wpaper), sprite_get_height(wpaper), 300, 8, 16)
17+
}
18+
}

scripts/wallpaper_init/wallpaper_init.yy

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)