Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo font previewer #1249

Merged
merged 2 commits into from
Mar 22, 2024
Merged

Redo font previewer #1249

merged 2 commits into from
Mar 22, 2024

Conversation

Sieluna
Copy link
Contributor

@Sieluna Sieluna commented Mar 16, 2024

@ds5678
Copy link
Collaborator

ds5678 commented Mar 17, 2024

Thank you for the contribution. I can't review it right now, but I'll get to it as soon as I can.

Copy link
Collaborator

@ds5678 ds5678 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes required, but otherwise good.

}
}

private static string TryDecode(IUnityObjectBase asset, out byte[] data, out string? fileName, out string? mimeType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods with this design pattern should always have a boolean return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this part is similar to the code:

private static string TryDecode(IUnityObjectBase asset)
{
if (asset is IAudioClip clip && AudioClipDecoder.TryDecode(clip, out byte[]? decodedAudioData, out string? extension, out _))
{
return $"data:audio/{extension};base64,{Convert.ToBase64String(decodedAudioData, Base64FormattingOptions.None)}";
}
return "";
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code doesn't have any out parameters, which makes it different. In this case, we want a Boolean return. The current return can be made into another out parameter.

public override string DisplayName => Localization.AssetTabFont;

public override string HtmlName => "font";

public override bool Enabled => Data.Length > 0;
public override bool Enabled => !string.IsNullOrEmpty(Source);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want it keep the same structure as

public override bool Enabled => !string.IsNullOrEmpty(Source);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intuition says that the previous version is more future-proof. I foresee Source being removed in some way when this becomes asynchronous.

@Sieluna Sieluna requested a review from ds5678 March 22, 2024 21:38
@ds5678 ds5678 merged commit db2bd9d into AssetRipper:master Mar 22, 2024
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2024
@Sieluna Sieluna deleted the patch-1 branch March 31, 2024 22:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants