Skip to content

Commit

Permalink
Update dependences.
Browse files Browse the repository at this point in the history
  • Loading branch information
BearOffice committed Jan 13, 2022
1 parent 7994322 commit fcd0de5
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 79 deletions.
8 changes: 4 additions & 4 deletions BearSubPlayer/BearSubPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Version>1.3.3</Version>
<Version>1.3.4</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ConfigReadingLib" Version="2.0.1" />
<PackageReference Include="BearMLLib" Version="3.1.6" />
<PackageReference Include="TriggerLib" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
<None Update="config.conf">
<None Update="config.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
65 changes: 13 additions & 52 deletions BearSubPlayer/Core/Config.cs
Original file line number Diff line number Diff line change
@@ -1,78 +1,39 @@
using System;
using ConfigReadingLib;
using BearMLLib;

namespace BearSubPlayer
{
public static class Config
{
private static readonly ConfigInfo[] _defaultConfigs = new[]
public static ConfigArgs GetConfigArgs()
{
new ConfigInfo { Key = "mainop", Value = "0.5", Comment = "value=\"0-1\"" },
new ConfigInfo { Key = "maincol", Value = "0", Comment = "value=\"white=0, black=1\"" },
new ConfigInfo { Key = "fontsize", Value = "32", Comment = "value=\"12-46\"" },
new ConfigInfo { Key = "fontcol", Value = "0", Comment = "value=\"white=0, black=1\"" },
new ConfigInfo { Key = "fontop", Value = "0.5", Comment = "value=\"0-1\"" },
new ConfigInfo { Key = "fontsn", Value = "8", Comment = "value=\"5-15\"" }
};
private static readonly ParseToString _parseToString = new ParseToString
{
[typeof(double)] = x => x.ToString(),
};
private static readonly ParseFromString _parseFromString = new ParseFromString
{
[typeof(double)] = x => double.Parse(x),
};

public static ConfigArgs GetConfig()
{
var configargs = GetArgs();
if (configargs == null)
{
SetDefault();
configargs = GetArgs();
}

return configargs;
}

private static ConfigArgs GetArgs()
{
ConfigReader reader;
try
{
reader = new ConfigReader("config.conf", strict: true);
var reader = new BearML("config.txt");
return reader.DeserializeObjectGroup<ConfigArgs>("configs");
}
catch
catch
{
return null;
SetDefault();
return new ConfigArgs();
}

var configargs = new ConfigArgs();
reader.SetPropertiesFromKeys(configargs, _parseFromString, exactmatch: true);

if (!(0 <= configargs.MainOp && configargs.MainOp <= 1)) return null;
if (!(0 <= configargs.MainCol && configargs.MainCol <= 1)) return null;
if (!(12 <= configargs.FontSize && configargs.FontSize <= 46)) return null;
if (!(0 <= configargs.FontCol && configargs.FontCol <= 1)) return null;
if (!(0 <= configargs.FontOp && configargs.FontOp <= 1)) return null;
if (!(5 <= configargs.FontSn && configargs.FontSn <= 15)) return null;

return configargs;
}

public static void SetDefault()
{
ConfigReader.Create(_defaultConfigs, "config.conf");
var reader = new BearML();
reader.AddObjectGroup("configs", new ConfigArgs());
reader.SaveCopyTo("config.txt");
}

public static void SaveConfig(ConfigArgs configargs)
{
try
{
var reader = new ConfigReader("config.conf", strict: true);
reader.SavePropertiesToKeys(configargs, _parseToString, exactmatch: true);
var reader = new BearML("config.txt");
reader.ChangeObjectGroup("configs", configargs);
}
catch
catch
{
SetDefault();
}
Expand Down
31 changes: 25 additions & 6 deletions BearSubPlayer/Core/ConfigArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,35 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BearMLLib.Serialization;

namespace BearSubPlayer
{
public record ConfigArgs
{
public double MainOp { get; set; }
public int MainCol { get; set; }
public int FontSize { get; set; }
public int FontCol { get; set; }
public double FontOp { get; set; }
public int FontSn { get; set; }
private double _mainOp = 0.5;
private int _mainCol = 0;
private int _fontSize = 32;
private int _fontCol = 0;
private double _fontOp = 0.5;
private int _fontSn = 8;

[Comment(" Main window opacity: 0.0 ~ 1.0")]
public double MainOp { get => _mainOp; set => _mainOp = value >= 0.0 && value <= 1.0 ? value : _mainOp; }

[Comment(" Main window color: white = 0, black = 1")]
public int MainCol { get => _mainCol; set => _mainCol = value == 0 || value == 1 ? value : _mainCol; }

[Comment(" Font size: 12 ~ 46")]
public int FontSize { get => _fontSize; set => _fontSize = value >= 12 && value <= 46 ? value : _fontSize; }

[Comment(" Font color: white = 0, black = 1")]
public int FontCol { get => _fontCol; set => _fontCol = value == 0 || value == 1 ? value : _fontCol; }

[Comment(" Font opacity: 0.0 ~ 1.0")]
public double FontOp { get => _fontOp; set => _fontOp = value >= 0.0 && value <= 1.0 ? value : _fontOp; }

[Comment(" Font shadow softness: 5 ~ 15")]
public int FontSn { get => _fontSn; set => _fontSn = value >= 5 && value <= 15 ? value : _fontSn; }
}
}
Binary file not shown.
Binary file modified BearSubPlayer/NuGet Packages/TriggerLib.1.1.1.nupkg
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions BearSubPlayer/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net5.0-windows\publish\</PublishDir>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishReadyToRun>True</PublishReadyToRun>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion BearSubPlayer/UIDesign/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private SettingWindow()

private void Initialize()
{
var config = Config.GetConfig();
var config = Config.GetConfigArgs();

OpacitySld.Value = config.MainOp;
OpacityLb.Content = (int)(config.MainOp * 100) + "%";
Expand Down
2 changes: 1 addition & 1 deletion BearSubPlayer/UIFunction/MainWindow.uictrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void FontEffect(Brush fontbrush, Color shadowcolor, double opacity, doub

private void MainInitialize()
{
var config = Config.GetConfig();
var config = Config.GetConfigArgs();
if (config.MainCol == 0) // White
MainBackground(Brushes.Black, Colors.White, config.MainOp);
else
Expand Down
6 changes: 0 additions & 6 deletions BearSubPlayer/config.conf

This file was deleted.

13 changes: 13 additions & 0 deletions BearSubPlayer/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
>>> configs
# Main window opacity: 0.0 ~ 1.0
MainOp: 0.5
# Main window color: white = 0, black = 1
MainCol: 0
# Font size: 12 ~ 46
FontSize: 32
# Font color: white = 0, black = 1
FontCol: 0
# Font opacity: 0.0 ~ 1.0
FontOp: 0.5
# Font shadow softness: 5 ~ 15
FontSn: 8
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

This will help you when you watch online videos but there are no subtitles or the subtitles are of poor quality.

Using library [ConfigReadingLib](https://github.com/MisakiBear/ConfigReadingLib) and [TriggerLib](https://github.com/MisakiBear/TriggerLib).
.Net5.0 is needed.
Using library [BearMarkupLanguageLib](https://github.com/MisakiBear/BearMarkupLanguageLib) and [TriggerLib](https://github.com/MisakiBear/TriggerLib).
.Net6.0 is needed.

> Old Repository: https://github.com/MisakiBear/Subtitle-Player-Obsolete-

# 字幕プレーヤー
BearSubPlayer
外部で字幕を再生できるシンプルな字幕プレーヤー(*.srt *.assをサポート)

この字幕プレーヤーでは,オンライン動画を視聴する際に,字幕がない時や字幕の品質が悪い時に役立ちます.
この字幕プレーヤーは,オンライン動画を視聴する際に,字幕がない時や字幕の品質が悪い時に役立ちます.

.Net5.0が必要です.
.Net6.0が必要です.

0 comments on commit fcd0de5

Please sign in to comment.