Skip to content

Commit

Permalink
优化使用寒霜弹幕使的同屏密度选项,修复显示区域选项未生效
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Oct 3, 2023
1 parent 53cf1a9 commit ba196cc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ private void LoadDanmuSetting()
{
if (miniWin) return;
SettingService.SetValue<double>(SettingConstants.VideoDanmaku.AREA, DanmuSettingArea.Value);
m_danmakuController.SetArea(DanmuSettingArea.Value);
});

//弹幕速度
Expand Down Expand Up @@ -559,11 +560,17 @@ private void LoadDanmuSetting()
//弹幕最大值
DanmuSettingMaxNum.Value = SettingService.GetValue<double>(SettingConstants.VideoDanmaku.MAX_NUM, 0);
m_danmakuController.SetDensity((int)DanmuSettingMaxNum.Value);
DanmuSettingMaxNum.ValueChanged += new RangeBaseValueChangedEventHandler((e, args) =>
DanmuSettingMaxNum.ValueChanged += async (e, args) =>
{
SettingService.SetValue<double>(SettingConstants.VideoDanmaku.MAX_NUM, DanmuSettingMaxNum.Value);
m_danmakuController.SetDensity((int)DanmuSettingMaxNum.Value);
});
if (!m_useNsDanmaku)
{
var segIndex = Convert.ToInt32(Math.Ceiling(Player.Position / (60 * 6d)));
if (segIndex <= 0) segIndex = 1;
await LoadDanmaku(segIndex);
}
};

//弹幕云屏蔽等级
DanmuSettingShieldLevel.Value = SettingService.GetValue<int>(SettingConstants.VideoDanmaku.SHIELD_LEVEL, 0);
Expand Down Expand Up @@ -820,8 +827,15 @@ private List<DanmakuItem> FilterFrostDanmaku(IEnumerable<DanmakuItem> danmakus)
danmakus = danmakus.Where(x => !Regex.IsMatch(x.Text, item));
}

//danmakus = danmakus.GroupBy(x => x.StartMs).ToDictionary(x => (int)x.Key, x => x.ToList())
// .TakeIf(max > 0, max).SelectMany(x=>x.Value);
// 同屏密度
if (max > 0)
{
// 弹幕按每秒分组,每组取前x项
danmakus = danmakus.GroupBy(x => (x.StartMs / 1000) * 1000)
.ToDictionary(x => (int)x.Key, x => x.ToList())
.SelectMany(x => x.Value.Take(max));
}

return danmakus.ToList();
}

Expand Down
14 changes: 10 additions & 4 deletions src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public FrostMasterDanmakuController()
{
DanmakuViewModel = new DanmakuViewModel()
{
ShowAreaControl = false,
ShowAreaControl = true,
ShowBoldControl = false,
ShowBoldStyleControl = false,
IsHide = false,
Expand Down Expand Up @@ -118,12 +118,18 @@ public override void SetBold(bool bold)
m_danmakuMaster.SetIsTextBold(bold);
}

public override void SetDensity(int density)
public override void SetArea(double area)
{
base.SetDensity(density);
m_danmakuMaster.SetRollingDensity(density-1);
base.SetArea(area);
m_danmakuMaster.SetRollingAreaRatio((int)(area*10));
}

//public override void SetDensity(int density)
//{
// base.SetDensity(density);
// //m_danmakuMaster.SetRollingDensity(density-1);
//}

public override void Load(IEnumerable danmakuList)
{
var realDanmakuList = (danmakuList as List<DanmakuItem>).ToList();
Expand Down

0 comments on commit ba196cc

Please sign in to comment.