1
0
فهرست منبع

Make entire window draggable

habeebweeb 4 سال پیش
والد
کامیت
d4d5aad731
1فایلهای تغییر یافته به همراه46 افزوده شده و 47 حذف شده
  1. 46 47
      MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

+ 46 - 47
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

@@ -51,8 +51,9 @@ namespace CM3D2.MultipleMaids.Plugin
             style.fontSize = GetPix(11);
             style.alignment = TextAnchor.UpperRight;
 
-            if (isGuiInit)
+            if (isGuiInit || screenSize != new Vector2(Screen.width, Screen.height))
             {
+                screenSize = new Vector2(Screen.width, Screen.height);
                 isGuiInit = false;
 
                 rectWin2.width = Screen.width * 0.4f;
@@ -60,7 +61,7 @@ namespace CM3D2.MultipleMaids.Plugin
 
                 rectWin2.x = (float)(Screen.width / 2.0 - rectWin2.width / 2.0);
                 rectWin2.y = sceneLevel != 5
-                    ? Screen.width - rectWin2.height
+                    ? Screen.height - rectWin2.height
                     : Screen.height * 0.94f - rectWin2.height;
 
                 rectWin.width = GetPix(kankyoFlg || kankyo2Flg ? 210 : 170);
@@ -75,8 +76,8 @@ namespace CM3D2.MultipleMaids.Plugin
                 rectWin2.width = Screen.width * 0.4f;
                 rectWin2.height = Screen.height * 0.15f;
 
-                rectWin2.x = Mathf.Clamp(rectWin2.x, 0, Screen.width - rectWin2.width);
-                rectWin2.y = Mathf.Clamp(rectWin2.y, 0, Screen.height - rectWin2.height);
+                rectWin2.x = Mathf.Clamp(rectWin2.x, -rectWin2.width + GetPix(20), Screen.width - GetPix(20));
+                rectWin2.y = Mathf.Clamp(rectWin2.y, -rectWin2.height + GetPix(20), Screen.height - GetPix(20));
 
                 rectWin2 = GUI.Window(130, rectWin2, MessageWindow, "", style);
             }
@@ -84,7 +85,7 @@ namespace CM3D2.MultipleMaids.Plugin
             if (bGui)
             {
                 rectWin.x = Mathf.Clamp(rectWin.x, 0, Screen.width - rectWin.width);
-                rectWin.y = Mathf.Clamp(rectWin.y, 0, Screen.height - DRAG_BAR_HEIGHT);
+                rectWin.y = Mathf.Clamp(rectWin.y, -rectWin.height + GetPix(20), Screen.height - GetPix(20));
 
                 rectWin.height = Screen.height * 0.9f;
                 rectWin.width = GetPix(kankyoFlg || kankyo2Flg ? 210 : 170);
@@ -293,8 +294,6 @@ namespace CM3D2.MultipleMaids.Plugin
 
         private void SaveSceneWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             GUIStyle style1 = "label";
             style1.fontSize = GetPix(12);
             style1.alignment = TextAnchor.UpperLeft;
@@ -503,12 +502,11 @@ namespace CM3D2.MultipleMaids.Plugin
                     GameMain.Instance.SoundMgr.PlaySe("se002.ogg", false);
                 }
             }
+            GUI.DragWindow();
         }
 
         private void BGSelectWindow2(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             GUIStyle guiStyle1 = "label";
             guiStyle1.fontSize = GetPix(12);
             guiStyle1.alignment = TextAnchor.UpperLeft;
@@ -1091,6 +1089,9 @@ namespace CM3D2.MultipleMaids.Plugin
             }
 
             GUI.enabled = true;
+
+            GUI.DragWindow();
+
             if (num1 == slotIndex)
             {
                 return;
@@ -1206,8 +1207,6 @@ namespace CM3D2.MultipleMaids.Plugin
 
         private void BGSelectWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             GUIStyle guistyle = "label";
             guistyle.fontSize = GetPix(12);
             guistyle.alignment = TextAnchor.UpperLeft;
@@ -3340,6 +3339,8 @@ namespace CM3D2.MultipleMaids.Plugin
                 bgmCombo.selectedItemIndex = bgmIndex;
             }
 
+            GUI.DragWindow();
+
             if (bgmCombo.isClickedComboButton)
             {
                 GUI.enabled = false;
@@ -3349,8 +3350,6 @@ namespace CM3D2.MultipleMaids.Plugin
 
         private void PoseWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             GUIStyle style1 = "label";
             style1.fontSize = GetPix(12);
             style1.alignment = TextAnchor.UpperLeft;
@@ -5878,13 +5877,8 @@ namespace CM3D2.MultipleMaids.Plugin
                 {
                     isCombo3 = true;
                 }
-                else
+                else if (isCombo3)
                 {
-                    if (!isCombo3)
-                    {
-                        return;
-                    }
-
                     isCombo3 = false;
                     strArray1 = new string[2];
                     string[] strArray2 = itemArray[itemIndex2[selectMaidIndex]].Split(',');
@@ -6045,12 +6039,15 @@ namespace CM3D2.MultipleMaids.Plugin
                                    "ずらし",
                                    style4);
             }
