Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimap angle #672

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Daybreak/Controls/Minimap/GuildwarsMinimap.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
using System.Diagnostics;
using Daybreak.Models.FocusView;
using Daybreak.Models.LaunchConfigurations;
using System.Configuration;
using System.Runtime.CompilerServices;

namespace Daybreak.Controls.Minimap;

Expand Down Expand Up @@ -349,6 +347,7 @@ private void DrawEntities()

this.CalculatePathsToObjectives();

var angleRads = -(Math.PI / 180 * this.Angle);
var foregroundColor = this.FindResource("MahApps.Colors.ThemeBackground").Cast<Color>();
bitmap.Clear(Colors.Transparent);
using var context = bitmap.GetBitmapContext();
Expand All @@ -365,9 +364,9 @@ private void DrawEntities()
this.drawingService.DrawEngagementArea(bitmap, this.GameData);
this.drawingService.DrawMainPlayerPositionHistory(bitmap, this.mainPlayerPositionHistory);
this.drawingService.DrawPaths(bitmap, this.pathfindingCache);
this.drawingService.DrawQuestObjectives(bitmap, this.GameData.MainPlayer?.QuestLog ?? []);
this.drawingService.DrawMapIcons(bitmap, this.GameData.MapIcons ?? []);
this.drawingService.DrawEntities(bitmap, this.GameData, this.TargetEntityId);
this.drawingService.DrawQuestObjectives(bitmap, this.GameData.MainPlayer?.QuestLog ?? [], angleRads);
this.drawingService.DrawMapIcons(bitmap, this.GameData.MapIcons ?? [], angleRads);
this.drawingService.DrawEntities(bitmap, this.GameData, this.TargetEntityId, angleRads);
bitmap.Unlock();
this.drawingLatency.Record(sw.ElapsedMilliseconds);
}
Expand Down Expand Up @@ -819,7 +818,6 @@ private static Point RotatePointAroundPivot(Point point, Point pivot, double ang
return new Point(rotatedX, rotatedY);
}


private static bool PositionsCollide(Position position1, Position position2)
{
var a = PositionRadius + PositionRadius;
Expand Down
16 changes: 8 additions & 8 deletions Daybreak/Services/Drawing/DrawingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public bool IsEntityOnScreen(Position? position, out int x, out int y)
return true;
}

public void DrawEntities(WriteableBitmap bitmap, GameData gameData, int targetEntityId)
public void DrawEntities(WriteableBitmap bitmap, GameData gameData, int targetEntityId, double angle)
{
if (bitmap is null)
{
Expand Down Expand Up @@ -100,7 +100,7 @@ gameData.Party is null ||
{
if (module.CanDrawEntity(entity))
{
module.DrawEntity(finalX, finalY, this.finalEntitySize, bitmap, false, this.foregroundColor);
module.DrawEntity(finalX, finalY, this.finalEntitySize, angle, bitmap, false, this.foregroundColor);
}
}
}
Expand All @@ -113,7 +113,7 @@ gameData.Party is null ||
{
if (module.CanDrawEntity(targetedEntity))
{
module.DrawEntity(finalTargetedX, finalTargetedY, this.finalEntitySize, bitmap, true, this.foregroundColor);
module.DrawEntity(finalTargetedX, finalTargetedY, this.finalEntitySize, angle, bitmap, true, this.foregroundColor);
}
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public void DrawMainPlayerPositionHistory(WriteableBitmap bitmap, List<Position>
}
}

public void DrawMapIcons(WriteableBitmap bitmap, List<MapIcon> mapIcons)
public void DrawMapIcons(WriteableBitmap bitmap, List<MapIcon> mapIcons, double angle)
{
if (bitmap is null)
{
Expand All @@ -171,7 +171,7 @@ public void DrawMapIcons(WriteableBitmap bitmap, List<MapIcon> mapIcons)
break;
}

module.DrawMapIcon(finalX, finalY, this.finalEntitySize, bitmap, mapIcon.Affiliation!.Value, this.foregroundColor);
module.DrawMapIcon(finalX, finalY, this.finalEntitySize, angle, bitmap, mapIcon.Affiliation!.Value, this.foregroundColor);
}
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ public void DrawPaths(WriteableBitmap bitmap, PathfindingCache? pathfindingCache
}
}

