PresetButtonCtrl.cs 27 KB

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