MaidMiniStatusCtrl.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using MaidStatus;
  5. using UnityEngine;
  6. using wf;
  7. namespace Kasizuki
  8. {
  9. public class MaidMiniStatusCtrl : NGUIWindow, IStatusCtrl<Maid>
  10. {
  11. protected override void Awake()
  12. {
  13. base.Awake();
  14. base.CacheChildObject<UILabel>("FirstName/Value", "FirstName");
  15. base.CacheChildObject<UILabel>("LastName/Value", "LastName");
  16. base.CacheChildObject<Transform>("FirstName/Title", "FirstNameTitle");
  17. base.CacheChildObject<Transform>("LastName/Title", "LastNameTitle");
  18. base.CacheChildObject<UILabel>("Column1/Character/Value", "Personal");
  19. base.CacheChildObject<UILabel>("Column1/SexExperience/Value", "SexualExp");
  20. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Height/Value", "Height");
  21. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Weight/Value", "Weight");
  22. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Bust/Value", "Bust");
  23. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Bust/Cup/Value", "Cup");
  24. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Waist/Value", "Waist");
  25. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Hip/Value", "Hip");
  26. base.CacheChildObject<UILabel>("WorkCount/Value", "WorkCount");
  27. MaidAppealComment maidAppealComment = base.CacheChildObject<MaidAppealComment>("AppealComment", "Appeal");
  28. MaidAppealComment maidAppealComment2 = maidAppealComment;
  29. maidAppealComment2.onClickRight = (Action)Delegate.Combine(maidAppealComment2.onClickRight, new Action(delegate()
  30. {
  31. this.ChangeMaidAppeal(1);
  32. }));
  33. MaidAppealComment maidAppealComment3 = maidAppealComment;
  34. maidAppealComment3.onClickLeft = (Action)Delegate.Combine(maidAppealComment3.onClickLeft, new Action(delegate()
  35. {
  36. this.ChangeMaidAppeal(-1);
  37. }));
  38. UIInput uiinput = base.CacheChildObject<UIInput>("FreeCommentWindow/FreeComment", "FreeComment");
  39. EventDelegate.Add(uiinput.onChange, new EventDelegate.Callback(this.OnChangeFreeComment));
  40. if (Product.isEnglish)
  41. {
  42. Vector3 position = base.GetCache<Transform>("FirstNameTitle").position;
  43. base.GetCache<Transform>("FirstNameTitle").position = base.GetCache<Transform>("LastNameTitle").position;
  44. base.GetCache<Transform>("LastNameTitle").position = position;
  45. }
  46. this.m_IsAwaked = true;
  47. }
  48. public void SetData(Maid maid)
  49. {
  50. if (maid == null)
  51. {
  52. NDebug.Warning("情報を表示するメイドにnullが指定されました。");
  53. return;
  54. }
  55. this.m_TargetMaid = maid;
  56. this.UpdateNGUILabel();
  57. }
  58. public void UpdateMaidInfo()
  59. {
  60. if (this.m_TargetMaid == null)
  61. {
  62. NDebug.Warning("情報を表示するメイドがnullでした。SetMaid( Maid )関数で、情報を表示するメイドを指定してください。");
  63. return;
  64. }
  65. this.UpdateNGUILabel();
  66. }
  67. private void UpdateNGUILabel()
  68. {
  69. if (!this.m_IsAwaked)
  70. {
  71. base.gameObject.SetActive(true);
  72. }
  73. Maid targetMaid = this.m_TargetMaid;
  74. Status status = targetMaid.status;
  75. NamePair charaName = status.charaName;
  76. base.GetCache<UILabel>("LastName").text = charaName.name1;
  77. base.GetCache<UILabel>("FirstName").text = charaName.name2;
  78. UILabel cache = base.GetCache<UILabel>("Personal");
  79. cache.fontSize = 25;
  80. cache.text = status.personal.drawName;
  81. if (!Utility.SetLocalizeTerm(cache, status.personal.termName, false))
  82. {
  83. Utility.ResizeUILabelFontSize(cache, 251);
  84. }
  85. base.GetCache<UILabel>("SexualExp").text = EnumConvert.GetString(status.seikeiken);
  86. Utility.SetLocalizeTerm(base.GetCache<UILabel>("SexualExp"), EnumConvert.GetTerm(status.seikeiken), false);
  87. base.GetCache<UILabel>("Height").text = status.body.height.ToString();
  88. base.GetCache<UILabel>("Weight").text = status.body.weight.ToString();
  89. base.GetCache<UILabel>("Bust").text = status.body.bust.ToString();
  90. base.GetCache<UILabel>("Cup").text = status.body.cup;
  91. base.GetCache<UILabel>("Waist").text = status.body.waist.ToString();
  92. base.GetCache<UILabel>("Hip").text = status.body.hip.ToString();
  93. int maidData = GameMain.Instance.KasizukiMgr.GetMaidData<int>(targetMaid, MaidDataType.仕事回数, false);
  94. base.GetCache<UILabel>("WorkCount").text = maidData.ToString();
  95. string maidData2 = GameMain.Instance.KasizukiMgr.GetMaidData<string>(targetMaid, MaidDataType.フリ\u30FCコメント, false);
  96. base.GetCache<UIInput>("FreeComment").value = maidData2;
  97. this.ChangeMaidAppeal(0);
  98. }
  99. private void ChangeMaidAppeal(int relativeIndex)
  100. {
  101. MaidAppealComment cache = base.GetCache<MaidAppealComment>("Appeal");
  102. Maid targetMaid = this.m_TargetMaid;
  103. int maidData = GameMain.Instance.KasizukiMgr.GetMaidData<int>(targetMaid, MaidDataType.アピ\u30FCル欄, false);
  104. List<AppealData.Data> datas = AppealData.GetDatas(targetMaid);
  105. if (AppealData.Contains(maidData))
  106. {
  107. AppealData.Data relativeAppealData = this.GetRelativeAppealData(datas, AppealData.GetData(maidData), relativeIndex);
  108. if (relativeAppealData != null)
  109. {
  110. this.SetAppealImage(relativeAppealData);
  111. }
  112. }
  113. else if (datas.Count > 0)
  114. {
  115. this.SetAppealImage(datas[0]);
  116. }
  117. }
  118. private void SetAppealImage(AppealData.Data data)
  119. {
  120. MaidAppealComment cache = base.GetCache<MaidAppealComment>("Appeal");
  121. if (Product.supportMultiLanguage)
  122. {
  123. Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>();
  124. foreach (string text in LocalizationManager.GetAllLanguages(true))
  125. {
  126. dictionary.Add(text, data.GetTexture(text));
  127. }
  128. cache.ChangeImage(dictionary);
  129. }
  130. else
  131. {
  132. cache.ChangeImage(data.GetTexture());
  133. }
  134. GameMain.Instance.KasizukiMgr.SetMaidData<int>(this.m_TargetMaid, MaidDataType.アピ\u30FCル欄, data.ID, false);
  135. }
  136. private AppealData.Data GetRelativeAppealData(List<AppealData.Data> list, AppealData.Data now, int index)
  137. {
  138. if (list == null || now == null)
  139. {
  140. return null;
  141. }
  142. int num = -1;
  143. if (list.Count > 0)
  144. {
  145. num = list.IndexOf(now);
  146. }
  147. if (num >= 0 && 0 <= num + index && num + index < list.Count)
  148. {
  149. return list[num + index];
  150. }
  151. return null;
  152. }
  153. private void OnChangeFreeComment()
  154. {
  155. if (this.m_TargetMaid == null)
  156. {
  157. Debug.LogWarning("フリーコメント欄に文字が入力されましたが、選択中のメイドが存在しないので何もしません。");
  158. return;
  159. }
  160. string value = UIInput.current.value;
  161. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  162. kasizukiMgr.SetMaidData<string>(this.m_TargetMaid, MaidDataType.フリ\u30FCコメント, value, false);
  163. }
  164. private string AdjustStrLengthIfOver(string str, int length)
  165. {
  166. if (str.Length > length)
  167. {
  168. str = str.Substring(length);
  169. Debug.LogError(string.Format("入力された文字数が最大文字数を超えています。入力文字={0}, 最大文字数={1}", str, length));
  170. }
  171. return str;
  172. }
  173. private const int MAX_FREE_COMMENT_LENGTH = 70;
  174. private Maid m_TargetMaid;
  175. private bool m_IsAwaked;
  176. }
  177. }