mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
refactor: 将获取物品名称移至Utils
This commit is contained in:
@@ -92,40 +92,6 @@ namespace MaaWpfGui
|
||||
// new StageInfo { Display = Localization.GetString("CurrentStage"), Value = string.Empty },
|
||||
// new StageInfo { Display = Localization.GetString("LastBattle"), Value = "LastBattle" },
|
||||
};
|
||||
|
||||
var language = ViewStatusStorage.Get("GUI.Localization", Localization.DefaultLanguage);
|
||||
string filename = string.Empty;
|
||||
if (language == "zh-cn")
|
||||
{
|
||||
filename = Directory.GetCurrentDirectory() + "\\resource\\item_index.json";
|
||||
}
|
||||
else if (language == "pallas")
|
||||
{
|
||||
// DoNothing
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, string> client = new Dictionary<string, string>
|
||||
{
|
||||
{ "zh-tw", "txwy" },
|
||||
{ "en-us", "YoStarEN" },
|
||||
{ "ja-jp", "YoStarJP" },
|
||||
{ "ko-kr", "YoStarKR" },
|
||||
};
|
||||
filename = Directory.GetCurrentDirectory() + "\\resource\\global\\" + client[language] + "\\resource\\item_index.json";
|
||||
}
|
||||
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
try
|
||||
{
|
||||
data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(File.ReadAllText(filename));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// DoNothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,8 +116,6 @@ namespace MaaWpfGui
|
||||
return GetStageInfo(stage)?.IsStageOpen(dayOfWeek) == true;
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Dictionary<string, string>> data;
|
||||
|
||||
/// <summary>
|
||||
/// Gets open stage tips at specified day of week
|
||||
/// </summary>
|
||||
@@ -183,10 +147,7 @@ namespace MaaWpfGui
|
||||
|
||||
if (!string.IsNullOrEmpty(item.Value.Drop))
|
||||
{
|
||||
if (data != null && data.ContainsKey(item.Value.Drop))
|
||||
{
|
||||
builder.AppendLine(item.Value.Display + ": " + data[item.Value.Drop]["name"]);
|
||||
}
|
||||
builder.AppendLine(item.Value.Display + ": " + Utils.GetItemName(item.Value.Drop));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,52 @@
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MaaWpfGui
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
static Utils()
|
||||
{
|
||||
var language = ViewStatusStorage.Get("GUI.Localization", Localization.DefaultLanguage);
|
||||
string filename = string.Empty;
|
||||
if (language == "zh-cn")
|
||||
{
|
||||
filename = Directory.GetCurrentDirectory() + "\\resource\\item_index.json";
|
||||
}
|
||||
else if (language == "pallas")
|
||||
{
|
||||
// DoNothing
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, string> client = new Dictionary<string, string>
|
||||
{
|
||||
{ "zh-tw", "txwy" },
|
||||
{ "en-us", "YoStarEN" },
|
||||
{ "ja-jp", "YoStarJP" },
|
||||
{ "ko-kr", "YoStarKR" },
|
||||
};
|
||||
filename = Directory.GetCurrentDirectory() + "\\resource\\global\\" + client[language] + "\\resource\\item_index.json";
|
||||
}
|
||||
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
try
|
||||
{
|
||||
_itemList = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(filename));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// DoNothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取yj历时间
|
||||
/// </summary>
|
||||
@@ -62,5 +103,21 @@ namespace MaaWpfGui
|
||||
{
|
||||
return dt.AddHours(4);
|
||||
}
|
||||
|
||||
private static readonly JObject _itemList = new JObject();
|
||||
|
||||
public static JObject GetItemList() => _itemList;
|
||||
|
||||
public static string GetItemName(string id)
|
||||
{
|
||||
if (_itemList.ContainsKey(id))
|
||||
{
|
||||
return _itemList[id]["name"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user