Skip to content

Commit

Permalink
refactor: make name static
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Sep 28, 2023
1 parent ec2c5c4 commit b438443
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal CommandHandler(Plugin plugin) {

foreach (var name in CommandNames) {
this.Plugin.CommandManager.AddHandler(name, new CommandInfo(this.Command) {
HelpMessage = $"Toggle the {this.Plugin.Name} interface",
HelpMessage = $"Toggle the {Plugin.Name} interface",
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions DownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private async Task Run() {
this.StateData = this.StateDataMax = 1;
this.Plugin.Interface.UiBuilder.AddNotification(
$"{this.PackageName} installed in Penumbra.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Success
);

Expand All @@ -132,7 +132,7 @@ await this.Plugin.Framework.RunOnFrameworkThread(() => {
this.Error = ex;
this.Plugin.Interface.UiBuilder.AddNotification(
$"Failed to install {this.PackageName ?? "mod"}.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error,
5_000
);
Expand Down
4 changes: 2 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Heliosphere;

public class Plugin : IDalamudPlugin {
public string Name => "Heliosphere";
internal static string Name => "Heliosphere";

internal static HttpClient Client { get; } = new();
internal static Plugin Instance { get; private set; }
Expand Down Expand Up @@ -204,7 +204,7 @@ internal async Task AddDownloadAsync(DownloadTask task, CancellationToken token
if (!wasAdded) {
this.Interface.UiBuilder.AddNotification(
$"Already downloading that mod!",
this.Name,
Name,
NotificationType.Error
);

Expand Down
30 changes: 15 additions & 15 deletions Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void HandleConnection() {
try {
this.Plugin.Interface.UiBuilder.AddNotification(
"Installing a mod...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
if (this.Plugin.Penumbra.TryGetModDirectory(out var modDir)) {
Expand All @@ -153,15 +153,15 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
} else {
this.Plugin.Interface.UiBuilder.AddNotification(
"Cannot install mod: Penumbra is not set up.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
} catch (Exception ex) {
ErrorHelper.Handle(ex, "Error performing one-click install");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error performing one-click install.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand All @@ -172,7 +172,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
try {
this.Plugin.Interface.UiBuilder.AddNotification(
"Opening mod installer, please wait...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
var window = await PromptWindow.Open(this.Plugin, info.PackageId, info.VersionId, info.DownloadCode);
Expand All @@ -181,7 +181,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
ErrorHelper.Handle(ex, "Error opening prompt window");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand All @@ -205,7 +205,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
var plural = info.VariantIds.Length == 1 ? "" : "s";
this.Plugin.Interface.UiBuilder.AddNotification(
$"Installing a mod with {info.VariantIds.Length} variant{plural}...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
var resp = await Plugin.GraphQl.MultiVariantInstall.ExecuteAsync(info.PackageId);
Expand All @@ -230,15 +230,15 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
} else {
this.Plugin.Interface.UiBuilder.AddNotification(
"Cannot install mod: Penumbra is not set up.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
} catch (Exception ex) {
ErrorHelper.Handle(ex, "Error performing one-click install");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error performing one-click install.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand All @@ -249,7 +249,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
try {
this.Plugin.Interface.UiBuilder.AddNotification(
"Opening mod installer, please wait...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
var window = await MultiVariantPromptWindow.Open(this.Plugin, info.PackageId, info.VariantIds, info.DownloadCode);
Expand All @@ -258,7 +258,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
ErrorHelper.Handle(ex, "Error opening prompt window");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand All @@ -279,7 +279,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
if (!this.Plugin.Penumbra.TryGetModDirectory(out var modDir)) {
this.Plugin.Interface.UiBuilder.AddNotification(
"Cannot install mod: Penumbra is not set up.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);

Expand All @@ -291,7 +291,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
var plural = info.Installs.Length == 1 ? "" : "s";
this.Plugin.Interface.UiBuilder.AddNotification(
$"Installing {info.Installs.Length} mod{plural}...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
Expand All @@ -310,7 +310,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
ErrorHelper.Handle(ex, "Error performing one-click install");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error performing one-click install.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand All @@ -322,7 +322,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
try {
this.Plugin.Interface.UiBuilder.AddNotification(
"Opening mod installer, please wait...",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
var window = await MultiPromptWindow.Open(this.Plugin, info.Installs);
Expand All @@ -331,7 +331,7 @@ await this.Plugin.AddDownloadAsync(new DownloadTask(
ErrorHelper.Handle(ex, "Error opening prompt window");
this.Plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand Down
2 changes: 1 addition & 1 deletion Ui/AntiVirusWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DrawStatus Draw() {
}

using var end = new OnDispose(ImGui.End);
if (!ImGui.Begin($"{this.Plugin.Name}##av-warning", ref this._visible, ImGuiWindowFlags.AlwaysAutoResize)) {
if (!ImGui.Begin($"{Plugin.Name}##av-warning", ref this._visible, ImGuiWindowFlags.AlwaysAutoResize)) {
return DrawStatus.Continue;
}

Expand Down
2 changes: 1 addition & 1 deletion Ui/DownloadStatusWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void Draw() {
}

ImGui.SetNextWindowSize(new Vector2(500, 160), ImGuiCond.FirstUseEver);
if (!ImGui.Begin($"{this.Plugin.Name} downloads", flags)) {
if (!ImGui.Begin($"{Plugin.Name} downloads", flags)) {
ImGui.End();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Ui/InstallerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal static async Task OpenAndAdd(OpenOptions options, string? packageName =
ErrorHelper.Handle(ex, "Could not open installer window");
options.Plugin.Interface.UiBuilder.AddNotification(
$"Could not open installer window for {options.Info?.Variant.Package.Name ?? packageName}. Check that it still exists and that your internet connection is working.",
$"[{options.Plugin.Name}] Error opening installer",
$"[{Plugin.Name}] Error opening installer",
NotificationType.Error,
5_000
);
Expand Down
2 changes: 1 addition & 1 deletion Ui/MultiPromptWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static async Task OpenAndAdd(Plugin plugin, IEnumerable<InstallInfo> in
ErrorHelper.Handle(ex, "Error opening prompt window");
plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand Down
2 changes: 1 addition & 1 deletion Ui/MultiVariantPromptWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal static async Task OpenAndAdd(Plugin plugin, Guid packageId, Guid[] vari
ErrorHelper.Handle(ex, "Error opening prompt window");
plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand Down
2 changes: 1 addition & 1 deletion Ui/PluginUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void Inner() {
}

ImGui.SetNextWindowSize(new Vector2(585, 775), ImGuiCond.FirstUseEver);
if (!ImGui.Begin(this.Plugin.Name, ref this.Visible)) {
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
ImGui.End();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Ui/PromptWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal static async Task OpenAndAdd(Plugin plugin, Guid packageId, Guid versio
ErrorHelper.Handle(ex, "Error opening prompt window");
plugin.Interface.UiBuilder.AddNotification(
"Error opening installer prompt.",
plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand Down
4 changes: 2 additions & 2 deletions Ui/Tabs/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void DrawActionsTab(HeliosphereMeta pkg) {
if (info.Versions.Count == 0 || info.Versions[0].Version == pkg.Version) {
this.Plugin.Interface.UiBuilder.AddNotification(
$"{pkg.Name} is already up-to-date.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
return;
Expand Down Expand Up @@ -708,7 +708,7 @@ private async Task DownloadUpdatesInner(bool useConfig) {
var autoHeader = $"{numMods} mod{plural} auto-updated successfully.";
this.Plugin.Interface.UiBuilder.AddNotification(
autoHeader,
this.Plugin.Name,
Plugin.Name,
NotificationType.Success
);
this.Plugin.ChatGui.Print(autoHeader);
Expand Down
8 changes: 4 additions & 4 deletions Ui/Tabs/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ref this.Plugin.Config.DefaultCollection
ImGui.SetClipboardText(Base64.Default.Encode(password));
this.Plugin.Interface.UiBuilder.AddNotification(
"Code copied to clipboard. Paste it on the Heliosphere website.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ ref this.Plugin.Config.OneClickCollection
ImGui.SetClipboardText($"{this.Plugin.Config.UserId:N}");
this.Plugin.Interface.UiBuilder.AddNotification(
"Support ID copied to clipboard.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
}
Expand All @@ -184,7 +184,7 @@ ref this.Plugin.Config.OneClickCollection

this.Plugin.Interface.UiBuilder.AddNotification(
"Config copied to clipboard.",
this.Plugin.Name,
Plugin.Name,
NotificationType.Info
);
}
Expand All @@ -199,7 +199,7 @@ ref this.Plugin.Config.OneClickCollection
ErrorHelper.Handle(ex, "Could not start server");
this.Plugin.Interface.UiBuilder.AddNotification(
"Could not start server",
this.Plugin.Name,
Plugin.Name,
NotificationType.Error
);
}
Expand Down

0 comments on commit b438443

Please sign in to comment.