mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
feat: vertical tanks tree connections added
This commit is contained in:
1 parent
5a60c8e906
commit
1081d6297f
9 files changed
+85
-46
No files matched your search
+6
-12
@@ -11,24 +11,18 @@ namespace WotBlitzStatisticsPro.Blazor.GraphQl
|
||||
{
|
||||
return serializedValue switch
|
||||
{
|
||||
"NONE" => MarkOfMastery.None,
|
||||
"RANK3" => MarkOfMastery.Rank3,
|
||||
"RANK2" => MarkOfMastery.Rank2,
|
||||
"RANK1" => MarkOfMastery.Rank1,
|
||||
"MASTER" => MarkOfMastery.Master,
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
"NONE" => MarkOfMastery.None, "RANK3" => MarkOfMastery.Rank3, "RANK2" => MarkOfMastery.Rank2, "RANK1" => MarkOfMastery.Rank1, "MASTER" => MarkOfMastery.Master, _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public global::System.Object Format(global::System.Object? runtimeValue)
|
||||
{
|
||||
return runtimeValue switch
|
||||
{
|
||||
MarkOfMastery.None => "NONE",
|
||||
MarkOfMastery.Rank3 => "RANK3",
|
||||
MarkOfMastery.Rank2 => "RANK2",
|
||||
MarkOfMastery.Rank1 => "RANK1",
|
||||
MarkOfMastery.Master => "MASTER",
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
MarkOfMastery.None => "NONE", MarkOfMastery.Rank3 => "RANK3", MarkOfMastery.Rank2 => "RANK2", MarkOfMastery.Rank1 => "RANK1", MarkOfMastery.Master => "MASTER", _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -11,22 +11,18 @@ namespace WotBlitzStatisticsPro.Blazor.GraphQl
|
||||
{
|
||||
return serializedValue switch
|
||||
{
|
||||
"RU" => RealmType.Ru,
|
||||
"EU" => RealmType.Eu,
|
||||
"NA" => RealmType.Na,
|
||||
"ASIA" => RealmType.Asia,
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
"RU" => RealmType.Ru, "EU" => RealmType.Eu, "NA" => RealmType.Na, "ASIA" => RealmType.Asia, _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public global::System.Object Format(global::System.Object? runtimeValue)
|
||||
{
|
||||
return runtimeValue switch
|
||||
{
|
||||
RealmType.Ru => "RU",
|
||||
RealmType.Eu => "EU",
|
||||
RealmType.Na => "NA",
|
||||
RealmType.Asia => "ASIA",
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
RealmType.Ru => "RU", RealmType.Eu => "EU", RealmType.Na => "NA", RealmType.Asia => "ASIA", _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -11,20 +11,18 @@ namespace WotBlitzStatisticsPro.Blazor.GraphQl
|
||||
{
|
||||
return serializedValue switch
|
||||
{
|
||||
"RU" => RequestLanguage.Ru,
|
||||
"EN" => RequestLanguage.En,
|
||||
"DE" => RequestLanguage.De,
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
"RU" => RequestLanguage.Ru, "EN" => RequestLanguage.En, "DE" => RequestLanguage.De, _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public global::System.Object Format(global::System.Object? runtimeValue)
|
||||
{
|
||||
return runtimeValue switch
|
||||
{
|
||||
RequestLanguage.Ru => "RU",
|
||||
RequestLanguage.En => "EN",
|
||||
RequestLanguage.De => "DE",
|
||||
_ => throw new global::StrawberryShake.GraphQLClientException()};
|
||||
RequestLanguage.Ru => "RU", RequestLanguage.En => "EN", RequestLanguage.De => "DE", _ => throw new global::StrawberryShake.GraphQLClientException()}
|
||||
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -13,16 +13,18 @@ namespace WotBlitzStatisticsPro.Blazor.GraphQl.State
|
||||
global::System.String __typename = obj.GetProperty("__typename").GetString()!;
|
||||
return __typename switch
|
||||
{
|
||||
"Achievement" => ParseAchievementEntityId(obj, __typename),
|
||||
_ => throw new global::System.NotSupportedException()};
|
||||
"Achievement" => ParseAchievementEntityId(obj, __typename), _ => throw new global::System.NotSupportedException()}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public global::System.String Format(global::StrawberryShake.EntityId entityId)
|
||||
{
|
||||
return entityId.Name switch
|
||||
{
|
||||
"Achievement" => FormatAchievementEntityId(entityId),
|
||||
_ => throw new global::System.NotSupportedException()};
|
||||
"Achievement" => FormatAchievementEntityId(entityId), _ => throw new global::System.NotSupportedException()}
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
private global::StrawberryShake.EntityId ParseAchievementEntityId(global::System.Text.Json.JsonElement obj, global::System.String type)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace WotBlitzStatisticsPro.Blazor.GraphQl.State
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "11.2.2.0")]
|
||||
public partial class WotBlitzStatisticsProClientStoreAccessor : global::StrawberryShake.StoreAccessor
|
||||
{
|
||||
public WotBlitzStatisticsProClientStoreAccessor(global::StrawberryShake.IOperationStore operationStore, global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer entityIdSerializer, global::System.Collections.Generic.IEnumerable<global::StrawberryShake.IOperationRequestFactory> requestFactories, global::System.Collections.Generic.IEnumerable<global::StrawberryShake.IOperationResultDataFactory> resultDataFactories) : base(operationStore, entityStore, entityIdSerializer, requestFactories, resultDataFactories)
|
||||
public WotBlitzStatisticsProClientStoreAccessor(global::StrawberryShake.IOperationStore operationStore, global::StrawberryShake.IEntityStore entityStore, global::StrawberryShake.IEntityIdSerializer entityIdSerializer, global::System.Collections.Generic.IEnumerable<global::StrawberryShake.IOperationRequestFactory> requestFactories, global::System.Collections.Generic.IEnumerable<global::StrawberryShake.IOperationResultDataFactory> resultDataFactories): base(operationStore, entityStore, entityIdSerializer, requestFactories, resultDataFactories)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace WotBlitzStatisticsPro.Blazor.Pages
|
||||
foreach (var nextRow in treeItem.NextRows)
|
||||
{
|
||||
Connections.Add(SvgHelper.TankTreeConnectionPath(treeItem.Row, nextRow.Row, tier, CardWidth, CardHeigth));
|
||||
// TODO: Calc ConnectionsInVerticalView
|
||||
ConnectionsInVerticalView.Add(SvgHelper.TankTreeConnectionVerticalPath(treeItem.Row, nextRow.Row, tier, CardWidth, CardHeigth, LeftMargin));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace WotBlitzStatisticsPro.Blazor
|
||||
//var useMock = Environment.GetEnvironmentVariable("USE_GRAPH_QL_MOCK");
|
||||
//if (useMock != null && useMock == "true")
|
||||
//{
|
||||
builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>();
|
||||
//builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendMockService>();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>();
|
||||
builder.Services.AddTransient<IGraphQlBackendService, GraphQlBackendService>();
|
||||
//}
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
@@ -8,5 +8,7 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
ElementDimensions CalculateTextBlockSize(string text, string fontFace, int fontSize);
|
||||
|
||||
string TankTreeConnectionPath(int rowStart, int rowEnd, int tierStart, int cardWidth, int cardHeight);
|
||||
|
||||
string TankTreeConnectionVerticalPath(int rowStart, int rowEnd, int tierStart, int cardWidth, int cardHeight, int leftMargin);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,16 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
// Tank Tree dimensions
|
||||
const int CardMargin = 20;
|
||||
|
||||
private readonly int _halfMargin;
|
||||
private readonly int _quarterMargin;
|
||||
|
||||
// Tank Tree path corners
|
||||
private readonly string _leftDown;
|
||||
private readonly string _rightDown;
|
||||
private readonly string _leftUp;
|
||||
private readonly string _rightUp;
|
||||
private readonly string _upRight;
|
||||
private readonly string _upLeft;
|
||||
|
||||
private readonly IJSRuntime _jsRuntime;
|
||||
|
||||
@@ -24,13 +29,15 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
{
|
||||
_jsRuntime = jsRuntime;
|
||||
|
||||
int halfMargin = CardMargin / 2;
|
||||
int quarterMargin = CardMargin / 4;
|
||||
_halfMargin = CardMargin / 2;
|
||||
_quarterMargin = CardMargin / 4;
|
||||
|
||||
_leftDown = $"h {halfMargin} c {quarterMargin} 0, {halfMargin} {quarterMargin}, {halfMargin} {halfMargin}";
|
||||
_rightDown = $"c 0 {quarterMargin}, {quarterMargin} {halfMargin}, {halfMargin} {halfMargin} h {halfMargin}";
|
||||
_leftUp = $"h {halfMargin} c {quarterMargin} 0, {halfMargin} -{quarterMargin}, {halfMargin} -{halfMargin}";
|
||||
_rightUp = $"c 0 -{quarterMargin}, {quarterMargin} -{halfMargin}, {halfMargin} -{halfMargin} h {halfMargin}";
|
||||
_leftDown = $"c {_quarterMargin} 0, {_halfMargin} {_quarterMargin}, {_halfMargin} {_halfMargin}";
|
||||
_rightDown = $"c 0 {_quarterMargin}, {_quarterMargin} {_halfMargin}, {_halfMargin} {_halfMargin}";
|
||||
_leftUp = $"c {_quarterMargin} 0, {_halfMargin} -{_quarterMargin}, {_halfMargin} -{_halfMargin}";
|
||||
_rightUp = $"c 0 -{_quarterMargin}, {_quarterMargin} -{_halfMargin}, {_halfMargin} -{_halfMargin}";
|
||||
_upRight = $"c 0 -{_quarterMargin}, -{_quarterMargin} -{_halfMargin}, -{_halfMargin} -{_halfMargin}";
|
||||
_upLeft = $"c -{_quarterMargin} 0, -{_halfMargin} -{_quarterMargin}, -{_halfMargin} -{_halfMargin}";
|
||||
}
|
||||
|
||||
public ElementDimensions CalculateTextBlockSize(string text, string fontFace, int fontSize)
|
||||
@@ -51,8 +58,6 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
int startXPoint = (tierStart - 1) * (cardWidth + horizontalMargin) + cardWidth + CardMargin;
|
||||
int startYpoint = rowStart * (cardHeight + CardMargin) + (cardHeight / 2) + CardMargin;
|
||||
|
||||
int stopYPoint = rowEnd * (cardHeight + CardMargin) + (cardHeight / 2) + CardMargin;
|
||||
|
||||
var path = new StringBuilder($"M {startXPoint} {startYpoint}");
|
||||
if(rowStart == rowEnd)
|
||||
{
|
||||
@@ -60,19 +65,61 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
return path.ToString();
|
||||
}
|
||||
|
||||
int stopYPoint = rowEnd * (cardHeight + CardMargin) + (cardHeight / 2) + CardMargin;
|
||||
int verticalLineHeight = Math.Abs(stopYPoint - startYpoint) - CardMargin;
|
||||
|
||||
if(rowStart < rowEnd)
|
||||
{
|
||||
path.AppendLine($"h {_halfMargin}");
|
||||
path.AppendLine(_leftDown);
|
||||
path.AppendLine($"v {verticalLineHeight}");
|
||||
path.AppendLine(_rightDown);
|
||||
path.AppendLine($"h {_halfMargin}");
|
||||
}
|
||||
else
|
||||
{
|
||||
path.AppendLine($"h {_halfMargin}");
|
||||
path.AppendLine(_leftUp);
|
||||
path.AppendLine($"v -{verticalLineHeight}");
|
||||
path.AppendLine(_rightUp);
|
||||
path.AppendLine($"h {_halfMargin}");
|
||||
}
|
||||
|
||||
return path.ToString();
|
||||
}
|
||||
|
||||
public string TankTreeConnectionVerticalPath(int rowStart, int rowEnd, int tierStart, int cardWidth, int cardHeight, int leftMargin)
|
||||
{
|
||||
int verticalMargin = 2 * CardMargin;
|
||||
|
||||
int startYPoint = (10 - tierStart) * (cardWidth + verticalMargin) + CardMargin;
|
||||
int startXPoint = rowStart * (cardHeight + CardMargin) + (cardHeight / 2) + CardMargin + leftMargin;
|
||||
|
||||
var path = new StringBuilder($"M {startXPoint} {startYPoint}");
|
||||
if (rowStart == rowEnd)
|
||||
{
|
||||
path.AppendLine($"v -{verticalMargin}");
|
||||
return path.ToString();
|
||||
}
|
||||
|
||||
int stopXPoint = rowEnd * (cardHeight + CardMargin) + (cardHeight / 2) + CardMargin + leftMargin;
|
||||
int horizontalWidth = Math.Abs(stopXPoint - startXPoint) - CardMargin;
|
||||
|
||||
if (rowStart < rowEnd)
|
||||
{
|
||||
path.AppendLine($"v -{_halfMargin}");
|
||||
path.AppendLine(_rightUp);
|
||||
path.AppendLine($"h {horizontalWidth}");
|
||||
path.AppendLine(_leftUp);
|
||||
path.AppendLine($"v -{_halfMargin}");
|
||||
}
|
||||
else
|
||||
{
|
||||
path.AppendLine($"v -{_halfMargin}");
|
||||
path.AppendLine(_upRight);
|
||||
path.AppendLine($"h -{horizontalWidth}");
|
||||
path.AppendLine(_upLeft);
|
||||
path.AppendLine($"v -{_halfMargin}");
|
||||
}
|
||||
|
||||
return path.ToString();
|
||||
|
||||
Reference in new issue
Block a user