TabsPane.cs 1.3 KB

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