Use assets for custom html frame and dialog icons#6005
Conversation
|
Some MTScript to have a play with toggling frame/dialog icons: |
|
Nice to see this being picked up! I like that HTML tags can be used to do this. One general concern I have developed in the few years since opening the FR is that not all of "features" will keep working right if/when we tighten up the asset cache so that loaded assets need to be part of the campaign. One case I remember where this is a "no" is global macros that use assets as icons. I don't know what the answer would be for frames & dialogs. Not that it's really new for them, as they can already load assets in Anyhow, I don't think anything needs to change in this PR regarding that point. I just wanted to make sure it's something we think about, and maybe we'll have to rethink a couple things in the future. |
| ImageIcon imageIcon = new ImageIcon(RessourceManager.getImage(Images.BROKEN)); | ||
| byte[] imageBytes = asset.getData(); | ||
| if (imageBytes != null && imageBytes.length > 0) { |
There was a problem hiding this comment.
Should check that the asset is an image with asset.getType()
There was a problem hiding this comment.
Added an asset type check.
| } catch (IOException | ExecutionException | InterruptedException e) { | ||
| // Do nothing | ||
| } | ||
| } else if (rel.toString().equalsIgnoreCase("icon")) { |
There was a problem hiding this comment.
rel could be null so need to check that it isn't first
There was a problem hiding this comment.
Think that is already covered by the checks done at the parent nested level on line 308?
Identify the Bug or Feature request
closes #4018
Description of the Change
Icons for
DIALOG,DIALOG5,FRAME,FRAME5(and theirhtml.*` variants) can now be set by:icon=asset://...;<link rel="icon" type="..." href="asset://...">(requires all three attribute to be present).setFrameIcon()orsetDialogIcon()without having to do a full frame/dialog refresh. However, if the frame/dialog is subsequently refreshed the icon will change to whatever has been specified according to methods 1 and 2 above.Code changes:
iconparameter and newgetScaledImageIconmethod.ChangeIconActionEventclass.<link rel="icon"type tags and attributes.Possible Drawbacks
<link>tag, the property icon is set first (or set the default current icon if the property icon is not set), then the<link>tag icon is set. The icon may flicker as it needs to wait for the HTML content to load first. This flicker is similar to if setting the frame/dialog title via the<title>tag. Had a go a cracking this, but was getting no where fast and I persevered for as long I could.Documentation Notes
New functions:
setFrameIcon(frameName, assetId)frameName - the name of the frame
assetId - the asset ID. If blank (i.e. "" will reset the frame icon to the default)
ditto for dialogs
Enhanced functions:
getFrameProperties(): now returns aniconkey with the assigned asset.frame/frame5/dialog/dialog5/html.frame/html.frame5/html.dialog/html.dialog5can now take an assetid for theiconparameter.Release Notes
This change is