12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using UnityEngine;
- namespace MeidoPhotoStudio.Plugin;
- public class TabsPane : BasePane
- {
- private static readonly string[] tabNames = { "call", "pose", "face", "bg", "bg2" };
- private readonly SelectionGrid Tabs;
- public event EventHandler TabChange;
- private Constants.Window selectedTab;
- public Constants.Window SelectedTab
- {
- get => selectedTab;
- set => Tabs.SelectedItemIndex = (int)value;
- }
- public TabsPane()
- {
- Translation.ReloadTranslationEvent += (_, _) =>
- ReloadTranslation();
- Tabs = new(Translation.GetArray("tabs", tabNames));
- Tabs.ControlEvent += (_, _) =>
- OnChangeTab();
- }
- public override void Draw()
- {
- Tabs.Draw(GUILayout.ExpandWidth(false));
- MpsGui.BlackLine();
- }
- protected override void ReloadTranslation()
- {
- updating = true;
- Tabs.SetItems(Translation.GetArray("tabs", tabNames), Tabs.SelectedItemIndex);
- updating = false;
- }
- private void OnChangeTab()
- {
- if (updating)
- return;
- selectedTab = (Constants.Window)Tabs.SelectedItemIndex;
- TabChange?.Invoke(null, EventArgs.Empty);
- }
- }
|