Skip to content

Commit

Permalink
added thickness and world size support to line decorations
Browse files Browse the repository at this point in the history
  • Loading branch information
EliphasNUIT committed Nov 22, 2024
1 parent 58a49ef commit fe6a990
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
20 changes: 18 additions & 2 deletions GW2EIBuilders/Resources/JS/CR-JS/decorations.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class DoughnutDecorationMetadata extends FormDecorationMetadata {
class LineDecorationMetadata extends FormDecorationMetadata {
constructor(params) {
super(params);
this.thickness = params.thickness;
this.worldSizeThickness = params.worldSizeThickness;
if (this.worldSizeThickness) {
this.thickness *= InchToPixel;
}
}
}

Expand Down Expand Up @@ -693,6 +698,14 @@ class LineMechanicDrawable extends FormMechanicDrawable {
this.endMaster = null;
}

get thickness() {
return this.metadata.thickness;
}

get worldSizeThickness() {
return this.metadata.worldSizeThickness;
}

getTargetPosition() {
var time = animator.reactiveDataStatus.time;
if (this.start > time || this.end < time) {
Expand Down Expand Up @@ -749,8 +762,11 @@ class LineMechanicDrawable extends FormMechanicDrawable {
ctx.lineTo(percent * (target.x - pos.x), percent * (target.y - pos.y));
ctx.closePath();
}

ctx.lineWidth = (2 / animator.scale).toString();
let thickness = this.thickness;
if (!this.worldSizeThickness) {
thickness /= animator.scale;
}
ctx.lineWidth = (thickness).toString();
ctx.strokeStyle = this.color;
ctx.stroke();
ctx.restore();
Expand Down
13 changes: 9 additions & 4 deletions GW2EIEvtcParser/EIData/CombatReplay/CombatReplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ internal void AddDecorationWithBorder(FormDecoration decoration, long growingEnd
/// </summary>
/// <param name="tethers">Buff events of the tethers.</param>
/// <param name="color">color of the tether</param>
internal void AddTether(IEnumerable<BuffEvent> tethers, string color)
/// <param name="thickness">thickness of the tether</param>
/// <param name="worldSizeThickess">true to indicate that thickness is in inches instead of pixels</param>
internal void AddTether(IEnumerable<BuffEvent> tethers, string color, uint thickness = 2, bool worldSizeThickess = false)
{
int tetherStart = 0;
AgentItem src = ParserHelper._unknownAgent;
Expand All @@ -475,7 +477,7 @@ internal void AddTether(IEnumerable<BuffEvent> tethers, string color)
int tetherEnd = (int)tether.Time;
if (src != ParserHelper._unknownAgent && dst != ParserHelper._unknownAgent)
{
Decorations.Add(new LineDecoration((tetherStart, tetherEnd), color, new AgentConnector(dst), new AgentConnector(src)));
Decorations.Add(new LineDecoration((tetherStart, tetherEnd), color, new AgentConnector(dst), new AgentConnector(src)).WithThickess(thickness, worldSizeThickess));
src = ParserHelper._unknownAgent;
dst = ParserHelper._unknownAgent;
}
Expand All @@ -487,9 +489,12 @@ internal void AddTether(IEnumerable<BuffEvent> tethers, string color)
/// </summary>
/// <param name="tethers">Buff events of the tethers.</param>
/// <param name="color">color of the tether</param>
internal void AddTether(IEnumerable<BuffEvent> tethers, Color color, double opacity)
/// <param name="opacity">opacity of the tether</param>
/// <param name="thickness">thickness of the tether</param>
/// <param name="worldSizeThickess">true to indicate that thickness is in inches instead of pixels</param>
internal void AddTether(IEnumerable<BuffEvent> tethers, Color color, double opacity, uint thickness = 2, bool worldSizeThickess = false)
{
AddTether(tethers, color.WithAlpha(opacity).ToString(true));
AddTether(tethers, color.WithAlpha(opacity).ToString(true), thickness, worldSizeThickess);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ namespace GW2EIEvtcParser.EIData;
public class LineDecorationMetadataDescription : FormDecorationMetadataDescription
{

public readonly bool WorldSizeThickness;
public readonly uint Thickness;
internal LineDecorationMetadataDescription(LineDecorationMetadata decoration) : base(decoration)
{
Type = "Line";
WorldSizeThickness = decoration.WorldSizeThickness;
Thickness = decoration.Thickness;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ internal class LineDecoration : FormDecoration
{
internal class LineDecorationMetadata : FormDecorationMetadata
{
public bool WorldSizeThickness;
public uint Thickness;
public LineDecorationMetadata(string color, uint thickness = 2, bool worldSizeThickness = false) : base(color)
{
Thickness = thickness;
WorldSizeThickness = worldSizeThickness;
}

public LineDecorationMetadata(string color) : base(color)
public void WithThickess(uint thickness, bool worldSizeThickness = false)
{
Thickness = thickness;
WorldSizeThickness = worldSizeThickness;
}

public override string GetSignature()
{
return "Line" + Color;
return "Line" + Color + "Thickness" + Thickness + "WorldSize" + WorldSizeThickness;
}
public override DecorationMetadataDescription GetCombatReplayMetadataDescription()
{
Expand Down Expand Up @@ -41,6 +50,9 @@ public override DecorationRenderingDescription GetCombatReplayRenderingDescripti
}
private new LineDecorationRenderingData DecorationRenderingData => (LineDecorationRenderingData)base.DecorationRenderingData;
public GeographicalConnector ConnectedFrom => DecorationRenderingData.ConnectedFrom;
private new LineDecorationMetadata DecorationMetadata => (LineDecorationMetadata)base.DecorationMetadata;
public bool WorldSizeThickness => DecorationMetadata.WorldSizeThickness;
public uint Thickness => DecorationMetadata.Thickness;

internal LineDecoration(LineDecorationMetadata metadata, LineDecorationRenderingData renderingData) : base(metadata, renderingData)
{
Expand All @@ -65,6 +77,12 @@ public override FormDecoration Copy(string? color = null)
return (FormDecoration)new LineDecoration(Lifespan, color ?? Color, ConnectedTo, ConnectedFrom).UsingFilled(Filled).UsingGrowingEnd(GrowingEnd, GrowingReverse).UsingRotationConnector(RotationConnectedTo).UsingSkillMode(SkillMode);
}

public LineDecoration WithThickess(uint thickness, bool worldSizeThickness = false)
{
DecorationMetadata.WithThickess(thickness, worldSizeThickness);
return this;
}

public override FormDecoration GetBorderDecoration(string? borderColor = null)
{
throw new InvalidOperationException("Lines can't have borders");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using GW2EIEvtcParser.Exceptions;
using GW2EIEvtcParser.ParsedData;
using GW2EIEvtcParser.ParserHelpers;
using static GW2EIEvtcParser.EncounterLogic.EncounterCategory;
using static GW2EIEvtcParser.EncounterLogic.EncounterImages;
using static GW2EIEvtcParser.EncounterLogic.EncounterLogicPhaseUtils;
using static GW2EIEvtcParser.EncounterLogic.EncounterLogicUtils;
using static GW2EIEvtcParser.SkillIDs;

namespace GW2EIEvtcParser.EncounterLogic;
Expand Down Expand Up @@ -104,6 +104,8 @@ internal override void ComputeNPCCombatReplayActors(NPC target, ParsedEvtcLog lo
//replay.Decorations.Add(new CircleDecoration(150, aoeLifeSpan, Colors.DarkPurple, 0.3, new PositionConnector(effect.Position)));
}
}
var walls = GetFilteredList(log.CombatData, DecimaConduitWallBuff, target, true, true);
replay.AddTether(walls, Colors.Purple, 0.4, 60, true);
break;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions GW2EIEvtcParser/ParserHelpers/SkillIDs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4522,6 +4522,7 @@ public static class SkillIDs
public const long TargetOrder3JW = 74789;
public const long HarmonicSensitivity = 74904;
public const long SulfuricAcid = 74933;
public const long DecimaConduitWallBuff = 74962;
public const long ThrummingPresence = 74982;
public const long TargetOrder1JW = 75023;
public const long TargetOrder5JW = 75034;
Expand Down

0 comments on commit fe6a990

Please sign in to comment.