mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Merge branch 'feature/branchswitcher' into net5
This commit is contained in:
commit
082aa2f0b1
4 changed files with 157 additions and 17 deletions
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
|
|
@ -82,6 +82,7 @@ jobs:
|
|||
} else {
|
||||
Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip"
|
||||
$versionData.AssemblyVersion = $newVersion
|
||||
$versionData.GitSha = $newVersion
|
||||
$versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@ namespace Dalamud.Configuration.Internal
|
|||
[Serializable]
|
||||
internal sealed class DalamudConfiguration : IServiceType
|
||||
{
|
||||
/// <summary>
|
||||
/// Currently used beta key for Dalamud staging builds.
|
||||
/// </summary>
|
||||
public const string DalamudCurrentBetaKey = "proof of context";
|
||||
|
||||
private static readonly JsonSerializerSettings SerializerSettings = new()
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.All,
|
||||
|
|
@ -44,12 +39,6 @@ namespace Dalamud.Configuration.Internal
|
|||
/// </summary>
|
||||
public event DalamudConfigurationSavedDelegate DalamudConfigurationSaved;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not Dalamud staging is enabled.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public bool IsConventionalStaging => this.DalamudBetaKey == DalamudCurrentBetaKey;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of muted works.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ namespace Dalamud.Interface.Internal
|
|||
private readonly StyleEditorWindow styleEditorWindow;
|
||||
private readonly TitleScreenMenuWindow titleScreenMenuWindow;
|
||||
private readonly ProfilerWindow profilerWindow;
|
||||
private readonly BranchSwitcherWindow branchSwitcherWindow;
|
||||
|
||||
private readonly TextureWrap logoTexture;
|
||||
private readonly TextureWrap tsmLogoTexture;
|
||||
|
|
@ -100,6 +101,7 @@ namespace Dalamud.Interface.Internal
|
|||
this.styleEditorWindow = new StyleEditorWindow() { IsOpen = false };
|
||||
this.titleScreenMenuWindow = new TitleScreenMenuWindow() { IsOpen = false };
|
||||
this.profilerWindow = new ProfilerWindow() { IsOpen = false };
|
||||
this.branchSwitcherWindow = new BranchSwitcherWindow() { IsOpen = false };
|
||||
|
||||
this.WindowSystem.AddWindow(this.changelogWindow);
|
||||
this.WindowSystem.AddWindow(this.colorDemoWindow);
|
||||
|
|
@ -116,6 +118,7 @@ namespace Dalamud.Interface.Internal
|
|||
this.WindowSystem.AddWindow(this.styleEditorWindow);
|
||||
this.WindowSystem.AddWindow(this.titleScreenMenuWindow);
|
||||
this.WindowSystem.AddWindow(this.profilerWindow);
|
||||
this.WindowSystem.AddWindow(this.branchSwitcherWindow);
|
||||
|
||||
ImGuiManagedAsserts.AssertsEnabled = configuration.AssertsEnabledAtStartup;
|
||||
this.isImGuiDrawDevMenu = this.isImGuiDrawDevMenu || configuration.DevBarOpenAtStartup;
|
||||
|
|
@ -139,7 +142,7 @@ namespace Dalamud.Interface.Internal
|
|||
tsm.AddEntryCore(Loc.Localize("TSMDalamudPlugins", "Plugin Installer"), this.tsmLogoTexture, () => this.pluginWindow.IsOpen = true);
|
||||
tsm.AddEntryCore(Loc.Localize("TSMDalamudSettings", "Dalamud Settings"), this.tsmLogoTexture, () => this.settingsWindow.IsOpen = true);
|
||||
|
||||
if (configuration.IsConventionalStaging)
|
||||
if (!configuration.DalamudBetaKind.IsNullOrEmpty())
|
||||
{
|
||||
tsm.AddEntryCore(Loc.Localize("TSMDalamudDevMenu", "Developer Menu"), this.tsmLogoTexture, () => this.isImGuiDrawDevMenu = true);
|
||||
}
|
||||
|
|
@ -266,6 +269,11 @@ namespace Dalamud.Interface.Internal
|
|||
/// </summary>
|
||||
public void OpenProfiler() => this.profilerWindow.IsOpen = true;
|
||||
|
||||
/// <summary>
|
||||
/// Opens the <see cref="BranchSwitcherWindow"/>
|
||||
/// </summary>
|
||||
public void OpenBranchSwitcher() => this.branchSwitcherWindow.IsOpen = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Close
|
||||
|
|
@ -618,17 +626,15 @@ namespace Dalamud.Interface.Internal
|
|||
|
||||
ImGui.Separator();
|
||||
|
||||
var isBeta = configuration.DalamudBetaKey == DalamudConfiguration.DalamudCurrentBetaKey;
|
||||
if (ImGui.MenuItem("Enable Dalamud testing", string.Empty, isBeta))
|
||||
if (ImGui.MenuItem("Open Dalamud branch switcher"))
|
||||
{
|
||||
configuration.DalamudBetaKey = isBeta ? null : DalamudConfiguration.DalamudCurrentBetaKey;
|
||||
configuration.Save();
|
||||
this.OpenBranchSwitcher();
|
||||
}
|
||||
|
||||
var startInfo = Service<DalamudStartInfo>.Get();
|
||||
ImGui.MenuItem(Util.AssemblyVersion, false);
|
||||
ImGui.MenuItem(startInfo.GameVersion.ToString(), false);
|
||||
ImGui.MenuItem($"CS: {Util.GetGitHashClientStructs()}", false);
|
||||
ImGui.MenuItem($"D: {Util.GetGitHash()} CS: {Util.GetGitHashClientStructs()}", false);
|
||||
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
|
|
|||
144
Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs
Normal file
144
Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Window responsible for switching Dalamud beta branches.
|
||||
/// </summary>
|
||||
public class BranchSwitcherWindow : Window
|
||||
{
|
||||
private const string BranchInfoUrl = "https://kamori.goats.dev/Dalamud/Release/Meta";
|
||||
|
||||
private Dictionary<string, VersionEntry>? branches;
|
||||
private int selectedBranchIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BranchSwitcherWindow"/> class.
|
||||
/// </summary>
|
||||
public BranchSwitcherWindow()
|
||||
: base("Branch Switcher", ImGuiWindowFlags.AlwaysAutoResize)
|
||||
{
|
||||
this.ShowCloseButton = false;
|
||||
this.RespectCloseHotkey = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnOpen()
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
this.branches = await client.GetFromJsonAsync<Dictionary<string, VersionEntry>>(BranchInfoUrl);
|
||||
Debug.Assert(this.branches != null, "this.branches != null");
|
||||
|
||||
var config = Service<DalamudConfiguration>.Get();
|
||||
this.selectedBranchIndex = this.branches!.Any(x => x.Key == config.DalamudBetaKind) ?
|
||||
this.branches.TakeWhile(x => x.Key != config.DalamudBetaKind).Count()
|
||||
: 0;
|
||||
|
||||
if (this.branches.ElementAt(this.selectedBranchIndex).Value.Key != config.DalamudBetaKey)
|
||||
this.selectedBranchIndex = 0;
|
||||
});
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Draw()
|
||||
{
|
||||
if (this.branches == null)
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, "Loading branches...");
|
||||
return;
|
||||
}
|
||||
|
||||
var si = Service<DalamudStartInfo>.Get();
|
||||
|
||||
var itemsArray = this.branches.Select(x => x.Key).ToArray();
|
||||
ImGui.ListBox("Branch", ref this.selectedBranchIndex, itemsArray, itemsArray.Length);
|
||||
|
||||
var pickedBranch = this.branches.ElementAt(this.selectedBranchIndex);
|
||||
|
||||
if (pickedBranch.Value.SupportedGameVer != si.GameVersion)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
ImGui.TextWrapped("Can't pick this branch. GameVer != SupportedGameVer.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text($"Version: {pickedBranch.Value.AssemblyVersion} ({pickedBranch.Value.GitSha ?? "unk"})");
|
||||
ImGui.Text($"Runtime: {pickedBranch.Value.RuntimeVersion}");
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
void Pick()
|
||||
{
|
||||
var config = Service<DalamudConfiguration>.Get();
|
||||
config.DalamudBetaKind = pickedBranch.Key;
|
||||
config.DalamudBetaKey = pickedBranch.Value.Key;
|
||||
config.Save();
|
||||
}
|
||||
|
||||
if (ImGui.Button("Pick"))
|
||||
{
|
||||
Pick();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGui.Button("Pick & Restart"))
|
||||
{
|
||||
Pick();
|
||||
|
||||
var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var xlPath = Path.Combine(appData, "XIVLauncher", "XIVLauncher.exe");
|
||||
|
||||
if (File.Exists(xlPath))
|
||||
{
|
||||
Process.Start(xlPath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class VersionEntry
|
||||
{
|
||||
[JsonProperty("key")]
|
||||
public string? Key { get; set; }
|
||||
|
||||
[JsonProperty("track")]
|
||||
public string? Track { get; set; }
|
||||
|
||||
[JsonProperty("assemblyVersion")]
|
||||
public string? AssemblyVersion { get; set; }
|
||||
|
||||
[JsonProperty("runtimeVersion")]
|
||||
public string? RuntimeVersion { get; set; }
|
||||
|
||||
[JsonProperty("runtimeRequired")]
|
||||
public bool RuntimeRequired { get; set; }
|
||||
|
||||
[JsonProperty("supportedGameVer")]
|
||||
public string? SupportedGameVer { get; set; }
|
||||
|
||||
[JsonProperty("downloadUrl")]
|
||||
public string? DownloadUrl { get; set; }
|
||||
|
||||
[JsonProperty("gitSha")]
|
||||
public string? GitSha { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue