|
@@ -1,3 +1,4 @@
|
|
|
|
+using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace MeidoPhotoStudio.Plugin
|
|
namespace MeidoPhotoStudio.Plugin
|
|
@@ -6,8 +7,11 @@ namespace MeidoPhotoStudio.Plugin
|
|
{
|
|
{
|
|
private readonly MeidoManager meidoManager;
|
|
private readonly MeidoManager meidoManager;
|
|
private Vector2 maidListScrollPos;
|
|
private Vector2 maidListScrollPos;
|
|
|
|
+ private Vector2 activeMaidListScrollPos;
|
|
private readonly Button clearMaidsButton;
|
|
private readonly Button clearMaidsButton;
|
|
private readonly Button callMaidsButton;
|
|
private readonly Button callMaidsButton;
|
|
|
|
+ private readonly Toggle activeMeidoListToggle;
|
|
|
|
+
|
|
public MaidSelectorPane(MeidoManager meidoManager)
|
|
public MaidSelectorPane(MeidoManager meidoManager)
|
|
{
|
|
{
|
|
this.meidoManager = meidoManager;
|
|
this.meidoManager = meidoManager;
|
|
@@ -16,12 +20,28 @@ namespace MeidoPhotoStudio.Plugin
|
|
|
|
|
|
callMaidsButton = new Button(Translation.Get("maidCallWindow", "callButton"));
|
|
callMaidsButton = new Button(Translation.Get("maidCallWindow", "callButton"));
|
|
callMaidsButton.ControlEvent += (s, a) => this.meidoManager.CallMeidos();
|
|
callMaidsButton.ControlEvent += (s, a) => this.meidoManager.CallMeidos();
|
|
|
|
+
|
|
|
|
+ activeMeidoListToggle = new(Translation.Get("maidCallWindow", "activeOnlyToggle"));
|
|
|
|
+
|
|
|
|
+ this.meidoManager.BeginCallMeidos += (_, _) =>
|
|
|
|
+ {
|
|
|
|
+ if (meidoManager.SelectedMeidoSet.Count == 0)
|
|
|
|
+ activeMeidoListToggle.Value = false;
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
protected override void ReloadTranslation()
|
|
protected override void ReloadTranslation()
|
|
{
|
|
{
|
|
clearMaidsButton.Label = Translation.Get("maidCallWindow", "clearButton");
|
|
clearMaidsButton.Label = Translation.Get("maidCallWindow", "clearButton");
|
|
callMaidsButton.Label = Translation.Get("maidCallWindow", "callButton");
|
|
callMaidsButton.Label = Translation.Get("maidCallWindow", "callButton");
|
|
|
|
+ activeMeidoListToggle.Label = Translation.Get("maidCallWindow", "activeOnlyToggle");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override void Activate()
|
|
|
|
+ {
|
|
|
|
+ base.Activate();
|
|
|
|
+ // Leaving this mode enabled pretty much softlocks meido selection so disable it on activation
|
|
|
|
+ activeMeidoListToggle.Value = false;
|
|
}
|
|
}
|
|
|
|
|
|
public override void Draw()
|
|
public override void Draw()
|
|
@@ -31,48 +51,75 @@ namespace MeidoPhotoStudio.Plugin
|
|
callMaidsButton.Draw();
|
|
callMaidsButton.Draw();
|
|
GUILayout.EndHorizontal();
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
|
- GUIStyle labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14 };
|
|
|
|
- GUIStyle selectLabelStyle = new GUIStyle(labelStyle);
|
|
|
|
- selectLabelStyle.normal.textColor = Color.black;
|
|
|
|
- selectLabelStyle.alignment = TextAnchor.UpperRight;
|
|
|
|
- GUIStyle labelSelectedStyle = new GUIStyle(labelStyle);
|
|
|
|
- labelSelectedStyle.normal.textColor = Color.black;
|
|
|
|
|
|
+ MpsGui.WhiteLine();
|
|
|
|
+
|
|
|
|
+ GUI.enabled = meidoManager.HasActiveMeido;
|
|
|
|
+
|
|
|
|
+ activeMeidoListToggle.Draw();
|
|
|
|
+
|
|
|
|
+ GUI.enabled = true;
|
|
|
|
+
|
|
|
|
+ var onlyActiveMeido = activeMeidoListToggle.Value;
|
|
|
|
+
|
|
|
|
+ IList<Meido> meidoList = onlyActiveMeido
|
|
|
|
+ ? meidoManager.ActiveMeidoList
|
|
|
|
+ : meidoManager.Meidos;
|
|
|
|
|
|
- Rect windowRect = parent.WindowRect;
|
|
|
|
- float windowHeight = windowRect.height;
|
|
|
|
- float buttonWidth = windowRect.width - 30f;
|
|
|
|
|
|
+ var labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14 };
|
|
|
|
+
|
|
|
|
+ var selectLabelStyle = new GUIStyle(labelStyle)
|
|
|
|
+ {
|
|
|
|
+ normal = { textColor = Color.black },
|
|
|
|
+ alignment = TextAnchor.UpperRight,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var labelSelectedStyle = new GUIStyle(labelStyle)
|
|
|
|
+ {
|
|
|
|
+ normal = { textColor = Color.black },
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var windowRect = parent.WindowRect;
|
|
|
|
+ var windowHeight = windowRect.height;
|
|
|
|
+ var buttonWidth = windowRect.width - 30f;
|
|
const float buttonHeight = 85f;
|
|
const float buttonHeight = 85f;
|
|
|
|
+ const float offsetTop = 130f;
|
|
|
|
|
|
- Rect positionRect = new Rect(5f, 90f, windowRect.width - 10f, windowHeight - 125f);
|
|
|
|
- Rect viewRect = new Rect(0f, 0f, buttonWidth, (buttonHeight * meidoManager.Meidos.Length) + 5f);
|
|
|
|
- maidListScrollPos = GUI.BeginScrollView(positionRect, maidListScrollPos, viewRect);
|
|
|
|
|
|
+ var positionRect = new Rect(5f, offsetTop, windowRect.width - 10f, windowHeight - (offsetTop + 35));
|
|
|
|
+ var viewRect = new Rect(0f, 0f, buttonWidth, buttonHeight * meidoList.Count + 5f);
|
|
|
|
|
|
- for (int i = 0; i < meidoManager.Meidos.Length; i++)
|
|
|
|
|
|
+ if (onlyActiveMeido)
|
|
|
|
+ activeMaidListScrollPos = GUI.BeginScrollView(positionRect, activeMaidListScrollPos, viewRect);
|
|
|
|
+ else
|
|
|
|
+ maidListScrollPos = GUI.BeginScrollView(positionRect, maidListScrollPos, viewRect);
|
|
|
|
+
|
|
|
|
+ for (var i = 0; i < meidoList.Count; i++)
|
|
{
|
|
{
|
|
- Meido meido = meidoManager.Meidos[i];
|
|
|
|
- float y = i * buttonHeight;
|
|
|
|
- bool selectedMaid = meidoManager.SelectedMeidoSet.Contains(i);
|
|
|
|
|
|
+ var meido = meidoList[i];
|
|
|
|
+ var y = i * buttonHeight;
|
|
|
|
+ var selectedMaid = meidoManager.SelectedMeidoSet.Contains(meido.StockNo);
|
|
|
|
|
|
- if (GUI.Button(new Rect(0f, y, buttonWidth, buttonHeight), string.Empty)) meidoManager.SelectMeido(i);
|
|
|
|
|
|
+ if (GUI.Button(new(0f, y, buttonWidth, buttonHeight), string.Empty))
|
|
|
|
+ meidoManager.SelectMeido(meido.StockNo);
|
|
|
|
|
|
if (selectedMaid)
|
|
if (selectedMaid)
|
|
{
|
|
{
|
|
- int selectedIndex = meidoManager.SelectMeidoList.IndexOf(i) + 1;
|
|
|
|
- GUI.DrawTexture(
|
|
|
|
- new Rect(5f, y + 5f, buttonWidth - 10f, buttonHeight - 10f), Texture2D.whiteTexture
|
|
|
|
- );
|
|
|
|
|
|
+ var selectedIndex = meidoManager.SelectMeidoList.IndexOf(meido.StockNo) + 1;
|
|
|
|
+ GUI.DrawTexture(new(5f, y + 5f, buttonWidth - 10f, buttonHeight - 10f), Texture2D.whiteTexture);
|
|
|
|
+
|
|
GUI.Label(
|
|
GUI.Label(
|
|
- new Rect(0f, y + 5f, buttonWidth - 10f, buttonHeight),
|
|
|
|
- selectedIndex.ToString(), selectLabelStyle
|
|
|
|
|
|
+ new(0f, y + 5f, buttonWidth - 10f, buttonHeight), selectedIndex.ToString(), selectLabelStyle
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- if (meido.Portrait) GUI.DrawTexture(new Rect(5f, y, buttonHeight, buttonHeight), meido.Portrait);
|
|
|
|
|
|
+ if (meido.Portrait != null)
|
|
|
|
+ GUI.DrawTexture(new(5f, y, buttonHeight, buttonHeight), meido.Portrait);
|
|
|
|
+
|
|
GUI.Label(
|
|
GUI.Label(
|
|
- new Rect(95f, y + 30f, buttonWidth - 80f, buttonHeight),
|
|
|
|
|
|
+ new(95f, y + 30f, buttonWidth - 80f, buttonHeight),
|
|
$"{meido.LastName}\n{meido.FirstName}", selectedMaid ? labelSelectedStyle : labelStyle
|
|
$"{meido.LastName}\n{meido.FirstName}", selectedMaid ? labelSelectedStyle : labelStyle
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
GUI.EndScrollView();
|
|
GUI.EndScrollView();
|
|
}
|
|
}
|
|
}
|
|
}
|