mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-01 10:39:50 +08:00
* AutoFishing为单元测试重构;一个简单的单元测试GetFishpondTest * 将鼠标操作的注入挪到DesktopRegion中;提供LoadAssetImage的一个不依赖配置的重载;ChooseBait的代码中将Bv的方法替换成不依赖配置的写法;完成ChooseBait的单元测试 * 使用TimeProvider改写ChooseBait以适用单元测试;添加假的绘图上下文类;添加抛竿行为的单元测试 * 选择鱼饵行为比对上次选择的鱼饵,如果相同则直接抛竿(之前的版本曾有此逻辑),但测下来有时会选错饵导致无限抛竿,调整了相关步骤的等待间隔,希望能简单地压制此bug * 获取鱼群时过滤“获得”界面的鱼图标:1、在Fishpond构造函数中实现。2、配有此类情况的单元测试。3、并由此降低鱼钓上后的等待时间; 修复绘制鱼群时索引不正确导致遗漏的bug;获取鱼群时绘制鱼群供分析
124 lines
3.0 KiB
C#
124 lines
3.0 KiB
C#
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
|
|
namespace BetterGenshinImpact.View.Drawable;
|
|
|
|
public class DrawContent
|
|
{
|
|
/// <summary>
|
|
/// 在遮罩窗口上绘制的矩形
|
|
/// </summary>
|
|
public ConcurrentDictionary<string, List<RectDrawable>> RectList { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// 在遮罩窗口上绘制的文本
|
|
/// </summary>
|
|
public ConcurrentDictionary<string, List<TextDrawable>> TextList { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// 在遮罩窗口上绘制的文本
|
|
/// </summary>
|
|
public ConcurrentDictionary<string, List<LineDrawable>> LineList { get; set; } = new();
|
|
|
|
public virtual void PutRect(string key, RectDrawable newRect)
|
|
{
|
|
if (RectList.TryGetValue(key, out var prevRect))
|
|
{
|
|
if (prevRect.Count == 0 && newRect.Equals(prevRect[0]))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
RectList[key] = [newRect];
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
|
|
public virtual void PutOrRemoveRectList(string key, List<RectDrawable>? list)
|
|
{
|
|
bool changed = false;
|
|
|
|
if (RectList.TryGetValue(key, out var prevRect))
|
|
{
|
|
if (list == null)
|
|
{
|
|
RectList.TryRemove(key, out _);
|
|
changed = true;
|
|
}
|
|
else if (prevRect.Count != list.Count)
|
|
{
|
|
RectList[key] = list;
|
|
changed = true;
|
|
}
|
|
else
|
|
{
|
|
// 不逐一比较了,使用这个方法的地方,都是在每一帧都会刷新的
|
|
RectList[key] = list;
|
|
changed = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (list is { Count: > 0 })
|
|
{
|
|
RectList[key] = list;
|
|
changed = true;
|
|
}
|
|
}
|
|
|
|
if (changed)
|
|
{
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
}
|
|
|
|
public virtual void RemoveRect(string key)
|
|
{
|
|
if (RectList.TryGetValue(key, out _))
|
|
{
|
|
RectList.TryRemove(key, out _);
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
}
|
|
|
|
public virtual void PutLine(string key, LineDrawable newLine)
|
|
{
|
|
if (LineList.TryGetValue(key, out var prev))
|
|
{
|
|
if (prev.Count == 0 && newLine.Equals(prev[0]))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
LineList[key] = [newLine];
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
|
|
|
|
public virtual void RemoveLine(string key)
|
|
{
|
|
if (LineList.TryGetValue(key, out _))
|
|
{
|
|
LineList.TryRemove(key, out _);
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 清理所有绘制内容
|
|
/// </summary>
|
|
public virtual void ClearAll()
|
|
{
|
|
if (RectList.IsEmpty && TextList.IsEmpty && LineList.IsEmpty)
|
|
{
|
|
return;
|
|
}
|
|
RectList.Clear();
|
|
TextList.Clear();
|
|
LineList.Clear();
|
|
MaskWindow.Instance().Refresh();
|
|
}
|
|
} |