Browse Source

Prevent dragging GUI outside of screen

habeebweeb 4 năm trước cách đây
mục cha
commit
6ac16801dd

+ 12 - 8
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

@@ -50,6 +50,7 @@ namespace CM3D2.MultipleMaids.Plugin
             GUIStyle style = GUI.skin.box;
             style.fontSize = GetPix(11);
             style.alignment = TextAnchor.UpperRight;
+
             if (bGui)
             {
                 if (isGuiInit || screenSize != new Vector2(Screen.width, Screen.height))
@@ -58,11 +59,14 @@ namespace CM3D2.MultipleMaids.Plugin
                     screenSize = new Vector2(Screen.width, Screen.height);
 
                     //rectWin.x = screenSize.x - rectWin.width;
-                    //rectWin.y = GetPix(65);
+                    rectWin.y = GetPix(65);
                     //if (sceneLevel == 14)
                     //    rectWin.x = screenSize.x - rectWin.width - GetPix(23);
                 }
 
+                rectWin.x = Mathf.Clamp(rectWin.x, 0, Screen.width - rectWin.width);
+                rectWin.y = Mathf.Clamp(rectWin.y, 0, Screen.height - DRAG_BAR_HEIGHT);
+
                 rectWin.height = Screen.height * 0.9f;
                 rectWin.width = GetPix(kankyoFlg || kankyo2Flg ? 210 : 170);
                 if (sceneLevel == 5 || sceneLevel == 14)
@@ -287,7 +291,7 @@ namespace CM3D2.MultipleMaids.Plugin
                 kankyoFlg = true;
                 kankyo2Flg = false;
                 bGui = true;
-                isGuiInit = true;
+                // isGuiInit = true;
                 copyIndex = 0;
             }
 
@@ -580,7 +584,7 @@ namespace CM3D2.MultipleMaids.Plugin
                         kankyoFlg = false;
                         kankyo2Flg = false;
                         bGui = true;
-                        isGuiInit = true;
+                        // isGuiInit = true;
                     }
                 }
 
@@ -1325,7 +1329,7 @@ namespace CM3D2.MultipleMaids.Plugin
                         kankyoFlg = false;
                         kankyo2Flg = false;
                         bGui = true;
-                        isGuiInit = true;
+                        // isGuiInit = true;
                     }
                 }
 
@@ -3786,7 +3790,7 @@ namespace CM3D2.MultipleMaids.Plugin
                         kankyoFlg = false;
                         kankyo2Flg = false;
                         bGui = true;
-                        isGuiInit = true;
+                        // isGuiInit = true;
                     }
                 }
 
@@ -6110,7 +6114,7 @@ namespace CM3D2.MultipleMaids.Plugin
                         kankyoFlg = false;
                         kankyo2Flg = false;
                         bGui = true;
-                        isGuiInit = true;
+                        // isGuiInit = true;
                     }
                 }
 
@@ -7710,7 +7714,7 @@ namespace CM3D2.MultipleMaids.Plugin
                 kankyoFlg = false;
                 kankyo2Flg = false;
                 bGui = true;
-                isGuiInit = true;
+                // isGuiInit = true;
             }
 
             if (!yotogiFlg && GUI.Toggle(new Rect(GetPix(41),
@@ -9154,4 +9158,4 @@ namespace CM3D2.MultipleMaids.Plugin
             inst.FinishChAnime();
         }
     }
-}
+}