make "start on boot" work as expected for dev plugins

This commit is contained in:
goat 2023-04-11 21:45:26 +02:00
parent 9b3990e5c7
commit 3f112376eb
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 29 additions and 16 deletions

View file

@ -2581,26 +2581,32 @@ internal class PluginInstallerWindow : Window, IDisposable
if (localPlugin is LocalDevPlugin plugin) if (localPlugin is LocalDevPlugin plugin)
{ {
var isInDefaultProfile =
Service<ProfileManager>.Get().IsInDefaultProfile(localPlugin.Manifest.InternalName);
// https://colorswall.com/palette/2868/ // https://colorswall.com/palette/2868/
var greenColor = new Vector4(0x5C, 0xB8, 0x5C, 0xFF) / 0xFF; var greenColor = new Vector4(0x5C, 0xB8, 0x5C, 0xFF) / 0xFF;
var redColor = new Vector4(0xD9, 0x53, 0x4F, 0xFF) / 0xFF; var redColor = new Vector4(0xD9, 0x53, 0x4F, 0xFF) / 0xFF;
// Load on boot // Load on boot
ImGui.PushStyleColor(ImGuiCol.Button, plugin.StartOnBoot ? greenColor : redColor); using (ImRaii.Disabled(!isInDefaultProfile))
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, plugin.StartOnBoot ? greenColor : redColor);
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.PowerOff))
{ {
plugin.StartOnBoot ^= true; ImGui.PushStyleColor(ImGuiCol.Button, plugin.StartOnBoot ? greenColor : redColor);
configuration.QueueSave(); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, plugin.StartOnBoot ? greenColor : redColor);
}
ImGui.PopStyleColor(2); ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.PowerOff))
{
plugin.StartOnBoot ^= true;
configuration.QueueSave();
}
if (ImGui.IsItemHovered()) ImGui.PopStyleColor(2);
{
ImGui.SetTooltip(Locs.PluginButtonToolTip_StartOnBoot); if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(isInDefaultProfile ? Locs.PluginButtonToolTip_StartOnBoot : Locs.PluginButtonToolTip_NeedsToBeInDefault);
}
} }
// Automatic reload // Automatic reload

View file

@ -862,10 +862,17 @@ Thanks and have fun!";
var devPlugin = new LocalDevPlugin(dllFile, manifest); var devPlugin = new LocalDevPlugin(dllFile, manifest);
loadPlugin &= !isBoot || devPlugin.StartOnBoot; loadPlugin &= !isBoot || devPlugin.StartOnBoot;
// If we're not loading it, make sure it's disabled var probablyInternalNameForThisPurpose = manifest?.InternalName ?? dllFile.Name;
// NOTE: Should be taken care of below by the profile code var wantsInDefaultProfile =
// if (!loadPlugin && !devPlugin.IsDisabled) this.profileManager.DefaultProfile.WantsPlugin(probablyInternalNameForThisPurpose);
// devPlugin.Disable(); if (wantsInDefaultProfile == false && devPlugin.StartOnBoot)
{
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, true, false);
}
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
{
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false);
}
plugin = devPlugin; plugin = devPlugin;
} }