mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
@@ -26,6 +26,8 @@ namespace MaaWpfGui.Helper
|
||||
// 储存角色信息的字典
|
||||
public static Dictionary<string, CharacterInfo> Characters { get; } = new();
|
||||
|
||||
public static HashSet<string> CharacterNames { get; } = new();
|
||||
|
||||
static DataHelper()
|
||||
{
|
||||
const string FilePath = "resource/battle_data.json";
|
||||
@@ -37,9 +39,14 @@ namespace MaaWpfGui.Helper
|
||||
string jsonText = File.ReadAllText(FilePath);
|
||||
var characterData = JsonConvert.DeserializeObject<Dictionary<string, CharacterInfo>>(JObject.Parse(jsonText)["chars"]?.ToString() ?? string.Empty) ?? new();
|
||||
|
||||
foreach (var pair in characterData)
|
||||
foreach ((var key, var value) in characterData)
|
||||
{
|
||||
Characters.Add(pair.Key, pair.Value);
|
||||
Characters.Add(key, value);
|
||||
CharacterNames.Add(value.Name ?? string.Empty);
|
||||
CharacterNames.Add(value.NameEn ?? string.Empty);
|
||||
CharacterNames.Add(value.NameJp ?? string.Empty);
|
||||
CharacterNames.Add(value.NameKr ?? string.Empty);
|
||||
CharacterNames.Add(value.NameTw ?? string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,11 @@
|
||||
SelectedValuePath="Value"
|
||||
Style="{StaticResource ComboBoxExtend}" />
|
||||
<hc:ComboBox
|
||||
Name="StartingCoreCharComboBox"
|
||||
Margin="0,5"
|
||||
hc:InfoElement.Title="{DynamicResource StartingCoreChar}"
|
||||
AutoComplete="True"
|
||||
DropDownClosed="StartingCoreCharComboBox_DropDownClosed"
|
||||
IsEditable="True"
|
||||
IsTextSearchEnabled="False"
|
||||
ItemsSource="{Binding RoguelikeCoreCharList}"
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace MaaWpfGui.Views.UserControl
|
||||
public RoguelikeSettingsUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
_current = this;
|
||||
}
|
||||
|
||||
private static readonly MethodInfo _setText = typeof(HandyControl.Controls.NumericUpDown).GetMethod("SetText", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
@@ -42,6 +43,36 @@ namespace MaaWpfGui.Views.UserControl
|
||||
{
|
||||
_setText?.Invoke(sender, _paras);
|
||||
}
|
||||
|
||||
private static RoguelikeSettingsUserControl _current;
|
||||
private static bool _isValidResult;
|
||||
|
||||
internal static bool IsValidResult
|
||||
{
|
||||
get => _isValidResult;
|
||||
set
|
||||
{
|
||||
_isValidResult = value;
|
||||
if (!IsValidResult)
|
||||
{
|
||||
_current.StartingCoreCharComboBox.ItemsSource = DataHelper.CharacterNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StartingCoreCharComboBox_DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
if (IsValidResult)
|
||||
{
|
||||
var name = StartingCoreCharComboBox.Text;
|
||||
if (!string.IsNullOrEmpty(name) && !Instances.SettingsViewModel.RoguelikeCoreCharList.Contains(name))
|
||||
{
|
||||
Instances.SettingsViewModel.RoguelikeCoreCharList.Add(name);
|
||||
}
|
||||
|
||||
StartingCoreCharComboBox.ItemsSource = Instances.SettingsViewModel.RoguelikeCoreCharList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class InvestmentButtonCheckedConverter : IMultiValueConverter
|
||||
@@ -75,7 +106,14 @@ namespace MaaWpfGui.Views.UserControl
|
||||
return new ValidationResult(false, HandyControl.Properties.Langs.Lang.FormatError);
|
||||
}
|
||||
|
||||
return new ValidationResult(DataHelper.GetCharacterByNameOrAlias(stringValue) is not null, HandyControl.Properties.Langs.Lang.FormatError);
|
||||
if (!string.IsNullOrEmpty(stringValue) && DataHelper.GetCharacterByNameOrAlias(stringValue) is null)
|
||||
{
|
||||
RoguelikeSettingsUserControl.IsValidResult = false;
|
||||
return new ValidationResult(false, LocalizationHelper.GetString("RoguelikeStartingCoreCharNotFound"));
|
||||
}
|
||||
|
||||
RoguelikeSettingsUserControl.IsValidResult = true;
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user