Skip to content

Commit

Permalink
1.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paissaheavyindustries committed Apr 25, 2023
1 parent 951a845 commit 383e17f
Show file tree
Hide file tree
Showing 6 changed files with 536 additions and 54 deletions.
6 changes: 4 additions & 2 deletions Telesto/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ public class Config : IPluginConfiguration

public int Version { get; set; } = 0;

public bool AutostartEndpoint { get; set; } = true;
public bool Opened { get; set; } = true;

public string HttpEndpoint { get; set; } = "http://localhost:51323/";
public bool AutostartEndpoint { get; set; } = true;
public string HttpEndpoint { get; set; } = "http://localhost:45678/";
public bool DismissUpgrade { get; set; } = false;

}

Expand Down
8 changes: 8 additions & 0 deletions Telesto/Doodle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ internal static Doodle Deserialize(Dictionary<string, object> d)
case "image":
doo = new Doodles.Image();
break;
case "cone":
doo = new Doodles.Cone();
break;
case "donut":
doo = new Doodles.Donut();
break;
default:
throw new ArgumentException(String.Format("Unsupported doodle type '{0}'", type));
}
if (doo != null)
{
Expand Down
144 changes: 144 additions & 0 deletions Telesto/Doodles/Cone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;
using ImGuiNET;
using System;
using System.Collections.Generic;
using Vector2 = System.Numerics.Vector2;
using Vector3 = System.Numerics.Vector3;

namespace Telesto.Doodles
{

internal class Cone : Doodle
{

internal enum CoordSystemEnum
{
Screen,
World
}

internal CoordSystemEnum csys { get; set; }
internal Coordinate position { get; set; }
internal Coordinate target { get; set; }
internal float radiuschonk { get; set; }
internal float linechonk { get; set; }
internal float anglechonk { get; set; }
internal float headingchonk { get; set; }
internal string Radius { get; set; }
internal string Thickness { get; set; }
internal string Angle { get; set; }
internal string Heading { get; set; }
internal bool filled { get; set; }
internal bool targeted { get; set; }

internal override Coordinate GetCoordinateByName(string id)
{
switch (id.ToLower())
{
default:
case "position": return position;
}
}

internal override void Initialize(Dictionary<string, object> d)
{
base.Initialize(d);
Radius = (d.ContainsKey("radius") == true) ? d["radius"].ToString() : "10";
Thickness = (d.ContainsKey("thickness") == true) ? d["thickness"].ToString() : "1";
Angle = (d.ContainsKey("angle") == true) ? d["angle"].ToString() : "pi05";
Heading = (d.ContainsKey("heading") == true) ? d["heading"].ToString() : "0";
string fill = (d.ContainsKey("filled") == true) ? d["filled"].ToString() : "false";
filled = false;
bool.TryParse(fill, out bool filledtemp);
filled = filledtemp;
position = new Coordinate() { doo = this };
if (d.ContainsKey("position") == true)
{
position.Initialize((Dictionary<string, object>)d["position"]);
}
if (d.ContainsKey("target") == true)
{
target = new Coordinate() { doo = this };
target.Initialize((Dictionary<string, object>)d["target"]);
targeted = true;
}
string csystem = (d.ContainsKey("system") == true) ? d["system"].ToString() : "screen";
switch (csystem.ToLower())
{
case "world":
csys = CoordSystemEnum.World;
break;
default:
csys = CoordSystemEnum.Screen;
break;
}
}

internal override bool Update()
{
if (base.Update() == false)
{
return false;
}
position.RefreshVector(p);
radiuschonk = (float)p.EvaluateNumericExpression(this, Radius);
linechonk = (float)p.EvaluateNumericExpression(this, Thickness);
anglechonk = (float)p.EvaluateNumericExpression(this, Angle);
if (targeted == true)
{
Vector3 temp1 = position.UntranslatedPosition(p);
Vector3 temp2 = target.UntranslatedPosition(p);
headingchonk = -1.0f * (float)Math.Atan2(temp1.Z - temp2.Z, temp1.X - temp2.X) - (float)(Math.PI / 2.0f);
}
else
{
headingchonk = (float)p.EvaluateNumericExpression(this, Heading);
}
return true;
}

internal override void Draw()
{
if (csys == CoordSystemEnum.Screen)
{
}
else
{
Vector3 temp = position.UntranslatedPosition(p);
int segments = (int)Math.Ceiling(48.0 / Math.PI * 2.0 * anglechonk);
segments = segments < 2 ? 2 : segments;
float segangle = anglechonk / (float)segments;
Vector3 mid = p.TranslateToScreen(temp.X, temp.Y, temp.Z);
ImGui.GetWindowDrawList().PathLineTo(new Vector2(mid.X, mid.Y));
float baseangle = headingchonk - (anglechonk / 2.0f);
for (int i = 0; i < segments; i++)
{
Vector3 mauw = p.TranslateToScreen(
temp.X + (radiuschonk * Math.Sin(baseangle + (segangle * i))),
temp.Y,
temp.Z + (radiuschonk * Math.Cos(baseangle + (segangle * i)))
);
ImGui.GetWindowDrawList().PathLineTo(new Vector2(mauw.X, mauw.Y));
}
ImGui.GetWindowDrawList().PathLineTo(new Vector2(mid.X, mid.Y));
if (filled == true)
{
ImGui.GetWindowDrawList().PathFillConvex(
ImGui.GetColorU32(col)
);
}
else
{
ImGui.GetWindowDrawList().PathStroke(
ImGui.GetColorU32(col),
ImDrawFlags.None,
linechonk
);
}
}
}

}

}
160 changes: 160 additions & 0 deletions Telesto/Doodles/Donut.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
using Dalamud.Interface.Style;
using ImGuiNET;
using System;
using System.Collections.Generic;
using Vector2 = System.Numerics.Vector2;
using Vector3 = System.Numerics.Vector3;

namespace Telesto.Doodles
{

internal class Donut : Doodle
{

internal enum CoordSystemEnum
{
Screen,
World
}

internal CoordSystemEnum csys { get; set; }
internal Coordinate position { get; set; }
internal float innerradiuschonk { get; set; }
internal float outerradiuschonk { get; set; }
internal float linechonk { get; set; }
internal string InnerRadius { get; set; }
internal string OuterRadius { get; set; }
internal string Thickness { get; set; }
internal bool filled { get; set; }

internal override Coordinate GetCoordinateByName(string id)
{
switch (id.ToLower())
{
default:
case "position": return position;
}
}

internal override void Initialize(Dictionary<string, object> d)
{
base.Initialize(d);
InnerRadius = (d.ContainsKey("innerradius") == true) ? d["innerradius"].ToString() : "10";
OuterRadius = (d.ContainsKey("outerradius") == true) ? d["outerradius"].ToString() : "15";
Thickness = (d.ContainsKey("thickness") == true) ? d["thickness"].ToString() : "1";
string fill = (d.ContainsKey("filled") == true) ? d["filled"].ToString() : "false";
filled = false;
bool.TryParse(fill, out bool filledtemp);
filled = filledtemp;
position = new Coordinate() { doo = this };
if (d.ContainsKey("position") == true)
{
position.Initialize((Dictionary<string, object>)d["position"]);
}
string csystem = (d.ContainsKey("system") == true) ? d["system"].ToString() : "screen";
switch (csystem.ToLower())
{
case "world":
csys = CoordSystemEnum.World;
break;
default:
csys = CoordSystemEnum.Screen;
break;
}
}

internal override bool Update()
{
if (base.Update() == false)
{
return false;
}
position.RefreshVector(p);
innerradiuschonk = (float)p.EvaluateNumericExpression(this, InnerRadius);
outerradiuschonk = (float)p.EvaluateNumericExpression(this, OuterRadius);
linechonk = (float)p.EvaluateNumericExpression(this, Thickness);
return true;
}

internal override void Draw()
{
if (csys == CoordSystemEnum.Screen)
{
}
else
{
Vector3 temp = position.UntranslatedPosition(p);
if (filled == false)
{
for (int i = 0; i <= 48; i++)
{
Vector3 mauw = p.TranslateToScreen(
temp.X + (innerradiuschonk * Math.Sin((Math.PI / 24.0) * i)),
temp.Y,
temp.Z + (innerradiuschonk * Math.Cos((Math.PI / 24.0) * i))
);
ImGui.GetWindowDrawList().PathLineTo(new Vector2(mauw.X, mauw.Y));
}
ImGui.GetWindowDrawList().PathStroke(
ImGui.GetColorU32(col),
ImDrawFlags.None,
linechonk
);
for (int i = 0; i <= 48; i++)
{
Vector3 mauw = p.TranslateToScreen(
temp.X + (outerradiuschonk * Math.Sin((Math.PI / 24.0) * i)),
temp.Y,
temp.Z + (outerradiuschonk * Math.Cos((Math.PI / 24.0) * i))
);
ImGui.GetWindowDrawList().PathLineTo(new Vector2(mauw.X, mauw.Y));
}
ImGui.GetWindowDrawList().PathStroke(
ImGui.GetColorU32(col),
ImDrawFlags.None,
linechonk
);
}
else
{
Vector3 v1, v2, v3, v4;
v1 = p.TranslateToScreen(
temp.X + (innerradiuschonk * Math.Sin((Math.PI / 23.0) * 0)),
temp.Y,
temp.Z + (innerradiuschonk * Math.Cos((Math.PI / 24.0) * 0))
);
v4 = p.TranslateToScreen(
temp.X + (outerradiuschonk * Math.Sin((Math.PI / 24.0) * 0)),
temp.Y,
temp.Z + (outerradiuschonk * Math.Cos((Math.PI / 24.0) * 0))
);
for (int i = 0; i <= 47; i++)
{
v2 = p.TranslateToScreen(
temp.X + (innerradiuschonk * Math.Sin((Math.PI / 24.0) * (i + 1))),
temp.Y,
temp.Z + (innerradiuschonk * Math.Cos((Math.PI / 24.0) * (i + 1)))
);
v3 = p.TranslateToScreen(
temp.X + (outerradiuschonk * Math.Sin((Math.PI / 24.0) * (i + 1))),
temp.Y,
temp.Z + (outerradiuschonk * Math.Cos((Math.PI / 24.0) * (i + 1)))
);
ImGui.GetWindowDrawList().PathLineTo(new Vector2(v1.X, v1.Y));
ImGui.GetWindowDrawList().PathLineTo(new Vector2(v2.X, v2.Y));
ImGui.GetWindowDrawList().PathLineTo(new Vector2(v3.X, v3.Y));
ImGui.GetWindowDrawList().PathLineTo(new Vector2(v4.X, v4.Y));
ImGui.GetWindowDrawList().PathLineTo(new Vector2(v1.X, v1.Y));
ImGui.GetWindowDrawList().PathFillConvex(
ImGui.GetColorU32(col)
);
v1 = v2;
v4 = v3;
}
}
}
}

}

}
8 changes: 8 additions & 0 deletions Telesto/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public void Start()
{
try
{
if (Status != StatusEnum.Stopped)
{
return;
}
SetStatus(StatusEnum.Starting, null);
HttpListener http = new HttpListener();
http.Prefixes.Clear();
Expand Down Expand Up @@ -84,6 +88,10 @@ public void Start()

public void Stop()
{
if (Status != StatusEnum.Started)
{
return;
}
SetStatus(StatusEnum.Stopping, null);
lock (this)
{
Expand Down
Loading

0 comments on commit 383e17f

Please sign in to comment.