Compare commits
10 Commits
a35c0f1084
...
bd9e54fedb
Author | SHA1 | Date | |
---|---|---|---|
bd9e54fedb | |||
8a4718d64c | |||
![]() |
cf23b39353 | ||
![]() |
2631590df6 | ||
![]() |
68ff1a83bd | ||
![]() |
9cba2c8a71 | ||
![]() |
5460659b9e | ||
![]() |
5169ba01e7 | ||
![]() |
263c156231 | ||
![]() |
af14298473 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -398,4 +398,5 @@ FodyWeavers.xsd
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
/libs
|
||||
/libs
|
||||
.idea
|
||||
|
@@ -50,15 +50,16 @@ public static class FilterOutOfStockPatches
|
||||
|
||||
HorizontalLayoutGroup layoutGroup = OutOfStockPanel.AddComponent<HorizontalLayoutGroup>();
|
||||
layoutGroup.childForceExpandHeight = layoutGroup.childForceExpandWidth = false;
|
||||
layoutGroup.childControlHeight = layoutGroup.childControlWidth = false;
|
||||
layoutGroup.childControlHeight = false;
|
||||
layoutGroup.childControlWidth = true;
|
||||
layoutGroup.childAlignment = TextAnchor.MiddleRight;
|
||||
|
||||
Image checkbox = UnityEngine.Object.Instantiate(__instance.transform.Find("TradeControll/Tabs/FillButton/Default/Icon_Box").GetComponent<Image>(), OutOfStockPanel.transform, false);
|
||||
checkbox.SetNativeSize();
|
||||
checkbox.RectTransform().sizeDelta = new Vector2(20f, 20f);
|
||||
checkbox.preserveAspect = true;
|
||||
Image check = UnityEngine.Object.Instantiate(__instance.transform.Find("TradeControll/Tabs/FillButton/Checkmark").GetComponent<Image>(), checkbox.transform, false);
|
||||
check.SetNativeSize();
|
||||
check.RectTransform().anchoredPosition = Vector2.zero;
|
||||
check.transform.localScale = new Vector3(.7f, .7f, .7f);
|
||||
check.RectTransform().anchoredPosition = new Vector2(-2f, 0f);
|
||||
check.RectTransform().sizeDelta = new Vector2(13f, 12f);
|
||||
check.gameObject.SetActive(ShowOutOfStockItems);
|
||||
|
||||
LocalizedText text = UnityEngine.Object.Instantiate(____updateAssort.transform.Find("TextWhite").GetComponent<LocalizedText>(), OutOfStockPanel.transform, false);
|
||||
@@ -67,7 +68,7 @@ public static class FilterOutOfStockPatches
|
||||
|
||||
TextMeshProUGUI textMesh = text.GetComponent<TextMeshProUGUI>();
|
||||
textMesh.enableAutoSizing = false;
|
||||
textMesh.fontSize = 18f;
|
||||
textMesh.fontSize = 14f;
|
||||
|
||||
Image background = OutOfStockPanel.AddComponent<Image>();
|
||||
background.color = Color.clear;
|
||||
|
@@ -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 * item.StackObjectsCount * 1.4),
|
||||
_tpl = "5449016a4bdc2d6f028b456f"
|
||||
};
|
||||
Console.WriteLine("Selling " + item.Name + " for " + req.count + " roubl");
|
||||
Session.RagFair.AddOffer(true, [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;
|
||||
|
@@ -19,17 +19,24 @@ public class OpenSortingTablePatch : ModulePatch
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static void Prefix(ItemUiContext __instance)
|
||||
public static bool Prefix(ItemUiContext __instance, ref ItemOperation __result)
|
||||
{
|
||||
if (!Settings.AutoOpenSortingTable.Value || !AllowedScreens.Contains(__instance.ContextType) || Plugin.InRaid())
|
||||
// BSG checks visibility, not in-raid. There's a bug where somehow that visibility can be true in raid
|
||||
if (Plugin.InRaid())
|
||||
{
|
||||
return;
|
||||
__result = new GClass3370("SortingTable/VisibilityError");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Settings.AutoOpenSortingTable.Value || !AllowedScreens.Contains(__instance.ContextType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Temporary work-around for LootValue bug - bail out if the ALT key is down
|
||||
if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
SortingTableClass sortingTable = __instance.R().InventoryController.Inventory.SortingTable;
|
||||
@@ -46,5 +53,7 @@ public class OpenSortingTablePatch : ModulePatch
|
||||
Singleton<CommonUI>.Instance.ScavengerInventoryScreen.R().SimpleStashPanel.ChangeSortingTableTabState(true);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ using EFT.UI;
|
||||
using EFT.UI.DragAndDrop;
|
||||
using HarmonyLib;
|
||||
using SPT.Reflection.Patching;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
@@ -34,6 +33,11 @@ public static class SortPatches
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(LootItemClass sortingItem, InventoryControllerClass controller, bool simulate, ref GStruct414<SortOperation> __result)
|
||||
{
|
||||
if (IncludeContainers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = Sorter.Sort(sortingItem, controller, IncludeContainers, simulate);
|
||||
return false;
|
||||
}
|
||||
|
@@ -140,7 +140,7 @@ internal class Settings
|
||||
"Show Transfer Items Confirmation Dialog",
|
||||
TransferConfirmationOption.Never,
|
||||
new ConfigDescription(
|
||||
"When to show the confirmation dialog when you close the item transfer screen without tSPTng all the items",
|
||||
"When to show the confirmation dialog when you close the item transfer screen without taking all the items",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
@@ -448,7 +448,7 @@ internal class Settings
|
||||
"Autostack Money with FiR Money",
|
||||
true,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid money with other money, mSPTng container interaction easier",
|
||||
"Allows automatic stacking of Found In Raid money with other money, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
@@ -457,7 +457,7 @@ internal class Settings
|
||||
"Autostack Ammo with FiR Ammo",
|
||||
false,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid ammo with other money, mSPTng container interaction easier",
|
||||
"Allows automatic stacking of Found In Raid ammo with other ammo, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
@@ -466,7 +466,7 @@ internal class Settings
|
||||
"Autostack Items with FiR Items",
|
||||
false,
|
||||
new ConfigDescription(
|
||||
"Allows automatic stacking of Found In Raid items with other items, mSPTng container interaction easier",
|
||||
"Allows automatic stacking of Found In Raid items with other items, making container interaction easier",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net471</TargetFramework>
|
||||
<AssemblyName>Tyfon.UIFixes</AssemblyName>
|
||||
<Description>SPT UI Fixes</Description>
|
||||
<Version>2.2.1</Version>
|
||||
<Version>2.2.2</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
@@ -15,8 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PathToSPT Condition="'$(Configuration)'=='Debug'">..\..\..\..\SPT\3.9.0-debug</PathToSPT>
|
||||
<PathToSPT Condition="'$(Configuration)'=='Release'">..\..\..\..\SPT\3.9.0</PathToSPT>
|
||||
<PathToSPT>C:\Games\Escape from Tarkov\Escape from Tarkov</PathToSPT>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -83,6 +82,18 @@
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="lib\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="lib\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="lib\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command='if $(ConfigurationName) == Debug (
|
||||
xcopy /F /Y "$(TargetPath)" "$(ProjectDir)$(PathToSPT)\BepInEx\plugins\"
|
||||
|
@@ -38,7 +38,7 @@ import ignore from "ignore";
|
||||
import archiver from "archiver";
|
||||
import winston from "winston";
|
||||
|
||||
const sptPath = "/SPT/3.9.0-debug";
|
||||
const sptPath = "/SPT/3.9.2-debug";
|
||||
|
||||
// Get the command line arguments to determine whether to use verbose logging.
|
||||
const args = process.argv.slice(2);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uifixes",
|
||||
"version": "2.2.1",
|
||||
"version": "2.2.2",
|
||||
"main": "src/mod.js",
|
||||
"license": "MIT",
|
||||
"author": "Tyfon",
|
||||
|
@@ -56,6 +56,4 @@ export class RagfairLinkedSlotItemService extends RagfairLinkedItemService {
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private getCategoryItems(category: string) {}
|
||||
}
|
||||
|
65
util/FleaCache.cs
Normal file
65
util/FleaCache.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using SPT.Common.Http;
|
||||
|
||||
namespace UIFixes.util {
|
||||
internal static class FleaPriceCache {
|
||||
static Dictionary<string, CachePrice> cache = new Dictionary<string, CachePrice>();
|
||||
|
||||
public static double? FetchPrice(string templateId) {
|
||||
if (cache.ContainsKey(templateId)) {
|
||||
double secondsSinceLastUpdate = (DateTime.Now - cache[templateId].lastUpdate).TotalSeconds;
|
||||
if (secondsSinceLastUpdate > 300)
|
||||
return QueryAndTryUpsertPrice(templateId, true);
|
||||
return cache[templateId].price;
|
||||
}
|
||||
|
||||
return QueryAndTryUpsertPrice(templateId, false);
|
||||
}
|
||||
|
||||
private static string QueryPrice(string templateId) {
|
||||
return RequestHandler.PostJson("/LootValue/GetItemLowestFleaPrice",
|
||||
JsonConvert.SerializeObject(new FleaPriceRequest(templateId)));
|
||||
}
|
||||
|
||||
private static double? QueryAndTryUpsertPrice(string templateId, bool update) {
|
||||
string response = QueryPrice(templateId);
|
||||
|
||||
bool hasPlayerFleaPrice = !(string.IsNullOrEmpty(response) || response == "null");
|
||||
|
||||
if (hasPlayerFleaPrice) {
|
||||
double price = double.Parse(response);
|
||||
|
||||
if (update)
|
||||
cache[templateId].Update(price);
|
||||
else
|
||||
cache[templateId] = new CachePrice(price);
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class FleaPriceRequest {
|
||||
public string templateId;
|
||||
public FleaPriceRequest(string templateId) => this.templateId = templateId;
|
||||
}
|
||||
|
||||
internal class CachePrice {
|
||||
public double price { get; private set; }
|
||||
public DateTime lastUpdate { get; private set; }
|
||||
|
||||
public CachePrice(double price) {
|
||||
this.price = price;
|
||||
lastUpdate = DateTime.Now;
|
||||
}
|
||||
|
||||
public void Update(double price) {
|
||||
this.price = price;
|
||||
lastUpdate = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user