123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using UnityEngine;
- namespace COM3D2.MeidoPhotoStudio.Plugin
- {
- internal class MaidSwitcherPane : BasePane
- {
- private readonly MeidoManager meidoManager;
- private readonly Button previousButton;
- private readonly Button nextButton;
- public MaidSwitcherPane(MeidoManager meidoManager)
- {
- this.meidoManager = meidoManager;
- previousButton = new Button("<");
- previousButton.ControlEvent += (s, a) => ChangeMaid(-1);
- nextButton = new Button(">");
- nextButton.ControlEvent += (s, a) => ChangeMaid(1);
- }
- public override void Draw()
- {
- const float boxSize = 70;
- const int margin = (int)(boxSize / 2.8f);
- GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
- buttonStyle.margin.top = margin;
- GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
- labelStyle.margin.top = margin;
- GUIStyle boxStyle = new GUIStyle(GUI.skin.box) { margin = new RectOffset(0, 0, 0, 0) };
- GUIStyle horizontalStyle = new GUIStyle { padding = new RectOffset(4, 4, 0, 0) };
- GUILayoutOption[] buttonOptions = new[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false) };
- GUILayoutOption[] boxLayoutOptions = new[] { GUILayout.Height(boxSize), GUILayout.Width(boxSize) };
- GUI.enabled = meidoManager.HasActiveMeido;
- Meido meido = meidoManager.ActiveMeido;
- GUILayout.BeginHorizontal(horizontalStyle, GUILayout.Height(boxSize));
- previousButton.Draw(buttonStyle, buttonOptions);
- GUILayout.Space(20);
- if (meidoManager.HasActiveMeido && meido.Portrait) MpsGui.DrawTexture(meido.Portrait, boxLayoutOptions);
- else GUILayout.Box(GUIContent.none, boxStyle, boxLayoutOptions);
- string label = meidoManager.HasActiveMeido ? $"{meido.LastName}\n{meido.FirstName}" : string.Empty;
- GUILayout.Label(label, labelStyle, GUILayout.ExpandWidth(false));
- GUILayout.FlexibleSpace();
- nextButton.Draw(buttonStyle, buttonOptions);
- GUILayout.EndHorizontal();
- Rect previousRect = GUILayoutUtility.GetLastRect();
- Rect labelRect = new Rect(previousRect.width - 45f, previousRect.y, 40f, 20f);
- GUIStyle slotStyle = new GUIStyle()
- {
- alignment = TextAnchor.UpperRight,
- fontSize = 13
- };
- slotStyle.padding.right = 5;
- slotStyle.normal.textColor = Color.white;
- if (meidoManager.HasActiveMeido) GUI.Label(labelRect, $"{meidoManager.ActiveMeido.Slot + 1}", slotStyle);
- }
- private void ChangeMaid(int dir)
- {
- int selected = Utility.Wrap(
- meidoManager.SelectedMeido + (int)Mathf.Sign(dir), 0, meidoManager.ActiveMeidoList.Count
- );
- meidoManager.ChangeMaid(selected);
- }
- }
- }
|