RimWorld

RimWorld

479 ratings
Dynamic Trade Interface
3
3
2
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.4, 1.5
File Size
Posted
Updated
728.105 KB
15 Aug, 2023 @ 10:12am
19 Sep @ 9:11am
37 Change Notes ( view )

Subscribe to download
Dynamic Trade Interface

Description
A high-performance and customizable trade interface originally inspired by Trade UI Revised.
Written from scratch to not only avoid the biggest performance hits of the vanilla UI but to also allow for other mods to easily extend it with additional columns.

Can be safely added or removed at any time during a playthrough, since it doesn't add any game content.
Does not replace the vanilla trade window. Instead you can choose in the mod options whether to open this or vanilla one by default, the other one can be accessed by holding down ctrl as the window opens.

The changelog can be found under the Change Notes tab.

Features:
  • Performance friendly.
  • Resizable window.
  • Selectable and resizable columns.
  • Column sorting. (Multiple by holding shift)
  • Buy or Sell max affordable using double arrow buttons.
  • Hide everything trader is unwilling to buy.
  • Open vanilla trade interface by holding ctrl as the window opens.
  • Option to only show trade buttons near the cursor for better performance.
  • Xenotype support.
  • Togglable and resizable summary section similar to TradeHelper.

Added columns:
  • Durability.
  • Price per weight.
  • Label variant of counter column.
  • Category.

Integrations & Compatibilities:

Limitations:
  • Due to how Rimworld's UI system works, controls will lose focus if any other control is made visible or invisible ahead of it. Generally to the left and up.
    This means that for example, putting the buttons to the left of the input counter boxes will cause them to unfocus when buttons change.
    There is now an option that can be enabled in the mod settings that attempts to compensate for this, by automatically refocusing the control whenever the focus is lost from changing interface. Often the escape button can be used to close windows that appear unreponsive.

Extendability (For modders):
XSD files are bundled with the mod describing how to define a TradeColumnDef.
Based on a number of method handlers, column behaviour can be easily referenced in C#.
Because it doesn't use any custom typings, it can all be defined without any need for assembly references or otherwise.

The following C# handlers can be defined:
  • static void PostOpen(IEnumerable<Tradeable> rows, Transactor transactor)
    Called twice after the window is opened initially, for Colony and Trader respectively. Useful for preparing cache.
  • static void PostClosed(IEnumerable<Tradeable> rows, Transactor transactor)
    Called twice after the window is closed, for Colony and Trader respectively. Useful for cleaning up cache.
  • static void Draw(ref Rect cell, Tradeable row, Transactor transactor, ref bool refresh)
    Called every frame for each row to draw column cells.
  • static Func<Tradeable, IComparable> OrderbyValue(Transactor transactor)
    Called once when the table is prepared to provide a sorting value selection function.

All source code can be found on Github[github.com]


Troubleshooting
Experiencing an issue?
  1. First check that it is actually caused by this mod; Either remove it temporarily, (can be added or removed any time!) or hold ctrl while trade opens to open the original vanilla trade window and check if isssue is also present there.
  2. If the issue is still there, then it isn't related to this mod and should be reported somewhere else.
  3. If you don't experience the issue with or in vanilla, then do provide a description of what you are trying to do, and what the problem you are experiencing is. The more details the better!
  4. If the issue causes an error in the log, then use Hugslib log publisher to provide the log in your report.

Credits
Joseasoler for helping sanity checking code and ideas.
Ryan for the initial implementation of DragSelect and Gene Assistant support
Madman666 for the preview and icons.
Timmy for permission to implement features of TradeHelper
Popular Discussions View All (2)
10
17 Mar @ 11:48am
Error offering gifts to hostile settlement
Tom Jackal
4
14 Mar @ 5:23pm
Error when trying to trade.
Tandy1000Synth
139 Comments
Solitaire 19 Sep @ 9:35am 
Love it will test it in future playthroughs. Thank you.
Zeracronius  [author] 19 Sep @ 9:13am 
As far as i could tell from the log, the error happened when trying to render a partial pawn for sale.
I have pushed a new update with additional checks that will hopefully solve the issue!
Solitaire 19 Sep @ 8:44am 
Scroll to the bottom of the 2nd link for the relevant error. Can't paste it in fully but it starts like this

"Wrote screenshot C:/Users/User/AppData/LocalLow/Ludeon Studios/RimWorld by Ludeon Studios\RimSaves\Previews\Autosave-1.jpg of size 33267
Exception filling window for RimWorld.Dialog_NodeTreeWithFactionInfo: "
Solitaire 19 Sep @ 8:31am 
Hello. Have an issue with your mod and AOBA's mod, Dead Man's Switch. The full bug report can be seen on their discord (report: https://discord.com/channels/847023921508777984/1286345487640690828)

(AOBA discord: https://discord.gg/Pvj5Xj3yBm)

Basically your mod generates an error when trying to trade on the world map with caravan encounters with his "colonial faction." I don't know why.

Logs below

https://gist.github.com/HugsLibRecordKeeper/b3b1cbf3cbf101f880d61720d03a2f80
https://gist.githubusercontent.com/HugsLibRecordKeeper/b3b1cbf3cbf101f880d61720d03a2f80/raw/aac671de5bdce3ec83e1b996249392fe7251e9de/output_log.txt
https://rentry.co/ckb6w948
Zeracronius  [author] 14 Sep @ 12:56pm 
I of course meant that if the item is in trader's wares...
Zeracronius  [author] 14 Sep @ 12:53pm 
@5150, Thanks for the report!
Nothing in the update impacted this, however based on your log it seems to be related to tech prints. Specifically the game is throwing an error when the window is trying load tech print's tradability.
You have a tech print without a def, which tends to be caused by removed mods. Either this print is in your wares or trader's wares, and if it is the former then it would work like normal when trading with anyone else.

I can however add some additional failsafes to skip such items and prevent them from breaking the window.
5150 14 Sep @ 10:15am 
I removed the mod and tried sending out a caravan to trade with an external settlement again, and it worked fine.
5150 14 Sep @ 10:07am 
https://gist.github.com/HugsLibRecordKeeper/a250eae8d1445ddc1d4844f8ebc2ed99

Since the update on September 14th, the transaction button hasn't been working, and it appears in the developer logs.

- PREFIX DynamicTradeInterfaceMod: Void DynamicTradeInterface.Patches.Dialog_TradePatches:Prefix(Dialog_Trade __instance, Boolean ___giftsOnly)
at Verse.WindowStack.Add (Verse.Window window) [0x0003a] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0
at RimWorld.Planet.CaravanArrivalAction_Trade.Arrived (RimWorld.Planet.Caravan caravan) [0x0003b] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0
at RimWorld.Planet.Caravan_PathFollower.PatherArrived () [0x0002e] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0
at RimWorld.Planet.Caravan_PathFollower.StartPath (System.Int32 destTile, RimWorld.Planet.CaravanArrivalAction arrivalAction, System.Boolean repathImmediately, System.Boolean resetPauseStatus) [0x000da] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0
Zeracronius  [author] 14 Sep @ 3:21am 
Looking at MP's code, i don't believe it will be compatible since they are making significant changes to vanilla's trade interface to make it function, and those modifications would not be applied here.

I am not sure what VE packs you are talking about?
TypicalVolpe 13 Sep @ 6:08pm 
Is this mod friendly and working well with multiplayer along with it's vanilla expanded packs?