Skip to content

Commit 71af564

Browse files
committed
Fixed SafeZone scaling
this fixed Panels mouse precision
1 parent dced341 commit 71af564

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

NativeUI/Panels/UIMenuColorPanel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,16 @@ private void UpdateSelection(bool update)
134134

135135
private void Functions()
136136
{
137-
if (ScreenTools.IsMouseInBounds(LeftArrow.Position, LeftArrow.Size))
137+
Point safezoneOffset = ScreenTools.SafezoneBounds;
138+
if (ScreenTools.IsMouseInBounds(new PointF(LeftArrow.Position.X + safezoneOffset.X, LeftArrow.Position.Y + safezoneOffset.Y), LeftArrow.Size))
138139
if (API.IsDisabledControlJustPressed(0, 24) || API.IsControlJustPressed(0, 24))
139140
GoLeft();
140-
if (ScreenTools.IsMouseInBounds(RightArrow.Position, RightArrow.Size))
141+
if (ScreenTools.IsMouseInBounds(new PointF(RightArrow.Position.X + safezoneOffset.X, RightArrow.Position.Y + safezoneOffset.Y), RightArrow.Size))
141142
if (API.IsDisabledControlJustPressed(0, 24) || API.IsControlJustPressed(0, 24))
142143
GoRight();
143144
for (int Index = 0; Index < Bar.Count; Index++)
144145
{
145-
if (ScreenTools.IsMouseInBounds(Bar[Index].Position, Bar[Index].Size))
146+
if (ScreenTools.IsMouseInBounds(new PointF(Bar[Index].Position.X + safezoneOffset.X, Bar[Index].Position.Y + safezoneOffset.Y), Bar[Index].Size))
146147
if (API.IsDisabledControlJustPressed(0, 24) || API.IsControlJustPressed(0, 24))
147148
{
148149
CurrentSelection = Data.Pagination.Min + Index;

NativeUI/Panels/UIMenuGridPanel.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ internal void UpdateParent( float X, float Y)
7272

7373
internal async void Functions()
7474
{
75-
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f , Grid.Size.Height - 40f)))
75+
Point safezoneOffset = ScreenTools.SafezoneBounds;
76+
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
7677
{
7778
if (API.IsDisabledControlPressed(0, 24))
7879
{
@@ -81,18 +82,18 @@ internal async void Functions()
8182
Pressed = true;
8283
Audio.Id = API.GetSoundId();
8384
API.PlaySoundFrontend(Audio.Id, Audio.Slider, Audio.Library, true);
84-
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
85+
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
8586
{
8687
await BaseScript.Delay(0);
8788
var res = ScreenTools.ResolutionMaintainRatio;
8889
float mouseX = API.GetDisabledControlNormal(0, 239) * res.Width;
8990
float mouseY = API.GetDisabledControlNormal(0, 240) * res.Height;
90-
mouseX -= (Circle.Size.Width / 2);
91-
mouseY -= (Circle.Size.Height / 2);
92-
PointF Position = new PointF(mouseX > (Grid.Position.X + 10 + Grid.Size.Width - 40) ? (Grid.Position.X + 10 + Grid.Size.Width - 40) : ((mouseX < (Grid.Position.X + 20 - (Circle.Size.Width / 2))) ? (Grid.Position.X + 20 - (Circle.Size.Width / 2)) : mouseX), mouseY > (Grid.Position.Y + 10 + Grid.Size.Height - 40) ? (Grid.Position.Y + 10 + Grid.Size.Height - 40) : ((mouseY < (Grid.Position.Y + 20 - (Circle.Size.Height / 2))) ? (Grid.Position.Y + 20 - (Circle.Size.Height / 2)) : mouseY));
91+
mouseX -= (Circle.Size.Width / 2) + safezoneOffset.X;
92+
mouseY -= (Circle.Size.Height / 2) + safezoneOffset.Y;
93+
PointF Position = new PointF(mouseX > (Grid.Position.X + 10 + Grid.Size.Width - 40) ? (Grid.Position.X + 10 + Grid.Size.Width - 40) : ((mouseX < (Grid.Position.X + 20 - (Circle.Size.Width / 2))) ? (Grid.Position.X + 20 - (Circle.Size.Width / 2)) : mouseX), mouseY > (Grid.Position.Y + 10 + safezoneOffset.Y + Grid.Size.Height - 40) ? (Grid.Position.Y + 10 + Grid.Size.Height - 40) : ((mouseY < (Grid.Position.Y + 20 - (Circle.Size.Height / 2))) ? (Grid.Position.Y + 20 - (Circle.Size.Height / 2)) : mouseY));
9394
Circle.Position = Position;
94-
var resultX = (float)Math.Round((Circle.Position.X - (Grid.Position.X + 20) + (Circle.Size.Width + 20)) / (Grid.Size.Width - 40), 2);
95-
var resultY = (float)Math.Round((Circle.Position.Y - (Grid.Position.Y + 20) + (Circle.Size.Height + 20)) / (Grid.Size.Height - 40), 2);
95+
var resultX = (float)Math.Round((Circle.Position.X - (Grid.Position.X + 20) + (Circle.Size.Width + 20)) / (Grid.Size.Width - 40), 2) + safezoneOffset.X;
96+
var resultY = (float)Math.Round((Circle.Position.Y - (Grid.Position.Y + 20) + (Circle.Size.Height + 20)) / (Grid.Size.Height - 40), 2) + safezoneOffset.Y;
9697
UpdateParent(((resultX >= 0.0f && resultX <= 1.0f) ? resultX : ((resultX <= 0f) ? 0.0f : 1.0f) * 2f) - 1f, ((resultY >= 0.0f && resultY <= 1.0f) ? resultY : ((resultY <= 0f) ? 0.0f : 1.0f) * 2f) - 1f);
9798
}
9899
API.StopSound(Audio.Id);

NativeUI/Panels/UIMenuHorizontalOneLineGridPanel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ private void UpdateParent(float X)
6767

6868
private async void Functions()
6969
{
70-
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
70+
Point safezoneOffset = ScreenTools.SafezoneBounds;
71+
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
7172
{
7273
if (API.IsDisabledControlPressed(0, 24))
7374
{
@@ -76,12 +77,12 @@ private async void Functions()
7677
Pressed = true;
7778
Audio.Id = API.GetSoundId();
7879
API.PlaySoundFrontend(Audio.Id, Audio.Slider, Audio.Library, true);
79-
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
80+
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
8081
{
8182
await BaseScript.Delay(0);
8283
var res = ScreenTools.ResolutionMaintainRatio;
8384
float mouseX = API.GetDisabledControlNormal(0, 239) * res.Width;
84-
mouseX -= (Circle.Size.Width / 2);
85+
mouseX -= (Circle.Size.Width / 2) + safezoneOffset.X;
8586
Circle.Position = new PointF(mouseX > (Grid.Position.X + 10 + Grid.Size.Width - 40) ? (Grid.Position.X + 10 + Grid.Size.Width - 40) : ((mouseX < (Grid.Position.X + 20 - (Circle.Size.Width / 2))) ? (Grid.Position.X + 20 - (Circle.Size.Width / 2)) : mouseX), 0.5f);
8687
var resultX = (float)Math.Round((Circle.Position.X - (Grid.Position.X + 20) + (Circle.Size.Width + 20)) / (Grid.Size.Width - 40), 2);
8788
UpdateParent(((resultX >= 0.0f && resultX <= 1.0f) ? resultX : ((resultX <= 0f) ? 0.0f : 1.0f) * 2f) - 1f);

NativeUI/Panels/UIMenuPercentagePanel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public void UpdateParent(float Percentage)
6767

6868
private async void Functions()
6969
{
70-
if (ScreenTools.IsMouseInBounds(new PointF(BackgroundBar.Position.X, BackgroundBar.Position.Y - 4f), new SizeF(BackgroundBar.Size.Width, BackgroundBar.Size.Height + 8f)))
70+
Point safezoneOffset = ScreenTools.SafezoneBounds;
71+
if (ScreenTools.IsMouseInBounds(new PointF(BackgroundBar.Position.X + safezoneOffset.X, BackgroundBar.Position.Y - 4f + safezoneOffset.Y), new SizeF(BackgroundBar.Size.Width, BackgroundBar.Size.Height + 8f)))
7172
{
7273
if (API.IsDisabledControlPressed(0, 24))
7374
{
@@ -76,12 +77,12 @@ private async void Functions()
7677
Pressed = true;
7778
Audio.Id = API.GetSoundId();
7879
API.PlaySoundFrontend(Audio.Id, Audio.Slider, Audio.Library, true);
79-
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(BackgroundBar.Position.X, BackgroundBar.Position.Y - 4f), new SizeF(BackgroundBar.Size.Width, BackgroundBar.Size.Height + 8f)))
80+
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(BackgroundBar.Position.X + safezoneOffset.X, BackgroundBar.Position.Y - 4f + safezoneOffset.Y), new SizeF(BackgroundBar.Size.Width, BackgroundBar.Size.Height + 8f)))
8081
{
8182
await BaseScript.Delay(0);
8283
var res = ScreenTools.ResolutionMaintainRatio;
8384
float Progress = API.GetDisabledControlNormal(0, 239) * res.Width;
84-
Progress -= ActiveBar.Position.X;
85+
Progress -= ActiveBar.Position.X + safezoneOffset.X;
8586
ActiveBar.Size = new SizeF(Progress >= 0 && Progress <= 413 ? Progress : (Progress < 0 ? 0 : 413), ActiveBar.Size.Height);
8687
UpdateParent((float)Math.Round(Progress >= 0 && Progress <= 413 ? Progress : (Progress < 0 ? 0 : 413) / BackgroundBar.Size.Width, 2));
8788
}

NativeUI/Panels/UIMenuVerticalOneLineGridPanel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private void UpdateParent(float Y)
6868

6969
private async void Functions()
7070
{
71-
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
71+
Point safezoneOffset = ScreenTools.SafezoneBounds;
72+
if (ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
7273
{
7374
if (API.IsDisabledControlPressed(0, 24))
7475
{
@@ -77,13 +78,13 @@ private async void Functions()
7778
Pressed = true;
7879
Audio.Id = API.GetSoundId();
7980
API.PlaySoundFrontend(Audio.Id, Audio.Slider, Audio.Library, true);
80-
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f, Grid.Position.Y + 20f), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
81+
while (API.IsDisabledControlPressed(0, 24) && ScreenTools.IsMouseInBounds(new PointF(Grid.Position.X + 20f + safezoneOffset.X, Grid.Position.Y + 20f + safezoneOffset.Y), new SizeF(Grid.Size.Width - 40f, Grid.Size.Height - 40f)))
8182
{
8283
await BaseScript.Delay(0);
8384
var res = ScreenTools.ResolutionMaintainRatio;
8485
float mouseY = API.GetDisabledControlNormal(0, 240) * res.Height;
85-
mouseY -= (Circle.Size.Height / 2);
86-
Circle.Position = new PointF(0.5f, (mouseY > (Grid.Position.Y + 10 + Grid.Size.Height - 40) ? (Grid.Position.Y + 10 + Grid.Size.Height - 40) : ((mouseY < (Grid.Position.Y + 20 - (Circle.Size.Height / 2))) ? (Grid.Position.Y + 20 - (Circle.Size.Height / 2)) : mouseY)));
86+
mouseY -= (Circle.Size.Height / 2) + safezoneOffset.Y;
87+
Circle.Position = new PointF(0.5f, mouseY > (Grid.Position.Y + 10 + Grid.Size.Height - 40) ? (Grid.Position.Y + 10 + Grid.Size.Height - 40) : ((mouseY < (Grid.Position.Y + 20 - (Circle.Size.Height / 2))) ? (Grid.Position.Y + 20 - (Circle.Size.Height / 2)) : mouseY));
8788
var resultY = (float)Math.Round((Circle.Position.Y - (Grid.Position.Y + 20) + (Circle.Size.Height + 20)) / (Grid.Size.Height - 40), 2);
8889
UpdateParent(((resultY >= 0.0f && resultY <= 1.0f) ? resultY : ((resultY <= 0f) ? 0.0f : 1.0f) * 2f) - 1f);
8990
}

0 commit comments

Comments
 (0)