geheur / More-menu-entry-swaps

https://github.com/runelite/plugin-hub#creating-new-plugins
BSD 2-Clause "Simplified" License
7 stars 13 forks source link

Add support for sorting ground items by price (#34) #35

Closed Infinitay closed 6 months ago

Infinitay commented 6 months ago

New Feature

New Additions

Changes

https://github.com/geheur/More-menu-entry-swaps/assets/6964154/813e1295-ac81-42a4-a4dc-029f66c83b71

When watching the video, the list under "Custom hides" is the proper ordering from most expensive to least. Please also keep in mind of the custom ground item order that I pass in later to show that it still works.

geheur commented 6 months ago

I think it would be confusing to have the list of ground items take priority - you can set values in it so it's weird that a value of "2" would go over an expensive item on the ground. Maybe these should be sorted together, with the value in the list overriding the ge price? Not sure which is better.

Also, how does it handle untradeable items? Lots of untradeable items show up at the top of the list for good reason. Would this sort them to the bottom? I feel like this might make this feature very annoying to use.

HA price max is weird because many items have significantly higher HA price than GE price, e.g. steel longsword at 110 vs 300. I would avoid doing that. Items worth alching are high enough value that this won't matter but for these low value items it will be confusing.

Infinitay commented 6 months ago

you can set values in it so it's weird that a value of "2" would go over an expensive item on the ground

That is my fault. I completely forgot to test it with positive values

Maybe these should be sorted together, with the value in the list overriding the ge price?

That was my intent. It crossed my mind to test the changes with a positive value and I did not see that wasn't the case

how does it handle untradeable items?

image

Lots of untradeable items show up at the top of the list for good reason

When I was making this feature I had the intent in mind that items with value > untradeables.

Would this sort them to the bottom?

Yes. I suppose I can add an option to always have it at the top if they choose to and make it sort after the custom list sort

HA price max is weird because many items have significantly higher HA price than GE price

The reason I did this is for two reasons

geheur commented 6 months ago

For the HA thing - maybe the dropdown can be disabled, ge, or highest ge/ha I don't like the idea of descending anyways because I don't know what anyone would ever use it for.

I think the untradeable thing is important because if you get a drop like a dragon defender it would be odd for it to show at the bottom. Maybe you can use the "price" (shop value)? That is what it sorts by normally, somewhat. Or maybe just HA value since people are way more familiar with that value.

Infinitay commented 6 months ago

Initially I wanted to make everything optional, but I feel like I have a bad habit of offering too much customization. I will go ahead and continue with it and make the changes since you approve of them. I will:

I don't like the idea of descending anyways because I don't know what anyone would ever use it for.

I think you mean ascending? I think everyone would want descending so it's from most expensive to least expensive. Back before there was loot keys in PVP, you would want to snag up the most expensive loot first and then get out as fast as you can. Although, since I'm already adding options for price sorting I will keep the sorting order option unless you really object it.

I think the untradeable thing is important

What if I were to make it so when the user selects to show untradeables on top, it will sort those untradeables by max(Store Price, High Alch Price)? Because I don't think some untradeables could be bought at stores just as some untradeables can't be alched.

geheur commented 6 months ago

Untradeables are not always on top. I believe it uses the "store price" (1.5x HA). I think using the HA price for these is fine, and just including them in the sort normally. FYI this store price thing exists for all items iirc.

The custom list should always override everything else.

I mean descending because players think of the list from top to bottom. Ascending has the cheapest stuff at the top. I see you did the opposite in the code but I don't think that is intuitive.

so tl;dr for changes as far as I can tell: make untradables worth ha value in sorting. options should be off, ge, or max(ha, ge) Make the custom list's values be used as values for the sorting, as overrides for the ge/ha price. The comments I made on the code.

Infinitay commented 6 months ago

I discussed it with you on GitHub briefly but I'll go ahead and write it here too

make untradables worth ha value in sorting.

I think RL already does this because the OSRS wiki for the Dragon Defender say's it is unalchable, but there is still a price return of 40804 by ItemComposition#getHaPrice. I also tested it with a firecape and it returned a value of around 39K.

make untradables worth ha value in sorting.

For the reason above, this is already done assuming `ItemComposition#getHaPrice does return a price for all untradeable items

options should be off, ge, or max(ha, ge)

I will go ahead and do this now as you suggested due to issues with items such as the steel sword. For items with a GE value of 0 I'll make it sort by the HA price instead.

Make the custom list's values be used as values for the sorting, as overrides for the ge/ha price.

This is already the behavior (first it will sort by GE price, then it will sort again using custom values (overrides ge sort), then untradeables always on top option (overrides ge price and custom value)

image

Although as mentioned previously, I want to add an option to always include untradeables at the top because of items like desert ammy having no price at all and being at the bottom

Infinitay commented 6 months ago

With the latest few commits, I replaced ground item price sorting order to a price sorting method instead such as Grand Exchange pricing or the maximum between the Grand Exchange and High Alchemy prices.

Config

Plugin

GroundItemPriceSortMode

GroundItemsStuff

Note, ended up leaving a debug statement so fixup'ed the commit and rebased

Infinitay commented 6 months ago

Refactored ground items price sorting by removing the separate sorting method and instead handling it within HotkeyableMenuSwapsPlugin#sortGroundItems instead

Previous behavior:

image

After:

image

Infinitay commented 6 months ago

I realized now there is some odd issue where changing the sort mode starts incrementing the count by * however many times you changed the sort mode but resets it back to 0 if you disable it. I guess that's why logging in GroundItemsStuff is being printed out multiple times and essentially isn't clearing the state. I'll work on this after I push the missing price sort mode check within #sortGroundItems

Infinitay commented 6 months ago

Fixed registering multiple instances of GroundItemsStuff to EventBus

GroundItemsStuff

HotkeyableMenuSwapsPlugin

Preview

GE Value of items

image

https://github.com/geheur/More-menu-entry-swaps/assets/6964154/2c0de0e7-676a-4ac6-8cfe-14459fd82943

Final thoughts

This should be everything. If you could test out the plugin for yourself in case you can find any issues I would appreciate it if you find the time to do so. If you have any questions or issues with the code let me know. Thanks.