public void DrawQuestObjectives(WriteableBitmap bitmap, IEnumerable<QuestMetadata> quests)
public void DrawQuestObjectives(WriteableBitmap bitmap, IEnumerable<QuestMetadata> quests, double angle)
{
if (bitmap is null)
{
Expand All @@ -255,12 +255,12 @@ public void DrawQuestObjectives(WriteableBitmap bitmap, IEnumerable<QuestMetadat
var position = this.ForceOnScreenPosition(questMetadata.Position!.Value);
if (this.IsEntityOnScreen(questMetadata.Position!.Value, out var finalX, out var finalY))
{
module.DrawQuestObjective(finalX, finalY, this.finalEntitySize, bitmap, GetQuestColor(questMetadata), this.foregroundColor);
module.DrawQuestObjective(finalX, finalY, this.finalEntitySize, angle, bitmap, GetQuestColor(questMetadata), this.foregroundColor);
}
else
{
this.IsEntityOnScreen(position, out var finalOnscreenX, out var finalOnscreenY);
module.DrawQuestObjective(finalX, finalY, this.finalEntitySize, bitmap, GetQuestColor(questMetadata), this.foregroundColor);
module.DrawQuestObjective(finalX, finalY, this.finalEntitySize, angle, bitmap, GetQuestColor(questMetadata), this.foregroundColor);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Daybreak/Services/Drawing/IDrawingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public interface IDrawingService

void DrawPaths(WriteableBitmap writeableBitmap, PathfindingCache? pathfindingCache);

void DrawEntities(WriteableBitmap bitmap, GameData gameData, int targetEntityId);
void DrawEntities(WriteableBitmap bitmap, GameData gameData, int targetEntityId, double angle);

void DrawQuestObjectives(WriteableBitmap bitmap, IEnumerable<QuestMetadata> quests);
void DrawQuestObjectives(WriteableBitmap bitmap, IEnumerable<QuestMetadata> quests, double angle);

void DrawMainPlayerPositionHistory(WriteableBitmap bitmap, List<Position> mainPlayerPositionHistory);

void DrawMapIcons(WriteableBitmap bitmap, List<MapIcon> mapIcons);
void DrawMapIcons(WriteableBitmap bitmap, List<MapIcon> mapIcons, double angle);

void DrawEngagementArea(WriteableBitmap bitmap, GameData gameData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public override bool CanDrawEntity(IEntity entity)
livingEntity.State is LivingEntityState.Boss;
}

public override void DrawEntity(int finalX, int finalY, int size, WriteableBitmap bitmap, bool targeted, Color shade)
public override void DrawEntity(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, bool targeted, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, targeted ? this.OutlineColor : this.FillColor, this.FillColor, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, targeted ? this.OutlineColor : this.FillColor, this.FillColor, shade);
}
}
6 changes: 3 additions & 3 deletions Daybreak/Services/Drawing/Modules/DrawingModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public abstract class DrawingModuleBase

public virtual bool CanDrawEngagementArea(IEntity entity) => false;

public virtual void DrawEntity(int finalX, int finalY, int size, WriteableBitmap bitmap, bool targeted, Color shade) { }
public virtual void DrawEntity(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, bool targeted, Color shade) { }

public virtual void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation affiliation, Color shade) { }
public virtual void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation affiliation, Color shade) { }

public virtual void DrawPlayerPositionHistory(int finalX, int finalY, int size, WriteableBitmap bitmap, Color shade) { }

public virtual void DrawPathFinding(int finalX, int finalY, int size, WriteableBitmap bitmap, Color color, Color shade) { }

public virtual void DrawQuestObjective(int finalX, int finalY, int size, WriteableBitmap bitmap, Color color, Color shade) { }
public virtual void DrawQuestObjective(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Color color, Color shade) { }

