From dc7d657b8733b82231fc4ca1d3302fae2bb2d6bf Mon Sep 17 00:00:00 2001 From: Halfstar <81277833+HalfstarDev@users.noreply.github.com> Date: Mon, 8 Jul 2024 00:56:21 +0200 Subject: [PATCH] Fixed screenshots --- matchanovel/defold_gui/images.lua | 13 +++++++++---- matchanovel/defold_gui/menu.gui_script | 9 ++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/matchanovel/defold_gui/images.lua b/matchanovel/defold_gui/images.lua index 5a10b27..261b583 100644 --- a/matchanovel/defold_gui/images.lua +++ b/matchanovel/defold_gui/images.lua @@ -138,16 +138,21 @@ function M.set_node_to_thumbnail(node_id, slot) end end local loaded_screenshot = loaded_screenshots[slot] - if loaded_screenshot then + if loaded_screenshot and loaded_screenshot ~= "" then local node = gui.get_node(node_id) set_node_to_png_buffer(node, loaded_screenshot, node_id) + return true + else + return false end end function M.save_cached_screenshot(slot) - local filename = save.get_path(slot, nil, nil, "png") - files.write_binary(filename, cached_screenshot) - loaded_screenshots[slot] = cached_screenshot + if cached_screenshot then + local filename = save.get_path(slot, nil, nil, "png") + files.write_binary(filename, cached_screenshot) + loaded_screenshots[slot] = cached_screenshot + end end diff --git a/matchanovel/defold_gui/menu.gui_script b/matchanovel/defold_gui/menu.gui_script index 55f82ba..6b3c95d 100644 --- a/matchanovel/defold_gui/menu.gui_script +++ b/matchanovel/defold_gui/menu.gui_script @@ -1203,7 +1203,14 @@ local function show_slot_as_written(page_slot, text) end --gui.play_flipbook(gui.get_node("save_"..page_slot.."/thumbnail"), "thumbnail") gui.set_enabled(gui.get_node("save_"..page_slot.."/thumbnail"), true) - images.set_node_to_thumbnail("save_"..page_slot.."/thumbnail", slot) + local node_id = "save_"..page_slot.."/thumbnail" + local node = gui.get_node(node_id) + local thumbnail_loaded = images.set_node_to_thumbnail(node_id, slot) + if thumbnail_loaded then + gui.set_color(node, vmath.vector3(1, 1, 1)) + else + gui.set_color(node, vmath.vector3(0.5, 0.5, 0.5)) + end --gui.animate(gui.get_node("save_"..page_slot.."/slot"), "color.w", 0.95, gui.EASING_INOUTSINE, 0.25) end