using System.Collections.Generic; namespace Cute; public class AssetErrorState { public enum Code { NONE = 0, SERVER_TIMEOUT = 1, SERVER_UNDEFINED_ERROR = 2, LOCAL_CAPACITY_OVER = 4, CANCELED = 8, FILE_READ_ERROR = 0x10, SERVER_NOT_FOUND_ERROR = 0x20 } public enum DialogDecision { UNDECIDED, RETRY, TERMINATE } private Dictionary errors = new Dictionary(); public DialogDecision lastDialogDecision; public int errorFlag { get; private set; } public bool canceled { get; private set; } public bool HasError() { return errorFlag != 0; } public bool HasError(Code code) { return ((uint)errorFlag & (uint)code) != 0; } public void SetCanceled() { canceled = true; } public int ErrorCount() { return errors.Count; } public AssetErrorState() { Reset(); } public void Report(string filename, Code errorCode) { if (errorCode != Code.NONE) { errorFlag |= (int)errorCode; errors[filename] = errorCode; } } public Code Query(string filename) { if (!errors.TryGetValue(filename, out var value)) { return Code.NONE; } return value; } public void Reset() { errorFlag = 0; lastDialogDecision = DialogDecision.UNDECIDED; errors.Clear(); canceled = false; } public List GatherErrorFilenames() { List list = new List(); foreach (KeyValuePair error in errors) { list.Add(error.Key); } return list; } }