public virtual void DrawEngagementArea(int finalX, int finalY, int size, WriteableBitmap bitmap, Color shade) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public override bool CanDrawEntity(IEntity entity)
livingEntity.NpcDefinition == Npc.Unknown);
}

public override void DrawEntity(int finalX, int finalY, int size, WriteableBitmap bitmap, bool targeted, Color shade)
public override void DrawEntity(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, bool targeted, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, (int)(size / 1.3), this.StrokeColor, Colors.Transparent, shade);
this.DrawSvg(bitmap, finalX, finalY, (int)(size / 1.3), angle, this.StrokeColor, Colors.Transparent, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.AreaMap;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, Colors.Transparent, Colors.Transparent, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, Colors.Transparent, Colors.Transparent, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.Collector;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation _, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation _, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, Colors.Transparent, Colors.Transparent, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, Colors.Transparent, Colors.Transparent, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.DungeonBoss;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, Colors.Transparent, ColorPalette.Red, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, Colors.Transparent, ColorPalette.Red, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.ResurrectionShrine;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation _, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation _, Color shade)
{
this.DrawCross(bitmap, finalX, finalY, size, Colors.CornflowerBlue, shade);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.StairsDown;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation _, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation _, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, Colors.White, Colors.Red, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, Colors.White, Colors.Red, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public override bool CanDrawMapIcon(MapIcon mapIcon)
return mapIcon.Icon == GuildwarsIcon.StairsUp;
}

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation _, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation _, Color shade)
{
this.DrawSvg(bitmap, finalX, finalY, size, Colors.White, Colors.Red, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, Colors.White, Colors.Red, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public abstract class CircleEntityDrawingModuleBase : CircleDrawingModuleBase
{
protected abstract Color FillColor { get; }

public override void DrawEntity(int finalX, int finalY, int size, WriteableBitmap bitmap, bool targeted, Color shade)
public override void DrawEntity(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, bool targeted, Color shade)
{
this.DrawFilledCircle(bitmap, finalX, finalY, size, this.FillColor, shade);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public abstract class CircleTargetedEntityDrawingModuleBase : CircleEntityDrawin
{
protected virtual Color OutlineColor { get; } = Colors.Chocolate;

public override sealed void DrawEntity(int finalX, int finalY, int size, WriteableBitmap bitmap, bool targeted, Color shade)
public override sealed void DrawEntity(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, bool targeted, Color shade)
{
if (targeted)
{
var outlineSize = size + (size / 5);
this.DrawFilledCircle(bitmap, finalX, finalY, outlineSize, this.OutlineColor, shade);
}

base.DrawEntity(finalX, finalY, size, bitmap, targeted, shade);
base.DrawEntity(finalX, finalY, size, angle, bitmap, targeted, shade);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ public abstract class ColoredEmbeddedSvgDrawingModuleBase<TDerivingType> : Embed
{
protected abstract Color StrokeColor { get; }

public override void DrawMapIcon(int finalX, int finalY, int size, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
public override void DrawMapIcon(int finalX, int finalY, int size, double angle, WriteableBitmap bitmap, Affiliation affiliation, Color shade)
{
switch (affiliation)
{
case Affiliation.Gray:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, Colors.Red, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, Colors.Red, shade);
break;
case Affiliation.Red:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Red, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Red, shade);
break;
case Affiliation.Blue:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Blue, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Blue, shade);
break;
case Affiliation.Yellow:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Yellow, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Yellow, shade);
break;
case Affiliation.Green:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Green, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Green, shade);
break;
case Affiliation.GrayNeutral:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, Colors.Gray, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, Colors.Gray, shade);
break;
case Affiliation.Teal:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Teal, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Teal, shade);
break;
case Affiliation.Purple:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, ColorPalette.Purple, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, ColorPalette.Purple, shade);
break;
case Affiliation.Any:
this.DrawSvg(bitmap, finalX, finalY, size, this.StrokeColor, Colors.Gray, shade);
this.DrawSvg(bitmap, finalX, finalY, size, angle, this.StrokeColor, Colors.Gray, shade);
break;

}
Expand Down
Loading
Loading