About this mod
Makes the default sorting mode "No Sorting" sort by item type.
- Permissions and credits
- Changelogs
Ooh boy, here we go. I've been playing a lot of PoE II recently, and as my character amassed riches and wealth beyond what the common squabble could ever comprehend, so did I amass a rising frustration at the lack of a sorting option for Item Type. I'm just trying to find a greatsword for my companion, but the greatswords are scattered all across my inventory, and the only visual distinction between greatswords and other swords is the angle at which the model is shown on the item icon. "Enough," is said to myself, "I'll sort it my damn self".
Description:
Now that you know my lore and backstory, let me explain what the mod does:
- Sort items alphabetically by their item types (e.g. Blunderbuss, Dagger, Large Shield etc.)
- If item types are the same, sort alphabetically by item name
How to Install:
Method 1: Using Unity Mod Manager (preferred, this is the most up-to-date version):
- Download Unity Mod Manager here: https://www.nexusmods.com/site/mods/21
- Follow the instructions detailed on that page and install my mod.
Method 2: Replacing the Assembly-CSharp.dll file in your game folder:
- Go to your game folder for Pillars of Eternity II. Where this is located depends on from which platform you downloaded the game.
- From your game folder, go to PillarsOfEternityII_Data/Managed/
- Make a backup of your Assembly-CSharp.dll in case something goes wrong (just copy it and paste is somewhere else).
- Replace the current Assembly-CSharp.dll file with the one from this mod.
- Start the game, open your inventory, and change the sorting option to "No Sorting".
- If the sorting option is already set to "No Sorting" but it still isn't sorted, you may need to flick through the options until you get to "No Sorting" again to trigger the algorithm.
Source Code:
By request, here is the source code for the non-UMM version of the mod:
Added to the Game.BaseInventory class:
public static int CompareItemsByItemType(Item a, Item b)
{
if (a == null)
{
return 1;
}
if (b == null)
{
return -1;
}
if (a.GetTypeBlock() == b.GetTypeBlock())
{
int num = string.Compare(a.GetName(), b.GetName(), true);
if (num == -1)
{
return -1;
}
if (num == 1)
{
return 1;
}
return 0;
}
else
{
if (string.Compare(a.GetTypeBlock(), b.GetTypeBlock(), true) == -1)
{
return -1;
}
if (string.Compare(a.GetTypeBlock(), b.GetTypeBlock(), true) == 1)
{
return 1;
}
return 0;
}
}
In the method ReSort() in the Game.UI.UIInventorySortWidget class, rewrote the first case in the switch-case to this:
case UIInventorySortWidget.SortType.None:
{
UIInventoryItemGrid targetGrid = this.m_targetGrid;
if (UIInventorySortWidget.cache6 == null)
{
UIInventorySortWidget.cache6 = new Comparison<Item>(BaseInventory.CompareItemsByItemType);
}
targetGrid.SortComparison = UIInventorySortWidget.cache6;
return;
}
**IMPORTANT!**
If you want to use this code yourself to merge it with another mod, keep in mind that some of the files may contain compiler-generated variables with names that are not allowed in C#. All you have to do is rename the variables to something that is allowed. One such variable is the cache6 variable in the code above.