Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed macro about settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 11, 2023
1 parent d3b3f80 commit 0331668
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
33 changes: 26 additions & 7 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,35 @@ private static void DoSettingCommand(string str)
var value = str.Split(' ').LastOrDefault();
if(TryGetOneEnum<PluginConfigBool>(str, out var b))
{
Service.ConfigNew.SetValue(b, !Service.ConfigNew.GetValue(b));
var v = !Service.ConfigNew.GetValue(b);
Service.ConfigNew.SetValue(b, v);
value = v.ToString();
}
if (TryGetOneEnum<PluginConfigFloat>(str, out var f))
else if (TryGetOneEnum<PluginConfigFloat>(str, out var f) && float.TryParse(value, out var f1))
{
//Service.ConfigNew.SetValue(boolean, !Service.ConfigNew.GetValue(boolean));
Service.ConfigNew.SetValue(f, f1);
}
else if (TryGetOneEnum<PluginConfigInt>(str, out var i) && int.TryParse(value, out var i1))
{
Service.ConfigNew.SetValue(i, i1);
}
else if (TryGetOneEnum<JobConfigFloat>(str, out var f2) && float.TryParse(value, out f1))
{
Service.ConfigNew.SetValue(job, f2, f1);
}
else if (TryGetOneEnum<JobConfigInt>(str, out var i2) && int.TryParse(value, out i1))
{
Service.ConfigNew.SetValue(job, i2, i1);
}
else
{
Svc.Chat.PrintError(LocalizationManager.RightLang.Commands_CannotFindConfig);
return;
}

////Say out.
//Svc.Chat.Print(string.Format(LocalizationManager.RightLang.Commands_ChangeSettingsValue,
// type.ToString(), Service.Config.GetValue(type)));
//Say out.
Svc.Chat.Print(string.Format(LocalizationManager.RightLang.Commands_ChangeSettingsValue,
str, value));
}

private static void ToggleActionCommand(string str)
Expand Down Expand Up @@ -118,7 +137,7 @@ private static void DoRotationCommand(ICustomRotation customCombo, string str)
return;
}
}
Svc.Chat.Print(LocalizationManager.RightLang.Commands_CannotFindRotationConfig);
Svc.Chat.PrintError(LocalizationManager.RightLang.Commands_CannotFindRotationConfig);
}
}
}
34 changes: 9 additions & 25 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RotationSolver.Basic.Configuration;
using ECommons.Configuration;
using RotationSolver.Basic.Configuration;

namespace RotationSolver.Localization;

Expand Down Expand Up @@ -67,30 +68,13 @@ internal static class ConfigTranslation
_ => string.Empty,
};

public static string ToCommand(this JobConfigInt config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this JobConfigFloat config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigInt config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigBool config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigFloat config) => config switch
{
_ => string.Empty,
};
public static string ToCommand(this JobConfigInt config) => ToCommandStr(config);
public static string ToCommand(this JobConfigFloat config) => ToCommandStr(config);
public static string ToCommand(this PluginConfigInt config) => ToCommandStr(config);
public static string ToCommand(this PluginConfigBool config) => ToCommandStr(config);
public static string ToCommand(this PluginConfigFloat config) => ToCommandStr(config);
private static string ToCommandStr(object obj)
=> Service.Command + " " + OtherCommandType.Settings.ToString() + " " + obj.ToString();

public static LinkDescription[] ToAction(this JobConfigInt config) => config switch
{
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ internal partial class Strings
public string Commands_ChangeRotationConfig { get; set; } = "Modify {0} to {1}";
public string Commands_CannotFindRotationConfig { get; set; } = "Failed to find the config in this rotation, please check it.";

public string Commands_CannotFindConfig { get; set; } = "Failed to find the config, please check it.";

public string Commands_InsertAction { get; set; } = "Will use it within {0}s";

public string Commands_InsertActionFailure { get; set; } = "Can not find the action, please check the action name.";
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ internal class DragFloatRangeSearchJob : DragFloatRangeSearch

public override LinkDescription[] Tooltips => _configMin.ToAction();

public override string Command => _configMin.ToCommand();

public DragFloatRangeSearchJob(JobConfigFloat configMin, JobConfigFloat configMax, float min, float max, float speed)
: base (min, max, speed)
{
Expand Down Expand Up @@ -69,7 +67,6 @@ internal class DragFloatRangeSearchPlugin : DragFloatRangeSearch

public override LinkDescription[] Tooltips => _configMin.ToAction();

public override string Command => _configMin.ToCommand();

public DragFloatRangeSearchPlugin(PluginConfigFloat configMin, PluginConfigFloat configMax, float min, float max, float speed)
: base(min, max, speed)
Expand Down Expand Up @@ -111,6 +108,8 @@ internal abstract class DragFloatRangeSearch : Searchable
public float Max { get; init; }
public float Speed { get; init; }

public sealed override string Command => "";

public DragFloatRangeSearch(float min, float max, float speed)
{
Min = min; Max = max;
Expand Down
6 changes: 2 additions & 4 deletions RotationSolver/UI/SearchableConfigs/DragIntRangeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ internal class DragIntRangeSearchJob : DragIntRangeSearch

public override LinkDescription[] Tooltips => _configMin.ToAction();

public override string Command => _configMin.ToCommand();

public DragIntRangeSearchJob(JobConfigInt configMin, JobConfigInt configMax, int min, int max, float speed)
:base (min, max, speed)
{
Expand Down Expand Up @@ -71,8 +69,6 @@ internal class DragIntRangeSearchPlugin : DragIntRangeSearch

public override LinkDescription[] Tooltips => _configMin.ToAction();

public override string Command => _configMin.ToCommand();

public DragIntRangeSearchPlugin(PluginConfigInt configMin, PluginConfigInt configMax, int min, int max, float speed)
: base(min, max, speed)
{
Expand Down Expand Up @@ -113,6 +109,8 @@ internal abstract class DragIntRangeSearch : Searchable
public int Max { get; init; }
public float Speed { get; init; }

public sealed override string Command => "";

public DragIntRangeSearch(int min, int max, float speed)
{
Min = min; Max = max;
Expand Down

0 comments on commit 0331668

Please sign in to comment.