Make sell to flea on shift alt click
This commit is contained in:
@@ -13,9 +13,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using UIFixes.util;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using FleaRequirement = GClass1859;
|
||||
|
||||
namespace UIFixes;
|
||||
|
||||
@@ -174,6 +176,8 @@ public static class MultiSelectPatches
|
||||
|
||||
public class ItemViewClickPatch : ModulePatch
|
||||
{
|
||||
private static ISession Session => ClientAppUtils.GetMainApp().GetClientBackEndSession();
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(GridItemView), nameof(GridItemView.OnClick));
|
||||
@@ -191,6 +195,10 @@ public static class MultiSelectPatches
|
||||
bool shiftDown = Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift);
|
||||
bool altDown = Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt);
|
||||
|
||||
if (shiftDown && altDown) {
|
||||
SellAllToFlea();
|
||||
}
|
||||
|
||||
if (ctrlDown && !shiftDown && !altDown)
|
||||
{
|
||||
QuickMove(__instance, ___ItemUiContext, ___ItemController);
|
||||
@@ -205,7 +213,7 @@ public static class MultiSelectPatches
|
||||
|
||||
if (shiftDown)
|
||||
{
|
||||
// Nothing to do, mousedown handled it.
|
||||
// Nothing to do, mousedown handled it.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -274,6 +282,32 @@ public static class MultiSelectPatches
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SellAllToFlea() {
|
||||
foreach (DragItemContext selectedItemContext in MultiSelect.SortedItemContexts()) {
|
||||
try {
|
||||
SellToFlea(selectedItemContext.Item);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Console.WriteLine("Oopsie!");
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SellToFlea(Item item) {
|
||||
double? fleaPrice = FleaPriceCache.FetchPrice(item.TemplateId);
|
||||
Console.WriteLine("Flea price for " + item.Name + ":" + fleaPrice);
|
||||
|
||||
if (fleaPrice.HasValue) {
|
||||
var req = new FleaRequirement {
|
||||
count = (int)(fleaPrice.Value * 1.4),
|
||||
_tpl = "5449016a4bdc2d6f028b456f"
|
||||
};
|
||||
Console.WriteLine("Selling " + item.Name + " for " + req.count + " roubl");
|
||||
Session.RagFair.AddOffer(false, [item.Id], [req], null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ContextActionsPatch : ModulePatch
|
||||
@@ -1110,7 +1144,7 @@ public static class MultiSelectPatches
|
||||
}
|
||||
}
|
||||
|
||||
// Reimplement this method because BSG ignores the operation that is passed in and re-does the entire logic,
|
||||
// Reimplement this method because BSG ignores the operation that is passed in and re-does the entire logic,
|
||||
// like the dumb assholes they are
|
||||
public class TradingTableGetHighlightColorPatch : ModulePatch
|
||||
{
|
||||
@@ -1217,7 +1251,7 @@ public static class MultiSelectPatches
|
||||
}
|
||||
|
||||
// This is an insane way of doing this, but inside of the above method, I want ItemAddress.Equals to always return false, to allow
|
||||
// same place moves.
|
||||
// same place moves.
|
||||
public class AllowFindSameSpotPatch : ModulePatch
|
||||
{
|
||||
public static bool DisableItemAddressEquals = false;
|
||||
|
||||
Reference in New Issue
Block a user