Skip to content

Commit

Permalink
Merge pull request #381 from Sidekick-Poe/feature/about
Browse files Browse the repository at this point in the history
Add About section
  • Loading branch information
leMicin authored Dec 24, 2024
2 parents a78e8ec + a352551 commit 541f61c
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
@if (Count != Completed)
{
<ButtonPrimary OnClick="Exit">
@Resources.Exit
@Resources["Exit"]
</ButtonPrimary>
}
else
{
<ButtonPrimary OnClick="CurrentView.Close">
@Resources.Close
@Resources["Close"]
</ButtonPrimary>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Sidekick.Common.Browser;
Expand All @@ -18,7 +19,7 @@ namespace Sidekick.Common.Blazor.Initialization
public partial class Initialization : SidekickView
{
[Inject]
private InitializationResources Resources { get; set; } = null!;
private IStringLocalizer<InitializationResources> Resources { get; set; } = null!;

[Inject]
private ILogger<Initialization> Logger { get; set; } = null!;
Expand Down Expand Up @@ -65,7 +66,7 @@ protected override async Task OnInitializedAsync()
InitializationTask = Handle();
var keyOpenPriceCheck = await SettingsService.GetString(SettingKeys.KeyOpenPriceCheck);
var keyClose = await SettingsService.GetString(SettingKeys.KeyClose);
WelcomeMessage = string.Format(Resources.Notification, keyOpenPriceCheck.ToKeybindString(), keyClose.ToKeybindString());
WelcomeMessage = string.Format(Resources["Notification"], keyOpenPriceCheck.ToKeybindString(), keyClose.ToKeybindString());
await base.OnInitializedAsync();
await InitializationTask;
}
Expand Down Expand Up @@ -149,12 +150,12 @@ private Task ReportProgress()
Percentage = Count == 0 ? 0 : Completed * 100 / Count;
if (Percentage >= 100)
{
Step = Resources.Ready;
Step = Resources["Ready"];
Percentage = 100;
}
else
{
Step = Resources.Title(Completed, Count);
Step = Resources["Title", Completed, Count];
}

StateHasChanged();
Expand All @@ -175,7 +176,7 @@ private void InitializeTray()
menuItems.AddRange(new List<TrayMenuItem>()
{
new(label: "Sidekick - " + GetVersion()),
new(label: "Open Website",
new(label: Resources["Open_Website"],
onClick: () =>
{
BrowserProvider.OpenSidekickWebsite();
Expand All @@ -184,8 +185,8 @@ private void InitializeTray()

// new(label: "Wealth", onClick: () => ViewLocator.Open("/wealth")),

new(label: "Settings", onClick: () => ViewLocator.Open("/settings")),
new(label: "Exit",
new(label: Resources["Settings"], onClick: () => ViewLocator.Open("/settings")),
new(label: Resources["Exit"],
onClick: () =>
{
ApplicationService.Shutdown();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
using Microsoft.Extensions.Localization;

namespace Sidekick.Common.Blazor.Initialization;

public class InitializationResources(IStringLocalizer<InitializationResources> localizer)
public class InitializationResources()
{
public string Close => localizer["Close"];
public string Error => localizer["Error"];
public string Exit => localizer["Exit"];
public string Notification => localizer["Notification"];
public string Ready => localizer["Ready"];

public string Title(int completed, int count) => localizer["Title", completed, count];

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@
<data name="Notification" xml:space="preserve">
<value>Faites {0} sur un item dans le jeu et {1} pour fermer la fenêtre.</value>
</data>
<data name="Open_Website" xml:space="preserve">
<value>Ouvrir le site web</value>
</data>
<data name="Ready" xml:space="preserve">
<value>Prêt</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Configurations</value>
</data>
<data name="Title" xml:space="preserve">
<value>Initialisation ({0} de {1})</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@
<data name="Notification" xml:space="preserve">
<value>Press {0} over an item in-game to use. Press {1} to close overlay.</value>
</data>
<data name="Open_Website" xml:space="preserve">
<value>Open website</value>
</data>
<data name="Ready" xml:space="preserve">
<value>Ready</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Settings</value>
</data>
<data name="Title" xml:space="preserve">
<value>Initializing ({0} of {1})</value>
</data>
Expand Down
33 changes: 33 additions & 0 deletions src/Sidekick.Common.Blazor/Settings/About/About.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@page "/settings/about"
@layout SettingsLayout
@inherits Sidekick.Common.Ui.Views.SidekickView
@using Sidekick.Common.Browser
@using Sidekick.Common.Folder

<AppTitle Title="@Resources["About"]" />

<AppContainer>
<Fieldset Legend="@($"{Resources["Sidekick"]} - {Title}")">
<div class="mb-3"><span class="text-lg underline text-blue-500 cursor-pointer" onclick="@(() => BrowserProvider.OpenSidekickWebsite())">@Resources["Official_Website"]</span></div>
<div class="mb-3"><span class="text-lg underline text-blue-500 cursor-pointer" onclick="@(() => BrowserProvider.OpenGitHubRepository())">@Resources["GitHub_Repository"]</span></div>

<LayoutDivider/>

<div class="mb-3"><ButtonPrimary OnClick="@(() => FolderProvider.OpenDataFolderPath())">@Resources["Open_Settings_Folder"]</ButtonPrimary></div>
<i>@FolderProvider.GetDataFolderPath()</i>
</Fieldset>
</AppContainer>

@inject IStringLocalizer<SettingsResources> Resources
@inject IBrowserProvider BrowserProvider
@inject IFolderProvider FolderProvider

@code
{
private string? Title { get; set; } = string.Empty;

protected override void OnInitialized()
{
Title = AppDomain.CurrentDomain.GetAssemblies().Select(x => x.GetName()).FirstOrDefault(x => x.Name == "Sidekick")?.Version?.ToString();
}
}
1 change: 1 addition & 0 deletions src/Sidekick.Common.Blazor/Settings/SettingsLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<MenuItem Href="/settings/map">@Resources["Map_Check"]</MenuItem>
<MenuItem Href="/settings/wiki">@Resources["Wiki"]</MenuItem>
<MenuItem Href="/settings/chat">@Resources["Chat_Commands"]</MenuItem>
<MenuItem Href="/settings/about">@Resources["About"]</MenuItem>

@if (Debugger.IsAttached)
{
Expand Down
13 changes: 13 additions & 0 deletions src/Sidekick.Common.Blazor/Settings/SettingsResources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,17 @@
<data name="League_Hint" xml:space="preserve">
<value>Sidekick supporte à la fois Path of Exile 1 et Path of Exile 2, veuillez choisir la ligue correspondante lorsque vous jouez à l'un ou l'autre.</value>
</data>
<data name="About" xml:space="preserve">
<value>À propos</value>
</data>
<data name="Official_Website" xml:space="preserve">
<value>Site officiel</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="GitHub_Repository" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="Open_Settings_Folder" xml:space="preserve">
<value>Ouvrir le répertoire des configurations</value>
</data>
</root>
12 changes: 12 additions & 0 deletions src/Sidekick.Common.Blazor/Settings/SettingsResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,16 @@
<data name="League_Hint" xml:space="preserve">
<value>For convenience, Sidekick supports both Path of Exile 2 and Path of Exile 1, simply choose the appropriate league when playing either of them.</value>
</data>
<data name="About" xml:space="preserve">
<value>About</value>
</data>
<data name="Official_Website" xml:space="preserve">
<value>Official website</value>
</data>
<data name="GitHub_Repository" xml:space="preserve">
<value>GitHub Repository</value>
</data>
<data name="Open_Settings_Folder" xml:space="preserve">
<value>Open the settings folder</value>
</data>
</root>
54 changes: 54 additions & 0 deletions src/Sidekick.Common.Ui/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,11 @@ video {
margin-bottom: 0px;
}

.my-1 {
margin-top: 0.25rem;
margin-bottom: 0.25rem;
}

.my-2 {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
Expand Down Expand Up @@ -1535,6 +1540,10 @@ video {
margin-bottom: 0.75rem;
}

.mb-4 {
margin-bottom: 1rem;
}

.ml-0 {
margin-left: 0px;
}
Expand All @@ -1559,10 +1568,22 @@ video {
margin-left: auto;
}

.mr-1 {
margin-right: 0.25rem;
}

.mr-2 {
margin-right: 0.5rem;
}

.mr-3 {
margin-right: 0.75rem;
}

.mr-4 {
margin-right: 1rem;
}

.mt-1 {
margin-top: 0.25rem;
}
Expand All @@ -1579,6 +1600,10 @@ video {
margin-top: 1rem;
}

.mt-6 {
margin-top: 1.5rem;
}

.mt-9 {
margin-top: 2.25rem;
}
Expand Down Expand Up @@ -1903,6 +1928,10 @@ video {
flex-grow: 1;
}

.flex-grow-0 {
flex-grow: 0;
}

.grow {
flex-grow: 1;
}
Expand Down Expand Up @@ -3292,11 +3321,20 @@ video {
padding-bottom: 0.5rem;
}

.py-3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}

.py-4 {
padding-top: 1rem;
padding-bottom: 1rem;
}

.pb-0 {
padding-bottom: 0px;
}

.pb-2 {
padding-bottom: 0.5rem;
}
Expand All @@ -3317,6 +3355,10 @@ video {
padding-bottom: 4px;
}

.pl-12 {
padding-left: 3rem;
}

.pl-2 {
padding-left: 0.5rem;
}
Expand All @@ -3333,10 +3375,22 @@ video {
padding-right: 0.5rem;
}

.pr-4 {
padding-right: 1rem;
}

.pt-0 {
padding-top: 0px;
}

.pt-2 {
padding-top: 0.5rem;
}

.pt-4 {
padding-top: 1rem;
}

.pt-\[4px\] {
padding-top: 4px;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Sidekick.Common/Browser/BrowserProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ public void OpenSidekickWebsite()
{
OpenUri(new Uri("https://sidekick-poe.github.io/"));
}

public void OpenGitHubRepository()
{
OpenUri(new Uri("https://github.com/Sidekick-Poe/Sidekick"));
}
}
5 changes: 5 additions & 0 deletions src/Sidekick.Common/Browser/IBrowserProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public interface IBrowserProvider
/// Opens the sidekick website in the user's browser.
/// </summary>
void OpenSidekickWebsite();

/// <summary>
/// Opens the Sidekick GitHub repository in the user's browser.
/// </summary>
void OpenGitHubRepository();
}
31 changes: 31 additions & 0 deletions src/Sidekick.Common/Folder/FolderProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics;
using Microsoft.Extensions.Logging;

namespace Sidekick.Common.Folder;

public class FolderProvider(ILogger<FolderProvider> logger) : IFolderProvider
{
public void OpenDataFolderPath()
{
try
{
var process = new Process();
process.StartInfo = new ProcessStartInfo
{
FileName = SidekickPaths.GetDataFilePath(),
UseShellExecute = true,
Verb = "open"
};
process.Start();
}
catch
{
logger.LogError("[Folder] Failed to open data file path.");
}
}

public string GetDataFolderPath()
{
return SidekickPaths.GetDataFilePath();
}
}
18 changes: 18 additions & 0 deletions src/Sidekick.Common/Folder/IFolderProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Sidekick.Common.Folder;

public interface IFolderProvider
{
/// <summary>
/// Opens the folder where the data files are stored.
///
/// <para>Windows: C:\Users\___\AppData\Roaming</para>
/// <para>Linux: /home/___/.config</para>
/// <para>OSX: /Users/___/.config</para>
/// </summary>
void OpenDataFolderPath();

/// <summary>
/// Gets the folder path where the data files are stored.
/// </summary>
public string GetDataFolderPath();
}
Loading

0 comments on commit 541f61c

Please sign in to comment.