Skip to content

Commit

Permalink
2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Eternal-ll committed Jan 7, 2023
1 parent 2d0ec0c commit e8cdfa4
Show file tree
Hide file tree
Showing 40 changed files with 1,432 additions and 629 deletions.
26 changes: 19 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Changelog

## [2.0.3](https://github.com/Eternal-ll/Ethereal-FAF-Client/releases/tag/2.0.3)

** Changelog **

- Added search support by map name in Hosting tab
- Added Mods vault tab
- Changed list views in Players/Games/Maps/Hosting tab
- Fixed error when grouping by rating ranges in Players tab
- Fixed Changelog tab
- Preview of Profile tab
- Preview of Data tab

## [2.0.2](https://github.com/Eternal-ll/Ethereal-FAF-Client/releases/tag/2.0.2-beta.1) (2023-01-03)

**Changelog**

- [x] Support of multiple connected servers
- [x] Fixed Ice related problems
- [x] Fixed patch related problems
- [x] Added startup pages
- [x] Added vault page
- [x] Added maps vault page
- [x] Added [3.3.0 Ice Adapter](https://github.com/FAForever/java-ice-adapter/releases/tag/v3.3.0)
- Support of multiple connected servers
- Fixed Ice related problems
- Fixed patch related problems
- Added startup pages
- Added vault page
- Added maps vault page
- Added [3.3.0 Ice Adapter](https://github.com/FAForever/java-ice-adapter/releases/tag/v3.3.0)

**FAQ**

Expand Down
14 changes: 12 additions & 2 deletions Ethereal.FA.Scmap/MapScenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class FAUtils
{
public static double KmFromPixels(double pixels) => pixels switch
{
2096 => 80,
4096 => 80,
2048 => 40,
1024 => 20,
512 => 10,
Expand All @@ -29,15 +29,20 @@ public class MapScenario
public double WidthInKm => FAUtils.KmFromPixels(Width);
public double HeigthInKm => FAUtils.KmFromPixels(Height);

public string SizeLabelKm => $"{WidthInKm}x{WidthInKm} km";

public string PathToMap { get; set; }
public string PathToSave { get; set; }
public string PathToScript { get; set; }
public string PathToScenario { get; set; }
public string PathToDirectory { get; set; }

public double NoRushRadius { get; set; }

public bool Starts { get; set; }

public List<string> Armies { get; set; }
public string BattleType { get; set; }

/// <summary>
///
Expand All @@ -47,7 +52,11 @@ public class MapScenario
public static MapScenario FromFile(string file)
{
if (!File.Exists(file)) return null;
var scenario = new MapScenario();
var scenario = new MapScenario()
{
PathToScenario = file,
PathToDirectory = Path.GetDirectoryName(file)
};
var test = File.ReadAllText(file);
var regex = new Regex(@"STRING\( (.*) \)");
var match = regex.Match(test);
Expand Down Expand Up @@ -83,6 +92,7 @@ public static MapScenario FromFile(string file)
{
if (teams[1] is LuaTable data)
{
scenario.BattleType = data["name"].ToString();
if (data["armies"] is LuaTable armiesTable)
{
var armies = new List<string>();
Expand Down
36 changes: 22 additions & 14 deletions Ethereal.FAF.API.Client/Converters/SingleOrArrayConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,29 @@ public SingleOrArrayConverter() : this(true) { }

public override TCollection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
try
{
case JsonTokenType.Null:
return null;
case JsonTokenType.StartArray:
var list = new TCollection();
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndArray)
break;
list.Add(JsonSerializer.Deserialize<TItem>(ref reader, options));
}
return list;
default:
return new TCollection { JsonSerializer.Deserialize<TItem>(ref reader, options) };

switch (reader.TokenType)
{
case JsonTokenType.Null:
return null;
case JsonTokenType.StartArray:
var list = new TCollection();
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndArray)
break;
list.Add(JsonSerializer.Deserialize<TItem>(ref reader, options));
}
return list;
default:
return new TCollection { JsonSerializer.Deserialize<TItem>(ref reader, options) };
}
}
catch (Exception ex)
{
return null;
}
}

Expand Down
6 changes: 6 additions & 0 deletions Ethereal.FAF.API.Client/Interfaces/IFafApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ Task<ApiResponse<ApiMapsResult>> GetMapsAsync(
[Query(CollectionFormat.Csv)]
string[] include = null,
CancellationToken cancellationToken = default);
[Get("/data/mod")]
Task<ApiResponse<ModsResult>> GetModsAsync(string filter = null, Sorting sorting = null, Pagination pagination = null,
[AliasAs("include")]
[Query(CollectionFormat.Csv)]
string[] include = null,
CancellationToken cancellationToken = default);
}
public interface IFafContentClient
{
Expand Down
37 changes: 37 additions & 0 deletions Ethereal.FAF.API.Client/Models/Base/ApiUniversalResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,43 @@ public virtual void ParseIncluded(out SortedDictionary<string, string[]> entityP
entityProperties = null;
}
}
public class ModsResult : ApiUniversalResult<Mod[]>
{
public override void ParseIncluded()
{
var included = Included;
if (included is null || Data is null) return;
if (included.Length == 0 || Data.Length == 0) return;
foreach (var mod in Data)
{
if (mod.Relations is null) continue;
foreach (var relation in mod.Relations)
{
if (relation.Value.Data is null) continue;
if (relation.Value.Data.Count == 0) continue;
var entity = ApiUniversalTools.GetDataFromIncluded(included, relation.Value.Data[0].Type, relation.Value.Data[0].Id);
if (entity is null) continue;

switch (relation.Value.Data[0].Type)
{
case ApiDataType.modVersion:
mod.LatestVersion = entity.CastTo<ModVersion>();
//if (map.LatestVersion.IsLegacyMap)
//{
// map.LatestVersion.Attributes["hidden"] = "false";
//}
continue;
case ApiDataType.player:
mod.Uploader = entity?.Attributes["login"];
continue;
case ApiDataType.modReviewsSummary:
mod.ReviewsSummary = entity?.CastTo<ApiUniversalSummary>();
continue;
}
}
}
}
}
public class ApiMapsResult : ApiUniversalResult<ApiMapModel[]>
{
public override void ParseIncluded()
Expand Down
16 changes: 12 additions & 4 deletions Ethereal.FAF.API.Client/Models/Enums/ApiDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
public enum ApiDataType : byte
{
mod,
modVersion,
modStatistics,
modReviewsSummary,


modVersion,
modVersionStatistics,
modVersionReview,
modVersionReviewsSummary,

map,
mapStatistics,
mapReviewsSummary,
Expand All @@ -21,13 +25,17 @@ public enum ApiDataType : byte

player,
clanMembership,

avatar,
avatarAssignment,

nameRecord,
globalRating,
ladder1v1Rating,



accountLink,


game,
gamePlayerStats,

Expand Down
49 changes: 10 additions & 39 deletions Ethereal.FAF.API.Client/Models/MapsVault/ApiMap.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using beta.Models.API.Enums;
using beta.Models.API.Universal;
using beta.Models.API.Universal;
using System.Text.Json.Serialization;

namespace beta.Models.API.MapsVault
{
public interface IVaultEntity
{
public bool IsHidden { get; }
public bool HasVersion { get; }
}
public class ApiMap : Base.ApiUniversalData
{
public string DisplayedName => Attributes["displayName"];
Expand Down Expand Up @@ -40,12 +44,12 @@ public class ApiMapPoolAssignment : Base.ApiUniversalData
// JsonSerializer.Deserialize<MapPoolAssignmentParams>(parameters) : null;
public MapVersionModel LatestVersion { get; set; }
}
public class ApiMapModel : ApiMap
public class ApiMapModel : ApiMap, IVaultEntity
{
public string Author { get; set; } = "Unknown";

public string SmallPreviewUrl => LatestVersion is null ?
$"https://via.placeholder.com/468x60?text={DisplayedName}.png" :
$"https://via.placeholder.com/60x60?text={DisplayedName}.png" :
LatestVersion.ThumbnailUrlLarge.Replace("faforever.ru", "content.faforever.ru");


Expand All @@ -54,40 +58,7 @@ public class ApiMapModel : ApiMap
public MapVersionModel LatestVersion { get; set; }
public MapVersionModel[] Versions { get; set; }



public bool TryGetRelationId(ApiDataType type, out int id)
{
id = -1;
var relations = Relations;
if (relations is not null && relations.Count > 0)
{
foreach (var relation in relations)
{
if (relation.Value.Data[0].Type == type)
{
id = relation.Value.Data[0].Id;
return true;
}
}
}
return false;
}
public Dictionary<ApiDataType, int> GetRelations()
{
var dic = new Dictionary<ApiDataType, int>();
var relations = Relations;
if (relations is not null)
{
foreach (var relation in relations)
{
var data = relation.Value.Data;
if (data is null) continue;
if (data.Count == 0) continue;
dic.TryAdd(data[0].Type, data[0].Id);
}
}
return dic;
}
public bool IsHidden => HasVersion && LatestVersion.IsHidden;
public bool HasVersion => LatestVersion is not null;
}
}
42 changes: 42 additions & 0 deletions Ethereal.FAF.API.Client/Models/MapsVault/Mod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using beta.Models.API.Universal;

namespace beta.Models.API.MapsVault
{
public class Mod : Base.ApiUniversalData, IVaultEntity
{
public string Author => Attributes["author"];
public string Name => Attributes["displayName"];
public bool IsRecommended => bool.Parse(Attributes["recommended"]);
public DateTime UpdateTime => DateTime.Parse(Attributes["updateTime"]);
public DateTime CreateTime => DateTime.Parse(Attributes["createTime"]);
public string Uploader { get; set; }
public ApiUniversalSummary ReviewsSummary { get; set; }
public ModVersion[] Versions { get; set; }
public ModVersion LatestVersion { get; set; }

public bool IsHidden => HasVersion && LatestVersion.IsHidden;
public bool HasVersion => LatestVersion is not null;
}
public enum ModType
{
UI,
SIM,
}
public class ModVersion : Base.ApiUniversalData
{
public string Uid => Attributes["uid"];
public ModType ModType => Enum.Parse<ModType>(Attributes["type"]);
public int Version => int.Parse(Attributes["version"]);
public string Description => Attributes["description"];
public string DownloadUrl => Attributes["downloadUrl"];
public string Filename => Attributes["filename"];
public bool IsHidden => bool.Parse(Attributes["hidden"]);
public bool IsRanked => bool.Parse(Attributes["ranked"]);
public string ThumbnailUrl => Attributes["thumbnailUrl"];
public DateTime Created => DateTime.Parse(Attributes["createTime"]);
public DateTime Updated => DateTime.Parse(Attributes["updateTime"]);

public ApiUniversalStatistics Statistics { get; set; }
public ApiUniversalSummary Summary { get; set; }
}
}
4 changes: 3 additions & 1 deletion Ethereal.FAF.UI.Client/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</ResourceDictionary>
<ui:ControlsDictionary />
<ui:ThemesDictionary Theme="Dark" />
<ResourceDictionary Source="Resources/Dictionaries/VaultDictionary.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Fonts;component/FontsDictionary.xaml"/>
<ResourceDictionary Source="Resources/Dictionaries/VaultDictionary.xaml"/>

<ResourceDictionary>
<Style x:Key="BorderPopup" TargetType="Border">
Expand Down Expand Up @@ -68,6 +68,8 @@
</Setter>
</Style>
</ResourceDictionary>

<ResourceDictionary Source="Resources/Dictionaries/CardsDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
8 changes: 5 additions & 3 deletions Ethereal.FAF.UI.Client/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ private void ConfigureServices(HostBuilderContext context, IServiceCollection se
services.AddScoped<ModsViewModel>();
services.AddScoped<ModsView>();

services.AddScoped<VaultViewModel>();
services.AddScoped<VaultView>();

services.AddTransient<SelectServerVM>();
services.AddTransient<SelectServerView>();

Expand All @@ -141,6 +138,11 @@ private void ConfigureServices(HostBuilderContext context, IServiceCollection se
services.AddScoped<LoaderViewModel>();
services.AddScoped<LoaderView>();

services.AddScoped<ProfileView>();

services.AddScoped<DataView>();
services.AddScoped<DataViewModel>();

services.AddScoped<SelectGameLocationView>();
services.AddScoped<SelectFaPatchLocationView>();
services.AddScoped<SelectVaultLocationView>();
Expand Down
6 changes: 6 additions & 0 deletions Ethereal.FAF.UI.Client/Ethereal.FAF.UI.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,11 @@
<Resource Include="Resources\Images\Flags\*.png" />
</ItemGroup>

<ItemGroup>
<Compile Update="Views\DataView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>


</Project>
Loading

0 comments on commit e8cdfa4

Please sign in to comment.