some summary comments
This commit is contained in:
parent
c375fb9af7
commit
d0e91fdc78
@ -11,7 +11,9 @@ namespace Campofinale.Resource
|
||||
{
|
||||
public class ResourceLoader
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Load table cfg automatically inside ResourceManager fields
|
||||
/// </summary>
|
||||
public static void LoadTableCfg()
|
||||
{
|
||||
var tableCfgTypes = GetAllTableCfgTypes();
|
||||
@ -19,7 +21,7 @@ namespace Campofinale.Resource
|
||||
foreach (var type in tableCfgTypes)
|
||||
{
|
||||
var attr = type.GetCustomAttribute<TableCfgTypeAttribute>();
|
||||
string json = ReadJsonFile(attr.Name);
|
||||
string json = ResourceManager.ReadJsonFile(attr.Name);
|
||||
FieldInfo field = GetResourceField(type);
|
||||
if (field != null && json.Length > 0)
|
||||
{
|
||||
@ -49,20 +51,6 @@ namespace Campofinale.Resource
|
||||
|
||||
return JsonConvert.DeserializeObject(json, valueType);
|
||||
}
|
||||
public static string ReadJsonFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.PrintError($"Error occured while loading {path} Err: {e.Message}");
|
||||
ResourceManager.missingResources = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<Type> GetAllTableCfgTypes()
|
||||
{
|
||||
|
@ -78,6 +78,11 @@ namespace Campofinale.Resource
|
||||
return levelDatas.Find(a => a.id == name).idNum;
|
||||
}
|
||||
public static bool missingResources = false;
|
||||
/// <summary>
|
||||
/// Utility method for read a json file
|
||||
/// </summary>
|
||||
/// <param name="path">The file path</param>
|
||||
/// <returns>Return the file content if the file exist, else it return an empty string</returns>
|
||||
public static string ReadJsonFile(string path)
|
||||
{
|
||||
try
|
||||
|
@ -8,7 +8,9 @@ namespace Campofinale.Resource
|
||||
{
|
||||
public abstract class TableCfgResource
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Not implemented yet
|
||||
/// </summary>
|
||||
public void OnLoad()
|
||||
{
|
||||
|
||||
@ -17,7 +19,13 @@ namespace Campofinale.Resource
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class TableCfgTypeAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Path of the Resource
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
/// <summary>
|
||||
/// Priority of load (still not implemented)
|
||||
/// </summary>
|
||||
public LoadPriority Priority { get; }
|
||||
|
||||
public TableCfgTypeAttribute(string name, LoadPriority priority)
|
||||
|
Loading…
Reference in New Issue
Block a user