TabsPane.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. internal class TabsPane : BasePane
  6. {
  7. private SelectionGrid Tabs;
  8. private Constants.Window selectedTab;
  9. public Constants.Window SelectedTab
  10. {
  11. get => selectedTab;
  12. set => Tabs.SelectedItemIndex = (int)value;
  13. }
  14. public event EventHandler TabChange;
  15. private new bool updating;
  16. private readonly string[] tabNames = { "call", "pose", "face", "bg", "bg2" };
  17. public TabsPane()
  18. {
  19. Translation.ReloadTranslationEvent += (s, a) => ReloadTranslation();
  20. Tabs = new SelectionGrid(Translation.GetArray("tabs", tabNames));
  21. Tabs.ControlEvent += (s, a) => OnChangeTab();
  22. }
  23. protected override void ReloadTranslation()
  24. {
  25. updating = true;
  26. Tabs.SetItems(Translation.GetArray("tabs", tabNames), Tabs.SelectedItemIndex);
  27. updating = false;
  28. }
  29. private void OnChangeTab()
  30. {
  31. if (updating) return;
  32. selectedTab = (Constants.Window)Tabs.SelectedItemIndex;
  33. TabChange?.Invoke(null, EventArgs.Empty);
  34. }
  35. public override void Draw()
  36. {
  37. Tabs.Draw(GUILayout.ExpandWidth(false));
  38. MiscGUI.BlackLine();
  39. }
  40. }
  41. }