Skip to content

Commit 16a9f32

Browse files
authored
Merge pull request Babyhamsta#1538 from whoswhip/aimmy-prs
Dynamic Maximum Fov Size & Bug Fixes
2 parents df5aa6b + a0be3cd commit 16a9f32

File tree

7 files changed

+72
-10
lines changed

7 files changed

+72
-10
lines changed

Aimmy2/AILogic/AIManager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void RequestSizeChange(int newSize)
3535
}
3636

3737
// Dynamic properties instead of constants
38-
private int IMAGE_SIZE => _currentImageSize;
38+
public int IMAGE_SIZE => _currentImageSize;
3939
private int NUM_DETECTIONS { get; set; } = 8400; // Will be set dynamically for dynamic models
4040
private bool IsDynamicModel { get; set; } = false;
4141
private int ModelFixedSize { get; set; } = 640; // Store the fixed size for non-dynamic models
@@ -46,6 +46,7 @@ public void RequestSizeChange(int newSize)
4646
};
4747
public Dictionary<int, string> ModelClasses => _modelClasses; // apparently this is better than making _modelClasses public
4848
public static event Action<Dictionary<int, string>>? ClassesUpdated;
49+
public static event Action<int>? ImageSizeUpdated;
4950

5051
private const int SAVE_FRAME_COOLDOWN_MS = 500;
5152

@@ -347,6 +348,7 @@ private bool ValidateOnnxShape()
347348
// For dynamic models, calculate NUM_DETECTIONS based on selected image size
348349
NUM_DETECTIONS = CalculateNumDetections(IMAGE_SIZE);
349350
LoadClasses();
351+
ImageSizeUpdated?.Invoke(IMAGE_SIZE);
350352
LogManager.Log(LogLevel.Info, $"Loaded dynamic model - using selected image size {IMAGE_SIZE}x{IMAGE_SIZE} with {NUM_DETECTIONS} detections", true, 3000);
351353
}
352354
else
@@ -384,6 +386,7 @@ private bool ValidateOnnxShape()
384386

385387
// The IMAGE_SIZE property will now return the correct value
386388
NUM_DETECTIONS = CalculateNumDetections(fixedInputSize);
389+
ImageSizeUpdated?.Invoke(fixedInputSize);
387390
}
388391
else if (!supportedSizes.Contains(fixedSizeStr))
389392
{
@@ -625,8 +628,8 @@ private async void UpdateFOV()
625628

626629
await Application.Current.Dispatcher.BeginInvoke(() =>
627630
Dictionary.FOVWindow.FOVStrictEnclosure.Margin = new Thickness(
628-
Convert.ToInt16(displayRelativeX / WinAPICaller.scalingFactorX) - (IMAGE_SIZE / 2),
629-
Convert.ToInt16(displayRelativeY / WinAPICaller.scalingFactorY) - (IMAGE_SIZE / 2), 0, 0));
631+
Convert.ToInt16(displayRelativeX / WinAPICaller.scalingFactorX) - 320, // this is based off the window size, not the size of the model -whip
632+
Convert.ToInt16(displayRelativeY / WinAPICaller.scalingFactorY) - 320, 0, 0));
630633
}
631634
}
632635

Aimmy2/AILogic/CaptureManager.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,27 @@ public void InitializeDxgiDuplication()
393393
_lastSrcStride = srcStride;
394394
_lastDstStride = dstStride;
395395
}
396+
397+
if (Dictionary.toggleState["Third Person Support"])
398+
{
399+
int width = w / 2;
400+
int height = h / 2;
401+
int startY = h - height;
402+
403+
byte* dstPtr = (byte*)mapDest.Scan0;
404+
for (int y = startY; y < h; y++)
405+
{
406+
byte* rowPtr = dstPtr + (y * dstStride);
407+
for (int x = 0; x < width; x++)
408+
{
409+
int pixelOffset = x * 4;
410+
rowPtr[pixelOffset] = 0; // R
411+
rowPtr[pixelOffset + 1] = 0; // G
412+
rowPtr[pixelOffset + 2] = 0; // B
413+
rowPtr[pixelOffset + 3] = 255; // A
414+
}
415+
}
416+
}
396417
}
397418

398419
UpdateCache(currentBitmap, detectionBox);
@@ -484,7 +505,22 @@ public Bitmap GDIScreen(Rectangle detectionBox)
484505
detectionBox.Size,
485506
CopyPixelOperation.SourceCopy
486507
);
508+
509+
if (Dictionary.toggleState["Third Person Support"])
510+
{
511+
int width = screenCaptureBitmap.Width / 2;
512+
int height = screenCaptureBitmap.Height / 2;
513+
int startY = screenCaptureBitmap.Height - height;
514+
515+
using (var brush = new SolidBrush(System.Drawing.Color.Black))
516+
{
517+
g.FillRectangle(brush, 0, startY, width, height);
518+
}
519+
}
487520
}
521+
522+
523+
488524
return screenCaptureBitmap;
489525
}
490526
catch (Exception ex)

