feat(Search) Search hotkey now working. CMD + K

This commit is contained in:
2022-04-16 22:47:09 -04:00
parent 0f67fc18c1
commit ba2eeec13f
42 changed files with 235 additions and 246 deletions
+4 -4
View File
@@ -28,16 +28,16 @@ public interface IToastService
public interface ISearchService
{
public List<SearchPointModel> SearchPoints { get; set; }
public Dictionary<string, List<SearchPointModel>> Searches { get; set; }
public bool IsVisible { get; set; }
public void Subscribe(Action action);
public void Unsubscribe(Action action);
public void Search(string entityId);
public Task Load();
public bool IsLoaded();
@@ -90,7 +90,7 @@ public interface IAgileService
public void Unsubscribe(Action? action);
public void Update();
public Task Load();
public Task Load();
public bool IsLoaded();
}
+6 -5
View File
@@ -13,14 +13,15 @@ namespace Services.Immortal;
public class BuildOrderService : IBuildOrderService
{
private BuildOrderModel buildOrder = new();
public int BuildingInputDelay { get; set; } = 2;
private int lastInterval = 0;
private int lastInterval;
public BuildOrderService()
{
Reset();
}
public int BuildingInputDelay { get; set; } = 2;
public Dictionary<int, List<EntityModel>> StartedOrders => buildOrder.StartedOrders;
public Dictionary<int, List<EntityModel>> CompletedOrders => buildOrder.CompletedOrders;
public Dictionary<string, int> UniqueCompletedTimes => buildOrder.UniqueCompletedTimes;
@@ -254,7 +255,7 @@ public class BuildOrderService : IBuildOrderService
public void Reset()
{
lastInterval = 0;
buildOrder = new BuildOrderModel
{
StartedOrders = new Dictionary<int, List<EntityModel>>
@@ -304,7 +305,7 @@ public class BuildOrderService : IBuildOrderService
}
}
};
NotifyDataChanged();
}
@@ -326,7 +327,7 @@ public class BuildOrderService : IBuildOrderService
atInterval = interval;
if (entity.EntityType != EntityType.Army) atInterval += BuildingInputDelay;
return true;
}
}
+2 -7
View File
@@ -1,8 +1,6 @@
using Model.Economy;
using Model.Entity;
using Model.Feedback;
using Model.Types;
using Services.Website;
namespace Services.Immortal;
@@ -159,11 +157,8 @@ public class EconomyService : IEconomyService
public EconomyModel GetEconomy(int atInterval)
{
if (atInterval >= economyOverTime.Count)
{
return economyOverTime.Last();
}
if (atInterval >= economyOverTime.Count) return economyOverTime.Last();
return economyOverTime[atInterval];
}
+1 -1
View File
@@ -28,7 +28,7 @@ public class TimingService : ITimingService
NotifyDataChanged();
}
}
public int GetTravelTime()
{
return travelTime;
+2 -2
View File
@@ -15,11 +15,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Model\Model.csproj"/>
</ItemGroup>
</Project>
+1 -2
View File
@@ -3,9 +3,8 @@
//TODO Move to a database folder, with EntityService, EntityFilterService
public class EntityDialogService : IEntityDialogService
{
private string? entityId;
private readonly List<string> history = new();
private string? entityId;
public void Subscribe(Action action)
{
+42 -33
View File
@@ -1,23 +1,20 @@
using Model.Entity.Data;
using Model.Feedback;
using Model.Website;
namespace Services.Website;
public class SearchService : ISearchService
{
private bool isLoaded = false;
public List<SearchPointModel> SearchPoints { get; set; } = new();
private readonly IDocumentationService documentationService;
public Dictionary<string, List<SearchPointModel>> Searches { get; set; } = new();
private bool isLoaded;
private readonly INoteService noteService;
private IWebsiteService websiteService;
private INoteService noteService;
private IDocumentationService documentationService;
private readonly IWebsiteService websiteService;
public SearchService(IWebsiteService websiteService, INoteService noteService, IDocumentationService documentationService)
public SearchService(IWebsiteService websiteService, INoteService noteService,
IDocumentationService documentationService)
{
this.websiteService = websiteService;
this.noteService = noteService;
@@ -25,7 +22,11 @@ public class SearchService : ISearchService
// All Unit Data
}
public List<SearchPointModel> SearchPoints { get; set; } = new();
public Dictionary<string, List<SearchPointModel>> Searches { get; set; } = new();
public bool IsVisible { get; set; }
public void Subscribe(Action action)
@@ -47,8 +48,8 @@ public class SearchService : ISearchService
await websiteService.Load();
await noteService.Load();
await documentationService.Load();
Searches.Add("Pages", new List<SearchPointModel>());
Searches.Add("Notes", new List<SearchPointModel>());
Searches.Add("Documents", new List<SearchPointModel>());
@@ -56,47 +57,55 @@ public class SearchService : ISearchService
foreach (var webPage in websiteService.WebPageModels)
{
SearchPoints.Add(new SearchPointModel{ Title = webPage.Name,
SearchPoints.Add(new SearchPointModel
{
Title = webPage.Name,
PointType = "WebPage",
Href=webPage.Href
Href = webPage.Href
});
Searches["Pages"].Add(SearchPoints.Last());
}
foreach (var note in noteService.NoteContentModels)
{
SearchPoints.Add(new SearchPointModel(){ Title = note.Name,
PointType = "Note", Href = note.GetNoteLink()});
Searches["Notes"].Add(SearchPoints.Last());
SearchPoints.Add(new SearchPointModel
{
Title = note.Name,
PointType = "Note", Href = note.GetNoteLink()
});
Searches["Notes"].Add(SearchPoints.Last());
}
foreach (var entity in DATA.Get().Values)
{
SearchPoints.Add(new SearchPointModel(){
Title = entity.Info().Name,
SearchPoints.Add(new SearchPointModel
{
Title = entity.Info().Name,
Tags = $"{entity.EntityType},{entity.Descriptive}",
PointType = "Entity",
Href = $"database/{entity.Info().Name.ToLower()}"
});
Searches["Entities"].Add(SearchPoints.Last());
}
foreach (var doc in documentationService.DocContentModels)
{
SearchPoints.Add(new SearchPointModel { Title = doc.Name,
PointType = "Document", Href = doc.GetDocLink()});
SearchPoints.Add(new SearchPointModel
{
Title = doc.Name,
PointType = "Document", Href = doc.GetDocLink()
});
Searches["Documents"].Add(SearchPoints.Last());
}
isLoaded = true;
NotifyDataChanged();
}
@@ -108,14 +117,14 @@ public class SearchService : ISearchService
public void Show()
{
IsVisible = true;
NotifyDataChanged();
}
public void Hide()
{
IsVisible = false;
NotifyDataChanged();
}