Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC and cfg fix #754

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions AutoDuty/Helpers/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace AutoDuty.Helpers
{
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

internal static class ConfigHelper
{
Expand Down Expand Up @@ -53,6 +55,37 @@ internal static bool ModifyConfig(string configName, string configValue)
return false;
}
}
else if (configType == typeof(TrustMemberName?[]))
{
string[] memberNames = configValue.Split(",");

if (memberNames.Length > 3)
{
Svc.Log.Error("Unable to set more than 3 trust members");
return false;
}

List<TrustMemberName> members = [];

foreach (string memberName in memberNames)
if (Enum.TryParse(typeof(TrustMemberName), memberName, true, out object? member))
members.Add((TrustMemberName)member);

if (members.Count <= 0)
{
Svc.Log.Error("No trust members recognized");
return false;
}

TrustMemberName?[] value = (TrustMemberName?[]) field.GetValue(Plugin.Configuration);

for (int i = 0; i < members.Count; i++)
{
TrustMemberName member = members[i];
value[i] = member;
}
field.SetValue(Plugin.Configuration, value);
}
else if(configType.GetInterface(nameof(IConvertible)) != null)
{
object newConfigValue = Convert.ChangeType(configValue, configType, CultureInfo.InvariantCulture);
Expand Down
2 changes: 1 addition & 1 deletion AutoDuty/IPC/IPCProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal IPCProvider()
[EzIPC] public void ListConfig() => ConfigHelper.ListConfig();
[EzIPC] public string GetConfig(string config) => ConfigHelper.GetConfig(config);
[EzIPC] public void SetConfig (string config, string setting) => ConfigHelper.ModifyConfig(config, setting);
[EzIPC] public void Run(uint territoryType, int loops = 0, bool bareMode = false) => Plugin.Run(territoryType, loops, bareMode);
[EzIPC] public void Run(uint territoryType, int loops = 0, bool bareMode = false) => Plugin.Run(territoryType, loops, startFromZero: true, bareMode: bareMode);
[EzIPC] public void Start(bool startFromZero = true) => Plugin.StartNavigation(startFromZero);
[EzIPC] public void Stop() => Plugin.Stage = Stage.Stopped;
[EzIPC] public bool IsNavigating() => Plugin.States.HasFlag(PluginState.Navigating);
Expand Down
Loading