work on inventory
This commit is contained in:
parent
50d32abd49
commit
32781b1462
11 changed files with 240 additions and 146 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using Avalonia.Media.Imaging;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Poe2Trade.Bot;
|
||||
|
|
@ -39,6 +41,8 @@ public partial class MainWindowViewModel : ObservableObject
|
|||
[NotifyCanExecuteChangedFor(nameof(PauseCommand))]
|
||||
private bool _isStarted;
|
||||
|
||||
[ObservableProperty] private Bitmap? _inventoryImage;
|
||||
|
||||
[ObservableProperty] private string _newUrl = "";
|
||||
[ObservableProperty] private string _newLinkName = "";
|
||||
[ObservableProperty] private LinkMode _newLinkMode = LinkMode.Live;
|
||||
|
|
@ -178,6 +182,20 @@ public partial class MainWindowViewModel : ObservableObject
|
|||
}
|
||||
}
|
||||
|
||||
var bytes = _bot.Inventory.LastScreenshot;
|
||||
if (bytes != null)
|
||||
{
|
||||
var old = InventoryImage;
|
||||
InventoryImage = new Bitmap(new MemoryStream(bytes));
|
||||
old?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
var old = InventoryImage;
|
||||
InventoryImage = null;
|
||||
old?.Dispose();
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(InventoryFreeCells));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public partial class SettingsViewModel : ObservableObject
|
|||
[ObservableProperty] private decimal? _stashScanTimeoutMs = 10000;
|
||||
[ObservableProperty] private decimal? _waitForMoreItemsMs = 20000;
|
||||
[ObservableProperty] private decimal? _betweenTradesDelayMs = 5000;
|
||||
[ObservableProperty] private bool _headless = true;
|
||||
[ObservableProperty] private bool _isSaved;
|
||||
|
||||
public SettingsViewModel(BotOrchestrator bot)
|
||||
|
|
@ -31,6 +32,7 @@ public partial class SettingsViewModel : ObservableObject
|
|||
StashScanTimeoutMs = s.StashScanTimeoutMs;
|
||||
WaitForMoreItemsMs = s.WaitForMoreItemsMs;
|
||||
BetweenTradesDelayMs = s.BetweenTradesDelayMs;
|
||||
Headless = s.Headless;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
|
@ -44,6 +46,7 @@ public partial class SettingsViewModel : ObservableObject
|
|||
s.StashScanTimeoutMs = (int)(StashScanTimeoutMs ?? 10000);
|
||||
s.WaitForMoreItemsMs = (int)(WaitForMoreItemsMs ?? 20000);
|
||||
s.BetweenTradesDelayMs = (int)(BetweenTradesDelayMs ?? 5000);
|
||||
s.Headless = Headless;
|
||||
});
|
||||
|
||||
IsSaved = true;
|
||||
|
|
@ -55,4 +58,5 @@ public partial class SettingsViewModel : ObservableObject
|
|||
partial void OnStashScanTimeoutMsChanged(decimal? value) => IsSaved = false;
|
||||
partial void OnWaitForMoreItemsMsChanged(decimal? value) => IsSaved = false;
|
||||
partial void OnBetweenTradesDelayMsChanged(decimal? value) => IsSaved = false;
|
||||
partial void OnHeadlessChanged(bool value) => IsSaved = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue