Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add a hotkey to enable price tooltip #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public class LootValueMod : BaseUnityPlugin
public const string pluginName = "LootValue";
public const string pluginVersion = "3.0.0";

public enum ModifierKey
{
None = 0,
Shift = KeyCode.LeftShift,
Control = KeyCode.LeftControl,
Alt = KeyCode.LeftAlt
}

private void Awake()
{
Config.SaveOnConfigSet = true;
Expand Down Expand Up @@ -100,6 +108,8 @@ private void Config_SettingChanged(object sender, SettingChangedEventArgs e)

internal static ConfigEntry<KeyboardShortcut> QuicksellModifier;

internal static ConfigEntry<ModifierKey> showPriceKey;

private void SetupConfig()
{
OneButtonQuickSell = Config.Bind("Quick Sell", "One button quick sell", false, "Selling is done using LMB only. Attempts to sell to flea and then to trader if the option is enabled");
Expand Down Expand Up @@ -128,6 +138,8 @@ The third is marked as the ultimate color. Anything over 10000 rubles would be w

blacklistedTraders.AddRange(TraderBlacklist.Value.ToLower().Split(','));

showPriceKey = Config.Bind("Tooltip", "Modifier key to show price", ModifierKey.None, "Only show price in tooltip while holding this key");

if (UseCustomColours.Value)
SlotColoring.ReadColors(CustomColours.Value);

Expand Down Expand Up @@ -532,16 +544,16 @@ protected override MethodBase GetTargetMethod()
[PatchPrefix]
private static void Prefix(ref string text, ref float delay, SimpleTooltip __instance)
{
delay = 0;

bool isFleaEligible = false;
double lowestFleaOffer = 0;

bool modifierKeyHeld = Input.GetKey((KeyCode)LootValueMod.showPriceKey.Value) || LootValueMod.showPriceKey.Value == 0;
bool inRaidAndCanShowInRaid = HasRaidStarted() && LootValueMod.showFleaPricesInRaid.Value;

if (hoveredItem != null && Session.Profile.Examined(hoveredItem) && LootValueMod.showPrices.Value && (!HasRaidStarted() || inRaidAndCanShowInRaid))
if (hoveredItem != null && Session.Profile.Examined(hoveredItem) && LootValueMod.showPrices.Value && (!HasRaidStarted() || inRaidAndCanShowInRaid) && modifierKeyHeld)
{
tooltip = __instance;
delay = 0; // Show tooltip immediately if showing price, otherwise use default delay
tooltip = __instance;

TraderOffer bestTraderOffer = GetBestTraderOffer(hoveredItem);

Expand Down