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

Some improvement in performance and reliability #57

Merged
merged 16 commits into from
Nov 2, 2022

Conversation

Scighost
Copy link
Contributor

@Scighost Scighost commented Oct 26, 2022

Improve endian convert method

Use IPAddress.HostToNetworkOrder insead.

[Benchmark]
public void BSwap()
{
    Tools.Bswap(1946182291478952);
}

[Benchmark(Baseline = true)]
public void IpSwap()
{
    IPAddress.HostToNetworkOrder(1946182291478952);
}

image

Use absolute path

Imagine that when open terminal from other directory not contains GICutscenes.exe, the program cannot find file appsettings.json and versions.json. Use absolute path to solve this problem.

Add command to reset appsettings.json

If appsettings.json is accidentally damaged or changed section name, program throw exception at the first time. So I made some changes:

  • Add command to reset file appsettings.json to default GICutsences.exe reset
  • Move read setting method to the beginning of command handler

Handle Exception

Showing stack trace when throw exception is unnecessary, and it occupies a large space in the terminal. I added an option and exception handler to define whether shows it.

Options:
  -st, --stack-trace     Show stack trace when throw exception.

Comparison:

image

image

Update Command

#28

Use GICutscenes.exe update to download versions.json and check update for program. Comparing program's AssemblyVerison and tag name of the latest release, skip the first character of tag name.

Critical code:

var currentVersion = typeof(Program).Assembly.GetName().Version;
// skip first character
if (System.Version.TryParse(release?.TagName?[1..], out var latestVersion))
{
    if (latestVersion > currentVersion)
    {
        // need to update, open browser to release page
    }
    else
    {
        // is already the latest version
    }
}
else
{
    // cannot compare verision
}

And there are two options of update command:

  • -nb, do not open bowser if there's new version
  • -p, specifies a proxy server for the request

Support Encoding Format when Merge into mkv

#55

Custom Subtutles Style

#41

Add SubsStyle node to appSettings.json, default is

Style: Default,{fontname},12,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,0,0.5,2,10,10,14,1

The converted ass subs will be saved in {outputPath}/Subs/ and deleted after task if no --no-cleanup.

@ToaHartor
Copy link
Owner

Thank you for your hard work ! Since I see you commit over the time, tell me when you feel this can be merged.

@Scighost
Copy link
Contributor Author

Scighost commented Oct 31, 2022

I have finished all of what I think need to improve, please merge it.

Broken Changes and Attention

  • The default output path changes to {work folder}/output/.
  • New .ass file is saved in {outputPath}/Subs/, it will be converted from .str file in GenshinData folder every time. However, if .str file doesn't exist, the old converted .ass file would be still merged into mkv.
  • Check update command parses tag name of github releases by System.Version, name it like v1.2.3 and don't add any suffix.

@ToaHartor ToaHartor merged commit deab311 into ToaHartor:main Nov 2, 2022
@Scighost Scighost deleted the improve branch March 1, 2023 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants