|
@@ -1,3 +1,4 @@
|
|
|
+using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
|
|
|
namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
@@ -7,29 +8,43 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
|
|
|
private static int id = 765;
|
|
|
private static int ID => id++;
|
|
|
public readonly int windowID;
|
|
|
- protected Rect windowRect;
|
|
|
- public abstract Rect WindowRect { get; set; }
|
|
|
-
|
|
|
- public BaseWindow() : base()
|
|
|
+ protected Rect windowRect = new Rect(0f, 0f, 480f, 270f);
|
|
|
+ public virtual Rect WindowRect
|
|
|
{
|
|
|
- windowID = ID;
|
|
|
+ get => windowRect;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ value.x = Mathf.Clamp(
|
|
|
+ value.x, -value.width + Utility.GetPix(20), Screen.width - Utility.GetPix(20)
|
|
|
+ );
|
|
|
+ value.y = Mathf.Clamp(
|
|
|
+ value.y, -value.height + Utility.GetPix(20), Screen.height - Utility.GetPix(20)
|
|
|
+ );
|
|
|
+ windowRect = value;
|
|
|
+ }
|
|
|
}
|
|
|
+ protected Vector2 MiddlePosition => new Vector2(
|
|
|
+ Screen.width / 2 - windowRect.width / 2,
|
|
|
+ Screen.height / 2 - windowRect.height / 2
|
|
|
+ );
|
|
|
+
|
|
|
+ public BaseWindow ModalWindow { get; private set; }
|
|
|
|
|
|
- protected virtual void HandleZoom()
|
|
|
+ public BaseWindow() : base() => windowID = ID;
|
|
|
+
|
|
|
+ public virtual void HandleZoom()
|
|
|
{
|
|
|
if (Input.mouseScrollDelta.y != 0f)
|
|
|
{
|
|
|
- if (Visible && WindowRect.Contains(Event.current.mousePosition))
|
|
|
+ if (Visible)
|
|
|
{
|
|
|
- Input.ResetInputAxes();
|
|
|
+ Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
|
|
|
+ if (WindowRect.Contains(mousePos)) Input.ResetInputAxes();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public virtual void Update()
|
|
|
- {
|
|
|
- HandleZoom();
|
|
|
- }
|
|
|
+ public virtual void Update() => HandleZoom();
|
|
|
|
|
|
public virtual void Activate() { }
|
|
|
|