123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using wf;
- namespace Kasizuki
- {
- public static class AppealData
- {
- public static int Count
- {
- get
- {
- AppealData.CreateData();
- return AppealData.commonIdManager.idMap.Count;
- }
- }
- public static bool Contains(int id)
- {
- AppealData.CreateData();
- return AppealData.commonIdManager.idMap.ContainsKey(id);
- }
- public static AppealData.Data GetData(int id)
- {
- AppealData.CreateData();
- NDebug.Assert(AppealData.basicDatas.ContainsKey(id), "傅き.アピール欄\nID[" + id + "]のデータは存在しません");
- return AppealData.basicDatas[id];
- }
- public static bool IsEnabled(int id)
- {
- AppealData.CreateData();
- return AppealData.commonIdManager.enabledIdList.Contains(id);
- }
- public static List<AppealData.Data> GetAllDatas(bool onlyEnabled)
- {
- AppealData.CreateData();
- List<AppealData.Data> list = new List<AppealData.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
- {
- if (!onlyEnabled || AppealData.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
- {
- list.Add(AppealData.basicDatas[keyValuePair.Key]);
- }
- }
- return list;
- }
- public static List<AppealData.Data> GetDatas(Func<AppealData.Data, bool> customCheckFunction)
- {
- AppealData.CreateData();
- List<AppealData.Data> list = new List<AppealData.Data>();
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
- {
- AppealData.Data data = AppealData.basicDatas[keyValuePair.Key];
- if (customCheckFunction(data))
- {
- list.Add(data);
- }
- }
- return list;
- }
- public static List<AppealData.Data> GetDatas(Maid maid)
- {
- Func<AppealData.Data, bool> customCheckFunction = (AppealData.Data data) => data.personalUniqueName == maid.status.personal.uniqueName;
- return AppealData.GetDatas(customCheckFunction);
- }
- public static void CreateData()
- {
- if (AppealData.commonIdManager != null)
- {
- return;
- }
- AppealData.commonIdManager = new CsvCommonIdManager("kasizuki_appeal", "傅き.アピール欄", CsvCommonIdManager.Type.IdOnly, null);
- AppealData.basicDatas = new Dictionary<int, AppealData.Data>();
- string[] array = new string[]
- {
- "list"
- };
- KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
- for (int i = 0; i < array2.Length; i++)
- {
- string text = "kasizuki_appeal_" + array[i] + ".nei";
- AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
- CsvParser csvParser = new CsvParser();
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, text + "\nopen failed.");
- array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
- }
- foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in AppealData.commonIdManager.idMap)
- {
- int key = keyValuePair.Key;
- AppealData.Data value = new AppealData.Data(key, array2[0].Value);
- AppealData.basicDatas.Add(key, value);
- }
- foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
- {
- keyValuePair2.Value.Dispose();
- keyValuePair2.Key.Dispose();
- }
- }
- private const string csvTopCommonName = "kasizuki_appeal";
- private const string typeNameForErrorLog = "傅き.アピール欄";
- private static CsvCommonIdManager commonIdManager;
- private static Dictionary<int, AppealData.Data> basicDatas;
- public class Data
- {
- public Data(int uniqueID, CsvParser csv)
- {
- for (int i = 1; i < csv.max_cell_y; i++)
- {
- if (csv.IsCellToExistData(0, i) && csv.GetCellAsInteger(0, i) == uniqueID)
- {
- int num = 1;
- this.ID = uniqueID;
- this.personalUniqueName = csv.GetCellAsString(num++, i);
- this.texName = csv.GetCellAsString(num++, i);
- }
- }
- }
- public string texNameTerm
- {
- get
- {
- return "SceneKasizukiMainMenu/アピールイメージ/" + this.ID;
- }
- }
- public Texture2D GetTexture()
- {
- if (!string.IsNullOrEmpty(this.texName))
- {
- string f_strFileName = this.texName + ".tex";
- if (GameUty.FileSystem.IsExistentFile(f_strFileName))
- {
- return ImportCM.CreateTexture(f_strFileName);
- }
- Debug.LogWarningFormat("テクスチャ「{0}」がない", new object[]
- {
- this.texName
- });
- }
- else
- {
- Debug.LogWarning("テクスチャ名が空でした");
- }
- return null;
- }
- public Texture2D GetTexture(string language)
- {
- string termTranslation = LocalizationManager.GetTermTranslation(this.texNameTerm, true, 0, true, false, null, language);
- if (!string.IsNullOrEmpty(termTranslation))
- {
- string f_strFileName = termTranslation + ".tex";
- if (GameUty.FileSystem.IsExistentFile(f_strFileName))
- {
- return ImportCM.CreateTexture(f_strFileName);
- }
- Debug.LogWarningFormat("テクスチャ「{0}」がない", new object[]
- {
- termTranslation
- });
- }
- else
- {
- Debug.LogWarning("テクスチャ名が空でした");
- }
- return null;
- }
- public readonly int ID;
- public readonly string personalUniqueName;
- public readonly string texName;
- }
- }
- }
|