MaidMiniStatusCtrl.cs 6.4 KB

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