PresetButtonCtrl.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using MaidStatus;
  5. using SceneEditWindow;
  6. using UnityEngine;
  7. public class PresetButtonCtrl : MonoBehaviour
  8. {
  9. public void Init(GameObject goPresetButtonPanel, Maid maid)
  10. {
  11. this.m_goPresetButtonPanel = goPresetButtonPanel;
  12. this.m_maid = maid;
  13. this.m_goItemPresetsViewer = UTY.GetChildObject(this.m_goPresetButtonPanel, "ItemPresetsViewer", false);
  14. this.m_listPresetBtn = new Dictionary<string, PresetButtonCtrl.PresetButton>();
  15. this.m_listItemPresetBtn = new Dictionary<string, PresetButtonCtrl.PresetButton>();
  16. IEnumerator enumerator = Enum.GetValues(typeof(PresetButtonCtrl.LeftButtons)).GetEnumerator();
  17. try
  18. {
  19. while (enumerator.MoveNext())
  20. {
  21. object obj = enumerator.Current;
  22. this.initBtnList("LeftButtons", ((PresetButtonCtrl.LeftButtons)obj).ToString());
  23. }
  24. }
  25. finally
  26. {
  27. IDisposable disposable;
  28. if ((disposable = (enumerator as IDisposable)) != null)
  29. {
  30. disposable.Dispose();
  31. }
  32. }
  33. IEnumerator enumerator2 = Enum.GetValues(typeof(PresetButtonCtrl.RightButtons)).GetEnumerator();
  34. try
  35. {
  36. while (enumerator2.MoveNext())
  37. {
  38. object obj2 = enumerator2.Current;
  39. this.initBtnList("RightButtons", ((PresetButtonCtrl.RightButtons)obj2).ToString());
  40. }
  41. }
  42. finally
  43. {
  44. IDisposable disposable2;
  45. if ((disposable2 = (enumerator2 as IDisposable)) != null)
  46. {
  47. disposable2.Dispose();
  48. }
  49. }
  50. this.m_goParentItemBtn = UTY.GetChildObject(this.m_goItemPresetsViewer, "Scroll View/Grid", false);
  51. UIButton component = UTY.GetChildObject(this.m_goPresetButtonPanel, "PresetButtons/LeftButtons/View", false).GetComponent<UIButton>();
  52. this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
  53. this.inActiveColor = component.defaultColor;
  54. this.m_sbScrollBar = UTY.GetChildObject(this.m_goItemPresetsViewer, "Scroll Bar", false).GetComponent<UIScrollBar>();
  55. this.m_goItemScrollView = UTY.GetChildObject(this.m_goPresetButtonPanel, "ItemPresetsViewer/Scroll View", false);
  56. this.m_pItemScrollViewPanel = this.m_goItemScrollView.GetComponent<UIPanel>();
  57. GameObject childObject = UTY.GetChildObject(this.m_goPresetButtonPanel, "ItemPresetsViewer/BG", false);
  58. this.m_spScrollViewBG = childObject.GetComponent<UISprite>();
  59. this.m_maxScrollViewWidth = (int)this.m_pItemScrollViewPanel.baseClipRegion.z;
  60. this.m_scrollViewSize = new Vector4(0f, 0f, (float)this.m_maxScrollViewWidth, (float)((int)this.m_pItemScrollViewPanel.baseClipRegion.w));
  61. this.m_scrollViewSoftnessX = (int)this.m_pItemScrollViewPanel.clipSoftness.x;
  62. this.m_nguiContentWidth = base.GetComponentInParent<UIRoot>().GetComponent<UIRoot>().manualWidth;
  63. this.m_ajustedNguiContentWidth = this.m_nguiContentWidth - 650;
  64. GameObject childObject2 = UTY.GetChildObject(this.m_goPresetButtonPanel, "PresetButtons", false);
  65. float x = UTY.GetChildObject(childObject2, "LeftButtons/Pose", false).transform.position.x;
  66. float x2 = UTY.GetChildObject(childObject2, "LeftButtons/Clothes", false).transform.position.x;
  67. float x3 = UTY.GetChildObject(childObject2, "LeftButtons/PriSave", false).transform.position.x;
  68. float x4 = UTY.GetChildObject(childObject2, "RightButtons/Voice", false).transform.position.x;
  69. float x5 = UTY.GetChildObject(childObject2, "RightButtons/BG", false).transform.position.x;
  70. this.dicBtnPosX = new Dictionary<string, float>
  71. {
  72. {
  73. "Pose",
  74. x
  75. },
  76. {
  77. "Clothes",
  78. x2
  79. },
  80. {
  81. "PriSave",
  82. x3
  83. },
  84. {
  85. "Voice",
  86. x4
  87. },
  88. {
  89. "BG",
  90. x5
  91. }
  92. };
  93. this.m_goItemSpriteBtn = (Resources.Load("SceneEdit/PresetButton/Prefabs/ItemSpritePresetButton") as GameObject);
  94. this.m_goItemTxtrBtn = (Resources.Load("SceneEdit/PresetButton/Prefabs/ItemTxtrPresetButton") as GameObject);
  95. this.m_spItemIcon = this.m_goItemSpriteBtn.GetComponent<UISprite>();
  96. this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
  97. this.m_goItemPresetsViewer.SetActive(false);
  98. if (this.m_sceneEdit.IsVRComMode)
  99. {
  100. UIButton component2 = UTY.GetChildObject(childObject2, "RightButtons/BG", false).GetComponent<UIButton>();
  101. component2.disabledColor.a = 0.5f;
  102. component2.SetState(UIButtonColor.State.Disabled, true);
  103. component2.isEnabled = false;
  104. UIButton component3 = UTY.GetChildObject(childObject2, "LeftButtons/View", false).GetComponent<UIButton>();
  105. component3.disabledColor.a = 0.5f;
  106. component3.SetState(UIButtonColor.State.Disabled, true);
  107. component3.isEnabled = false;
  108. }
  109. UIButton component4 = UTY.GetChildObject(this.m_goPresetButtonPanel, "HowToName", false).GetComponent<UIButton>();
  110. if (component4.onClick.Count == 0)
  111. {
  112. EventDelegate.Add(component4.onClick, new EventDelegate.Callback(this.m_sceneEdit.CallHowToNameDialog));
  113. }
  114. if (this.m_sceneEdit.modeType == SceneEdit.ModeType.OriginalChara || this.m_sceneEdit.modeType == SceneEdit.ModeType.MainChara || this.m_sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit || maid.status.heroineType == HeroineType.Sub || maid.boNPC)
  115. {
  116. component4.gameObject.SetActive(false);
  117. }
  118. else
  119. {
  120. component4.gameObject.SetActive(true);
  121. }
  122. UIButton component5 = UTY.GetChildObject(this.m_goPresetButtonPanel, "SettingName", false).GetComponent<UIButton>();
  123. if (component5.onClick.Count == 0)
  124. {
  125. EventDelegate.Add(component5.onClick, new EventDelegate.Callback(this.m_sceneEdit.CallSettingNamePanel));
  126. }
  127. component5.gameObject.SetActive(maid.status.heroineType == HeroineType.Sub);
  128. if (this.m_sceneEdit.modeType == SceneEdit.ModeType.CostumeEdit)
  129. {
  130. UTY.GetChildObject(this.m_goPresetButtonPanel, "WindowVoice/Button", false).GetComponent<UIButton>().isEnabled = false;
  131. UTY.GetChildObject(this.m_goPresetButtonPanel, "WindowPresetSave/Button", false).GetComponent<UIButton>().isEnabled = false;
  132. }
  133. if (maid.boNPC)
  134. {
  135. UTY.GetChildObject(this.m_goPresetButtonPanel, "WindowVoice/Button", false).GetComponent<UIButton>().isEnabled = false;
  136. }
  137. }
  138. public void CreateItemPresetsViewer(string type, string clickBtnName, string prevActiveBtnName)
  139. {
  140. if (!string.IsNullOrEmpty(this.last_draw_type_))
  141. {
  142. if (this.last_draw_type_ == PresetButtonMgr.ItemTypes.Pose.ToString())
  143. {
  144. this.backup_pose_scroll_pos_ = this.m_sbScrollBar.value;
  145. }
  146. else if (this.last_draw_type_ == PresetButtonMgr.ItemTypes.BG.ToString())
  147. {
  148. this.backup_bg_scroll_pos_ = this.m_sbScrollBar.value;
  149. }
  150. }
  151. this.m_dicItem = new Dictionary<string, PresetButtonCtrl.ItemPreset>();
  152. if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.Pose.ToString())
  153. {
  154. this.m_dicItem = this.LoadItemData(clickBtnName);
  155. }
  156. else if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.Clothes.ToString())
  157. {
  158. this.m_dicItem = this.LoadClothesData();
  159. }
  160. else if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.PriSave.ToString())
  161. {
  162. this.m_dicItem = this.LoadPriSaveData();
  163. }
  164. else if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.Voice.ToString())
  165. {
  166. this.m_dicItem = this.LoadItemData(clickBtnName);
  167. }
  168. else if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.BG.ToString())
  169. {
  170. this.m_dicItem = this.LoadItemData(clickBtnName);
  171. }
  172. this.last_draw_type_ = clickBtnName;
  173. List<PresetButtonCtrl.ItemPreset> list = new List<PresetButtonCtrl.ItemPreset>();
  174. foreach (KeyValuePair<string, PresetButtonCtrl.ItemPreset> keyValuePair in this.m_dicItem)
  175. {
  176. if (keyValuePair.Key.StartsWith(clickBtnName))
  177. {
  178. list.Add(keyValuePair.Value);
  179. }
  180. }
  181. if (list.Count == 0 && clickBtnName != "View")
  182. {
  183. Debug.LogError(string.Format("アイテムビューワに表示するアイテムが存在しません。押下されたボタン={0}", clickBtnName));
  184. return;
  185. }
  186. this.LoadItemBtn(list, clickBtnName);
  187. this.initItemBtnList(list);
  188. this.AdjustItemPresets(type, clickBtnName, prevActiveBtnName);
  189. if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.Pose.ToString())
  190. {
  191. this.m_sbScrollBar.value = this.backup_pose_scroll_pos_;
  192. }
  193. else if (type == "PresetButtons" && clickBtnName == PresetButtonMgr.ItemTypes.BG.ToString())
  194. {
  195. this.m_sbScrollBar.value = this.backup_bg_scroll_pos_;
  196. }
  197. }
  198. private void initBtnList(string btnType, string btnName)
  199. {
  200. string text = null;
  201. bool flag = false;
  202. PresetButtonCtrl.PresetButton presetButton = new PresetButtonCtrl.PresetButton();
  203. if (btnType == "LeftButtons" || btnType == "RightButtons")
  204. {
  205. text = "PresetButtons/" + btnType + "/" + btnName;
  206. flag = true;
  207. }
  208. else if (btnType == "itemPresetButtons")
  209. {
  210. text = "ItemPresetsViewer/Scroll View/Grid/" + btnName;
  211. flag = false;
  212. }
  213. UIButton component = UTY.GetChildObject(this.m_goPresetButtonPanel, text, false).GetComponent<UIButton>();
  214. GameObject childObject = UTY.GetChildObject(this.m_goPresetButtonPanel, text + "/SelectCursor", false);
  215. childObject.SetActive(false);
  216. if (flag && btnName != "View")
  217. {
  218. GameObject childObject2 = UTY.GetChildObject(this.m_goPresetButtonPanel, text + "/WindowArrow", false);
  219. childObject2.SetActive(false);
  220. presetButton.m_goWindowArrow = childObject2;
  221. }
  222. presetButton.m_btnButton = component;
  223. presetButton.m_name = btnName;
  224. presetButton.m_goSelectCursor = childObject;
  225. if (btnType == "LeftButtons" || btnType == "RightButtons")
  226. {
  227. this.m_listPresetBtn.Add(presetButton.m_name, presetButton);
  228. }
  229. else if (btnType == "itemPresetButtons")
  230. {
  231. this.m_listItemPresetBtn[presetButton.m_name] = presetButton;
  232. }
  233. }
  234. public void LoadItemBtn(List<PresetButtonCtrl.ItemPreset> listItemPreset, string clickBtnName)
  235. {
  236. if (clickBtnName == PresetButtonMgr.ItemTypes.Pose.ToString() || clickBtnName == PresetButtonMgr.ItemTypes.Voice.ToString() || clickBtnName == PresetButtonMgr.ItemTypes.BG.ToString())
  237. {
  238. this.m_goItemBtn = this.m_goItemTxtrBtn;
  239. }
  240. else if (clickBtnName == PresetButtonMgr.ItemTypes.Clothes.ToString() || clickBtnName == PresetButtonMgr.ItemTypes.PriSave.ToString())
  241. {
  242. this.m_goItemBtn = this.m_goItemSpriteBtn;
  243. }
  244. IEnumerator enumerator = this.m_goParentItemBtn.transform.GetEnumerator();
  245. try
  246. {
  247. while (enumerator.MoveNext())
  248. {
  249. object obj = enumerator.Current;
  250. Transform transform = (Transform)obj;
  251. UnityEngine.Object.Destroy(transform.gameObject);
  252. }
  253. }
  254. finally
  255. {
  256. IDisposable disposable;
  257. if ((disposable = (enumerator as IDisposable)) != null)
  258. {
  259. disposable.Dispose();
  260. }
  261. }
  262. this.m_goParentItemBtn.transform.DetachChildren();
  263. this.m_listItemPresetBtn.Clear();
  264. foreach (PresetButtonCtrl.ItemPreset itemPreset in listItemPreset)
  265. {
  266. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goItemBtn);
  267. switch (itemPreset.m_itemType)
  268. {
  269. case PresetButtonMgr.ItemTypes.Pose:
  270. case PresetButtonMgr.ItemTypes.Voice:
  271. case PresetButtonMgr.ItemTypes.BG:
  272. {
  273. UITexture component = gameObject.GetComponent<UITexture>();
  274. component.mainTexture = itemPreset.m_txtItemIcon;
  275. this.m_currentItemIconWidth = component.width;
  276. break;
  277. }
  278. case PresetButtonMgr.ItemTypes.Clothes:
  279. case PresetButtonMgr.ItemTypes.PriSave:
  280. {
  281. UISprite component2 = gameObject.GetComponent<UISprite>();
  282. string b = null;
  283. if (itemPreset.m_atlasName != b)
  284. {
  285. component2.atlas = Resources.Load<UIAtlas>(itemPreset.m_atlasName);
  286. b = itemPreset.m_atlasName;
  287. }
  288. component2.spriteName = itemPreset.m_spriteName;
  289. this.m_currentItemIconWidth = component2.width;
  290. break;
  291. }
  292. }
  293. gameObject.transform.name = itemPreset.m_name;
  294. gameObject.transform.parent = this.m_goParentItemBtn.transform;
  295. gameObject.transform.localScale = Vector3.one;
  296. gameObject.transform.localPosition = Vector3.zero;
  297. gameObject.transform.rotation = Quaternion.identity;
  298. switch (itemPreset.m_itemType)
  299. {
  300. case PresetButtonMgr.ItemTypes.Pose:
  301. {
  302. UIButton component3 = gameObject.GetComponent<UIButton>();
  303. EventDelegate.Add(component3.onClick, new EventDelegate.Callback(this.ClickPose));
  304. break;
  305. }
  306. case PresetButtonMgr.ItemTypes.Clothes:
  307. {
  308. UIButton component3 = gameObject.GetComponent<UIButton>();
  309. EventDelegate.Add(component3.onClick, new EventDelegate.Callback(this.ClickClothes));
  310. break;
  311. }
  312. case PresetButtonMgr.ItemTypes.PriSave:
  313. {
  314. UIButton component3 = gameObject.GetComponent<UIButton>();
  315. EventDelegate.Add(component3.onClick, new EventDelegate.Callback(this.PresetSave));
  316. break;
  317. }
  318. case PresetButtonMgr.ItemTypes.Voice:
  319. {
  320. UIButton component3 = gameObject.GetComponent<UIButton>();
  321. EventDelegate.Add(component3.onClick, new EventDelegate.Callback(this.ClickVoice));
  322. break;
  323. }
  324. case PresetButtonMgr.ItemTypes.BG:
  325. {
  326. UIButton component3 = gameObject.GetComponent<UIButton>();
  327. EventDelegate.Add(component3.onClick, new EventDelegate.Callback(this.ClickBG));
  328. break;
  329. }
  330. }
  331. }
  332. }
  333. public void initItemBtnList(List<PresetButtonCtrl.ItemPreset> listItemPreset)
  334. {
  335. foreach (PresetButtonCtrl.ItemPreset itemPreset in listItemPreset)
  336. {
  337. this.initBtnList("itemPresetButtons", itemPreset.m_name);
  338. }
  339. }
  340. public void AdjustItemPresets(string type, string clickBtnName, string prevActiveBtnName)
  341. {
  342. PresetButtonCtrl.PresetButton btn = new PresetButtonCtrl.PresetButton();
  343. PresetButtonCtrl.PresetButton btn2 = new PresetButtonCtrl.PresetButton();
  344. if (type == "PresetButtons")
  345. {
  346. btn = this.m_listPresetBtn[clickBtnName];
  347. if (prevActiveBtnName != null)
  348. {
  349. btn2 = this.m_listPresetBtn[prevActiveBtnName];
  350. }
  351. }
  352. else if (type == "ItemPresetsViewer")
  353. {
  354. btn = this.m_listItemPresetBtn[clickBtnName];
  355. if (prevActiveBtnName != null)
  356. {
  357. btn2 = this.m_listItemPresetBtn[prevActiveBtnName];
  358. }
  359. }
  360. this.SetActiveBtn(btn, true);
  361. if (prevActiveBtnName != null)
  362. {
  363. this.SetActiveBtn(btn2, false);
  364. }
  365. if (type == "PresetButtons")
  366. {
  367. if (clickBtnName == PresetButtonCtrl.LeftButtons.View.ToString())
  368. {
  369. this.m_goItemPresetsViewer.SetActive(false);
  370. }
  371. else
  372. {
  373. this.AdjustScrollViewWidth();
  374. this.m_goItemPresetsViewer.transform.position = new Vector2(this.dicBtnPosX[clickBtnName], this.m_goItemPresetsViewer.transform.position.y);
  375. float num = -this.m_goItemPresetsViewer.transform.localPosition.x + (float)(this.m_spScrollViewBG.width / 2) - (float)(this.m_nguiContentWidth / 2);
  376. if (num > 0f)
  377. {
  378. this.m_goItemPresetsViewer.transform.localPosition = new Vector2(this.m_goItemPresetsViewer.transform.localPosition.x + num, this.m_goItemPresetsViewer.transform.localPosition.y);
  379. }
  380. this.m_goItemPresetsViewer.SetActive(true);
  381. this.m_goParentItemBtn.GetComponent<UIGrid>().Reposition();
  382. this.AdjustScrollViewItemPos();
  383. if (this.m_scrollViewWidthOver)
  384. {
  385. this.m_sbScrollBar.value = 0f;
  386. }
  387. }
  388. }
  389. }
  390. private void AdjustScrollViewItemPos()
  391. {
  392. UIScrollView component = this.m_goItemScrollView.GetComponent<UIScrollView>();
  393. component.ResetPosition();
  394. }
  395. public void SetDefaultScrollBarPos()
  396. {
  397. this.m_sbScrollBar.value = 0f;
  398. }
  399. private void AdjustScrollViewWidth()
  400. {
  401. this.m_scrollViewWidthOver = false;
  402. int num = (this.m_currentItemIconWidth + this.itemIconOffsetX) * this.m_listItemPresetBtn.Count + this.m_scrollViewSoftnessX;
  403. if (num > this.m_maxScrollViewWidth)
  404. {
  405. num = this.m_maxScrollViewWidth;
  406. this.m_scrollViewWidthOver = true;
  407. }
  408. this.m_scrollViewSize.z = (float)(num + 10);
  409. this.m_pItemScrollViewPanel.baseClipRegion = this.m_scrollViewSize;
  410. int num2 = this.m_currentItemIconWidth * 3;
  411. int num3 = num2 + num;
  412. if (num3 > this.m_ajustedNguiContentWidth)
  413. {
  414. num3 = this.m_ajustedNguiContentWidth;
  415. }
  416. this.m_spScrollViewBG.width = num3;
  417. UIGrid component = this.m_goParentItemBtn.GetComponent<UIGrid>();
  418. component.cellWidth = (float)(this.m_currentItemIconWidth + this.itemIconOffsetX);
  419. }
  420. private void SetActiveBtn(PresetButtonCtrl.PresetButton btn, bool active)
  421. {
  422. if (Enum.IsDefined(typeof(PresetButtonMgr.ItemTypes), btn.m_name))
  423. {
  424. btn.m_goSelectCursor.SetActive(active);
  425. if (btn.m_goWindowArrow != null)
  426. {
  427. btn.m_goWindowArrow.SetActive(active);
  428. }
  429. if (active)
  430. {
  431. btn.m_btnButton.defaultColor = this.activeColor;
  432. }
  433. else
  434. {
  435. btn.m_btnButton.defaultColor = this.inActiveColor;
  436. }
  437. }
  438. }
  439. public void SetActiveBtn(string btnName, bool active)
  440. {
  441. PresetButtonCtrl.PresetButton btn = this.m_listPresetBtn[btnName];
  442. this.SetActiveBtn(btn, active);
  443. }
  444. private Dictionary<string, PresetButtonCtrl.ItemPreset> LoadPriSaveData()
  445. {
  446. Dictionary<string, PresetButtonCtrl.ItemPreset> dictionary = new Dictionary<string, PresetButtonCtrl.ItemPreset>();
  447. PresetButtonCtrl.ItemPreset itemPreset = new PresetButtonCtrl.ItemPreset();
  448. itemPreset.m_name = PresetButtonCtrl.PriSaveButton.PriSave_WearAndBody.ToString();
  449. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  450. itemPreset.m_spriteName = "cm3d2_edit_priset_buttom_clothes_body";
  451. itemPreset.m_spItemIcon = this.m_spItemIcon;
  452. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.PriSave;
  453. dictionary.Add(itemPreset.m_name, itemPreset);
  454. itemPreset = new PresetButtonCtrl.ItemPreset();
  455. itemPreset.m_name = PresetButtonCtrl.PriSaveButton.PriSave_Wear.ToString();
  456. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  457. itemPreset.m_spriteName = "cm3d2_edit_priset_buttom_clothes";
  458. itemPreset.m_spItemIcon = this.m_spItemIcon;
  459. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.PriSave;
  460. dictionary.Add(itemPreset.m_name, itemPreset);
  461. itemPreset = new PresetButtonCtrl.ItemPreset();
  462. itemPreset.m_name = PresetButtonCtrl.PriSaveButton.PriSave_Body.ToString();
  463. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  464. itemPreset.m_spriteName = "cm3d2_edit_preset_buttom_body";
  465. itemPreset.m_spItemIcon = this.m_spItemIcon;
  466. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.PriSave;
  467. dictionary.Add(itemPreset.m_name, itemPreset);
  468. return dictionary;
  469. }
  470. private Dictionary<string, PresetButtonCtrl.ItemPreset> LoadClothesData()
  471. {
  472. Dictionary<string, PresetButtonCtrl.ItemPreset> dictionary = new Dictionary<string, PresetButtonCtrl.ItemPreset>();
  473. PresetButtonCtrl.ItemPreset itemPreset = new PresetButtonCtrl.ItemPreset();
  474. itemPreset.m_name = PresetButtonCtrl.ClothesButton.Clothes_Dress.ToString();
  475. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  476. itemPreset.m_spriteName = "cm3d2_edit_clothesicon_dress";
  477. itemPreset.m_spItemIcon = this.m_spItemIcon;
  478. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.Clothes;
  479. dictionary.Add(itemPreset.m_name, itemPreset);
  480. itemPreset = new PresetButtonCtrl.ItemPreset();
  481. itemPreset.m_name = PresetButtonCtrl.ClothesButton.Clothes_Lingerie.ToString();
  482. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  483. itemPreset.m_spriteName = "cm3d2_edit_clothesicon_lingerie";
  484. itemPreset.m_spItemIcon = this.m_spItemIcon;
  485. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.Clothes;
  486. dictionary.Add(itemPreset.m_name, itemPreset);
  487. itemPreset = new PresetButtonCtrl.ItemPreset();
  488. itemPreset.m_name = PresetButtonCtrl.ClothesButton.Clothes_Nude.ToString();
  489. itemPreset.m_atlasName = "SceneEdit/Preset/Atlas/AtlasPreset";
  490. itemPreset.m_spriteName = "cm3d2_edit_clothesicon_nude";
  491. itemPreset.m_spItemIcon = this.m_spItemIcon;
  492. itemPreset.m_itemType = PresetButtonMgr.ItemTypes.Clothes;
  493. dictionary.Add(itemPreset.m_name, itemPreset);
  494. return dictionary;
  495. }
  496. private Dictionary<string, PresetButtonCtrl.ItemPreset> LoadItemData(string clickBtnName)
  497. {
  498. Dictionary<string, PresetButtonCtrl.ItemPreset> dictionary = new Dictionary<string, PresetButtonCtrl.ItemPreset>();
  499. Personal.Data personal = this.m_maid.status.personal;
  500. SceneEdit.PVBInfo[] array = null;
  501. if (clickBtnName == PresetButtonMgr.ItemTypes.Voice.ToString())
  502. {
  503. array = this.m_sceneEdit.m_dicVoice[personal].ToArray();
  504. }
  505. int num = 0;
  506. foreach (SceneEdit.PVBInfo pvbinfo in array)
  507. {
  508. PresetButtonCtrl.ItemPreset itemPreset = new PresetButtonCtrl.ItemPreset();
  509. itemPreset.m_name = clickBtnName + "_" + num;
  510. itemPreset.m_itemType = (PresetButtonMgr.ItemTypes)Enum.Parse(typeof(PresetButtonMgr.ItemTypes), clickBtnName);
  511. itemPreset.m_pvbInfo = pvbinfo;
  512. itemPreset.m_txtItemIcon = pvbinfo.texIcon;
  513. dictionary.Add(itemPreset.m_name, itemPreset);
  514. num++;
  515. }
  516. return dictionary;
  517. }
  518. public void PresetSaveType(PresetSaveWindow.SaveType type)
  519. {
  520. PresetMgr.Filter filter = PresetMgr.Filter.None;
  521. if (type == PresetSaveWindow.SaveType.All)
  522. {
  523. Debug.Log("「服/体」が押下されました");
  524. if (Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.LeftAlt))
  525. {
  526. GameMain.Instance.CharacterMgr.PresetSaveAsQRCode(this.m_maid, CharacterMgr.PresetType.All);
  527. GameMain.Instance.SysDlg.Show("QRコードとして保存しました\n(通常の保存を行いたい場合は「Alt」を押さずに保存してください)", SystemDialog.TYPE.OK, null, null);
  528. }
  529. else
  530. {
  531. GameMain.Instance.CharacterMgr.PresetSave(this.m_maid, CharacterMgr.PresetType.All);
  532. filter = PresetMgr.Filter.All;
  533. }
  534. }
  535. else if (type == PresetSaveWindow.SaveType.ClothesOnly)
  536. {
  537. Debug.Log("「服」が押下されました");
  538. if (Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.LeftAlt))
  539. {
  540. GameMain.Instance.CharacterMgr.PresetSaveAsQRCode(this.m_maid, CharacterMgr.PresetType.Wear);
  541. GameMain.Instance.SysDlg.Show("QRコードとして保存しました\n(通常の保存を行いたい場合は「Alt」を押さずに保存してください)", SystemDialog.TYPE.OK, null, null);
  542. }
  543. else
  544. {
  545. GameMain.Instance.CharacterMgr.PresetSave(this.m_maid, CharacterMgr.PresetType.Wear);
  546. filter = PresetMgr.Filter.Wear;
  547. }
  548. }
  549. else if (type == PresetSaveWindow.SaveType.BodyOnly)
  550. {
  551. if (Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.LeftAlt))
  552. {
  553. GameMain.Instance.CharacterMgr.PresetSaveAsQRCode(this.m_maid, CharacterMgr.PresetType.Body);
  554. GameMain.Instance.SysDlg.Show("QRコードとして保存しました\n(通常の保存を行いたい場合は「Alt」を押さずに保存してください)", SystemDialog.TYPE.OK, null, null);
  555. }
  556. else
  557. {
  558. Debug.Log("「体」が押下されました");
  559. GameMain.Instance.CharacterMgr.PresetSave(this.m_maid, CharacterMgr.PresetType.Body);
  560. filter = PresetMgr.Filter.Body;
  561. }
  562. }
  563. else
  564. {
  565. Debug.LogError(string.Format("不適切なボタンが押下されました。ボタン名={0}", type.ToString()));
  566. }
  567. if (this.isActivePresetPanel())
  568. {
  569. float scrollBarValue = BaseMgr<PresetMgr>.Instance.GetScrollBarValue();
  570. BaseMgr<PresetMgr>.Instance.UpdatePresetList();
  571. Debug.Log("Call UpdatePresetList");
  572. if (PresetMgr.m_currentActiveFilterBtnName != PresetMgr.Filter.None)
  573. {
  574. BaseMgr<PresetMgr>.Instance.UpdateFilterPreset(PresetMgr.m_currentActiveFilterBtnName);
  575. Debug.Log("Call UpdateFilterPreset");
  576. if (PresetMgr.m_currentActiveFilterBtnName != PresetMgr.Filter.NotFilter && PresetMgr.m_currentActiveFilterBtnName != filter)
  577. {
  578. BaseMgr<PresetMgr>.Instance.SetScrollBar(scrollBarValue);
  579. }
  580. }
  581. }
  582. }
  583. private void PresetSave()
  584. {
  585. string name = UIButton.current.name;
  586. if (name == PresetButtonCtrl.PriSaveButton.PriSave_WearAndBody.ToString())
  587. {
  588. this.PresetSaveType(PresetSaveWindow.SaveType.All);
  589. }
  590. else if (name == PresetButtonCtrl.PriSaveButton.PriSave_Wear.ToString())
  591. {
  592. this.PresetSaveType(PresetSaveWindow.SaveType.ClothesOnly);
  593. }
  594. else if (name == PresetButtonCtrl.PriSaveButton.PriSave_Body.ToString())
  595. {
  596. this.PresetSaveType(PresetSaveWindow.SaveType.BodyOnly);
  597. }
  598. else
  599. {
  600. Debug.LogError(string.Format("不適切なボタンが押下されました。ボタン名={0}", name));
  601. }
  602. }
  603. private bool isActivePresetPanel()
  604. {
  605. UIRoot componentInParent = base.GetComponentInParent<UIRoot>();
  606. GameObject gameObject = componentInParent.transform.Find("PresetPanel").gameObject;
  607. return gameObject.activeSelf;
  608. }
  609. private void ClickClothes()
  610. {
  611. string name = UIButton.current.name;
  612. this.ClickClothesByButtonName(name);
  613. }
  614. public void ClickClothesByButtonName(string clickBtnName)
  615. {
  616. if (clickBtnName == "Clothes_Nude")
  617. {
  618. this.m_sceneEdit.ClothesState(SceneEditInfo.ClothesState.Nude);
  619. }
  620. else if (clickBtnName == "Clothes_Dress")
  621. {
  622. this.m_sceneEdit.ClothesState(SceneEditInfo.ClothesState.Wear);
  623. }
  624. else if (clickBtnName == "Clothes_Lingerie")
  625. {
  626. this.m_sceneEdit.ClothesState(SceneEditInfo.ClothesState.Underwear);
  627. }
  628. Debug.Log(string.Format("{0}が押下(実行)されました。", clickBtnName));
  629. }
  630. private void ClickBG()
  631. {
  632. }
  633. private void ClickVoice()
  634. {
  635. string name = UIButton.current.name;
  636. PresetButtonCtrl.ItemPreset itemPreset;
  637. if (this.m_dicItem.TryGetValue(name, out itemPreset))
  638. {
  639. this.m_sceneEdit.Voice(itemPreset.m_pvbInfo);
  640. Debug.Log(string.Format("{0}が押下されました。", name));
  641. }
  642. else
  643. {
  644. Debug.LogError(string.Format("不適切なボタンが押下されました。ボタン名={0}", name));
  645. }
  646. }
  647. private void ClickPose()
  648. {
  649. }
  650. [SerializeField]
  651. private int itemIconOffsetX = 15;
  652. private Maid m_maid;
  653. private SceneEdit m_sceneEdit;
  654. private Dictionary<string, PresetButtonCtrl.PresetButton> m_listPresetBtn;
  655. private Dictionary<string, PresetButtonCtrl.PresetButton> m_listItemPresetBtn;
  656. private Dictionary<string, PresetButtonCtrl.ItemPreset> m_dicItem;
  657. private GameObject m_goPresetButtonPanel;
  658. private GameObject m_goItemBtn;
  659. private GameObject m_goItemPresetsViewer;
  660. private GameObject m_goItemScrollView;
  661. private GameObject m_goParentItemBtn;
  662. private UISprite m_spItemIcon;
  663. private UISprite m_spScrollViewBG;
  664. private UIPanel m_pItemScrollViewPanel;
  665. private UIScrollBar m_sbScrollBar;
  666. private bool m_scrollViewWidthOver;
  667. private GameObject m_goItemSpriteBtn;
  668. private GameObject m_goItemTxtrBtn;
  669. private Color activeColor;
  670. private Color inActiveColor;
  671. private int m_currentItemIconWidth;
  672. private Vector4 m_scrollViewSize;
  673. private int m_maxScrollViewWidth;
  674. private int m_scrollViewSoftnessX;
  675. private int m_ajustedNguiContentWidth;
  676. private int m_nguiContentWidth;
  677. private Dictionary<string, float> dicBtnPosX;
  678. private const string ITEM_SPRITE_PRESET_BUTTON_PATH = "SceneEdit/PresetButton/Prefabs/ItemSpritePresetButton";
  679. private const string ITEM_TXTR_PRESET_BUTTON_PATH = "SceneEdit/PresetButton/Prefabs/ItemTxtrPresetButton";
  680. private const string ATLAS_PRESET = "SceneEdit/Preset/Atlas/AtlasPreset";
  681. private const string PRISAVE_CLOTHES_BODY_SPRITE_NAME = "cm3d2_edit_priset_buttom_clothes_body";
  682. private const string PRISAVE_CLOTHES_SPRITE_NAME = "cm3d2_edit_priset_buttom_clothes";
  683. private const string PRISAVE_BODY_SPRITE_NAME = "cm3d2_edit_preset_buttom_body";
  684. private const string CLOTHES_NUDE_SPRITE_NAME = "cm3d2_edit_clothesicon_nude";
  685. private const string CLOTHES_DRESS_SPRITE_NAME = "cm3d2_edit_clothesicon_dress";
  686. private const string CLOTHES_LINGERIE_SPRITE_NAME = "cm3d2_edit_clothesicon_lingerie";
  687. private const int RIGHT_OFFSET = 650;
  688. private string last_draw_type_;
  689. private float backup_pose_scroll_pos_;
  690. private float backup_bg_scroll_pos_;
  691. private enum LeftButtons
  692. {
  693. View,
  694. Clothes,
  695. PriSave
  696. }
  697. private enum RightButtons
  698. {
  699. Voice
  700. }
  701. private enum PriSaveButton
  702. {
  703. PriSave_Wear,
  704. PriSave_Body,
  705. PriSave_WearAndBody
  706. }
  707. private enum ClothesButton
  708. {
  709. Clothes_Nude,
  710. Clothes_Dress,
  711. Clothes_Lingerie
  712. }
  713. public class ItemPreset
  714. {
  715. public string m_name { get; set; }
  716. public PresetButtonMgr.ItemTypes m_itemType { get; set; }
  717. public string m_atlasName { get; set; }
  718. public string m_spriteName { get; set; }
  719. public UISprite m_spItemIcon { get; set; }
  720. public SceneEdit.PVBInfo m_pvbInfo { get; set; }
  721. public Texture2D m_txtItemIcon { get; set; }
  722. }
  723. private class PresetButton
  724. {
  725. public string m_name { get; set; }
  726. public UIButton m_btnButton { get; set; }
  727. public GameObject m_goSelectCursor { get; set; }
  728. public GameObject m_goWindowArrow { get; set; }
  729. }
  730. }