Aimmy2/Class/Dictionary.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static class Dictionary
5858
{ "Anti Recoil", false },
5959
{ "FOV", false },
6060
{ "Dynamic FOV", false },
61+
{ "Third Person Support", false },
6162
{ "Masking", false },
6263
{ "Show Detected Player", false },
6364
{ "Cursor Check", false },

Aimmy2/Class/UI.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public class UI
7676

7777
// FOV
7878
public ATitle? AT_FOV { get; set; }
79-
//--
80-
public ADropdown D_FOVSTYLE { get; set; }
81-
//--
8279
public AToggle? T_FOV { get; set; }
83-
8480
public AToggle? T_DynamicFOV { get; set; }
81+
public AToggle? T_ThirdPersonSupport { get; set; }
8582
public AKeyChanger? C_DynamicFOV { get; set; }
83+
//--
84+
public ADropdown D_FOVSTYLE { get; set; }
85+
//--
8686
public AColorChanger? CC_FOVColor { get; set; }
8787
public ASlider? S_FOVSize { get; set; }
8888
public ASlider? S_DynamicFOVSize { get; set; }

Aimmy2/UISections/AboutMenuControl.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private static readonly (string category, (string name, string role)[] members)[
2626
("whoswhip", "Bug fixes & EMA"),
2727
("HakaCat", "Idea for Auto Labelling Data"),
2828
("Themida", "LGHub check"),
29+
("camilia2o7", "Stream Guard & Bug Fixes"),
2930
("Ninja", "MarsQQ's emotional support")
3031
}),
3132
("Model Creators", new[]
@@ -94,4 +95,4 @@ private async void CheckForUpdates_Click(object sender, RoutedEventArgs e)
9495
}
9596
}
9697
}
97-
}
98+
}

Aimmy2/UISections/AimMenuControl.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void Initialize(MainWindow mainWindow)
6161
LoadMinimizeStatesFromGlobal();
6262

6363
AIManager.ClassesUpdated += OnClassesChanged;
64+
AIManager.ImageSizeUpdated += OnImageSizeChanged;
6465

6566
// Load all sections
6667
LoadAimAssist();
@@ -418,6 +419,7 @@ private void LoadFOVConfig()
418419
})
419420
.AddToggle("FOV", t => uiManager.T_FOV = t)
420421
.AddToggle("Dynamic FOV", t => uiManager.T_DynamicFOV = t)
422+
.AddToggle("Third Person Support", t => uiManager.T_ThirdPersonSupport = t)
421423
.AddKeyChanger("Dynamic FOV Keybind", k => uiManager.C_DynamicFOV = k)
422424
.AddDropdown("FOV Style", d =>
423425
{
@@ -639,6 +641,27 @@ private void UpdateTargetClassDropdown(ADropdown dropdown, Dictionary<int, strin
639641
dropdown.DropdownBox.SelectedIndex = 0;
640642
}
641643

644+
private void OnImageSizeChanged(int imageSize)
645+
{
646+
Application.Current.Dispatcher.Invoke(() =>
647+
{
648+
if (_mainWindow?.uiManager.S_FOVSize != null && _mainWindow?.uiManager.S_DynamicFOVSize != null)
649+
{
650+
UpdateFovSizeSlider(_mainWindow.uiManager.S_FOVSize, imageSize);
651+
UpdateFovSizeSlider(_mainWindow.uiManager.S_DynamicFOVSize, imageSize);
652+
}
653+
});
654+
}
655+
private void UpdateFovSizeSlider(ASlider slider, int imageSize = 640)
656+
{
657+
if (slider.Slider == null) return;
658+
if (imageSize < slider.Slider.Value)
659+
{
660+
slider.Slider.Value = imageSize;
661+
}
662+
slider.Slider.Maximum = imageSize;
663+
}
664+
642665
private void HandleColorChange(AColorChanger colorChanger, string settingKey, Action<Color> updateAction)
643666
{
644667
var colorDialog = new System.Windows.Forms.ColorDialog();

Aimmy2/UISections/ModelMenuControl.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
<Border Background="#3F3C3C3C"
4747
BorderBrush="#3FFFFFFF"
4848
BorderThickness="1"
49-
CornerRadius="5,5,0,0"
5049
Margin="0,55,0,54">
5150
<ListBox x:Name="ModelListBox"
5251
AllowDrop="True"
@@ -126,7 +125,6 @@
126125
<Border Background="#3F3C3C3C"
127126
BorderBrush="#3FFFFFFF"
128127
BorderThickness="1"
129-
CornerRadius="5,5,0,0"
130128
Margin="0,55,0,54">
131129
<ListBox x:Name="ConfigsListBox"
132130
AllowDrop="True"

0 commit comments

Comments
 (0)