+
+            bool state = GUI.enabled;
+            GUI.enabled = true;
+            GUI.DragWindow();
+            GUI.enabled = state;
         }
 
         private void FaceWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             GUIStyle style1 = "label";
             style1.fontSize = GetPix(12);
             style1.alignment = TextAnchor.UpperLeft;
@@ -7665,13 +7662,16 @@ namespace CM3D2.MultipleMaids.Plugin
             }
 
             GUI.enabled = !faceCombo.isClickedComboButton;
+
+            bool state = GUI.enabled;
+            GUI.enabled = true;
+            GUI.DragWindow();
+            GUI.enabled = state;
+
             yotogiFlg = false;
             if (sceneLevel != 14
-                || !
-
-                            GameObject
-                                    .Find("/UI Root/YotogiPlayPanel/CommandViewer/SkillViewer/MaskGroup/SkillGroup/CommandParent/CommandUnit")
-                        )
+                || !GameObject
+                    .Find("/UI Root/YotogiPlayPanel/CommandViewer/SkillViewer/MaskGroup/SkillGroup/CommandParent/CommandUnit"))
             {
                 return;
             }
@@ -7681,8 +7681,6 @@ namespace CM3D2.MultipleMaids.Plugin
 
         private void MaidCallWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin.width, DRAG_BAR_HEIGHT), "");
             CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
             GUIStyle style1 = "label";
             style1.fontSize = GetPix(14);
@@ -8052,9 +8050,13 @@ namespace CM3D2.MultipleMaids.Plugin
                                  comboBoxList[comboBoxControl.GetSelectedItemIndex()].text,
                                  comboBoxList,
                                  listStyle);
-            if (!GUI.Button(new Rect(rectWin.width * 0.66f, GetPix(25), rectWin.width * 0.24f, GetPix(24)),
+            bool OKButton = GUI.Button(new Rect(rectWin.width * 0.66f, GetPix(25), rectWin.width * 0.24f, GetPix(24)),
                             "決定",
-                            style4))
+                            style4);
+
+            GUI.DragWindow();
+
+            if (!OKButton)
             {
                 return;
             }
@@ -9109,8 +9111,6 @@ namespace CM3D2.MultipleMaids.Plugin
 
         private void MessageWindow(int winID)
         {
-            GUI.DragWindow(new Rect(0, 0, rectWin2.width, DRAG_BAR_HEIGHT));
-            GUI.Box(new Rect(0, 0, rectWin2.width, DRAG_BAR_HEIGHT), "");
             GUIStyle style1 = "label";
             style1.fontSize = GetPix(12);
             style1.alignment = TextAnchor.UpperLeft;
@@ -9154,25 +9154,24 @@ namespace CM3D2.MultipleMaids.Plugin
                                             GetPix(52)),
                                   inText,
                                   300);
-            if (!GUI.Button(new Rect(GetPix(8), GetPix(82), GetPix(60), GetPix(20)),
+            if (GUI.Button(new Rect(GetPix(8), GetPix(82), GetPix(60), GetPix(20)),
                             "決定",
                             style2))
             {
-                return;
+                isMessage = true;
+                bGuiMessage = false;
+                GameObject gameObject1 = GameObject.Find("__GameMain__/SystemUI Root").transform.Find("MessageWindowPanel").gameObject;
+                MessageWindowMgr messageWindowMgr = GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr;
+                messageWindowMgr.OpenMessageWindowPanel();
+                MessageClass inst = new MessageClass(gameObject1, messageWindowMgr);
+                UILabel component = UTY.GetChildObject(gameObject1, "MessageViewer/MsgParent/Message", false).GetComponent<UILabel>();
+                component.ProcessText();
+                SetFieldValue2<UILabel, int>(component, "mFontSize", fontSize);
+                SetFieldValue5<MessageClass, UILabel>(inst, "message_label_", component);
+                inst.SetText(inName, inText, "", 0, AudioSourceMgr.Type.System);
+                inst.FinishChAnime();
             }
-
-            isMessage = true;
-            bGuiMessage = false;
-            GameObject gameObject1 = GameObject.Find("__GameMain__/SystemUI Root").transform.Find("MessageWindowPanel").gameObject;
-            MessageWindowMgr messageWindowMgr = GameMain.Instance.ScriptMgr.adv_kag.MessageWindowMgr;
-            messageWindowMgr.OpenMessageWindowPanel();
-            MessageClass inst = new MessageClass(gameObject1, messageWindowMgr);
-            UILabel component = UTY.GetChildObject(gameObject1, "MessageViewer/MsgParent/Message", false).GetComponent<UILabel>();
-            component.ProcessText();
-            SetFieldValue2<UILabel, int>(component, "mFontSize", fontSize);
-            SetFieldValue5<MessageClass, UILabel>(inst, "message_label_", component);
-            inst.SetText(inName, inText, "", 0, AudioSourceMgr.Type.System);
-            inst.FinishChAnime();
+            GUI.DragWindow();
         }
     }
 }