소스 검색

Add selecting dogu and light

Selecting dogu will make it convenient to select dogu for attaching.

WindowManager will also change to the appropriate tab when selecting
dogu or light.
habeebweeb 4 년 전
부모
커밋
8521b5555e

+ 5 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/BackgroundWindow2Panes/AttachPropPane.cs

@@ -50,8 +50,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             this.propManager = propManager;
             this.meidoManager = meidoManager;
 
-            this.propManager.DoguListChange += (s, a) => SetDoguDropdown();
             this.meidoManager.EndCallMeidos += (s, a) => SetMeidoDropdown();
+            this.propManager.DoguListChange += (s, a) => SetDoguDropdown();
+            this.propManager.DoguSelectChange += (s, a) =>
+            {
+                this.doguDropdown.SelectedItemIndex = this.propManager.CurrentDoguIndex;
+            };
 
             this.meidoDropdown = new Dropdown(new[] { Translation.Get("systemMessage", "noMaids") });
             this.meidoDropdown.SelectionChange += (s, a) => SwitchMaid();

+ 3 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/MainWindowPanes/BG2WindowPane.cs

@@ -3,6 +3,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     internal class BG2WindowPane : BaseWindowPane
     {
         private MeidoManager meidoManager;
+        private PropManager propManager;
         private PropsPane propsPane;
         private AttachPropPane attachPropPane;
         private MyRoomPropsPane myRoomPropsPane;
@@ -14,6 +15,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public BG2WindowPane(MeidoManager meidoManager, PropManager propManager)
         {
             this.meidoManager = meidoManager;
+            this.propManager = propManager;
+            this.propManager.DoguSelectChange += (s, a) => this.propTabs.SelectedItemIndex = 0;
 
             this.propsPane = AddPane(new PropsPane(propManager));
             this.myRoomPropsPane = AddPane(new MyRoomPropsPane(propManager));

+ 17 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindow.cs

@@ -6,6 +6,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     internal class MainWindow : BaseWindow
     {
         private MeidoManager meidoManager;
+        private PropManager propManager;
+        private LightManager lightManager;
         private Dictionary<Constants.Window, BaseWindowPane> windowPanes;
         private TabsPane tabsPane;
         private Button ReloadTranslationButton;
@@ -29,11 +31,18 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             set => AddWindow(id, value);
         }
 
-        public MainWindow(MeidoManager meidoManager) : base()
+        // TODO: Find a better way of doing this
+        public MainWindow(MeidoManager meidoManager, PropManager propManager, LightManager lightManager) : base()
         {
             this.meidoManager = meidoManager;
             this.meidoManager.UpdateMeido += UpdateMeido;
 
+            this.propManager = propManager;
+            this.propManager.DoguSelectChange += (s, a) => ChangeWindow(Constants.Window.BG2);
+
+            this.lightManager = lightManager;
+            this.lightManager.Select += (s, a) => ChangeWindow(Constants.Window.BG);
+
             windowPanes = new Dictionary<Constants.Window, BaseWindowPane>();
             windowRect = new Rect(Screen.width, Screen.height * 0.08f, 230f, Screen.height * 0.9f);
 
@@ -115,10 +124,15 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             if (args.FromMeido)
             {
                 Constants.Window newWindow = args.IsBody ? Constants.Window.Pose : Constants.Window.Face;
-                if (this.selectedWindow == newWindow) currentWindowPane.UpdatePanes();
-                else tabsPane.SelectedTab = newWindow;
+                ChangeWindow(newWindow);
             }
             else currentWindowPane.UpdatePanes();
         }
+
+        private void ChangeWindow(Constants.Window window)
+        {
+            if (this.selectedWindow == window) currentWindowPane.UpdatePanes();
+            else tabsPane.SelectedTab = window;
+        }
     }
 }

+ 17 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -42,6 +42,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private List<DragPointDogu> doguList = new List<DragPointDogu>();
         public int DoguCount => doguList.Count;
         public event EventHandler DoguListChange;
+        public event EventHandler DoguSelectChange;
         public string[] PropNameList
         {
             get
@@ -51,6 +52,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     : doguList.Select(dogu => dogu.Name).ToArray();
             }
         }
+        public int CurrentDoguIndex { get; private set; }
 
         public PropManager(MeidoManager meidoManager)
         {
@@ -200,6 +202,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 if (dogu != null)
                 {
                     dogu.Delete -= DeleteDogu;
+                    dogu.Select -= DeleteDogu;
                     GameObject.Destroy(dogu.gameObject);
                 }
             }
@@ -395,6 +398,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             dragDogu.AddGizmo(scale: 0.45f, mode: CustomGizmo.GizmoMode.World);
             dragDogu.ConstantScale = true;
             dragDogu.Delete += DeleteDogu;
+            dragDogu.Select += SelectDogu;
             dragDogu.DragPointScale = CubeSmall ? DragPointGeneral.smallCube : 1f;
             dragDogu.assetName = assetName;
 
@@ -486,6 +490,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 {
                     if (dragDogu == dogu)
                     {
+                        dogu.Delete -= DeleteDogu;
+                        dogu.Select -= SelectDogu;
                         GameObject.Destroy(dragDogu.gameObject);
                         return true;
                     }
@@ -495,6 +501,17 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             OnDoguListChange();
         }
 
+        private void SelectDogu(object sender, EventArgs args)
+        {
+            DragPointDogu dogu = (DragPointDogu)sender;
+            int doguIndex = doguList.IndexOf(dogu);
+            if (doguIndex != -1)
+            {
+                CurrentDoguIndex = doguIndex;
+                DoguSelectChange?.Invoke(this, EventArgs.Empty);
+            }
+        }
+
         private void OnCubeSmall(object sender, EventArgs args)
         {
             foreach (DragPointDogu dogu in doguList)

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs

@@ -332,7 +332,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             windowManager = new WindowManager()
             {
-                [Constants.Window.Main] = new MainWindow(meidoManager)
+                [Constants.Window.Main] = new MainWindow(meidoManager, propManager, lightManager)
                 {
                     [Constants.Window.Call] = new CallWindowPane(meidoManager),
                     [Constants.Window.Pose] = new PoseWindowPane(meidoManager, maidSwitcherPane),