Skarn Posted October 31, 2021 Share Posted October 31, 2021 Hi, In main UI you can right click and select Refresh Images for selected. Does anyone know an equivalent in plugin API? I have a good code flow for updating images, but once the process completes, I have to manually select Refresh Images to see the changes. Thanks! Quote Link to comment Share on other sites More sharing options...
Fry Posted October 31, 2021 Share Posted October 31, 2021 (edited) Is this in BigBox, refresh the image cache or something else you’re looking to do? Edit - oh you said Main UI so I assume LaunchBox. Not sure but have you tried RefrshData? This worked to make a new game show up when I added a new game so I’d think it will show updated images https://pluginapi.launchbox-app.com/html/da689f24-d5ec-7977-c285-e94ce60f7c94.htm Edited October 31, 2021 by Fry Quote Link to comment Share on other sites More sharing options...
Skarn Posted November 1, 2021 Author Share Posted November 1, 2021 Thanks Fry, unfortunately, PluginHelper.LaunchBoxMainViewModel.RefreshData(); looks like it is working - the grid reloads, but the new image isn't picked up until I select 'Refresh Selected Images' myself... Maybe I'm just trying too quickly... I'll try a delay. Quote Link to comment Share on other sites More sharing options...
Fry Posted November 1, 2021 Share Posted November 1, 2021 Oh shoot, you're right. I poked around and found that this has to do with the image cache. I'm assuming you're modifying or adding images into the Launchbox\Images folder. PluginHelper.LaunchBoxMainViewModel.RefreshData works BUT you first need to update the image cache and as far as I can tell there's no way to do that via the API. So this is a pretty ugly work around which is to write your image into the image cache yourself and then call PluginHelper.LaunchBoxMainViewModel.RefreshData. This isn't ideal because going around the plug-in API to write into the image cache could easily break your plug-in with a future launchbox update if they choose to change the way images in the image cache are stored. But, it does work as a hacky workaround. You would want to scale your image to whatever dimensions that LaunchBox would scale and would you need to name it with the naming convention that LaunchBox would name it. The naming convention looks to be something like: .{ImageType}-{Game.Id}-{MaxHeight}-{MaxWidth}.{jpg|png} I'm not 100% sure how the image scaling works. I think it's dependent on that slider that lets you choose how many games fit in a row because when I slide that around, I see the image cache updating like crazy and new files getting generated with new file names in that dimension part of the file name. So this is the dicey part of going around the plug-in API. I tested this out with a simple plug-in to test where all I do is call PluginHelper.LaunchBoxMainViewModel.RefreshData. While LaunchBox is open, I manually replaced an image in the LaunchBox\Images\Cache-LB folder with a new image. Then clicked my plug-in menu item to call RefreshData and the image updated on the screen. Quote Link to comment Share on other sites More sharing options...
Skarn Posted November 1, 2021 Author Share Posted November 1, 2021 This will suffice I'll give it a shot! 1 Quote Link to comment Share on other sites More sharing options...
Fry Posted November 1, 2021 Share Posted November 1, 2021 (edited) Cool. Be careful with the scaling logic if you’re planning to do a lot of images because if it’s not the right dimensions then I think launchbox (wpf) will have to resize the images on the fly and it will probably hurt performance. Edited November 1, 2021 by Fry Quote Link to comment Share on other sites More sharing options...
Fry Posted November 2, 2021 Share Posted November 2, 2021 (edited) Just had a thought and I am unable to test at the moment to confirm but one approach that might work would be to simply delete the image from the cache and call the refreshData method. I wonder if that would regenerate the image for you so you don’t need to worry about the file naming convention or scaling the image properly. May be worth a try. EDIT - tested and this works. Just delete the cached image and call RefreshData and it will regen itself properly Edited November 3, 2021 by Fry Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.